Signed-off-by: Jean Privat <jean@pryen.org>
fun dcp: DetectCovariancePhase do return modelbuilder.toolcontext.detect_covariance_phase
fun dcp: DetectCovariancePhase do return modelbuilder.toolcontext.detect_covariance_phase
- redef fun visit_expr_cast(node, nexpr, ntype)
+ redef fun check_expr_cast(node, nexpr, ntype)
- fun visit_expr_cast(node: ANode, nexpr: AExpr, ntype: AType): nullable MType
+ fun check_expr_cast(node: ANode, nexpr: AExpr, ntype: AType): nullable MType
- var sub = visit_expr(nexpr)
if sub == null then return null # Forward error
if sub == null then return null # Forward error
- var sup = self.resolve_mtype(ntype)
if sup == null then return null # Forward error
if sup == sub then
if sup == null then return null # Forward error
if sup == sub then
if not mtype2 isa MNullType then return
# Check of useless null
if not mtype2 isa MNullType then return
# Check of useless null
- if not check_can_be_null(anode.n_expr, mtype) then return
+ if not can_be_null(mtype) then return
if mtype isa MNullType then
# Because of type adaptation, we cannot just stop here
if mtype isa MNullType then
# Because of type adaptation, we cannot just stop here
if t1 isa MNullType then
self.mtype = t2
return
if t1 isa MNullType then
self.mtype = t2
return
- else if v.check_can_be_null(n_expr, t1) then
+ else if v.can_be_null(t1) then
+
+ redef fun accept_post_typing(v)
+ do
+ var t1 = n_expr.mtype
+ if t1 == null then
+ return
+ else
+ v.check_can_be_null(n_expr, t1)
+ end
+ end
end
redef class ATrueExpr
end
redef class ATrueExpr
var cast_type: nullable MType
redef fun accept_typing(v)
do
var cast_type: nullable MType
redef fun accept_typing(v)
do
- var mtype = v.visit_expr_cast(self, self.n_expr, self.n_type)
+ v.visit_expr(n_expr)
+
+ var mtype = v.resolve_mtype(n_type)
+
self.cast_type = mtype
var variable = self.n_expr.its_variable
self.cast_type = mtype
var variable = self.n_expr.its_variable
self.mtype = v.type_bool(self)
end
self.mtype = v.type_bool(self)
end
+
+ redef fun accept_post_typing(v)
+ do
+ v.check_expr_cast(self, self.n_expr, self.n_type)
+ end
end
redef class AAsCastExpr
redef fun accept_typing(v)
do
end
redef class AAsCastExpr
redef fun accept_typing(v)
do
- self.mtype = v.visit_expr_cast(self, self.n_expr, self.n_type)
+ v.visit_expr(n_expr)
+
+ self.mtype = v.resolve_mtype(n_type)
+ end
+
+ redef fun accept_post_typing(v)
+ do
+ v.check_expr_cast(self, self.n_expr, self.n_type)
- if v.check_can_be_null(n_expr, mtype) then
+ if v.can_be_null(mtype) then
mtype = mtype.as_notnull
end
self.mtype = mtype
end
mtype = mtype.as_notnull
end
self.mtype = mtype
end
+
+ redef fun accept_post_typing(v)
+ do
+ var mtype = n_expr.mtype
+ if mtype == null then return
+ v.check_can_be_null(n_expr, mtype)
+ end
super
v.null_test(self)
end
super
v.null_test(self)
end
+
+ redef fun accept_post_typing(v)
+ do
+ var mtype = n_expr.mtype
+ var mtype2 = n_expr2.mtype
+
+ if mtype == null or mtype2 == null then return
+
+ if not mtype2 isa MNullType then return
+
+ v.check_can_be_null(n_expr, mtype)
+ end
end
redef class AUnaryopExpr
end
redef class AUnaryopExpr