From 4a7975e73a2815b93caf6697fec4f4e777e729a1 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Fri, 15 Oct 2021 11:54:25 -0700 Subject: [PATCH] cmd/compile: convert to using a map in getInstInfo, rather than SetImplicit() SetImplicit() has an explicit meaning and really shouldn't be used in this way - its use is left over from early prototype of the dictionary code. Convert from using SetImplicit to just using a map during traversal. Change-Id: I3d257c101a859f000e159d7ced307d1b7cf990d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/356310 Run-TryBot: Dan Scales TryBot-Result: Go Bot Reviewed-by: Keith Randall Trust: Dan Scales --- src/cmd/compile/internal/noder/stencil.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index cfa90e4399..3a1baeae88 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1854,14 +1854,19 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } } + // Map to remember when we have seen an instantiated function value or method + // expression/value as part of a call, so we can determine when we encounter + // an uncalled function value or method expression/value. + callMap := make(map[ir.Node]bool) + var visitFunc func(ir.Node) visitFunc = func(n ir.Node) { - if n.Op() == ir.OFUNCINST && !n.(*ir.InstExpr).Implicit() { + if n.Op() == ir.OFUNCINST && !callMap[n] { if hasShapeNodes(n.(*ir.InstExpr).Targs) { infoPrint(" Closure&subdictionary required at generic function value %v\n", n.(*ir.InstExpr).X) info.subDictCalls = append(info.subDictCalls, n) } - } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !n.(*ir.SelectorExpr).Implicit() && + } else if (n.Op() == ir.OMETHEXPR || n.Op() == ir.OMETHVALUE) && !callMap[n] && !types.IsInterfaceMethod(n.(*ir.SelectorExpr).Selection.Type) && len(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { if hasShapeTypes(deref(n.(*ir.SelectorExpr).X.Type()).RParams()) { @@ -1874,16 +1879,15 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } } if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OFUNCINST { - n.(*ir.CallExpr).X.(*ir.InstExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true if hasShapeNodes(n.(*ir.CallExpr).X.(*ir.InstExpr).Targs) { infoPrint(" Subdictionary at generic function/method call: %v - %v\n", n.(*ir.CallExpr).X.(*ir.InstExpr).X, n) info.subDictCalls = append(info.subDictCalls, n) } } if n.Op() == ir.OCALLMETH && n.(*ir.CallExpr).X.Op() == ir.ODOTMETH && - //n.(*ir.CallExpr).X.(*ir.SelectorExpr).Selection != nil && len(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) > 0 { - n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true if hasShapeTypes(deref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()).RParams()) { infoPrint(" Subdictionary at generic method call: %v\n", n) info.subDictCalls = append(info.subDictCalls, n) @@ -1891,7 +1895,7 @@ func (g *genInst) getInstInfo(st *ir.Func, shapes []*types.Type, instInfo *instI } if n.Op() == ir.OCALL && n.(*ir.CallExpr).X.Op() == ir.OXDOT && isShapeDeref(n.(*ir.CallExpr).X.(*ir.SelectorExpr).X.Type()) { - n.(*ir.CallExpr).X.(*ir.SelectorExpr).SetImplicit(true) + callMap[n.(*ir.CallExpr).X] = true infoPrint(" Optional subdictionary at generic bound call: %v\n", n) info.subDictCalls = append(info.subDictCalls, n) } -- 2.48.1