From: Robert Griesemer Date: Mon, 15 Apr 2024 19:49:21 +0000 (-0700) Subject: go/types, types2: simplify TestUnaliasTooSoonInCycle (cleanup) X-Git-Tag: go1.23rc1~616 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7418d419afeeaa832bd5c9104f1ff90331eaf184;p=gostls13.git go/types, types2: simplify TestUnaliasTooSoonInCycle (cleanup) Follow-up on CL 576975 and CL 579015. Updates #66704 Updates #65294 Change-Id: Ied95386a346be38ccda86d332d09b2089a68c5e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/579075 LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer Reviewed-by: Robert Findley --- diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index cd979815bf..840a3f3bdc 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -2997,14 +2997,9 @@ type T[_ any] struct{} type A T[B] type B = T[A] ` - - f := mustParse(src) - pkg, err := new(Config).Check("a", []*syntax.File{f}, nil) - if err != nil { - t.Fatal(err) - } - + pkg := mustTypecheck(src, nil, nil) B := pkg.Scope().Lookup("B") + got, want := Unalias(B.Type()).String(), "a.T[a.A]" if got != want { t.Errorf("Unalias(type B = T[A]) = %q, want %q", got, want) diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 5ce17e3ddc..7ab695d365 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -3005,17 +3005,9 @@ type T[_ any] struct{} type A T[B] type B = T[A] ` - fset := token.NewFileSet() - f, err := parser.ParseFile(fset, "a.go", src, 0) - if err != nil { - t.Fatal(err) - } - pkg, err := new(Config).Check("a", fset, []*ast.File{f}, nil) - if err != nil { - t.Fatal(err) - } - + pkg := mustTypecheck(src, nil, nil) B := pkg.Scope().Lookup("B") + got, want := Unalias(B.Type()).String(), "a.T[a.A]" if got != want { t.Errorf("Unalias(type B = T[A]) = %q, want %q", got, want)