n_args.n_exprs.add_all(args)
end
self.callsite = callsite
+ self.recvtype = callsite.recv.as(MClassType)
if callsite.mproperty.is_new then
self.mtype = callsite.msignature.return_mtype
else
redef class ANewExpr
redef fun expr(v)
do
- var mtype = v.unanchor_type(self.mtype.as(not null))
+ var mtype = v.unanchor_type(self.recvtype.as(not null))
var recv: Instance = new MutableInstance(mtype)
v.init_instance(recv)
var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs)
# The constructor invoked by the new.
var callsite: nullable CallSite
+ # The designated type
+ var recvtype: nullable MClassType
+
redef fun accept_typing(v)
do
var recvtype = v.resolve_mtype(self.n_type)
if recvtype == null then return
- self.mtype = recvtype
if not recvtype isa MClassType then
if recvtype isa MNullableType then
end
end
+ self.recvtype = recvtype
+
var name: String
var nid = self.n_id
if nid != null then
var callsite = v.get_method(self, recvtype, name, false)
if callsite == null then return
+ if not callsite.mproperty.is_new then
+ self.mtype = recvtype
+ else
+ self.mtype = callsite.msignature.return_mtype
+ assert self.mtype != null
+ end
+
self.callsite = callsite
if not callsite.mproperty.is_init_for(recvtype.mclass) then