1//+build ignore
2
3package main
4
5// Test of interface calls.
6
7func use(interface{})
8
9type A byte // instantiated but not a reflect type
10
11func (A) f() {} // called directly
12func (A) F() {} // unreachable
13
14type B int // a reflect type
15
16func (*B) f() {} // reachable via interface invoke
17func (*B) F() {} // reachable: exported method of reflect type
18
19type B2 int // a reflect type, and *B2 also
20
21func (B2) f() {} // reachable via interface invoke
22func (B2) g() {} // reachable: exported method of reflect type
23
24type C string // not instantiated
25
26func (C) f() {} // unreachable
27func (C) F() {} // unreachable
28
29type D uint // instantiated only in dead code
30
31func (D) f() {} // unreachable
32func (D) F() {} // unreachable
33
34func main() {
35	A(0).f()
36
37	use(new(B))
38	use(B2(0))
39
40	var i interface {
41		f()
42	}
43	i.f() // calls (*B).f, (*B2).f and (B2.f)
44
45	live()
46}
47
48func live() {
49	var j interface {
50		f()
51		g()
52	}
53	j.f() // calls (B2).f and (*B2).f but not (*B).f (no g method).
54}
55
56func dead() {
57	use(D(0))
58}
59
60// WANT:
61// Dynamic calls
62//   live --> (*B2).f
63//   live --> (B2).f
64//   main --> (*B).f
65//   main --> (*B2).f
66//   main --> (B2).f
67// Reachable functions
68//   (*B).F
69//   (*B).f
70//   (*B2).f
71//   (A).f
72//   (B2).f
73//   live
74//   use
75// Reflect types
76//   *B
77//   *B2
78//   B
79//   B2
80