src: cleanup importations
[nit.git] / src / model / model.nit
index 2a5a092..d4d2c1c 100644 (file)
@@ -25,8 +25,6 @@
 # FIXME: better handling of the types
 module model
 
-import poset
-import location
 import mmodule
 import mdoc
 import ordered_tree
@@ -236,6 +234,13 @@ redef class MModule
                return get_primitive_class("Sys").mclass_type
        end
 
+       fun finalizable_type: nullable MClassType
+       do
+               var clas = self.model.get_mclasses_by_name("Finalizable")
+               if clas == null then return null
+               return get_primitive_class("Finalizable").mclass_type
+       end
+
        # Force to get the primitive class named `name` or abort
        fun get_primitive_class(name: String): MClass
        do
@@ -1302,7 +1307,13 @@ class MParameterType
                #print "{class_name}: {self}/{mtype}/{anchor}?"
 
                if mtype isa MGenericType and mtype.mclass == self.mclass then
-                       return mtype.arguments[self.rank]
+                       var res = mtype.arguments[self.rank]
+                       if anchor != null and res.need_anchor then
+                               # Maybe the result can be resolved more if are bound to a final class
+                               var r2 = res.anchor_to(mmodule, anchor)
+                               if r2 isa MClassType and r2.mclass.kind == enum_kind then return r2
+                       end
+                       return res
                end
 
                # self is a parameter type of mtype (or of a super-class of mtype)
@@ -1814,6 +1825,9 @@ class MMethod
        # therefore, you should use `is_init_for` the verify if the property is a legal constructor for a given class
        var is_init: Bool writable = false
 
+       # The constructor is a (the) root init with empty signature but a set of initializers
+       var is_root_init: Bool writable = false
+
        # The the property a 'new' contructor?
        var is_new: Bool writable = false
 
@@ -1932,6 +1946,19 @@ class MMethodDef
        # The signature attached to the property definition
        var msignature: nullable MSignature writable = null
 
+       # The signature attached to the `new` call on a root-init
+       # This is a concatenation of the signatures of the initializers
+       #
+       # REQUIRE `mproperty.is_root_init == (new_msignature != null)`
+       var new_msignature: nullable MSignature writable = null
+
+       # List of initialisers to call in root-inits
+       #
+       # They could be setters or attributes
+       #
+       # REQUIRE `mproperty.is_root_init == (new_msignature != null)`
+       var initializers = new Array[MProperty]
+
        # Is the method definition abstract?
        var is_abstract: Bool writable = false