Signed-off-by: Jean Privat <jean@pryen.org>
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
+ assert auto_super_init.mproperty != mpropdef.mproperty
v.compile_callsite(auto_super_init, args)
end
end
v.compile_callsite(auto_super_init, args)
end
end
+ if auto_super_call then
+ v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments)
+ end
var n_block = n_block
if n_block != null then
var n_block = n_block
if n_block != null then
- # In case of constructor, the list of implicit auto super init constructors invoked (if needed)
+ # In case of introduced constructor, the list of implicit auto super init constructors invoked (if needed)
var auto_super_inits: nullable Array[CallSite] = null
var auto_super_inits: nullable Array[CallSite] = null
+ # In case of redefined constructors, is an implicit call-to-super required?
+ var auto_super_call = false
+
fun do_auto_super_init(modelbuilder: ModelBuilder)
do
var mclassdef = self.parent.as(AClassdef).mclassdef.as(not null)
fun do_auto_super_init(modelbuilder: ModelBuilder)
do
var mclassdef = self.parent.as(AClassdef).mclassdef.as(not null)
if nosuper != null then return
if nosuper != null then return
+ # Still here? So it means that we must add an implicit super-call on redefinitions.
+ if not mpropdef.is_intro then
+ auto_super_call = true
+ mpropdef.has_supercall = true
+ return
+ end
+
# Still here? So it means that we must determine what super inits need to be automatically invoked
var auto_super_inits = new Array[CallSite]
# Still here? So it means that we must determine what super inits need to be automatically invoked
var auto_super_inits = new Array[CallSite]
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
+ assert auto_super_init.mproperty != mpropdef.mproperty
v.callsite(auto_super_init, args)
end
end
v.callsite(auto_super_init, args)
end
end
+ if auto_super_call then
+ # standard call-next-method
+ var superpd = mpropdef.lookup_next_definition(v.mainmodule, arguments.first.mtype)
+ v.call_without_varargs(superpd, arguments)
+ end
if n_block != null then
v.stmt(self.n_block)
if n_block != null then
v.stmt(self.n_block)
v.add_monomorphic_send(v.receiver, su)
end
end
v.add_monomorphic_send(v.receiver, su)
end
end
v.add_callsite(auto_super_init)
end
end
v.add_callsite(auto_super_init)
end
end
+ if npropdef.auto_super_call then
+ self.add_super_send(v.receiver, mmethoddef)
+ end