typ := r.typ()
pos := r.pos()
x := r.expr()
+
+ // TODO(mdempsky): Stop constructing expressions of untyped type.
+ x = typecheck.DefaultLit(x, typ)
+
+ if op, why := typecheck.Convertop(x.Op() == ir.OLITERAL, x.Type(), typ); op == ir.OXXX {
+ // types2 ensured that x is convertable to typ under standard Go
+ // semantics, but cmd/compile also disallows some conversions
+ // involving //go:notinheap.
+ //
+ // TODO(mdempsky): This can be removed after #46731 is implemented.
+ base.ErrorfAt(pos, "cannot convert %L to type %v%v", x, typ, why)
+ base.ErrorExit() // harsh, but prevents constructing invalid IR
+ }
+
return typecheck.Expr(ir.NewConvExpr(pos, ir.OCONV, typ, x))
}
}