mirror of
https://github.com/golang/go
synced 2024-11-11 20:40:21 -07:00
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
This commit is contained in:
parent
d00bd1d1f4
commit
f316a7ea87
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user