aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeichhorn <peichhor@web.de>2012-04-19 02:41:31 +0200
committerpeichhorn <peichhor@web.de>2012-04-19 02:41:31 +0200
commit3f408782de736a676ee19757894eb89c1f4ebf3b (patch)
treed7d64f1e91a9c7e624edae880c7a841be5b91ce2
parent48e73a7180ac459d2949e66f2cacc46e08466fce (diff)
downloadlombok-3f408782de736a676ee19757894eb89c1f4ebf3b.tar.gz
lombok-3f408782de736a676ee19757894eb89c1f4ebf3b.tar.bz2
lombok-3f408782de736a676ee19757894eb89c1f4ebf3b.zip
fixed: @val didn't work with rawtypes in enhanced for loops
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java5
-rw-r--r--test/transform/resource/after-delombok/ValRawType.java20
-rw-r--r--test/transform/resource/after-ecj/ValRawType.java27
-rw-r--r--test/transform/resource/before/ValRawType.java20
-rw-r--r--test/transform/resource/messages-ecj/ValRawType.java.messages1
5 files changed, 72 insertions, 1 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 6563c20a..16f11769 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -189,7 +189,8 @@ public class PatchVal {
private static TypeBinding getForEachComponentType(Expression collection, BlockScope scope) {
if (collection != null) {
- TypeBinding resolved = collection.resolveType(scope);
+ TypeBinding resolved = collection.resolvedType;
+ if (resolved == null) resolved = collection.resolveType(scope);
if (resolved == null) return null;
if (resolved.isArrayType()) {
resolved = ((ArrayBinding) resolved).elementsType();
@@ -205,6 +206,8 @@ public class PatchVal {
case Binding.PARAMETERIZED_TYPE : // for(E e : Iterable<E>)
arguments = ((ParameterizedTypeBinding)iterableType).arguments;
break;
+ case Binding.RAW_TYPE : // for(Object e : Iterable)
+ return null;
}
if (arguments != null && arguments.length == 1) {
diff --git a/test/transform/resource/after-delombok/ValRawType.java b/test/transform/resource/after-delombok/ValRawType.java
new file mode 100644
index 00000000..dc297046
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValRawType.java
@@ -0,0 +1,20 @@
+import java.util.List;
+
+public class ValRawType {
+
+ public void test() {
+ Element propElement = new Element();
+ for (final java.lang.Object attribute : propElement.attributes()) {
+ final ValRawType.Attribute attr = (Attribute)attribute;
+ }
+ }
+
+ static class Element {
+ public List attributes() {
+ return null;
+ }
+ }
+
+ static class Attribute {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ValRawType.java b/test/transform/resource/after-ecj/ValRawType.java
new file mode 100644
index 00000000..a8ab6ddc
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValRawType.java
@@ -0,0 +1,27 @@
+import java.util.List;
+import lombok.val;
+public class ValRawType {
+ static class Element {
+ Element() {
+ super();
+ }
+ public List attributes() {
+ return null;
+ }
+ }
+ static class Attribute {
+ Attribute() {
+ super();
+ }
+ }
+ public ValRawType() {
+ super();
+ }
+ public void test() {
+ Element propElement = new Element();
+ for (final @val java.lang.Object attribute : propElement.attributes())
+ {
+ final @val ValRawType.Attribute attr = (Attribute) attribute;
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ValRawType.java b/test/transform/resource/before/ValRawType.java
new file mode 100644
index 00000000..3ef8527e
--- /dev/null
+++ b/test/transform/resource/before/ValRawType.java
@@ -0,0 +1,20 @@
+import java.util.List;
+import lombok.val;
+
+public class ValRawType {
+ public void test() {
+ Element propElement = new Element();
+ for (val attribute : propElement.attributes()) {
+ val attr = (Attribute) attribute;
+ }
+ }
+
+ static class Element {
+ public List attributes() {
+ return null;
+ }
+ }
+
+ static class Attribute {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/ValRawType.java.messages b/test/transform/resource/messages-ecj/ValRawType.java.messages
new file mode 100644
index 00000000..b2b8d753
--- /dev/null
+++ b/test/transform/resource/messages-ecj/ValRawType.java.messages
@@ -0,0 +1 @@
+13 warning List is a raw type. References to generic type List<E> should be parameterized \ No newline at end of file