g.instTypeList = append(g.instTypeList, subst.unshapify.InstTypeList...)
g.instTypeList = append(g.instTypeList, subst.concretify.InstTypeList...)
+ if doubleCheck {
+ okConvs := map[ir.Node]bool{}
+ ir.Visit(newf, func(n ir.Node) {
+ if n.Op() == ir.OIDATA {
+ // IDATA(OCONVIFACE(x)) is ok, as we don't use the type of x.
+ // TODO: use some other op besides OCONVIFACE. ONEW might work
+ // (with appropriate direct vs. indirect interface cases).
+ okConvs[n.(*ir.UnaryExpr).X] = true
+ }
+ if n.Op() == ir.OCONVIFACE && !okConvs[n] {
+ c := n.(*ir.ConvExpr)
+ if c.X.Type().HasShape() {
+ ir.Dump("BAD FUNCTION", newf)
+ ir.Dump("BAD CONVERSION", c)
+ base.Fatalf("converting shape type to interface")
+ }
+ }
+ })
+ }
+
return newf
}
if x.X.Type().HasTParam() {
m = subst.convertUsingDictionary(m.Pos(), m.(*ir.ConvExpr).X, x, m.Type(), x.X.Type())
}
+ case ir.ODOTTYPE, ir.ODOTTYPE2:
+ m.SetType(subst.unshapifyTyp(m.Type()))
case ir.ONEW:
// New needs to pass a concrete type to the runtime.
// Enforce that only concrete types can make it to here.
for _, t := range targs {
- if t.IsShape() {
+ if t.HasShape() {
panic(fmt.Sprintf("shape %+v in dictionary for %s", t, gf.Sym().Name))
}
}
// MarkTypeUsedInInterface marks that type t is converted to an interface.
// This information is used in the linker in dead method elimination.
func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) {
+ if t.HasShape() {
+ // TODO: shape types shouldn't be put in interfaces, so we shouldn't ever get here.
+ // We don't from ../noder/stencil.go, but we do from ../walk/walk.go when we let
+ // shape types become the types of interfaces.
+ //base.Fatalf("shape types have no methods %+v", t)
+ }
tsym := TypeLinksym(t)
// Emit a marker relocation. The linker will know the type is converted
// to an interface if "from" is reachable.