1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package p
6
7 import "unsafe"
8
9 // Test case for issue 5090
10
11 type t interface {
12 f(u)
13 }
14
15 type u interface {
16 t
17 }
18
19 func _() {
20 var t t
21 var u u
22
23 t.f(t)
24 t.f(u)
25
26 u.f(t)
27 u.f(u)
28 }
29
30
31 // Test case for issues #6589, #33656.
32
33 type A interface {
34 a() interface {
35 AB
36 }
37 }
38
39 type B interface {
40 b() interface {
41 AB
42 }
43 }
44
45 type AB interface {
46 a() interface {
47 A
48 B
49 }
50 b() interface {
51 A
52 B
53 }
54 }
55
56 var x AB
57 var y interface {
58 A
59 B
60 }
61
62 var _ = x == y
63
64
65 // Test case for issue 6638.
66
67 type T interface {
68 m() [T(nil).m /* ERROR undefined */ ()[0]]int
69 }
70
71 // Variations of this test case.
72
73 type T1 /* ERROR cycle */ interface {
74 m() [x1.m()[0]]int
75 }
76
77 var x1 T1
78
79 type T2 /* ERROR cycle */ interface {
80 m() [len(x2.m())]int
81 }
82
83 var x2 T2
84
85 type T3 /* ERROR cycle */ interface {
86 m() [unsafe.Sizeof(x3.m)]int
87 }
88
89 var x3 T3
90
91 type T4 /* ERROR cycle */ interface {
92 m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off
93 }
94
95 var x4 T4
96 var _ = cast4(x4.m)
97
98 type cast4 func()
99
View as plain text