nullable: convert lib, tools and tests
[nit.git] / src / metamodel / genericity.nit
index 8a9d14b..dd84e14 100644 (file)
@@ -81,7 +81,7 @@ redef class MMLocalClass
        do
                if _base_type_cache == null and is_generic then
                        _base_type_cache = get_instantiate_type(formals_types)
-                       return _base_type_cache
+                       return _base_type_cache.as(not null)
                else
                        return super
                end
@@ -108,7 +108,6 @@ class MMTypeGeneric
 special MMTypeClass
        # Formal arguments
        readable attr _params: Array[MMType] 
-       attr _props: Map[MMGlobalProperty, MMLocalProperty] = new HashMap[MMGlobalProperty, MMLocalProperty]
 
        redef meth is_generic do return true
 
@@ -143,7 +142,6 @@ special MMTypeClass
                        var b = _local_class.for_module(mod)
                        t = b.get_instantiate_type(parms)
                end
-               assert t != null
                return t
        end
 
@@ -163,8 +161,6 @@ special MMTypeClass
                        return false
                end
                for i in [0..t.length[ do
-                       assert _params[i] != null
-                       assert t[i] != null
                        if _params[i] != t[i] then
                                return false
                        end
@@ -172,26 +168,6 @@ special MMTypeClass
                return true
        end
 
-       redef meth select_property(g)
-       do
-               if g == null then
-                       return null
-               end
-               if not _props.has_key(g) then
-                       assert _local_class != null
-                       var p = _local_class[g]
-                       if p != null then
-                               #var p2 = p.adapt_property(self)
-                               #_props[g] = p2
-                               #return p2
-                               return p
-                       else
-                               assert false
-                       end
-               end
-               return _props[g]
-       end
-
        redef meth to_s
        do
                return "{super}[{_params.join(", ")}]"
@@ -233,11 +209,10 @@ special MMTypeFormal
                if module != mod then
                        t = mod[_def_class.global].get_formal(position)
                end
-               assert t != null
                return t
        end
 
-       redef meth upcast_for(c) do return self
+       redef meth upcast_for(c) do return _bound.upcast_for(c)
 
        meth bound=(t: MMType)
        do
@@ -255,7 +230,6 @@ special MMTypeFormal
                #end
                assert old_r isa MMTypeGeneric
                var reduct = old_r.params[position]
-               assert reduct != null
                return reduct
        end
 
@@ -267,8 +241,7 @@ special MMTypeFormal
 
        init(n: Symbol, p: Int, intro: MMLocalClass)
        do
-               assert n != null
-               _name = n
+               super(n, null)
                _position = p
                _def_class = intro
        end