Skip to content

Commit 1b351c1

Browse files
committed
adds missing default constructors for second outer class in a file
1 parent b799976 commit 1b351c1

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,8 @@ public boolean visit(TypeDeclaration node) {
19651965
// definition that does not remove anything and needs no {...}
19661966
addAnonymousFunctionWrapper(true);
19671967
readSources(node, "@j2sPrefix", "", " ", true);
1968+
1969+
// add decorateAsClass
19681970
buffer.append("var C$ = Clazz.decorateAsClass (function () {\r\n");
19691971

19701972
// add all inner classes iteratively
@@ -2569,20 +2571,22 @@ static String j2sGetParamCode(ITypeBinding binding, boolean addAAA) {
25692571
}
25702572

25712573
private void addDefaultConstructor() {
2572-
if (defaultConstructor != null && !defaultConstructor.isVarargs())
2573-
return;
2574-
buffer.append("\r\nClazz.newMethod$(C$, 'construct', function () {");
2575-
if (defaultConstructor == null) {
2576-
addSuperConstructor(null, null);
2577-
} else {
2578-
// TODO BH: This is still not right. It's specifically for anonymous
2579-
// constructors
2580-
// But I can't seem to see how to get the right vararg constructor
2581-
// (float...) vs (int...)
2582-
addThisConstructorCall(defaultConstructor, new ArrayList<Object>());
2574+
if (defaultConstructor == null || defaultConstructor.isVarargs()) {
2575+
buffer.append("\r\nClazz.newMethod$(C$, 'construct', function () {");
2576+
if (defaultConstructor == null) {
2577+
addSuperConstructor(null, null);
2578+
} else {
2579+
// TODO BH: This is still not right. It's specifically for
2580+
// anonymous
2581+
// constructors
2582+
// But I can't seem to see how to get the right vararg
2583+
// constructor
2584+
// (float...) vs (int...)
2585+
addThisConstructorCall(defaultConstructor, new ArrayList<Object>());
2586+
}
2587+
buffer.append("}, 1);\r\n");
25832588
}
2584-
buffer.append("}, 1);\r\n");
2585-
2589+
defaultConstructor = null;
25862590
}
25872591

25882592
private void addSuperConstructor(SuperConstructorInvocation node, IMethodBinding methodDeclaration) {

0 commit comments

Comments
 (0)