From: Jean Privat Date: Tue, 22 Jul 2014 19:07:56 +0000 (-0400) Subject: model: add annotation `fixed` on virtual types X-Git-Tag: v0.6.7~16^2~9 X-Git-Url: http://nitlanguage.org?hp=357ea6d82b39d23700f4665e60c14396b29359c3 model: add annotation `fixed` on virtual types Signed-off-by: Jean Privat --- diff --git a/src/model/model.nit b/src/model/model.nit index 7568e9b..894278a 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -1945,6 +1945,9 @@ class MVirtualTypeDef # The bound of the virtual type var bound: nullable MType writable = null + + # Is the bound fixed? + var is_fixed writable = false end # A kind of class. diff --git a/src/modelize_property.nit b/src/modelize_property.nit index 93f0e00..f4f8661 100644 --- a/src/modelize_property.nit +++ b/src/modelize_property.nit @@ -975,6 +975,11 @@ redef class ATypePropdef self.mpropdef = mpropdef modelbuilder.mpropdef2npropdef[mpropdef] = self set_doc(mpropdef) + + var atfixed = get_single_annotation("fixed", modelbuilder) + if atfixed != null then + mpropdef.is_fixed = true + end end redef fun build_signature(modelbuilder) @@ -1028,6 +1033,10 @@ redef class ATypePropdef bound = mpropdef.bound.as(not null) for p in mpropdef.mproperty.lookup_super_definitions(mmodule, anchor) do var supbound = p.bound.as(not null) + if p.is_fixed then + modelbuilder.error(self, "Redef Error: Virtual type {mpropdef.mproperty} is fixed in super-class {p.mclassdef.mclass}") + break + end if p.mclassdef.mclass == mclassdef.mclass then # Still a warning to pass existing bad code modelbuilder.warning(n_type, "Redef Error: a virtual type cannot be refined.")