From e4bed415ead32ece0acb396f025d3338fab5029d Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 24 Aug 2022 13:47:48 -0700 Subject: [PATCH] go/internal/gcimporter: call Complete on cloned Interfaces too 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 Run-TryBot: Matthew Dempsky Reviewed-by: Robert Griesemer --- src/go/internal/gcimporter/ureader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/go/internal/gcimporter/ureader.go b/src/go/internal/gcimporter/ureader.go index 15c8c2032dd..53bb9bacb07 100644 --- a/src/go/internal/gcimporter/ureader.go +++ b/src/go/internal/gcimporter/ureader.go @@ -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)