Skip to content

Commit

Permalink
go/ssa: migrate TestGenericAliases away from loader
Browse files Browse the repository at this point in the history
Updates golang/go#69556

Change-Id: I50ac457a379afa9ceccd0031397fca7b38e7f689
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615015
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
xieyuschen authored and adonovan committed Sep 26, 2024
1 parent 81a4242 commit faf6e28
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions go/ssa/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,10 @@ func TestGenericAliases(t *testing.T) {
}

func testGenericAliases(t *testing.T) {
t.Setenv("GOEXPERIMENT", "aliastypeparams=1")
testenv.NeedsGoExperiment(t, "aliastypeparams")

const source = `
package P
package p
type A = uint8
type B[T any] = [4]T
Expand Down Expand Up @@ -1167,22 +1167,9 @@ func f[S any]() {
}
`

conf := loader.Config{Fset: token.NewFileSet()}
f, err := parser.ParseFile(conf.Fset, "p.go", source, 0)
if err != nil {
t.Fatal(err)
}
conf.CreateFromFiles("p", f)
iprog, err := conf.Load()
if err != nil {
t.Fatal(err)
}

// Create and build SSA program.
prog := ssautil.CreateProgram(iprog, ssa.InstantiateGenerics)
prog.Build()
p, _ := buildPackage(t, source, ssa.InstantiateGenerics)

probes := callsTo(ssautil.AllFunctions(prog), "print")
probes := callsTo(ssautil.AllFunctions(p.Prog), "print")
if got, want := len(probes), 3*4*2; got != want {
t.Errorf("Found %v probes, expected %v", got, want)
}
Expand Down

0 comments on commit faf6e28

Please sign in to comment.