redef class AArrayExpr
redef fun expr(v)
do
- var mtype = self.mtype.as(MClassType).arguments.first
+ var mtype = self.element_mtype.as(not null)
var array = new Array[RuntimeVariable]
for nexpr in self.n_exprs do
var i = v.expr(nexpr, mtype)
end
redef class AArrayExpr
+ # The `with_capacity` method on Array
var with_capacity_callsite: nullable CallSite
+
+ # The `push` method on arrays
var push_callsite: nullable CallSite
+ # The element of each type
+ var element_mtype: nullable MType
+
redef fun accept_typing(v)
do
var mtype: nullable MType = null
assert ntype != null
v.modelbuilder.warning(ntype, "useless-type", "Warning: useless type declaration `{mtype}` in literal Array since it can be inferred from the elements type.")
end
+
+ self.element_mtype = mtype
+
var mclass = v.get_mclass(self, "Array")
if mclass == null then return # Forward error
var array_mtype = mclass.get_mtype([mtype])