summaryrefslogtreecommitdiff
path: root/libgo/go/go/types/testdata/cycles1.src
blob: ae2b38ebec21e36d5f2e5bdd360948e8cbba97ce (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

type (
	A interface {
		a() interface {
			ABC1
		}
	}
	B interface {
		b() interface {
			ABC2
		}
	}
	C interface {
		c() interface {
			ABC3
		}
	}

	AB interface {
		A
		B
	}
	BC interface {
		B
		C
	}

	ABC1 interface {
		A
		B
		C
	}
	ABC2 interface {
		AB
		C
	}
	ABC3 interface {
		A
		BC
	}
)

var (
	x1 ABC1
	x2 ABC2
	x3 ABC3
)

func _() {
	// all types have the same method set
	x1 = x2
	x2 = x1

	x1 = x3
	x3 = x1

	x2 = x3
	x3 = x2

	// all methods return the same type again
	x1 = x1.a()
	x1 = x1.b()
	x1 = x1.c()

	x2 = x2.a()
	x2 = x2.b()
	x2 = x2.c()

	x3 = x3.a()
	x3 = x3.b()
	x3 = x3.c()
}