[dev.typeparams] cmd/compile: simplify NewClosureFunc

I initially made NewClosureFunc take an "outerfn *Func" parameter
because I was planning on having it handle closure naming, until
remembering that naming needs to wait until typecheck for noder.

We don't actually need the *Func yet, just to know whether it's
non-nil. So change the parameter to a bool, which simplifies callers a
little.

Change-Id: Ie83ee4a1ed0571ac6d3879ffd8474c6c3c1a9ff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/327450
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2021-06-12 07:33:18 -07:00
parent db7c868307
commit f1b1c2f67f
7 changed files with 20 additions and 20 deletions

View file

@ -280,7 +280,7 @@ func (g *irgen) buildClosure(outer *ir.Func, x ir.Node) ir.Node {
// }
// Make a new internal function.
fn := ir.NewClosureFunc(pos, outer)
fn := ir.NewClosureFunc(pos, outer != nil)
ir.NameClosure(fn.OClosure, outer)
// This is the dictionary we want to use.
@ -857,7 +857,7 @@ func (subst *subster) node(n ir.Node) ir.Node {
// Need to duplicate x.Func.Nname, x.Func.Dcl, x.Func.ClosureVars, and
// x.Func.Body.
oldfn := x.Func
newfn := ir.NewClosureFunc(oldfn.Pos(), subst.newf)
newfn := ir.NewClosureFunc(oldfn.Pos(), subst.newf != nil)
ir.NameClosure(newfn.OClosure, subst.newf)
newfn.SetClosureCalled(oldfn.ClosureCalled())