]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: pull up Unalias call to cover all of cycleFinder.typ
authorRobert Griesemer <gri@golang.org>
Thu, 23 May 2024 23:30:20 +0000 (16:30 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 24 May 2024 13:54:20 +0000 (13:54 +0000)
Without a test because it's unclear the situation can actually occur,
but the code is correct because it now mimics the behavior without
explicit Alias nodes.

For #67547.

Change-Id: I21a31af28880ca6d599fe465563d9574c26ed1f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/588117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/infer.go
src/go/types/infer.go

index 2a46de9b9742e1c7c6c3a0b0375a19731c966803..122ac9e04fce3edbc7ed64843c4701ea2d949f35 100644 (file)
@@ -693,6 +693,7 @@ type cycleFinder struct {
 }
 
 func (w *cycleFinder) typ(typ Type) {
+       typ = Unalias(typ)
        if w.seen[typ] {
                // We have seen typ before. If it is one of the type parameters
                // in w.tparams, iterative substitution will lead to infinite expansion.
@@ -714,8 +715,8 @@ func (w *cycleFinder) typ(typ Type) {
        case *Basic:
                // nothing to do
 
-       case *Alias:
-               w.typ(Unalias(t))
+       // *Alias:
+       //      This case should not occur because of Unalias(typ) at the top.
 
        case *Array:
                w.typ(t.elem)
index 7e63b0a6653f599763a606bb9142f9cc1d49da8a..d0f1c1caf48f2a4d79ac6cdf1e9e4a2d550ed557 100644 (file)
@@ -696,6 +696,7 @@ type cycleFinder struct {
 }
 
 func (w *cycleFinder) typ(typ Type) {
+       typ = Unalias(typ)
        if w.seen[typ] {
                // We have seen typ before. If it is one of the type parameters
                // in w.tparams, iterative substitution will lead to infinite expansion.
@@ -717,8 +718,8 @@ func (w *cycleFinder) typ(typ Type) {
        case *Basic:
                // nothing to do
 
-       case *Alias:
-               w.typ(Unalias(t))
+       // *Alias:
+       //      This case should not occur because of Unalias(typ) at the top.
 
        case *Array:
                w.typ(t.elem)