summaryrefslogtreecommitdiff
path: root/test/interface9.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/interface9.go')
-rw-r--r--test/interface9.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/interface9.go b/test/interface9.go
new file mode 100644
index 000000000..9ba5864a8
--- /dev/null
+++ b/test/interface9.go
@@ -0,0 +1,41 @@
+// Copyright 2009 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.
+
+// errchk $G $F.go
+
+package main
+
+type T int
+func (t T) V()
+func (t *T) P()
+
+type V interface { V() }
+type P interface { P(); V() }
+
+type S struct { T; }
+type SP struct { *T; }
+
+func main() {
+ var t T;
+ var v V;
+ var p P;
+ var s S;
+ var sp SP;
+
+ v = t;
+ p = t; // ERROR "is not"
+ v = &t;
+ p = &t;
+
+ v = s;
+ p = s; // ERROR "is not"
+ v = &s;
+ p = &s;
+
+ v = sp;
+ p = sp; // no error!
+ v = &sp;
+ p = &sp;
+}
+