From dfd875d015fb67671a2374c229e2159388d37693 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 22 Sep 2021 20:20:09 -0700 Subject: cmd/compile: allow methods on shape types (but no bodies) In a previous change, I was too aggressive in substInstType() in not generating methods for shape types during import. We do actually want to generate the method nodes - we just don't want to generate method bodies (which we would never use). We may need the method nodes for checking types later in the compile (especially with inlining). So, we do generate method nodes for shape types during import. In order to avoid the name collision we previously had, we now add ".nofunc." to the method nodes for shape types (during import and in the type substituter). We do that by passing in a 'isMethodNode' arg to MakeInstSym. We keep the normal name (without ".nofunc") for any other method nodes, and for the instantiated functions that help with implementing the methods of fully-instantiated types. The ".nofunc" names will never appear in the executable, since we don't generate any method bodies for the method nodes of shape types. Change-Id: I3e57e328691214140ca5f48d32011552d2a0d45d Reviewed-on: https://go-review.googlesource.com/c/go/+/352470 Trust: Dan Scales Reviewed-by: Keith Randall --- src/cmd/compile/internal/noder/stencil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/compile/internal/noder') diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index bc142e6985..772fcca46a 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -626,7 +626,7 @@ func (g *irgen) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMeth shapes = s1 } - sym := typecheck.MakeFuncInstSym(nameNode.Sym(), shapes, isMeth) + sym := typecheck.MakeFuncInstSym(nameNode.Sym(), shapes, false, isMeth) info := g.instInfoMap[sym] if info == nil { // If instantiation doesn't exist yet, create it and add -- cgit v1.3