Commit f316a7ea authored by Anthony Martin's avatar Anthony Martin Committed by Rob Pike

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
parent d00bd1d1
......@@ -265,8 +265,8 @@ imethods(Type *t)
last = a;
// Compiler can only refer to wrappers for
// named interface types.
if(t->sym == S)
// named interface types and non-blank methods.
if(t->sym == S || isblanksym(method))
continue;
// NOTE(rsc): Perhaps an oversight that
......
......@@ -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"
......@@ -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()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment