modelize: prevent the use of `lazy` on methods
authorJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 04:51:02 +0000 (11:51 +0700)
committerJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 04:51:02 +0000 (11:51 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize/modelize_property.nit
tests/base_attr_lazy.nit
tests/sav/base_attr_lazy_alt2.res [new file with mode: 0644]

index a643192..35a50c3 100644 (file)
@@ -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)
index d271411..6449ce9 100644 (file)
@@ -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 (file)
index 0000000..7c398a6
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_lazy_alt2.nit:29,20--23: Syntax error: `lazy` must be used on attributes.