Skip to content

Commit 4905118

Browse files
author
zhourenjian
committed
Fixing bug for such a class
class A { class B () { } static class C extends A { } } In generated *.js , A.B should be declared before A.C: c$.$A$B$ = function () ... c$.Clazz.decorateAsClass ( ...
1 parent eae578c commit 4905118

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,13 +2492,14 @@ public void endVisit(TypeDeclaration node) {
24922492
}
24932493
buffer.append(");\r\n");
24942494

2495-
buffer.append(laterBuffer);
2495+
StringBuffer laterBufferBackup = laterBuffer;
2496+
//buffer.append(laterBuffer);
24962497
laterBuffer = new StringBuffer();
24972498
// Enum is considered as static member!
24982499

24992500
List bodyDeclarations = node.bodyDeclarations();
25002501
StringBuffer tmpBuffer = buffer;
2501-
StringBuffer tmpLaterBuffer = laterBuffer;
2502+
//StringBuffer tmpLaterBuffer = laterBuffer;
25022503
// StringBuffer tmpMethodBuffer = methodBuffer;
25032504
// buffer = new StringBuffer();
25042505
// laterBuffer = new StringBuffer();
@@ -2599,7 +2600,7 @@ public void endVisit(TypeDeclaration node) {
25992600
buffer.append(laterBuffer);
26002601

26012602
tmpBuffer = buffer;
2602-
tmpLaterBuffer = laterBuffer;
2603+
StringBuffer tmpLaterBuffer = laterBuffer;
26032604
buffer = new StringBuffer();
26042605
laterBuffer = new StringBuffer();
26052606
/* Testing class declarations in initializers */
@@ -2655,6 +2656,21 @@ public void endVisit(TypeDeclaration node) {
26552656
buffer.append(methodBuffer);
26562657
methodBuffer = new StringBuffer();
26572658
}
2659+
// method first
2660+
/*
2661+
* Fixing bug for such class
2662+
* class A {
2663+
* class B () {
2664+
* }
2665+
* static class C extends A {
2666+
* }
2667+
* }
2668+
* A.B should be declared before A.C:
2669+
* c$.$A$B$ = function () ...
2670+
* c$.Clazz.decorateAsClass ( ...
2671+
*/
2672+
buffer.append(laterBufferBackup);
2673+
26582674
for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
26592675
ASTNode element = (ASTNode) iter.next();
26602676
if (element instanceof TypeDeclaration) {

0 commit comments

Comments
 (0)