]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: silence errors about missing blank methods
authorMatthew Dempsky <mdempsky@google.com>
Thu, 3 Dec 2020 22:00:19 +0000 (14:00 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 7 Dec 2020 06:40:04 +0000 (06:40 +0000)
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>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/noder.go
test/interface/explicit.go

index 5936aeb950152ea1980c8f35d430c7748085447a..a77c1aed455546f60a11798942a9882ff660c199 100644 (file)
@@ -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
index 61320123a8a2ccd982bc819786cedbb978e202fe..1cd83756773b7192ac6d65c50edb6f6411aaab7d 100644 (file)
@@ -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)
        }
index 3f9451e8d2faa1f34d8f0dda4c780a8ccaf44d10..b705b976760071f6cf132c0a4be545ddc1945882 100644 (file)
@@ -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{}