From a555ac63322f441f19a2a5130298c4c6ee6357dc Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 9 Apr 2024 12:42:37 -0400 Subject: [PATCH] cmd/compile/internal/types2: revert to three-phase alias resolution 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 LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/types2/resolver.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/types2/resolver.go b/src/cmd/compile/internal/types2/resolver.go index af932a80fe..2b1de600a7 100644 --- a/src/cmd/compile/internal/types2/resolver.go +++ b/src/cmd/compile/internal/types2/resolver.go @@ -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) }