Skip to content

Commit

Permalink
initialize module-use-instances before class-vars
Browse files Browse the repository at this point in the history
see #656
  • Loading branch information
peq committed May 16, 2018
1 parent c8b23d4 commit 2ae275e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ private void translateModuleConstructors(ModuleInstanciation mi) {


private void translateVars(ClassOrModuleInstanciation c) {
for (GlobalVarDef v : c.getVars()) {
translateVar(v);
}
for (ModuleInstanciation mi : c.getModuleInstanciations()) {
translateVars(mi);
}
for (GlobalVarDef v : c.getVars()) {
translateVar(v);
}
}

private void translateVar(GlobalVarDef s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,23 @@ public void stupidTest() { // see #656
"endpackage"
);
}

@Test
public void testModuleMemberInit2() { // see #656
testAssertOkLinesWithStdLib(true,
"package Test",
"import LinkedListModule",
"native testSuccess()",
"public class TestClass",
" use LinkedListModule",
" static TestClass a = new TestClass",
" construct()",
" print(\"constructed\")",
"init",
" print(\"size test2:\" + TestClass.size.toString())",
" if TestClass.size == 1",
" testSuccess()",
"endpackage"
);
}
}

0 comments on commit 2ae275e

Please sign in to comment.