Skip to content

Commit

Permalink
projectlombok#1976. [@Val] improved raw generic type inference by ecl…
Browse files Browse the repository at this point in the history
…ipse compiler.
  • Loading branch information
Bulgakov Alexander committed May 8, 2019
1 parent 8f8cbae commit 1fec035
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
Expand Down Expand Up @@ -965,7 +966,7 @@ public static TypeReference makeType(TypeBinding binding, ASTNode pos, boolean a
// Finally, add however many nullTypeArgument[] arrays as that are missing, inverse the list, toArray it, and use that as PTR's typeArgument argument.

List<TypeReference[]> params = new ArrayList<TypeReference[]>();
/* Calculate generics */ {
/* Calculate generics */ if(!(binding instanceof RawTypeBinding)) {
TypeBinding b = binding;
while (true) {
boolean isFinalStop = b.isLocalType() || !b.isMemberType() || b.enclosingType() == null;
Expand Down
5 changes: 4 additions & 1 deletion test/transform/resource/after-delombok/ValLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ public void easyIntersectionLambda() {
public void easyLubLambda() {
final java.lang.Runnable foo = (System.currentTimeMillis() > 0) ? (Runnable) () -> {
} : System.out::println;
final java.util.function.Function foo2 = (System.currentTimeMillis() < 0) ? (java.util.function.Function) r -> "" : r -> System.currentTimeMillis();
java.util.function.Function foo3 = (System.currentTimeMillis() < 0) ? (java.util.function.Function) r -> "" : r -> System.currentTimeMillis();
final java.util.function.Function<java.lang.String, java.lang.String> foo4 = (System.currentTimeMillis() < 0) ? (java.util.function.Function<String, String>) r -> "" : r -> String.valueOf(System.currentTimeMillis());
}
// public void castLubLambda() {
// Runnable foo = (Runnable) ((System.currentTimeMillis() > 0) ? () -> {} : System.out::println);
// lombok.val foo = (Runnable) ((System.currentTimeMillis() > 0) ? () -> {} : System.out::println);
// }
}
}
3 changes: 3 additions & 0 deletions test/transform/resource/after-ecj/ValLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public void easyIntersectionLambda() {
public void easyLubLambda() {
final @lombok.val java.lang.Runnable foo = ((System.currentTimeMillis() > 0) ? (Runnable) () -> {
} : System.out::println);
final @lombok.val java.util.function.Function foo2 = ((System.currentTimeMillis() < 0) ? (java.util.function.Function) (<no type> r) -> "" : (<no type> r) -> System.currentTimeMillis());
java.util.function.Function foo3 = ((System.currentTimeMillis() < 0) ? (java.util.function.Function) (<no type> r) -> "" : (<no type> r) -> System.currentTimeMillis());
final @lombok.val java.util.function.Function<java.lang.String, java.lang.String> foo4 = ((System.currentTimeMillis() < 0) ? (java.util.function.Function<String, String>) (<no type> r) -> "" : (<no type> r) -> String.valueOf(System.currentTimeMillis()));
}
}
3 changes: 3 additions & 0 deletions test/transform/resource/before/ValLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public void easyIntersectionLambda() {

public void easyLubLambda() {
lombok.val foo = (System.currentTimeMillis() > 0) ? (Runnable)()-> {} : System.out::println;
lombok.val foo2 = (System.currentTimeMillis() < 0) ? (java.util.function.Function) r -> "" : r -> System.currentTimeMillis();
java.util.function.Function foo3 = (System.currentTimeMillis() < 0) ? (java.util.function.Function) r -> "" : r -> System.currentTimeMillis();
lombok.val foo4 = (System.currentTimeMillis() < 0) ? (java.util.function.Function<String, String>) r -> "" : r -> String.valueOf(System.currentTimeMillis());
}

// public void castLubLambda() {
Expand Down
2 changes: 2 additions & 0 deletions test/transform/resource/messages-ecj/ValLambda.java.messages
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
14 Function is a raw type. References to generic type Function<T,R> should be parameterized
15 Function is a raw type. References to generic type Function<T,R> should be parameterized

0 comments on commit 1fec035

Please sign in to comment.