]> Cypherpunks repositories - gostls13.git/commitdiff
go/internal/gcimporter: call Complete on cloned Interfaces too
authorMatthew Dempsky <mdempsky@google.com>
Wed, 24 Aug 2022 20:47:48 +0000 (13:47 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 24 Aug 2022 21:09:24 +0000 (21:09 +0000)
For "type T interface{ M() }", go/types users expect T's underlying
interface type to specify T as the receiver parameter type (#49906).
The unified importer handles this by cloning the interface to rewrite
the receiver parameters before calling SetUnderlying.

I missed in CL 425360 that these interfaces would need to have
Complete called too.

Manually tested to confirm that this actually fixes "go test -race
golang.org/x/tools/go/analysis/internal/checker" now (when both CLs
are ported to the x/tools importer).

Updates #54653.

Change-Id: I51e6db925db56947cd39dbe880230f14734ca01c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425365
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/go/internal/gcimporter/ureader.go

index 15c8c2032ddaffad06cd19539d44558aa3dce024..53bb9bacb07ca249bc58933f982a6f41e5f391d4 100644 (file)
@@ -539,7 +539,9 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
                                                embeds[i] = iface.EmbeddedType(i)
                                        }
 
-                                       underlying = types.NewInterfaceType(methods, embeds)
+                                       newIface := types.NewInterfaceType(methods, embeds)
+                                       r.p.ifaces = append(r.p.ifaces, newIface)
+                                       underlying = newIface
                                }
 
                                named.SetUnderlying(underlying)