Source file
test/fixedbugs/issue41736.go
1
2
3
4
5
6
7 package p
8
9 type I struct {
10 x int64
11 }
12
13 type F struct {
14 x float64
15 }
16
17 type C struct {
18 x *complex128
19 }
20
21 type D struct {
22 x complex64
23 }
24
25 type A [1]*complex128
26
27
28 func (i I) X() C {
29 cx := complex(0, float64(i.x))
30 return C{&cx}
31 }
32
33
34 func (f F) X() C {
35 cx := complex(f.x, 0)
36 return C{&cx}
37 }
38
39
40 func (c C) X() C {
41 cx := complex(imag(*c.x), real(*c.x))
42 return C{&cx}
43 }
44
45
46 func (d D) X() C {
47 cx := complex(float64(imag(d.x)), -float64(real(d.x)))
48 return C{&cx}
49 }
50
51
52 func (a A) X() C {
53 cx := complex(-float64(imag(*a[0])), float64(real(*a[0])))
54 return C{&cx}
55 }
56
57
58 func (i I) id() I {
59 return i
60 }
61
62
63 func (f F) id() F {
64 return f
65 }
66
67
68 func (c C) id() C {
69 return c
70 }
71
72
73 func (d D) id() D {
74 return d
75 }
76
77
78 func (a A) id() A {
79 return a
80 }
81
82 type T interface {
83 X() C
84 }
85
86 func G(x []T) []T {
87 var y []T
88 for _, a := range x {
89 var v T
90 switch u := a.(type) {
91 case I:
92 v = u.id()
93 case F:
94 v = u.id()
95 case C:
96 v = u.id()
97 case D:
98 v = u.id()
99 case A:
100 v = u.id()
101 }
102 y = append(y, v)
103 }
104 return y
105 }
106
View as plain text