oldmm: add MMtype#has_formal
authorJean Privat <jean@pryen.org>
Thu, 14 Mar 2013 18:36:00 +0000 (14:36 -0400)
committerJean Privat <jean@pryen.org>
Thu, 14 Mar 2013 18:36:00 +0000 (14:36 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/metamodel/genericity.nit
src/metamodel/static_type.nit
src/metamodel/type_formal.nit

index 4de61f7..ec27bb1 100644 (file)
@@ -186,6 +186,14 @@ class MMTypeGeneric
                return true
        end
 
+       redef fun has_formal
+       do
+               for p in _params do
+                       if p.has_formal then return true
+               end
+               return false
+       end
+
        init(c: MMLocalClass, p: Array[MMType])
        do
                super(c)
index 09db136..62033e4 100644 (file)
@@ -417,7 +417,7 @@ end
 
 class MMNullableType
        super MMType
-       var _base_type: MMType
+       readable var _base_type: MMType
        redef fun is_valid do return _base_type.is_valid
        redef fun is_nullable: Bool do return true
        redef fun as_notnull do return _base_type
index afe5a21..ca5edef 100644 (file)
@@ -23,6 +23,8 @@ import inheritance
 redef class MMType
        # The type a indirect type refers to
        fun direct_type: MMType do return self
+
+       fun has_formal: Bool do return false
 end
 
 # Formal types are named indirect types
@@ -42,6 +44,7 @@ abstract class MMTypeFormal
        redef fun is_nullable do return _bound.is_nullable
        redef fun direct_type do return _bound.direct_type
        redef fun local_class do return _bound.local_class
+       redef fun has_formal do return true
 
        redef fun to_s do return _name.to_s
 
@@ -52,3 +55,6 @@ abstract class MMTypeFormal
        end
 end
 
+redef class MMNullableType
+       redef fun has_formal do return self.base_type.has_formal
+end