Skip to content

Commit 31f8287

Browse files
author
Robert Griesemer
committed
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 <markfreeman@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
1 parent 6346349 commit 31f8287

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/cmd/compile/internal/types2/decl.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN
575575
named.underlying = Typ[Invalid]
576576
}
577577

578-
// Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639).
579-
// We don't need this restriction anymore if we make the underlying type of a type
580-
// parameter its constraint interface: if the RHS is a lone type parameter, we will
581-
// use its underlying type (like we do for any RHS in a type declaration), and its
582-
// underlying type is an interface and the type declaration is well defined.
578+
// spec: "In a type definition the given type cannot be a type parameter."
579+
// (See also go.dev/issue/45639.)
583580
if isTypeParam(rhs) {
584581
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
585582
named.underlying = Typ[Invalid]

src/go/types/decl.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName
657657
named.underlying = Typ[Invalid]
658658
}
659659

660-
// Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639).
661-
// We don't need this restriction anymore if we make the underlying type of a type
662-
// parameter its constraint interface: if the RHS is a lone type parameter, we will
663-
// use its underlying type (like we do for any RHS in a type declaration), and its
664-
// underlying type is an interface and the type declaration is well defined.
660+
// spec: "In a type definition the given type cannot be a type parameter."
661+
// (See also go.dev/issue/45639.)
665662
if isTypeParam(rhs) {
666663
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
667664
named.underlying = Typ[Invalid]

0 commit comments

Comments
 (0)