mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: make sure closures inside generic funcs are not compiled
Closures inside generic functions were being added to the g.target.Decls list during noding, just like other closures. We remove generic functions/methods from g.target.Decls, so they don't get compiled (they're only available for export and stenciling). Most closures inside generic functions/methods were similarly being removed from g.target.Decls, because they have a generic parameter. But we need to ensure no closures in generic function/methods are left remaining in g.target.Decls, since we don't want them transformed and compiled. So, we set a flag in (*irgen) that records when we are noding a top-level generic function/method, and don't add any closures to g.target.Decls when the flag is true. Updates #47514 Change-Id: Id66b4c41d307ffa8f54cab6ce3646ade81606862 Reviewed-on: https://go-review.googlesource.com/c/go/+/340258 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
f78d538858
commit
ac78501b9c
4 changed files with 37 additions and 1 deletions
|
|
@ -154,6 +154,11 @@ type irgen struct {
|
|||
// dictionary syms which we need to finish, by writing out any itabconv
|
||||
// entries.
|
||||
dictSymsToFinalize []*delayInfo
|
||||
|
||||
// True when we are compiling a top-level generic function or method. Use to
|
||||
// avoid adding closures of generic functions/methods to the target.Decls
|
||||
// list.
|
||||
topFuncIsGeneric bool
|
||||
}
|
||||
|
||||
type delayInfo struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue