end
assert mproperty isa MMethod
- if mproperty.visibility == protected_visibility and not recv_is_self and self.mmodule.visibility_for(mproperty.intro_mclassdef.mmodule) < intrude_visibility then
- self.modelbuilder.error(node, "Error: Method '{name}' is protected and can only acceded by self. {mproperty.intro_mclassdef.mmodule.visibility_for(self.mmodule)}")
+ if mproperty.visibility == protected_visibility and not recv_is_self and self.mmodule.visibility_for(mproperty.intro_mclassdef.mmodule) < intrude_visibility and not modelbuilder.toolcontext.opt_ignore_visibility.value then
+ self.modelbuilder.error(node, "Error: Method '{name}' is protected and can only acceded by self.")
return null
end
end
end
- var callsite = new CallSite(node, recvtype, recv_is_self, mproperty, mpropdef, msignature, erasure_cast)
+ var callsite = new CallSite(node, recvtype, mmodule, anchor, recv_is_self, mproperty, mpropdef, msignature, erasure_cast)
return callsite
end
# The assiciated node for location
var node: ANode
- # The statis type of the receiver
+ # The static type of the receiver (possibly unresolved)
var recv: MType
+ # The module where the callsite is present
+ var mmodule: MModule
+
+ # The anchor to use with `recv` or `msignature`
+ var anchor: nullable MClassType
+
# Is the receiver self?
# If "for_self", virtual types of the signature are keeped
# If "not_for_self", virtual type are erased
end
redef class ARangeExpr
+ var init_callsite: nullable CallSite
+
redef fun accept_typing(v)
do
var discrete_class = v.get_mclass(self, "Discrete")
if t1 == null or t2 == null then return
var mclass = v.get_mclass(self, "Range")
if mclass == null then return # Forward error
+ var mtype
if v.is_subtype(t1, t2) then
- self.mtype = mclass.get_mtype([t2])
+ mtype = mclass.get_mtype([t2])
else if v.is_subtype(t2, t1) then
- self.mtype = mclass.get_mtype([t1])
+ mtype = mclass.get_mtype([t1])
else
v.error(self, "Type Error: Cannot create range: {t1} vs {t2}")
+ return
+ end
+
+ self.mtype = mtype
+
+ # get the constructor
+ var callsite
+ if self isa ACrangeExpr then
+ callsite = v.get_method(self, mtype, "init", false)
+ else if self isa AOrangeExpr then
+ callsite = v.get_method(self, mtype, "without_last", false)
+ else
+ abort
end
+ init_callsite = callsite
end
end
end
var msignature = v.resolve_signature_for(superprop, recvtype, true)
- var callsite = new CallSite(self, recvtype, true, superprop.mproperty, superprop, msignature, false)
+ var callsite = new CallSite(self, recvtype, v.mmodule, v.anchor, true, superprop.mproperty, superprop, msignature, false)
self.callsite = callsite
var args = self.n_args.to_a