methods.go
599 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s
// CHECK: X()
// CHECK-NEXT: Y()
// CHECK-NEXT: X()
// CHECK-NEXT: Y()
// CHECK-NEXT: X()
package main
type Stringer interface {
String() string
}
type X int
type Y int
type Z1 struct {
X
}
type Z2 struct {
Stringer
}
func (x X) String() string {
return "X()"
}
func (y *Y) String() string {
return "Y()"
}
func makeX() X {
return X(0)
}
func main() {
var z Stringer = X(0)
println(z.String())
z = new(Y)
println(z.String())
z = Z1{}
println(z.String())
z = Z2{new(Y)}
println(z.String())
println(makeX().String())
}