mirror of
https://github.com/golang/go
synced 2024-11-26 17:46:57 -07:00
cmd/gc: blank methods are not permitted in interface types
Fixes #6606. LGTM=rsc R=rsc CC=golang-codereviews, gri https://golang.org/cl/156210044
This commit is contained in:
parent
42c3130780
commit
db4dad7fd7
@ -558,6 +558,9 @@ ifacedcl(Node *n)
|
|||||||
if(n->op != ODCLFIELD || n->right == N)
|
if(n->op != ODCLFIELD || n->right == N)
|
||||||
fatal("ifacedcl");
|
fatal("ifacedcl");
|
||||||
|
|
||||||
|
if(isblank(n->left))
|
||||||
|
yyerror("methods must have a unique non-blank name");
|
||||||
|
|
||||||
dclcontext = PPARAM;
|
dclcontext = PPARAM;
|
||||||
markdcl();
|
markdcl();
|
||||||
funcdepth++;
|
funcdepth++;
|
||||||
|
@ -83,12 +83,12 @@ var m4 = M(jj) // ERROR "invalid|wrong type for M method"
|
|||||||
|
|
||||||
|
|
||||||
type B1 interface {
|
type B1 interface {
|
||||||
_()
|
_() // ERROR "methods must have a unique non-blank name"
|
||||||
}
|
}
|
||||||
|
|
||||||
type B2 interface {
|
type B2 interface {
|
||||||
M()
|
M()
|
||||||
_()
|
_() // ERROR "methods must have a unique non-blank name"
|
||||||
}
|
}
|
||||||
|
|
||||||
type T2 struct{}
|
type T2 struct{}
|
||||||
|
@ -14,7 +14,6 @@ type I interface {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
shouldPanic(p1)
|
shouldPanic(p1)
|
||||||
shouldPanic(p2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func p1() {
|
func p1() {
|
||||||
@ -30,19 +29,6 @@ type S struct{}
|
|||||||
|
|
||||||
func (s *S) _() {}
|
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()) {
|
func shouldPanic(f func()) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if recover() == nil {
|
if recover() == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user