From 31f82877e85a7e6c70b0104e704abfed622e345f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 15 Oct 2025 11:27:17 -0700 Subject: [PATCH] go/types, types2: fix misleading internal comment See also the discussion in #75885. Change-Id: Ieb964ea6ee51600c0c08ecba0af50a1deb209a4d Reviewed-on: https://go-review.googlesource.com/c/go/+/712141 Reviewed-by: Mark Freeman Auto-Submit: Robert Griesemer TryBot-Bypass: Robert Griesemer Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/types2/decl.go | 7 ++----- src/go/types/decl.go | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 4ebd945407..22fccc1519 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -575,11 +575,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN named.underlying = Typ[Invalid] } - // Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639). - // We don't need this restriction anymore if we make the underlying type of a type - // parameter its constraint interface: if the RHS is a lone type parameter, we will - // use its underlying type (like we do for any RHS in a type declaration), and its - // underlying type is an interface and the type declaration is well defined. + // spec: "In a type definition the given type cannot be a type parameter." + // (See also go.dev/issue/45639.) if isTypeParam(rhs) { check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid] diff --git a/src/go/types/decl.go b/src/go/types/decl.go index aef7f6ad0b..13d9d9ce57 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -657,11 +657,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName named.underlying = Typ[Invalid] } - // Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639). - // We don't need this restriction anymore if we make the underlying type of a type - // parameter its constraint interface: if the RHS is a lone type parameter, we will - // use its underlying type (like we do for any RHS in a type declaration), and its - // underlying type is an interface and the type declaration is well defined. + // spec: "In a type definition the given type cannot be a type parameter." + // (See also go.dev/issue/45639.) if isTypeParam(rhs) { check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration") named.underlying = Typ[Invalid] -- 2.52.0