Skip to content

Commit

Permalink
[fixes #2787] Handle right hand side of assignment first
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawi01 authored and rspilker committed Apr 1, 2021
1 parent 9b3e847 commit 462aedc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/lombok/javac/handlers/HandleVal.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static boolean eq(String typeTreeToString, String key) {
}

@SuppressWarnings("deprecation") @Override
public void visitLocal(JavacNode localNode, JCVariableDecl local) {
public void endVisitLocal(JavacNode localNode, JCVariableDecl local) {
JCTree typeTree = local.vartype;
if (typeTree == null) return;
String typeTreeToString = typeTree.toString();
Expand Down
11 changes: 11 additions & 0 deletions test/transform/resource/after-delombok/ValInLambda.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// version 8:
import java.util.function.Function;
import java.util.function.Supplier;

class ValInLambda {
Runnable foo = (Runnable) () -> {
final int i = 1;
Expand All @@ -24,4 +27,12 @@ public void easyLubLambda() {
} : System.out::println;
};
}

public void inParameter() {
final java.util.function.Function<java.util.function.Supplier<java.lang.String>, java.lang.String> foo = (Function<Supplier<String>, String>) s -> s.get();
final java.lang.String foo2 = foo.apply(() -> {
final java.lang.String bar = "";
return bar;
});
}
}
9 changes: 9 additions & 0 deletions test/transform/resource/after-ecj/ValInLambda.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.function.Function;
import java.util.function.Supplier;
import lombok.val;
class ValInLambda {
Runnable foo = (Runnable) () -> {
Expand All @@ -24,4 +26,11 @@ public void easyLubLambda() {
} : System.out::println);
};
}
public void inParameter() {
final @val java.util.function.Function<java.util.function.Supplier<java.lang.String>, java.lang.String> foo = (Function<Supplier<String>, String>) (<no type> s) -> s.get();
final @val java.lang.String foo2 = foo.apply(() -> {
final @val java.lang.String bar = "";
return bar;
});
}
}
11 changes: 11 additions & 0 deletions test/transform/resource/before/ValInLambda.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// version 8:

import java.util.function.Function;
import java.util.function.Supplier;

import lombok.val;

class ValInLambda {
Expand All @@ -25,4 +28,12 @@ public void easyLubLambda() {
lombok.val fooInner = (System.currentTimeMillis() > 0) ? (Runnable)()-> {} : System.out::println;
};
}

public void inParameter() {
val foo = (Function<Supplier<String>, String>) s -> s.get();
val foo2 = foo.apply(() -> {
val bar = "";
return bar;
});
}
}

0 comments on commit 462aedc

Please sign in to comment.