Parcourir la source

Fix import types qualifing one more time.

Vladislav Folts il y a 11 ans
Parent
commit
f797ef5812
3 fichiers modifiés avec 19 ajouts et 6 suppressions
  1. 5 4
      src/context.js
  2. 2 2
      test/expected/modules.js
  3. 12 0
      test/input/run/modules.ob

+ 5 - 4
src/context.js

@@ -1663,14 +1663,15 @@ exports.RecordDecl = ChainedContext.extend({
         var type = this.__type;
         var baseType = type.baseType();
         var gen = this.codeGenerator();
-        gen.write((baseType ? this.qualifyScope(baseType.scope()) + baseType.name() 
-                            : this.rtl().baseClass())
-                  + ".extend(");
+        var qualifiedBase = baseType 
+                          ? this.qualifyScope(baseType.scope()) + baseType.name() 
+                          : this.rtl().baseClass();
+        gen.write(qualifiedBase + ".extend(");
         gen.openScope();
         gen.write("init: function " + this.__type.cons() + "()");
         gen.openScope();
         if (baseType)
-            gen.write(baseType.name() + ".prototype.init.call(this);\n");
+            gen.write(qualifiedBase + ".prototype.init.call(this);\n");
         var ownFields = type.ownFields();
         for(var f in ownFields)
             gen.write("this." + f + " = " + ownFields[f].initializer(this) + ";\n");

+ 2 - 2
test/expected/modules.js

@@ -103,7 +103,7 @@ return {
 var m2 = function (m1){
 var T = m1.T.extend({
 	init: function T(){
-		T.prototype.init.call(this);
+		m1.T.prototype.init.call(this);
 		this.i2 = 0;
 	}
 });
@@ -134,7 +134,7 @@ ref(RTL$.makeRef(m1.pr2(), "i"));
 var m3 = function (m1, m2){
 var T = m2.T.extend({
 	init: function T(){
-		T.prototype.init.call(this);
+		m2.T.prototype.init.call(this);
 	}
 });
 var r = new m2.T();

+ 12 - 0
test/input/run/modules.ob

@@ -0,0 +1,12 @@
+MODULE m1;
+TYPE T1* = RECORD END;
+END m1.
+
+MODULE m2;
+IMPORT m1;
+TYPE T2* = RECORD(m1.T1) END;
+
+VAR v: T2;
+
+BEGIN
+END m2.