mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 10:18:46 +00:00
fixed: @val didn't work with rawtypes in enhanced for loops
This commit is contained in:
1 parent
48e73a7180
commit
3f408782de
5 files changed
+72
-1
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
13 warning List is a raw type. References to generic type List<E> should be parameterized
|
||||
Reference in new issue
Block a user