From: Robert Griesemer Date: Thu, 16 Oct 2025 17:33:34 +0000 (-0700) Subject: go/types, types2: remove superfluous unalias call (minor cleanup) X-Git-Tag: go1.26rc1~598 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=41f5659347f9498ce81911032bb46537d923bdd7;p=gostls13.git go/types, types2: remove superfluous unalias call (minor cleanup) Change-Id: Ifc0d6e999777513498f070c5bc2fb4640d38c671 Reviewed-on: https://go-review.googlesource.com/c/go/+/712460 Reviewed-by: Robert Griesemer LUCI-TryBot-Result: Go LUCI Auto-Submit: Robert Griesemer Reviewed-by: Mark Freeman --- diff --git a/src/cmd/compile/internal/types2/alias.go b/src/cmd/compile/internal/types2/alias.go index 90dda18cc8..d306600ebd 100644 --- a/src/cmd/compile/internal/types2/alias.go +++ b/src/cmd/compile/internal/types2/alias.go @@ -113,7 +113,6 @@ func unalias(a0 *Alias) Type { for a := a0; a != nil; a, _ = t.(*Alias) { t = a.fromRHS } - // It's fine to memoize nil types since it's the zero value for actual. // It accomplishes nothing. a0.actual = t diff --git a/src/cmd/compile/internal/types2/signature.go b/src/cmd/compile/internal/types2/signature.go index ea1cfd88cc..1e004eef4a 100644 --- a/src/cmd/compile/internal/types2/signature.go +++ b/src/cmd/compile/internal/types2/signature.go @@ -203,7 +203,7 @@ func (check *Checker) collectRecv(rparam *syntax.Field, scopePos syntax.Pos) (*V case *Alias: // Methods on generic aliases are not permitted. // Only report an error if the alias type is valid. - if isValid(unalias(t)) { + if isValid(t) { check.errorf(rbase, InvalidRecv, "cannot define new methods on generic alias type %s", t) } // Ok to continue but do not set basetype in this case so that diff --git a/src/go/types/alias.go b/src/go/types/alias.go index f15ff57030..a2eeb3afac 100644 --- a/src/go/types/alias.go +++ b/src/go/types/alias.go @@ -116,7 +116,6 @@ func unalias(a0 *Alias) Type { for a := a0; a != nil; a, _ = t.(*Alias) { t = a.fromRHS } - // It's fine to memoize nil types since it's the zero value for actual. // It accomplishes nothing. a0.actual = t diff --git a/src/go/types/signature.go b/src/go/types/signature.go index fa41c797b2..972de97b1a 100644 --- a/src/go/types/signature.go +++ b/src/go/types/signature.go @@ -226,7 +226,7 @@ func (check *Checker) collectRecv(rparam *ast.Field, scopePos token.Pos) (*Var, case *Alias: // Methods on generic aliases are not permitted. // Only report an error if the alias type is valid. - if isValid(unalias(t)) { + if isValid(t) { check.errorf(rbase, InvalidRecv, "cannot define new methods on generic alias type %s", t) } // Ok to continue but do not set basetype in this case so that