1
2
3
4
5
6
7
8
9 package main
10
11 import "os"
12
13 const Value = 1e12
14
15 type Inter interface { M() int64 }
16
17 type T int64
18 func (t T) M() int64 { return int64(t) }
19 var t = T(Value)
20 var pt = &t
21 var ti Inter = t
22
23 type S struct { Inter }
24 var s = S{ ti }
25 var ps = &s
26
27 var i Inter
28
29 var ok = true
30
31 func check(s string, v int64) {
32 if v != Value {
33 println(s, v)
34 ok = false
35 }
36 }
37
38 func main() {
39 check("t.M()", t.M())
40 check("pt.M()", pt.M())
41 check("ti.M()", ti.M())
42 check("s.M()", s.M())
43 check("ps.M()", ps.M())
44
45 i = t
46 check("i = t; i.M()", i.M())
47
48 i = pt
49 check("i = pt; i.M()", i.M())
50
51 i = s
52 check("i = s; i.M()", i.M())
53
54 i = ps
55 check("i = ps; i.M()", i.M())
56
57 if !ok {
58 println("BUG: interface10")
59 os.Exit(1)
60 }
61 }
62
View as plain text