diff options
author | Dan Scales <danscales@google.com> | 2021-05-10 16:23:35 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-05-21 23:13:46 +0000 |
commit | 8d2b4cb6cc3100f337e08cc7342f42823fa1dc9a (patch) | |
tree | 4eb794e8e1cf3f0235d4f13f659cbb52f45e2979 /src/cmd/compile/internal/typecheck/iimport.go | |
parent | 626e89c261297d13ef892bb569640cd72c35b98a (diff) | |
download | go-8d2b4cb6cc3100f337e08cc7342f42823fa1dc9a.tar.gz go-8d2b4cb6cc3100f337e08cc7342f42823fa1dc9a.zip |
[dev.typeparams] cmd/compile: fixing import of comm clauses/closures in generic functions
Improvements:
- Fix export/import of the default case of a select statement (was not
dealing with nil Comm case)
- Set properly the name of closure functions in imported generic
functions
Added new test exporting/importing a reasonably large channel package,
chansimp.go.
Change-Id: If2ee12bd749e5df415f48ec4b629a2fa68a79dcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/321734
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iimport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iimport.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 39b5ab09da..966e865630 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -1121,7 +1121,13 @@ func (r *importReader) caseList(switchExpr ir.Node) []*ir.CaseClause { func (r *importReader) commList() []*ir.CommClause { cases := make([]*ir.CommClause, r.uint64()) for i := range cases { - cases[i] = ir.NewCommStmt(r.pos(), r.node(), r.stmtList()) + pos := r.pos() + defaultCase := r.bool() + var comm ir.Node + if !defaultCase { + comm = r.node() + } + cases[i] = ir.NewCommStmt(pos, comm, r.stmtList()) } return cases } @@ -1257,6 +1263,12 @@ func (r *importReader) node() ir.Node { if go117ExportTypes { clo.SetType(typ) } + if r.curfn.Type().HasTParam() { + // Generic functions aren't inlined, so give the closure a + // function name now, which is then available for use + // (after appending the type args) for each stenciling. + fn.Nname.SetSym(ClosureName(r.curfn)) + } return clo |