From 3ea2be1e4786abd39bc1fbd429c936d9fb89ec00 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 23 May 2024 16:30:20 -0700 Subject: [PATCH] go/types, types2: pull up Unalias call to cover all of cycleFinder.typ 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 Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/infer.go | 5 +++-- src/go/types/infer.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 2a46de9b97..122ac9e04f 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -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) diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 7e63b0a665..d0f1c1caf4 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -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) -- 2.48.1