mirror of
https://github.com/tiennm99/lombok.git
synced 2026-06-05 14:13:48 +00:00
Fix for issue #1076
This commit is contained in:
@@ -3,6 +3,7 @@ Lombok Changelog
|
||||
|
||||
### v1.16.11 "Edgy Guinea Pig"
|
||||
* v1.16.10 is the latest release
|
||||
* BUGFIX: delombok: for-loops with initializers that are not local variable would be generated incorrectly [Issue 1076](https://github.com/rzwitserloot/lombok/issues/1076)
|
||||
|
||||
### v1.16.10 (July 15th, 2016)
|
||||
* FEATURE: Added support for JBoss logger [Issue #1103](https://github.com/rzwitserloot/lombok/issues/1103)
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.delombok;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
@@ -1054,6 +1075,7 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
@Override public void visitForLoop(JCForLoop tree) {
|
||||
aPrint("for (");
|
||||
if (tree.init.nonEmpty()) {
|
||||
// ForInit is either a list of StatementExpressionList or a LocalVariableDeclaration
|
||||
if (tree.init.head instanceof JCVariableDecl) {
|
||||
boolean first = true;
|
||||
int dims = 0;
|
||||
@@ -1075,7 +1097,12 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
first = false;
|
||||
}
|
||||
} else {
|
||||
print(tree.init, ", ");
|
||||
boolean first = true;
|
||||
for (JCStatement exprStatement : tree.init) {
|
||||
if (!first) print(", ");
|
||||
first = false;
|
||||
print(((JCExpressionStatement) exprStatement).expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
print("; ");
|
||||
|
||||
@@ -8,4 +8,11 @@ public class ForLoop {
|
||||
}
|
||||
// after loop
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,11 @@ public class ForLoop {
|
||||
}
|
||||
// after loop
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user