diff options
Diffstat (limited to 'src/cmd/compile/internal/noder/stencil.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 8dcc9d811e..78e701eaf8 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -715,12 +715,10 @@ func (subst *subster) typ(t *types.Type) *types.Type { return newsym.Def.Type() } - // In order to deal with recursive generic types, create a TFORW type - // initially and set its Def field, so it can be found if this type - // appears recursively within the type. - forw = types.New(types.TFORW) - forw.SetSym(newsym) - newsym.Def = ir.TypeNode(forw) + // In order to deal with recursive generic types, create a TFORW + // type initially and set the Def field of its sym, so it can be + // found if this type appears recursively within the type. + forw = newNamedTypeWithSym(t.Pos(), newsym) //println("Creating new type by sub", newsym.Name, forw.HasTParam()) forw.SetRParams(neededTargs) } @@ -894,3 +892,13 @@ func deref(t *types.Type) *types.Type { } return t } + +// newNamedTypeWithSym returns a TFORW type t with name specified by sym, such +// that t.nod and sym.Def are set correctly. +func newNamedTypeWithSym(pos src.XPos, sym *types.Sym) *types.Type { + name := ir.NewDeclNameAt(pos, ir.OTYPE, sym) + forw := types.NewNamed(name) + name.SetType(forw) + sym.Def = name + return forw +} |
