summaryrefslogtreecommitdiff
path: root/test/interface/explicit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-21 13:46:20 -0700
committerRuss Cox <rsc@golang.org>2009-05-21 13:46:20 -0700
commit48faec051f8b6e8462ce7f9db8c6230683afa82c (patch)
tree97c2f40f26cc4882dc5adb10c4961a6846f42cf4 /test/interface/explicit.go
parente357984efee23e82613cd9689d4aaa1df411479b (diff)
downloadgo-48faec051f8b6e8462ce7f9db8c6230683afa82c.tar.gz
add test for yesterday's interface rule change (interface/convert1.go).
move interface tests to subdirectory. R=r DELTA=1632 (827 added, 804 deleted, 1 changed) OCL=29181 CL=29191
Diffstat (limited to 'test/interface/explicit.go')
-rw-r--r--test/interface/explicit.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/interface/explicit.go b/test/interface/explicit.go
new file mode 100644
index 000000000..3b5ed01ca
--- /dev/null
+++ b/test/interface/explicit.go
@@ -0,0 +1,34 @@
+// errchk $G $D/$F.go
+
+// 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.
+
+// Static error messages about interface conversions.
+
+package main
+
+type T struct { a int }
+var t *T
+
+type I interface { M() }
+var i I
+
+type I2 interface { M(); N(); }
+var i2 I2;
+
+var e interface { };
+
+func main() {
+ e = t; // ok
+ t = e; // ERROR "need explicit"
+
+ // neither of these can work,
+ // because i has an extra method
+ // that t does not, so i cannot contain a t.
+ i = t; // ERROR "missing|incompatible|is not"
+ t = i; // ERROR "missing|incompatible|is not"
+
+ i = i2; // ok
+ i2 = i; // ERROR "need explicit"
+}