1// Copyright 2010 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
5package main
6
7import (
8	p0 "./bug0"
9	p1 "./bug1"
10)
11
12// both p0.T and p1.T are struct { X, Y int }.
13
14var v0 p0.T
15var v1 p1.T
16
17// interfaces involving the two
18
19type I0 interface {
20	M(p0.T)
21}
22
23type I1 interface {
24	M(p1.T)
25}
26
27// t0 satisfies I0 and p0.I
28type t0 int
29
30func (t0) M(p0.T) {}
31
32// t1 satisfies I1 and p1.I
33type t1 float64
34
35func (t1) M(p1.T) {}
36
37// check static interface assignments
38var i0 I0 = t0(0) // ok
39var i1 I1 = t1(0) // ok
40
41var i2 I0 = t1(0) // ERROR "does not implement|incompatible"
42var i3 I1 = t0(0) // ERROR "does not implement|incompatible"
43
44var p0i p0.I = t0(0) // ok
45var p1i p1.I = t1(0) // ok
46
47var p0i1 p0.I = t1(0) // ERROR "does not implement|incompatible"
48var p0i2 p1.I = t0(0) // ERROR "does not implement|incompatible"
49
50func main() {
51	// check that cannot assign one to the other,
52	// but can convert.
53	v0 = v1 // ERROR "assign"
54	v1 = v0 // ERROR "assign"
55
56	v0 = p0.T(v1)
57	v1 = p1.T(v0)
58
59	i0 = i1   // ERROR "cannot use|incompatible"
60	i1 = i0   // ERROR "cannot use|incompatible"
61	p0i = i1  // ERROR "cannot use|incompatible"
62	p1i = i0  // ERROR "cannot use|incompatible"
63	i0 = p1i  // ERROR "cannot use|incompatible"
64	i1 = p0i  // ERROR "cannot use|incompatible"
65	p0i = p1i // ERROR "cannot use|incompatible"
66	p1i = p0i // ERROR "cannot use|incompatible"
67
68	i0 = p0i
69	p0i = i0
70
71	i1 = p1i
72	p1i = i1
73}
74