semantize: move noinit attribute to `AAttrPropdef::build_property`
authorJean Privat <jean@pryen.org>
Wed, 29 Oct 2014 16:58:26 +0000 (12:58 -0400)
committerJean Privat <jean@pryen.org>
Fri, 31 Oct 2014 11:13:43 +0000 (07:13 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize/modelize_property.nit

index 69e1633..10b6ad4 100644 (file)
@@ -144,14 +144,7 @@ redef class ModelBuilder
                        end
                        if npropdef isa AAttrPropdef then
                                if npropdef.mpropdef == null then return # Skip broken attribute
-                               var at = npropdef.get_single_annotation("noinit", self)
-                               if at != null then
-                                       npropdef.noinit = true
-                                       if npropdef.has_value then
-                                               self.error(at, "Error: `noinit` attributes cannot have an initial value")
-                                       end
-                                       continue # Skip noinit attributes
-                               end
+                               if npropdef.noinit then continue # Skip noinit attribute
                                if npropdef.has_value then continue
                                var paramname = npropdef.mpropdef.mproperty.name.substring_from(1)
                                var ret_type = npropdef.mpropdef.static_mtype
@@ -804,6 +797,15 @@ redef class AAttrPropdef
 
                has_value = n_expr != null or n_block != null
 
+               var atnoinit = self.get_single_annotation("noinit", modelbuilder)
+               if atnoinit != null then
+                       noinit = true
+                       if has_value then
+                               modelbuilder.error(atnoinit, "Error: `noinit` attributes cannot have an initial value")
+                               return
+                       end
+               end
+
                var atlazy = self.get_single_annotation("lazy", modelbuilder)
                if atlazy != null then
                        if not has_value then