return s
}
- sym := shapePkg.Lookup(u.LinkString())
+ sym := types.ShapePkg.Lookup(u.LinkString())
+ if sym.Def != nil {
+ // Use any existing type with the same name
+ shaped[u] = sym.Def.Type()
+ return shaped[u]
+ }
name := ir.NewDeclNameAt(u.Pos(), ir.OTYPE, sym)
s := types.NewNamed(name)
+ sym.Def = name
s.SetUnderlying(u)
s.SetIsShape(true)
s.SetHasShape(true)
}
var shaped = map[*types.Type]*types.Type{}
-
-var shapePkg = types.NewPkg(".shape", ".shape")
t := newType(TFORW)
t.sym = obj.Sym()
t.nod = obj
+ if t.sym.Pkg == ShapePkg {
+ t.SetIsShape(true)
+ t.SetHasShape(true)
+ }
return t
}
)
var SimType [NTYPE]Kind
+
+var ShapePkg = NewPkg(".shape", ".shape")
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+type Container[T any] struct {
+ X T
+}
+
+func NewContainer[T any](x T) *Container[T] {
+ return &Container[T]{x}
+}
+
+type MetaContainer struct {
+ C *Container[Value]
+}
+
+type Value struct{}
+
+func NewMetaContainer() *MetaContainer {
+ c := NewContainer(Value{})
+ // c := &Container[Value]{Value{}} // <-- this works
+ return &MetaContainer{c}
+}
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "a"
+
+func main() {
+ a.NewMetaContainer()
+}
--- /dev/null
+// rundir -G=3
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored