cmd/compile: delay fillinMethods to deal with mutually-recursive types

We need to delay fillinMethods until we get to a top-level type, so we
know all the TFORW types have been filled in, and we can do the
substitutions required by fillinMethods.

Fixes #47710

Change-Id: I298de7e7753ed31a2c2b1ff04f35177a8afc7a66
Reviewed-on: https://go-review.googlesource.com/c/go/+/345149
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Dan Scales 2021-08-18 06:28:40 -07:00
parent c927599783
commit d7e2e2ec2b
4 changed files with 112 additions and 67 deletions

View file

@ -149,6 +149,9 @@ type irgen struct {
// statements yet.
exprStmtOK bool
// types which we need to finish, by doing g.fillinMethods.
typesToFinalize []*typeDelayInfo
// Fully-instantiated generic types whose methods should be instantiated
instTypeList []*types.Type
@ -184,6 +187,11 @@ type delayInfo struct {
off int
}
type typeDelayInfo struct {
typ *types2.Named
ntyp *types.Type
}
func (g *irgen) generate(noders []*noder) {
types.LocalPkg.Name = g.self.Name()
types.LocalPkg.Height = g.self.Height()