end
end
+redef class ASignature
+ redef fun after_typing(v)
+ do
+ if self.n_opar != null and self.n_params.is_empty then
+ v.warning(self, "Warning: superfluous parentheses.")
+ end
+ end
+end
+
redef class AParam
redef fun after_typing(v)
do
end
# An abstract control structure with feature escapable block
-class AAbsControl
+abstract class AAbsControl
super AExpr
# The corresponding escapable block
readable var _escapable: nullable EscapableBlock
if c == prev_class then
prev_class = null
else if c == cla then
- if prev_class != null then
- v.error(self, "Error: Constructor of {c} must be invoked before constructor of {prev_class}")
- end
esic.add(property)
break
end
v.error(self, "Error: try to instantiate abstract class {t.local_class}.")
return
end
+ if t.is_nullable then
+ v.error(self, "Type error: cannot instantiate the nullable type {t}.")
+ end
var name: Symbol
if n_id == null then
name = once "init".to_symbol
n = new AClosureCallExpr.init_aclosurecallexpr(n_id, n_args, n_closure_defs)
n._variable = variable
else
- if not n_args.n_exprs.is_empty then
+ if not n_args.n_exprs.is_empty or n_args isa AParExprs then
v.error(self, "Error: {name} is variable, not a function.")
return
end
end
end
-class ATypeCheckExpr
+abstract class ATypeCheckExpr
super AExpr
private fun check_expr_cast(v: TypingVisitor, n_expr: AExpr, n_type: AType)
do
if etype == ttype then
v.warning(self, "Warning: Expression is already a {ttype}.")
else if etype < ttype then
- v.warning(self, "Warning: Expression is already a {ttype} since it is a {etype}.")
+ if not ttype isa MMTypeFormal then
+ # the old metamodel is not that great with formal types
+ v.warning(self, "Warning: Expression is already a {ttype} since it is a {etype}.")
+ end
else if etype isa MMTypeNone then
# ttype is not nullable because of prevous test
v.warning(self, "Warning: Expression is null therefore cannot be a {ttype}.")
end
end
+redef class ADebugTypeExpr
+ redef fun after_typing(v)
+ do
+ if not v.check_expr(n_expr) then return
+ if not n_type.is_typed then return
+ var etype = n_expr.stype
+ var ttype = n_type.stype
+ if etype != ttype then
+ v.warning(self, "Warning: Expression is a {etype}, expected {ttype}.")
+ end
+ end
+end