model_utils: add MAttribute::is_nullable
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 25 Mar 2014 21:25:41 +0000 (17:25 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 25 Apr 2014 01:57:44 +0000 (21:57 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/model_utils.nit

index f893b8d..12b8907 100644 (file)
@@ -255,6 +255,15 @@ redef class MClass
        end
 end
 
+redef class MAttribute
+       # Is this attribute nullable for sure?
+       #
+       # This mean that its introduction is declarred with a nullable static type
+       # since attributes are invariant this will work on most cases
+       # attributes with static type anchored with a virtual type are not "nullable for-sure"
+       # because this type can be redefined in subclasses
+       fun is_nullable: Bool do return intro.static_mtype isa MNullableType
+end
 
 # Sorters