Skip to content

Commit

Permalink
[fixes #2049] Delombok now figures out usages of ‘var’ and delomboks …
Browse files Browse the repository at this point in the history
…them as just ‘var’ instead of their actual type.
  • Loading branch information
rzwitserloot committed Mar 26, 2019
1 parent 33281d8 commit 320fbfe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changelog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Lombok Changelog
* FEATURE: When using `@NonNull`, or any other annotation that would result in a null-check, you can configure to generate an assert statement instead. [Issue #2078](https://github.com/rzwitserloot/lombok/issues/2078).
* BUGFIX: var/val on methods that return an intersection type would now work in Eclipse. [Issue #1986](https://github.com/rzwitserloot/lombok/issues/1986)
* BUGFIX: Fix for java6 regression if a field has javadoc. [Issue #2066](https://github.com/rzwitserloot/lombok/issues/2066)
* BUGFIX: Delombok now delomboks java10's own `var` as `var` and not as the actual underlying type. [Issue #2049](https://github.com/rzwitserloot/lombok/issues/2049)
* IMPROBABLE BREAKING CHANGE: For fields and parameters marked non-null, if the method body starts with an assert statement to ensure the value isn't null, no code to throw an exception will be generated.

### v1.18.6 (February 12th, 2019)
Expand Down
1 change: 1 addition & 0 deletions src/delombok/lombok/delombok/Delombok.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ public boolean delombok() throws IOException {
Object care = callAttributeMethodOnJavaCompiler(delegate, delegate.todo);

callFlowMethodOnJavaCompiler(delegate, care);

FormatPreferences fps = new FormatPreferences(formatPrefs);
for (JCCompilationUnit unit : roots) {
DelombokResult result = new DelombokResult(catcher.getComments(unit), unit, force || options.isChanged(unit), fps);
Expand Down
6 changes: 5 additions & 1 deletion src/delombok/lombok/delombok/PrettyPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,11 @@ private void printVarDef0(JCVariableDecl tree) {
*/
try {
innermostArrayBracketsAreVarargs = varargs;
print(tree.vartype);
if (tree.vartype == null || tree.vartype.pos == -1) {
print("var");
} else {
print(tree.vartype);
}
} finally {
innermostArrayBracketsAreVarargs = false;
}
Expand Down
6 changes: 6 additions & 0 deletions test/pretty/resource/after/Java11Var.javva
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Java11Var {
public void test() {
var b = 10;
int c = 11;
}
}
7 changes: 7 additions & 0 deletions test/pretty/resource/before/Java11Var.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//version 11:
public class Java11Var {
public void test() {
var b = 10;
int c = 11;
}
}

0 comments on commit 320fbfe

Please sign in to comment.