mirror of
https://github.com/golang/go
synced 2024-11-26 10:48:22 -07:00
[dev.regabi] cmd/compile: silence errors about missing blank methods
If an interface contains a blank method, that's already an error. No need for useless follow-up error messages about not implementing them. Fixes #42964. Change-Id: I5bf53a8f27d75d4c86c61588c5e2e3e95563d320 Reviewed-on: https://go-review.googlesource.com/c/go/+/275294 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
e885df2731
commit
d90b199e9c
@ -317,18 +317,6 @@ func colasdefn(left []ir.Node, defn ir.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
// declare the arguments in an
|
||||
// interface field declaration.
|
||||
func ifacedcl(n *ir.Field) {
|
||||
if n.Sym == nil {
|
||||
base.Fatalf("ifacedcl")
|
||||
}
|
||||
|
||||
if n.Sym.IsBlank() {
|
||||
base.Errorf("methods must have a unique non-blank name")
|
||||
}
|
||||
}
|
||||
|
||||
// declare the function proper
|
||||
// and declare the arguments.
|
||||
// called in extern-declaration context
|
||||
|
@ -899,10 +899,13 @@ func (p *noder) interfaceType(expr *syntax.InterfaceType) ir.Node {
|
||||
n = ir.NewField(p.pos(method), nil, importName(p.packname(method.Type)).(ir.Ntype), nil)
|
||||
} else {
|
||||
mname := p.name(method.Name)
|
||||
if mname.IsBlank() {
|
||||
base.Errorf("methods must have a unique non-blank name")
|
||||
continue
|
||||
}
|
||||
sig := p.typeExpr(method.Type).(*ir.FuncType)
|
||||
sig.Recv = fakeRecv()
|
||||
n = ir.NewField(p.pos(method), mname, sig, nil)
|
||||
ifacedcl(n)
|
||||
}
|
||||
l = append(l, n)
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ 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"
|
||||
// Already reported about the invalid blank interface method above;
|
||||
// no need to report about not implementing it.
|
||||
var b1 B1 = &T2{}
|
||||
var b2 B2 = &T2{}
|
||||
|
Loading…
Reference in New Issue
Block a user