aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java7
-rw-r--r--src/core/lombok/javac/JavacResolution.java6
-rw-r--r--test/transform/resource/after-delombok/ValLambda.java4
-rw-r--r--test/transform/resource/after-delombok/ValWeirdTypes.java10
-rw-r--r--test/transform/resource/after-ecj/ValLambda.java4
-rw-r--r--test/transform/resource/after-ecj/ValWeirdTypes.java10
-rw-r--r--test/transform/resource/before/ValWeirdTypes.java8
7 files changed, 39 insertions, 10 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 010dc9d8..438314ca 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -893,7 +893,12 @@ public class EclipseHandlerUtil {
WildcardBinding wildcard = (WildcardBinding) binding;
if (wildcard.boundKind == Wildcard.EXTENDS) {
if (!allowCompound) {
- return makeType(wildcard.bound, pos, false);
+ TypeBinding bound = wildcard.bound;
+ boolean isObject = bound.id == TypeIds.T_JavaLangObject;
+ TypeBinding[] otherBounds = wildcard.otherBounds;
+ if (isObject && otherBounds != null && otherBounds.length > 0) {
+ return makeType(otherBounds[0], pos, false);
+ } else return makeType(bound, pos, false);
} else {
Wildcard out = new Wildcard(Wildcard.EXTENDS);
setGeneratedBy(out, pos);
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index abbf6726..7f940d2a 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -336,7 +336,7 @@ public class JavacResolution {
if (type instanceof ClassType) {
List<Type> ifaces = ((ClassType) type).interfaces_field;
Type supertype = ((ClassType) type).supertype_field;
- if (ifaces != null && ifaces.length() == 1) {
+ if (isObject(supertype) && ifaces != null && ifaces.length() > 0) {
return typeToJCTree(ifaces.get(0), ast, allowCompound, allowVoid);
}
if (supertype != null) return typeToJCTree(supertype, ast, allowCompound, allowVoid);
@@ -402,6 +402,10 @@ public class JavacResolution {
return genericsToJCTreeNodes(generics, ast, replacement);
}
+ private static boolean isObject(Type supertype) {
+ return supertype.tsym.toString().equals("java.lang.Object");
+ }
+
private static JCExpression genericsToJCTreeNodes(List<Type> generics, JavacAST ast, JCExpression rawTypeNode) throws TypeNotConvertibleException {
if (generics != null && !generics.isEmpty()) {
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
diff --git a/test/transform/resource/after-delombok/ValLambda.java b/test/transform/resource/after-delombok/ValLambda.java
index 9214b490..60aeaac9 100644
--- a/test/transform/resource/after-delombok/ValLambda.java
+++ b/test/transform/resource/after-delombok/ValLambda.java
@@ -5,9 +5,9 @@ class ValLambda {
};
}
public void easyIntersectionLambda() {
- final java.lang.Object foo = (Runnable & java.io.Serializable) () -> {
+ final java.lang.Runnable foo = (Runnable & java.io.Serializable) () -> {
};
- final java.lang.Object bar = (java.io.Serializable & Runnable) () -> {
+ final java.io.Serializable bar = (java.io.Serializable & Runnable) () -> {
};
}
public void easyLubLambda() {
diff --git a/test/transform/resource/after-delombok/ValWeirdTypes.java b/test/transform/resource/after-delombok/ValWeirdTypes.java
index a6bc9bd4..8b399fe8 100644
--- a/test/transform/resource/after-delombok/ValWeirdTypes.java
+++ b/test/transform/resource/after-delombok/ValWeirdTypes.java
@@ -56,8 +56,14 @@ public class ValWeirdTypes<Z> {
final int singleInt = copy[0];
}
public void arraysAsList() {
- final java.util.List<java.lang.Class<? extends java.lang.Object>> x = Arrays.asList(String.class, BigDecimal.class);
- for (final java.lang.Class<?> y : x) {
+ final java.util.List<java.lang.Class<? extends java.io.Serializable>> x = Arrays.asList(String.class, BigDecimal.class);
+ for (final java.lang.Class<? extends java.io.Serializable> y : x) {
+ }
+ }
+ @SuppressWarnings("all")
+ public void arraysAsList2() {
+ final java.util.List<java.lang.Class<? extends java.lang.Comparable>> x = Arrays.asList(String.class, BigDecimal.class, Comparable.class);
+ for (final java.lang.Class<? extends java.lang.Comparable> y : x) {
}
}
}
diff --git a/test/transform/resource/after-ecj/ValLambda.java b/test/transform/resource/after-ecj/ValLambda.java
index 4bf3265b..4e2b97a1 100644
--- a/test/transform/resource/after-ecj/ValLambda.java
+++ b/test/transform/resource/after-ecj/ValLambda.java
@@ -7,9 +7,9 @@ class ValLambda {
};
}
public void easyIntersectionLambda() {
- final @lombok.val java.lang.Object foo = (Runnable & java.io.Serializable) () -> {
+ final @lombok.val java.lang.Runnable foo = (Runnable & java.io.Serializable) () -> {
};
- final @lombok.val java.lang.Object bar = (java.io.Serializable & Runnable) () -> {
+ final @lombok.val java.io.Serializable bar = (java.io.Serializable & Runnable) () -> {
};
}
public void easyLubLambda() {
diff --git a/test/transform/resource/after-ecj/ValWeirdTypes.java b/test/transform/resource/after-ecj/ValWeirdTypes.java
index 9f448db9..e98b9753 100644
--- a/test/transform/resource/after-ecj/ValWeirdTypes.java
+++ b/test/transform/resource/after-ecj/ValWeirdTypes.java
@@ -63,8 +63,14 @@ public class ValWeirdTypes<Z> {
final @val int singleInt = copy[0];
}
public void arraysAsList() {
- final @val java.util.List<java.lang.Class<? extends java.lang.Object>> x = Arrays.asList(String.class, BigDecimal.class);
- for (final @val java.lang.Class<? extends java.lang.Object> y : x)
+ final @val java.util.List<java.lang.Class<? extends java.io.Serializable>> x = Arrays.asList(String.class, BigDecimal.class);
+ for (final @val java.lang.Class<? extends java.io.Serializable> y : x)
+ {
+ }
+ }
+ public @SuppressWarnings("all") void arraysAsList2() {
+ final @val java.util.List<java.lang.Class<? extends java.lang.Comparable>> x = Arrays.asList(String.class, BigDecimal.class, Comparable.class);
+ for (final @val java.lang.Class<? extends java.lang.Comparable> y : x)
{
}
}
diff --git a/test/transform/resource/before/ValWeirdTypes.java b/test/transform/resource/before/ValWeirdTypes.java
index 4ea1b5d4..157ffc76 100644
--- a/test/transform/resource/before/ValWeirdTypes.java
+++ b/test/transform/resource/before/ValWeirdTypes.java
@@ -72,4 +72,12 @@ public class ValWeirdTypes<Z> {
}
}
+
+ @SuppressWarnings("all")
+ public void arraysAsList2() {
+ val x = Arrays.asList(String.class, BigDecimal.class, Comparable.class);
+ for (val y : x) {
+
+ }
+ }
} \ No newline at end of file