]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: revert to three-phase alias resolution
authorAlan Donovan <adonovan@google.com>
Tue, 9 Apr 2024 16:42:37 +0000 (12:42 -0400)
committerAlan Donovan <adonovan@google.com>
Tue, 9 Apr 2024 20:03:51 +0000 (20:03 +0000)
This change reenables the legacy three-phase resolution
(non-alias typenames, aliases, the rest) even when
GODEBUG=gotypesalias=1. Unfortunately the existing test case
for #50259 causes the simpler logic to fail.

Updates #50259
Updates #65294

Change-Id: Ibfaf8146e46760718673a916a9b220a9d678409a
Reviewed-on: https://go-review.googlesource.com/c/go/+/577616
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

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

index af932a80fe07dd4d1ddce2185bebe86b5d9b41a8..2b1de600a7a17f54c956bd86a48ba601b605be18 100644 (file)
@@ -677,8 +677,23 @@ func (check *Checker) packageObjects() {
                }
        }
 
-       if check.enableAlias {
+       if false && check.enableAlias {
                // With Alias nodes we can process declarations in any order.
+               //
+               // TODO(adonovan): unfortunately, Alias nodes
+               // (GODEBUG=gotypesalias=1) don't entirely resolve
+               // problems with cycles. For example, in
+               // GOROOT/test/typeparam/issue50259.go,
+               //
+               //      type T[_ any] struct{}
+               //      type A T[B]
+               //      type B = T[A]
+               //
+               // TypeName A has Type Named during checking, but by
+               // the time the unified export data is written out,
+               // its Type is Invalid.
+               //
+               // Investigate and reenable this branch.
                for _, obj := range objList {
                        check.objDecl(obj, nil)
                }