Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cmd/compile/internal/types2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ func TestUsesInfo(t *testing.T) {

// Uses of fields are instantiated.
{`package s1; type N[A any] struct{ a A }; var f = N[int]{}.a`, `a`, `field a int`},
{`package s1; type N[A any] struct{ a A }; func (r N[B]) m(b B) { r.a = b }`, `a`, `field a B`},
{`package s2; type N[A any] struct{ a A }; func (r N[B]) m(b B) { r.a = b }`, `a`, `field a B`},

// Uses of methods are uses of the instantiated method.
{`package m0; type N[A any] int; func (r N[B]) m() { r.n() }; func (N[C]) n() {}`, `n`, `func (m0.N[B]).n()`},
Expand Down Expand Up @@ -809,13 +809,13 @@ func (r *N[C]) n() { }
t.Errorf(`N.Method(...) returns %v for "m", but Info.Defs has %v`, gm, dm)
}
if gn != dn {
t.Errorf(`N.Method(...) returns %v for "m", but Info.Defs has %v`, gm, dm)
t.Errorf(`N.Method(...) returns %v for "n", but Info.Defs has %v`, gn, dn)
}
if dmm != dm {
t.Errorf(`Inside "m", r.m uses %v, want the defined func %v`, dmm, dm)
}
if dmn == dn {
t.Errorf(`Inside "m", r.n uses %v, want a func distinct from %v`, dmm, dm)
t.Errorf(`Inside "m", r.n uses %v, want a func distinct from %v`, dmn, dn)
}
}

Expand Down Expand Up @@ -945,9 +945,9 @@ func TestPredicatesInfo(t *testing.T) {
{`package v0; var (a, b int; _ = a + b)`, `a + b`, `value`},
{`package v1; var _ = &[]int{1}`, `[]int{…}`, `value`},
{`package v2; var _ = func(){}`, `func() {}`, `value`},
{`package v4; func f() { _ = f }`, `f`, `value`},
{`package v3; var _ *int = nil`, `nil`, `value, nil`},
{`package v3; var _ *int = (nil)`, `(nil)`, `value, nil`},
{`package v3; func f() { _ = f }`, `f`, `value`},
{`package v4; var _ *int = nil`, `nil`, `value, nil`},
{`package v5; var _ *int = (nil)`, `(nil)`, `value, nil`},

// addressable (and thus assignable) operands
{`package a0; var (x int; _ = x)`, `x`, `value, addressable, assignable`},
Expand Down Expand Up @@ -978,8 +978,8 @@ func TestPredicatesInfo(t *testing.T) {
{`package m4; var v int`, `v`, `<missing>`},
{`package m5; func f() {}`, `f`, `<missing>`},
{`package m6; func _(x int) {}`, `x`, `<missing>`},
{`package m6; func _()(x int) { return }`, `x`, `<missing>`},
{`package m6; type T int; func (x T) _() {}`, `x`, `<missing>`},
{`package m7; func _()(x int) { return }`, `x`, `<missing>`},
{`package m8; type T int; func (x T) _() {}`, `x`, `<missing>`},
}

for _, test := range tests {
Expand Down