JS backend: fix order call super constructor

This commit is contained in:
Erokhin Stanislav
2013-10-04 20:30:20 +04:00
parent 8103626121
commit 71cfa86f19
3 changed files with 24 additions and 1 deletions
@@ -36,6 +36,10 @@ public final class ClassInheritanceTest extends SingleFileTranslationTest {
checkFooBoxIsOk();
}
public void testBaseCallOrder() throws Exception {
checkFooBoxIsOk();
}
public void testCrazyInheritance() throws Exception {
checkFooBoxIsOk();
}
@@ -117,7 +117,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
JsInvocation call = new JsInvocation(Namer.getFunctionCallRef(Namer.superMethodNameRef(ref)));
call.getArguments().add(JsLiteral.THIS);
call.getArguments().addAll(arguments);
initializerStatements.add(call.makeStmt());
initializerStatements.add(0, call.makeStmt());
}
@NotNull
@@ -0,0 +1,19 @@
package foo
var x = false
open class A {
{
x = (this as B).a != 3
}
}
class B(val a: Int = 3) : A() {
}
fun box(): String {
B()
if (!x) return "fail"
return "OK"
}