For
// -gotypesalias=1
package p
var x T[B]
type T[_ any] struct{}
type A T[B]
type B = T[A]
types2 produces the trace:
testdata/manual.go:7:6: -- checking type T (white, objPath = )
testdata/manual.go:7:10: . -- type any
testdata/manual.go:7:10: . => any (under = any) // *Alias
testdata/manual.go:7:15: . -- type struct{}
testdata/manual.go:7:15: . => struct{} // *Struct
testdata/manual.go:7:6: => type T[_ any] struct{} (black)
testdata/manual.go:8:6: -- checking type A (white, objPath = )
testdata/manual.go:8:9: . -- type T[B]
testdata/manual.go:8:8: . . -- instantiating type T with [B]
testdata/manual.go:8:8: . . . -- type T
testdata/manual.go:8:8: . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:8:10: . . . -- type B
testdata/manual.go:9:6: . . . . -- checking type B (white, objPath = A)
testdata/manual.go:9:11: . . . . . -- type T[A]
testdata/manual.go:9:10: . . . . . . -- instantiating type T with [A]
testdata/manual.go:9:10: . . . . . . . -- type T
testdata/manual.go:9:10: . . . . . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:9:12: . . . . . . . -- type A
testdata/manual.go:8:6: . . . . . . . . ## cycle detected: objPath = A->B->A (len = 2)
testdata/manual.go:8:6: . . . . . . . . ## cycle contains: 0 values, 1 type definitions
testdata/manual.go:8:6: . . . . . . . . => cycle is valid
testdata/manual.go:9:12: . . . . . . . => A (under = <nil>) // *Named
testdata/manual.go:9:10: . . . . . . => T[A]
testdata/manual.go:9:11: . . . . . => T[A] (under = <nil>) // *Named
testdata/manual.go:9:6: . . . . => type B = T[A] (black)
testdata/manual.go:8:10: . . . => B (under = <nil>) // *Alias
testdata/manual.go:8:8: . . => T[B]
testdata/manual.go:8:9: . => T[B] (under = <nil>) // *Named
testdata/manual.go:8:8: -- Named.expandUnderlying T[B]
testdata/manual.go:8:8: => T[B] (tparams = [], under = <nil>)
testdata/manual.go:8:6: => type A struct{} (black)
testdata/manual.go:5:5: -- checking var x (white, objPath = )
testdata/manual.go:5:8: . -- type T[B]
testdata/manual.go:5:7: . . -- instantiating type T with [B]
testdata/manual.go:5:7: . . . -- type T
testdata/manual.go:5:7: . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:5:9: . . . -- type B
testdata/manual.go:5:9: . . . => B (under = <nil>) // *Alias
testdata/manual.go:5:7: . . => T[B]
testdata/manual.go:5:8: . => T[B] (under = struct{}) // *Named
testdata/manual.go:5:5: => var x T[B] (black)
but go/types produces:
testdata/manual.go:5:5: -- checking var x (white, objPath = )
testdata/manual.go:5:7: . -- type T[B]
testdata/manual.go:5:7: . . -- instantiating type T with [B]
testdata/manual.go:5:7: . . . -- type T
testdata/manual.go:7:6: . . . . -- checking -> type T (white, objPath = x)
testdata/manual.go:7:8: . . . . . type params = [_₁]
testdata/manual.go:7:10: . . . . . -- type any
testdata/manual.go:7:10: . . . . . => any (under = any) // *Alias
testdata/manual.go:7:15: . . . . . -- type struct{}
testdata/manual.go:7:15: . . . . . => struct{} // *Struct
testdata/manual.go:7:6: . . . . => -> type T[_ any] struct{} (black)
testdata/manual.go:5:7: . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:5:9: . . . -- type B
testdata/manual.go:9:6: . . . . -- checking -> type B (white, objPath = x)
testdata/manual.go:9:10: . . . . . -- type T[A]
testdata/manual.go:9:10: . . . . . . -- instantiating type T with [A]
testdata/manual.go:9:10: . . . . . . . -- type T
testdata/manual.go:9:10: . . . . . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:9:12: . . . . . . . -- type A
testdata/manual.go:8:6: . . . . . . . . -- checking -> type A (white, objPath = x->B)
testdata/manual.go:8:8: . . . . . . . . . -- type T[B]
testdata/manual.go:8:8: . . . . . . . . . . -- instantiating type T with [B]
testdata/manual.go:8:8: . . . . . . . . . . . -- type T
testdata/manual.go:8:8: . . . . . . . . . . . => T[_₁ any] (under = struct{}) // *Named
testdata/manual.go:8:10: . . . . . . . . . . . -- type B
testdata/manual.go:9:6: . . . . . . . . . . . . ## cycle detected: objPath = B->A->B (len = 2)
testdata/manual.go:9:6: . . . . . . . . . . . . ## cycle contains: 0 values, 1 type definitions
testdata/manual.go:9:6: . . . . . . . . . . . . => cycle is valid
testdata/manual.go:8:10: . . . . . . . . . . . => B (under = invalid type) // *Alias
testdata/manual.go:8:8: . . . . . . . . . . => invalid type
testdata/manual.go:8:8: . . . . . . . . . => invalid type // *Basic
testdata/manual.go:8:6: . . . . . . . . => -> type A invalid type (black)
testdata/manual.go:9:12: . . . . . . . => A (under = invalid type) // *Named
testdata/manual.go:9:10: . . . . . . => T[A]
testdata/manual.go:9:10: . . . . . => T[A] (under = <nil>) // *Named
testdata/manual.go:9:6: . . . . => -> type B = T[A] (black)
testdata/manual.go:5:9: . . . => B (under = <nil>) // *Alias
testdata/manual.go:5:7: . . => T[B]
testdata/manual.go:5:7: . => T[B] (under = <nil>) // *Named
testdata/manual.go:5:5: => var x T[B] (black)
Note the invalid underlying types for A
and the different evaluation strategy.
This causes at least one of the failures in #66859.
Comment From: griesemer
Looks like this was already fixed in types2 with CL 577616 but not ported.
Comment From: gopherbot
Change https://go.dev/cl/586236 mentions this issue: go/types: re-enable suppressed gcimporter tests