modelbuilder: `build_a_mclassdef` reuse existing mclassdefs
authorJean Privat <jean@pryen.org>
Thu, 12 Jun 2014 17:18:25 +0000 (13:18 -0400)
committerJean Privat <jean@pryen.org>
Thu, 12 Jun 2014 17:18:25 +0000 (13:18 -0400)
In a module, a second AClassdef of a given class, that is valid for
implicit Object and implicit Sys, is now attached a single MClassDef.

Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize_class.nit

index 5bc395b..06e04b5 100644 (file)
@@ -109,7 +109,14 @@ redef class ModelBuilder
                var objectclass = try_get_mclass_by_name(nmodule, mmodule, "Object")
                var mclass = nclassdef.mclass
                if mclass == null then return # Skip error
-               #var mclassdef = nclassdef.mclassdef.as(not null)
+
+               # In case of non-standard AClassdef, try to attach to an already existing mclassdef
+               var other_nclassdef = nmodule.mclass2nclassdef[mclass]
+               if other_nclassdef != nclassdef then
+                       assert not nclassdef isa AStdClassdef
+                       nclassdef.mclassdef = other_nclassdef.mclassdef
+                       return
+               end
 
                var names = new Array[String]
                var bounds = new Array[MType]