mirror of
https://github.com/golang/go
synced 2024-11-24 19:50:18 -07:00
go/types, types: add additional generic cases for the Selections API
Change-Id: Icc5240db7447846061d0d81f5e15f788758d4d64 Reviewed-on: https://go-review.googlesource.com/c/go/+/393372 Trust: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
a8f019e956
commit
2da1e47fb0
@ -1428,6 +1428,14 @@ type C struct {
|
|||||||
c int
|
c int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type G[P any] struct {
|
||||||
|
p P
|
||||||
|
}
|
||||||
|
|
||||||
|
func (G[P]) m(P) {}
|
||||||
|
|
||||||
|
var Inst G[int]
|
||||||
|
|
||||||
func (C) g()
|
func (C) g()
|
||||||
func (*C) h()
|
func (*C) h()
|
||||||
|
|
||||||
@ -1452,6 +1460,9 @@ func main() {
|
|||||||
_ = A{}.c
|
_ = A{}.c
|
||||||
_ = new(A).c
|
_ = new(A).c
|
||||||
|
|
||||||
|
_ = Inst.p
|
||||||
|
_ = G[string]{}.p
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
_ = A{}.f
|
_ = A{}.f
|
||||||
_ = new(A).f
|
_ = new(A).f
|
||||||
@ -1465,12 +1476,14 @@ func main() {
|
|||||||
_ = C{}.g
|
_ = C{}.g
|
||||||
_ = new(C).g
|
_ = new(C).g
|
||||||
_ = new(C).h
|
_ = new(C).h
|
||||||
|
_ = Inst.m
|
||||||
|
|
||||||
// method expressions
|
// method expressions
|
||||||
_ = A.f
|
_ = A.f
|
||||||
_ = (*A).f
|
_ = (*A).f
|
||||||
_ = B.f
|
_ = B.f
|
||||||
_ = (*B).f
|
_ = (*B).f
|
||||||
|
_ = G[string].m
|
||||||
}`
|
}`
|
||||||
|
|
||||||
wantOut := map[string][2]string{
|
wantOut := map[string][2]string{
|
||||||
@ -1484,6 +1497,7 @@ func main() {
|
|||||||
"new(A).b": {"field (*main.A) b int", "->[0 0]"},
|
"new(A).b": {"field (*main.A) b int", "->[0 0]"},
|
||||||
"A{}.c": {"field (main.A) c int", ".[1 0]"},
|
"A{}.c": {"field (main.A) c int", ".[1 0]"},
|
||||||
"new(A).c": {"field (*main.A) c int", "->[1 0]"},
|
"new(A).c": {"field (*main.A) c int", "->[1 0]"},
|
||||||
|
"Inst.p": {"field (main.G[int]) p int", ".[0]"},
|
||||||
|
|
||||||
"A{}.f": {"method (main.A) f(int)", "->[0 0]"},
|
"A{}.f": {"method (main.A) f(int)", "->[0 0]"},
|
||||||
"new(A).f": {"method (*main.A) f(int)", "->[0 0]"},
|
"new(A).f": {"method (*main.A) f(int)", "->[0 0]"},
|
||||||
@ -1495,11 +1509,14 @@ func main() {
|
|||||||
"C{}.g": {"method (main.C) g()", ".[0]"},
|
"C{}.g": {"method (main.C) g()", ".[0]"},
|
||||||
"new(C).g": {"method (*main.C) g()", "->[0]"},
|
"new(C).g": {"method (*main.C) g()", "->[0]"},
|
||||||
"new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ?
|
"new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ?
|
||||||
|
"Inst.m": {"method (main.G[int]) m(int)", ".[0]"},
|
||||||
|
|
||||||
"A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"},
|
"A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"},
|
||||||
"(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"},
|
"(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"},
|
||||||
"B.f": {"method expr (main.B) f(main.B, int)", ".[0]"},
|
"B.f": {"method expr (main.B) f(main.B, int)", ".[0]"},
|
||||||
"(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"},
|
"(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"},
|
||||||
|
"G[string].m": {"method expr (main.G[string]) m(main.G[string], string)", ".[0]"},
|
||||||
|
"G[string]{}.p": {"field (main.G[string]) p string", ".[0]"},
|
||||||
}
|
}
|
||||||
|
|
||||||
makePkg("lib", libSrc)
|
makePkg("lib", libSrc)
|
||||||
|
@ -1432,6 +1432,14 @@ type C struct {
|
|||||||
c int
|
c int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type G[P any] struct {
|
||||||
|
p P
|
||||||
|
}
|
||||||
|
|
||||||
|
func (G[P]) m(P) {}
|
||||||
|
|
||||||
|
var Inst G[int]
|
||||||
|
|
||||||
func (C) g()
|
func (C) g()
|
||||||
func (*C) h()
|
func (*C) h()
|
||||||
|
|
||||||
@ -1456,6 +1464,9 @@ func main() {
|
|||||||
_ = A{}.c
|
_ = A{}.c
|
||||||
_ = new(A).c
|
_ = new(A).c
|
||||||
|
|
||||||
|
_ = Inst.p
|
||||||
|
_ = G[string]{}.p
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
_ = A{}.f
|
_ = A{}.f
|
||||||
_ = new(A).f
|
_ = new(A).f
|
||||||
@ -1469,12 +1480,14 @@ func main() {
|
|||||||
_ = C{}.g
|
_ = C{}.g
|
||||||
_ = new(C).g
|
_ = new(C).g
|
||||||
_ = new(C).h
|
_ = new(C).h
|
||||||
|
_ = Inst.m
|
||||||
|
|
||||||
// method expressions
|
// method expressions
|
||||||
_ = A.f
|
_ = A.f
|
||||||
_ = (*A).f
|
_ = (*A).f
|
||||||
_ = B.f
|
_ = B.f
|
||||||
_ = (*B).f
|
_ = (*B).f
|
||||||
|
_ = G[string].m
|
||||||
}`
|
}`
|
||||||
|
|
||||||
wantOut := map[string][2]string{
|
wantOut := map[string][2]string{
|
||||||
@ -1488,6 +1501,7 @@ func main() {
|
|||||||
"new(A).b": {"field (*main.A) b int", "->[0 0]"},
|
"new(A).b": {"field (*main.A) b int", "->[0 0]"},
|
||||||
"A{}.c": {"field (main.A) c int", ".[1 0]"},
|
"A{}.c": {"field (main.A) c int", ".[1 0]"},
|
||||||
"new(A).c": {"field (*main.A) c int", "->[1 0]"},
|
"new(A).c": {"field (*main.A) c int", "->[1 0]"},
|
||||||
|
"Inst.p": {"field (main.G[int]) p int", ".[0]"},
|
||||||
|
|
||||||
"A{}.f": {"method (main.A) f(int)", "->[0 0]"},
|
"A{}.f": {"method (main.A) f(int)", "->[0 0]"},
|
||||||
"new(A).f": {"method (*main.A) f(int)", "->[0 0]"},
|
"new(A).f": {"method (*main.A) f(int)", "->[0 0]"},
|
||||||
@ -1499,11 +1513,14 @@ func main() {
|
|||||||
"C{}.g": {"method (main.C) g()", ".[0]"},
|
"C{}.g": {"method (main.C) g()", ".[0]"},
|
||||||
"new(C).g": {"method (*main.C) g()", "->[0]"},
|
"new(C).g": {"method (*main.C) g()", "->[0]"},
|
||||||
"new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ?
|
"new(C).h": {"method (*main.C) h()", "->[1]"}, // TODO(gri) should this report .[1] ?
|
||||||
|
"Inst.m": {"method (main.G[int]) m(int)", ".[0]"},
|
||||||
|
|
||||||
"A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"},
|
"A.f": {"method expr (main.A) f(main.A, int)", "->[0 0]"},
|
||||||
"(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"},
|
"(*A).f": {"method expr (*main.A) f(*main.A, int)", "->[0 0]"},
|
||||||
"B.f": {"method expr (main.B) f(main.B, int)", ".[0]"},
|
"B.f": {"method expr (main.B) f(main.B, int)", ".[0]"},
|
||||||
"(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"},
|
"(*B).f": {"method expr (*main.B) f(*main.B, int)", "->[0]"},
|
||||||
|
"G[string].m": {"method expr (main.G[string]) m(main.G[string], string)", ".[0]"},
|
||||||
|
"G[string]{}.p": {"field (main.G[string]) p string", ".[0]"},
|
||||||
}
|
}
|
||||||
|
|
||||||
makePkg("lib", libSrc)
|
makePkg("lib", libSrc)
|
||||||
|
Loading…
Reference in New Issue
Block a user