Fixes #5691.
R=golang-dev, bradfitz, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/
10255047
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
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"
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()) {