aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/decl.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder/decl.go')
-rw-r--r--src/cmd/compile/internal/noder/decl.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/noder/decl.go b/src/cmd/compile/internal/noder/decl.go
index a1596be4a4..f0cdcbfc2e 100644
--- a/src/cmd/compile/internal/noder/decl.go
+++ b/src/cmd/compile/internal/noder/decl.go
@@ -134,14 +134,14 @@ func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
}
// We need to use g.typeExpr(decl.Type) here to ensure that for
- // chained, defined-type declarations like
+ // chained, defined-type declarations like:
//
// type T U
//
// //go:notinheap
// type U struct { … }
//
- // that we mark both T and U as NotInHeap. If we instead used just
+ // we mark both T and U as NotInHeap. If we instead used just
// g.typ(otyp.Underlying()), then we'd instead set T's underlying
// type directly to the struct type (which is not marked NotInHeap)
// and fail to mark T as NotInHeap.
@@ -154,6 +154,12 @@ func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
// [mdempsky: Subtleties like these are why I always vehemently
// object to new type pragmas.]
ntyp.SetUnderlying(g.typeExpr(decl.Type))
+ if len(decl.TParamList) > 0 {
+ // Set HasTParam if there are any tparams, even if no tparams are
+ // used in the type itself (e.g., if it is an empty struct, or no
+ // fields in the struct use the tparam).
+ ntyp.SetHasTParam(true)
+ }
types.ResumeCheckSize()
if otyp, ok := otyp.(*types2.Named); ok && otyp.NumMethods() != 0 {