]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "Revert "cmd/compile: discard duplicate inline method bodies""
authorAustin Clements <austin@google.com>
Fri, 11 Aug 2017 14:36:16 +0000 (14:36 +0000)
committerAustin Clements <austin@google.com>
Mon, 14 Aug 2017 01:38:08 +0000 (01:38 +0000)
This reverts commit f612cd704a260cf362e5b6307b7ace4eb83f5f56.

Reason for revert: We thought the original change had broken the
linux/amd64 and linux/386 builders, but it turned out to be a problem
with the build infrastructure, not the change.

Change-Id: Ic3318a63464fcba8d845ac04494115a7ba620364
Reviewed-on: https://go-review.googlesource.com/55050
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bimport.go

index 866b9a752586e975b98ecf65ea3aae126173d276..ba542b4719efead1403602f9dbe9661300bfd169 100644 (file)
@@ -484,6 +484,7 @@ func (p *importer) typ() *types.Type {
 
                t = pkgtype(p.imp, tsym)
                p.typList = append(p.typList, t)
+               dup := !t.IsKind(types.TFORW) // type already imported
 
                // read underlying type
                t0 := p.typ()
@@ -514,10 +515,19 @@ func (p *importer) typ() *types.Type {
                        result := p.paramList()
                        nointerface := p.bool()
 
+                       mt := functypefield(recv[0], params, result)
+                       addmethod(sym, mt, false, nointerface)
+
+                       if dup {
+                               // An earlier import already declared this type and its methods.
+                               // Discard the duplicate method declaration.
+                               p.funcList = append(p.funcList, nil)
+                               continue
+                       }
+
                        n := newfuncname(methodname(sym, recv[0].Type))
-                       n.Type = functypefield(recv[0], params, result)
+                       n.Type = mt
                        checkwidth(n.Type)
-                       addmethod(sym, n.Type, false, nointerface)
                        p.funcList = append(p.funcList, n)
                        importlist = append(importlist, n)