Skip to content

Commit faf6e28

Browse files
xieyuschenadonovan
authored andcommitted
go/ssa: migrate TestGenericAliases away from loader
Updates golang/go#69556 Change-Id: I50ac457a379afa9ceccd0031397fca7b38e7f689 Reviewed-on: https://go-review.googlesource.com/c/tools/+/615015 Reviewed-by: Tim King <[email protected]> Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 81a4242 commit faf6e28

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

go/ssa/builder_test.go

+4-17
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,10 @@ func TestGenericAliases(t *testing.T) {
11321132
}
11331133

11341134
func testGenericAliases(t *testing.T) {
1135-
t.Setenv("GOEXPERIMENT", "aliastypeparams=1")
1135+
testenv.NeedsGoExperiment(t, "aliastypeparams")
11361136

11371137
const source = `
1138-
package P
1138+
package p
11391139
11401140
type A = uint8
11411141
type B[T any] = [4]T
@@ -1167,22 +1167,9 @@ func f[S any]() {
11671167
}
11681168
`
11691169

1170-
conf := loader.Config{Fset: token.NewFileSet()}
1171-
f, err := parser.ParseFile(conf.Fset, "p.go", source, 0)
1172-
if err != nil {
1173-
t.Fatal(err)
1174-
}
1175-
conf.CreateFromFiles("p", f)
1176-
iprog, err := conf.Load()
1177-
if err != nil {
1178-
t.Fatal(err)
1179-
}
1180-
1181-
// Create and build SSA program.
1182-
prog := ssautil.CreateProgram(iprog, ssa.InstantiateGenerics)
1183-
prog.Build()
1170+
p, _ := buildPackage(t, source, ssa.InstantiateGenerics)
11841171

1185-
probes := callsTo(ssautil.AllFunctions(prog), "print")
1172+
probes := callsTo(ssautil.AllFunctions(p.Prog), "print")
11861173
if got, want := len(probes), 3*4*2; got != want {
11871174
t.Errorf("Found %v probes, expected %v", got, want)
11881175
}

0 commit comments

Comments
 (0)