nitc :: MMethodDef :: no_contract_apply
no_contract
annotation to the contract. This method removes the inheritance by adding an empty contract method.Display a warning if the annotation is not needed
# Apply the `no_contract` annotation to the contract. This method removes the inheritance by adding an empty contract method.
# Display a warning if the annotation is not needed
private fun no_contract_apply(v: ContractsVisitor, n_signature: ASignature)
do
var mensure = mproperty.mensure
var mexpect = mproperty.mexpect
if mensure == null and mexpect == null then
v.toolcontext.warning(location, "useless_nocontract", "Useless `no_contract`, no contract was declared for `{name}`. Remove the `no_contract`")
end
if mensure != null then
# Add an empty ensure method to replace the actual definition
v.toolcontext.modelbuilder.create_method_from_property(mensure, mclassdef, false, mensure.intro.msignature)
end
if mexpect != null then
# Add an empty expect method to replace the actual definition
v.toolcontext.modelbuilder.create_method_from_property(mexpect, mclassdef, false, mexpect.intro.msignature)
end
end
src/contracts.nit:679,2--696,4