end
end
+ # Display a warning on `node` if `not mpropdef.is_fictive`
+ fun display_warning(node: ANode, tag: String, message: String)
+ do
+ if not mpropdef.is_fictive then self.modelbuilder.warning(node, tag, message)
+ end
+
fun anchor_to(mtype: MType): MType
do
return mtype.anchor_to(mmodule, anchor)
if sup == null then return null # Forward error
if sup == sub then
- self.modelbuilder.warning(node, "useless-type-test", "Warning: expression is already a `{sup}`.")
+ display_warning(node, "useless-type-test", "Warning: expression is already a `{sup}`.")
else if self.is_subtype(sub, sup) then
- self.modelbuilder.warning(node, "useless-type-test", "Warning: expression is already a `{sup}` since it is a `{sub}`.")
+ display_warning(node, "useless-type-test", "Warning: expression is already a `{sup}` since it is a `{sub}`.")
end
return sup
end
fun check_can_be_null(anode: ANode, mtype: MType): Bool
do
if mtype isa MNullType then
- modelbuilder.warning(anode, "useless-null-test", "Warning: expression is always `null`.")
+ display_warning(anode, "useless-null-test", "Warning: expression is always `null`.")
return true
end
if can_be_null(mtype) then return true
if mtype isa MFormalType then
var res = anchor_to(mtype)
- modelbuilder.warning(anode, "useless-null-test", "Warning: expression is not null, since it is a `{mtype}: {res}`.")
+ display_warning(anode, "useless-null-test", "Warning: expression is not null, since it is a `{mtype}: {res}`.")
else
- modelbuilder.warning(anode, "useless-null-test", "Warning: expression is not null, since it is a `{mtype}`.")
+ display_warning(anode, "useless-null-test", "Warning: expression is not null, since it is a `{mtype}`.")
end
return false
end
if info != null and self.mpropdef.mproperty.deprecation == null then
var mdoc = info.mdoc
if mdoc != null then
- self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: method `{mproperty.name}` is deprecated: {mdoc.content.first}")
+ display_warning(node, "deprecated-method", "Deprecation Warning: method `{mproperty.name}` is deprecated: {mdoc.content.first}")
else
- self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: method `{mproperty.name}` is deprecated.")
+ display_warning(node, "deprecated-method", "Deprecation Warning: method `{mproperty.name}` is deprecated.")
end
end
else if propdefs.length == 1 then
mpropdef = propdefs.first
else
- self.modelbuilder.warning(node, "property-conflict", "Warning: conflicting property definitions for property `{mproperty.name}` in `{unsafe_type}`: {propdefs.join(" ")}")
+ display_warning(node, "property-conflict", "Warning: conflicting property definitions for property `{mproperty.name}` in `{unsafe_type}`: {propdefs.join(" ")}")
mpropdef = mproperty.intro
end
end
if useless then
assert ntype != null
- v.modelbuilder.warning(ntype, "useless-type", "Warning: useless type declaration `{mtype}` in literal Array since it can be inferred from the elements type.")
+ v.display_warning(ntype, "useless-type", "Warning: useless type declaration `{mtype}` in literal Array since it can be inferred from the elements type.")
end
self.element_mtype = mtype
if mtype == null or mtype2 == null then return
if mtype == v.type_bool(self) and (n_expr2 isa AFalseExpr or n_expr2 isa ATrueExpr) then
- v.modelbuilder.warning(self, "useless-truism", "Warning: useless comparison to a Bool literal.")
+ v.display_warning(self, "useless-truism", "Warning: useless comparison to a Bool literal.")
end
if not mtype2 isa MNullType then return
self.mtype = mtype.as_notnull
if not v.can_be_null(mtype) then
- v.modelbuilder.warning(self, "useless-safe", "Warning: useless safe operator `?` on non-nullable value.")
+ v.display_warning(self, "useless-safe", "Warning: useless safe operator `?` on non-nullable value.")
return
end
end
var mtype = v.resolve_mtype(ntype)
if mtype != null and mtype != expr then
var umtype = v.anchor_to(mtype)
- v.modelbuilder.warning(self, "debug", "Found type {expr} (-> {unsafe}), expected {mtype} (-> {umtype})")
+ v.display_warning(self, "debug", "Found type {expr} (-> {unsafe}), expected {mtype} (-> {umtype})")
end
self.is_typed = true
end