mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 16:14:46 +00:00
[fixes #1997] try-with-resources where the thing you’re guarding is just a variable ref instead of a full decl (legal since JDK9) would break delombok
This commit is contained in:
3 files changed
+33
-5
No files matched your search
@@ -1268,9 +1268,14 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
break;
|
||||
case 1:
|
||||
print("(");
|
||||
JCVariableDecl decl = (JCVariableDecl) resources.get(0);
|
||||
flagMod = -1L & ~FINAL;
|
||||
printVarDefInline(decl);
|
||||
JCTree resource = (JCTree) resources.get(0);
|
||||
if (resource instanceof JCVariableDecl) {
|
||||
JCVariableDecl decl = (JCVariableDecl) resource;
|
||||
flagMod = -1L & ~FINAL;
|
||||
printVarDefInline(decl);
|
||||
} else {
|
||||
print(resource);
|
||||
}
|
||||
print(") ");
|
||||
break;
|
||||
default:
|
||||
@@ -1279,8 +1284,12 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
int c = 0;
|
||||
for (Object i : resources) {
|
||||
align();
|
||||
flagMod = -1L & ~FINAL;
|
||||
printVarDefInline((JCVariableDecl) i);
|
||||
if (i instanceof JCVariableDecl) {
|
||||
flagMod = -1L & ~FINAL;
|
||||
printVarDefInline((JCVariableDecl) i);
|
||||
} else {
|
||||
print((JCTree) i);
|
||||
}
|
||||
if (++c == len) {
|
||||
print(") ");
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.io.PrintWriter;
|
||||
public class TryWithResourcesVarRef {
|
||||
{
|
||||
PrintWriter pw = new PrintWriter(System.out);
|
||||
try (pw) {
|
||||
pw.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//version 9:
|
||||
import java.io.PrintWriter;
|
||||
public class TryWithResourcesVarRef {
|
||||
{
|
||||
PrintWriter pw = new PrintWriter(System.out);
|
||||
try (pw) {
|
||||
pw.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user