1
2
3
4
5
6
7
8 package main
9
10 type T struct{}
11
12
13 func (T) cplx() complex128 {
14 return complex(1, 0)
15 }
16
17 func (T) cplx2() complex128 {
18 return complex(0, 1)
19 }
20
21 type I interface {
22 cplx() complex128
23 }
24
25 func main() {
26
27 var t T
28
29 if v := real(t.cplx()); v != 1 {
30 panic("not-inlined complex call failed")
31 }
32 _ = imag(t.cplx())
33
34 _ = real(t.cplx2())
35 if v := imag(t.cplx2()); v != 1 {
36 panic("potentially inlined complex call failed")
37 }
38
39 var i I
40 i = t
41 if v := real(i.cplx()); v != 1 {
42 panic("potentially inlined complex call failed")
43 }
44 _ = imag(i.cplx())
45 }
46
View as plain text