mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
6346349f56
commit
31f82877e8
2 changed files with 4 additions and 10 deletions
|
|
@ -575,11 +575,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN
|
||||||
named.underlying = Typ[Invalid]
|
named.underlying = Typ[Invalid]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639).
|
// spec: "In a type definition the given type cannot be a type parameter."
|
||||||
// We don't need this restriction anymore if we make the underlying type of a type
|
// (See also go.dev/issue/45639.)
|
||||||
// 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.
|
|
||||||
if isTypeParam(rhs) {
|
if isTypeParam(rhs) {
|
||||||
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
|
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
|
||||||
named.underlying = Typ[Invalid]
|
named.underlying = Typ[Invalid]
|
||||||
|
|
|
||||||
|
|
@ -657,11 +657,8 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName
|
||||||
named.underlying = Typ[Invalid]
|
named.underlying = Typ[Invalid]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disallow a lone type parameter as the RHS of a type declaration (go.dev/issue/45639).
|
// spec: "In a type definition the given type cannot be a type parameter."
|
||||||
// We don't need this restriction anymore if we make the underlying type of a type
|
// (See also go.dev/issue/45639.)
|
||||||
// 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.
|
|
||||||
if isTypeParam(rhs) {
|
if isTypeParam(rhs) {
|
||||||
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
|
check.error(tdecl.Type, MisplacedTypeParam, "cannot use a type parameter as RHS in type declaration")
|
||||||
named.underlying = Typ[Invalid]
|
named.underlying = Typ[Invalid]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue