diff options
author | Anthony Martin <ality@pbrane.org> | 2013-08-19 11:53:34 +1000 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2013-08-19 11:53:34 +1000 |
commit | f316a7ea87c192c62868331540db3ecc2fb2c08b (patch) | |
tree | 358fbd7be88ae224b3ffcb1cbd8e3fce00b66acc /test/interface | |
parent | d00bd1d1f4a39fb81b34150aca89dcc5e45b727e (diff) | |
download | go-f316a7ea87c192c62868331540db3ecc2fb2c08b.tar.gz go-f316a7ea87c192c62868331540db3ecc2fb2c08b.zip |
cmd/gc: don't attempt to generate wrappers for blank interface methods
Fixes #5691.
R=golang-dev, bradfitz, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/10255047
Diffstat (limited to 'test/interface')
-rw-r--r-- | test/interface/explicit.go | 19 | ||||
-rw-r--r-- | test/interface/fail.go | 19 |
2 files changed, 36 insertions, 2 deletions
diff --git a/test/interface/explicit.go b/test/interface/explicit.go index eb81156e08..36fa1a4224 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -80,3 +80,22 @@ var m2 M = jj // ERROR "incompatible|wrong type for M method" var m3 = M(ii) // ERROR "invalid|missing" var m4 = M(jj) // ERROR "invalid|wrong type for M method" + + +type B1 interface { + _() +} + +type B2 interface { + M() + _() +} + +type T2 struct{} + +func (t *T2) M() {} +func (t *T2) _() {} + +// Check that nothing satisfies an interface with blank methods. +var b1 B1 = &T2{} // ERROR "incompatible|missing _ method" +var b2 B2 = &T2{} // ERROR "incompatible|missing _ method" diff --git a/test/interface/fail.go b/test/interface/fail.go index 72b854dc00..81eb6cb3c1 100644 --- a/test/interface/fail.go +++ b/test/interface/fail.go @@ -14,18 +14,33 @@ type I interface { func main() { shouldPanic(p1) + shouldPanic(p2) } func p1() { var s *S var i I - var e interface {} + var e interface{} e = s i = e.(I) _ = i } -type S struct { +type S struct{} + +func (s *S) _() {} + +type B interface { + _() +} + +func p2() { + var s *S + var b B + var e interface{} + e = s + b = e.(B) + _ = b } func shouldPanic(f func()) { |