nitc :: AMethPropdef :: check_annotation
If this is the case, we built the appropriate contract.
# Verification of the annotation to know if it is a contract annotation.
# If this is the case, we built the appropriate contract.
private fun check_annotation(v: ContractsVisitor)
do
var annotations_expect = get_annotations("expect")
var annotations_ensure = get_annotations("ensure")
var annotation_no_contract = get_annotations("no_contract")
if (not annotations_expect.is_empty or not annotations_ensure.is_empty) and not annotation_no_contract.is_empty then
v.toolcontext.error(location, "The new contract definition is not correct when using `no_contract`. Remove the contract definition or the `no_contract`")
return
end
var nsignature = n_signature or else new ASignature
if not annotation_no_contract.is_empty then
mpropdef.no_contract_apply(v, nsignature.clone)
return
end
if not annotations_expect.is_empty then
var exist_contract = mpropdef.mproperty.has_expect
mpropdef.construct_contract(v, nsignature.clone, annotations_expect, mpropdef.mproperty.build_expect, exist_contract)
end
if not annotations_ensure.is_empty then
var exist_contract = mpropdef.mproperty.has_ensure
mpropdef.construct_contract(v, nsignature.clone, annotations_ensure, mpropdef.mproperty.build_ensure, exist_contract)
end
end
src/contracts.nit:718,2--747,4