mirror of
https://github.com/golang/go
synced 2024-09-04 15:34:21 +00:00
[dev.typeparams] cmd/compile: explain why reader.funcExt need to set n.Defn
Change-Id: I1a7d669879af57a1c1f48ce63ff0d214b694e680 Reviewed-on: https://go-review.googlesource.com/c/go/+/329572 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
3f7f72a258
commit
e57da8e53c
|
@ -741,8 +741,13 @@ func (r *reader) funcExt(name *ir.Name) {
|
||||||
fn.SetPos(name.Pos())
|
fn.SetPos(name.Pos())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mdempsky): Remember why I wrote this code. I think it has to
|
// Normally, we only compile local functions, which saves redundant compilation work.
|
||||||
// do with how ir.VisitFuncsBottomUp works?
|
// n.Defn is not nil for local functions, and is nil for imported function. But for
|
||||||
|
// generic functions, we might have an instantiation that no other package has seen before.
|
||||||
|
// So we need to be conservative and compile it again.
|
||||||
|
//
|
||||||
|
// That's why name.Defn is set here, so ir.VisitFuncsBottomUp can analyze function.
|
||||||
|
// TODO(mdempsky,cuonglm): find a cleaner way to handle this.
|
||||||
if name.Sym().Pkg == types.LocalPkg || r.hasTypeParams() {
|
if name.Sym().Pkg == types.LocalPkg || r.hasTypeParams() {
|
||||||
name.Defn = fn
|
name.Defn = fn
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue