From c9513e72d34c7d34be12f829e406d1d00896550f Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 26 Feb 2015 11:51:02 +0700 Subject: [PATCH] modelize: prevent the use of `lazy` on methods Signed-off-by: Jean Privat --- src/modelize/modelize_property.nit | 4 ++++ tests/base_attr_lazy.nit | 1 + tests/sav/base_attr_lazy_alt2.res | 1 + 3 files changed, 6 insertions(+) create mode 100644 tests/sav/base_attr_lazy_alt2.res diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index a643192..35a50c3 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -863,6 +863,10 @@ redef class AMethPropdef mpropdef.is_abstract = self.get_single_annotation("abstract", modelbuilder) != null mpropdef.is_intern = self.get_single_annotation("intern", modelbuilder) != null mpropdef.is_extern = self.n_extern_code_block != null or self.get_single_annotation("extern", modelbuilder) != null + + # Check annotations + var at = self.get_single_annotation("lazy", modelbuilder) + if at != null then modelbuilder.error(at, "Syntax error: `lazy` must be used on attributes.") end redef fun check_signature(modelbuilder) diff --git a/tests/base_attr_lazy.nit b/tests/base_attr_lazy.nit index d271411..6449ce9 100644 --- a/tests/base_attr_lazy.nit +++ b/tests/base_attr_lazy.nit @@ -26,6 +26,7 @@ class Foo return 20 end #alt1#var a3: Object is lazy + #alt2#fun a4: Object is lazy end var f = new Foo diff --git a/tests/sav/base_attr_lazy_alt2.res b/tests/sav/base_attr_lazy_alt2.res new file mode 100644 index 0000000..7c398a6 --- /dev/null +++ b/tests/sav/base_attr_lazy_alt2.res @@ -0,0 +1 @@ +alt/base_attr_lazy_alt2.nit:29,20--23: Syntax error: `lazy` must be used on attributes. -- 1.7.9.5