Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2018-03-30 04:44:34 +0000
committerSasikanth Bharadwaj2018-04-02 04:14:58 +0000
commit1ef1f22abad429e9ccfbd8b23de626642cab48c7 (patch)
tree28a4469da9841bbe352951c9cb529f42b186154f /org.eclipse.jdt.core
parent40de434eadcf8e8504778f1afe4d03f4ca423453 (diff)
downloadeclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.tar.gz
eclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.tar.xz
eclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.zip
Bug 532920: [10][compiler] NPE with var
Diffstat (limited to 'org.eclipse.jdt.core')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
index c0e2c3e039..42a5ebd0f9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
@@ -468,7 +468,6 @@ public class ForeachStatement extends Statement {
// Patch the resolved type
if (this.elementVariable.isTypeNameVar(upperScope)) {
- elementType = getCollectionElementType(collectionType);
if (this.elementVariable.type.dimensions() > 0 || this.elementVariable.type.extraDimensions() > 0) {
upperScope.problemReporter().varLocalCannotBeArray(this.elementVariable);
}
@@ -478,8 +477,12 @@ public class ForeachStatement extends Statement {
} else if (TypeBinding.equalsEquals(TypeBinding.VOID, collectionType)) {
upperScope.problemReporter().varLocalInitializedToVoid(this.elementVariable);
elementType = collectionType;
- }
- elementType = this.elementVariable.patchType(elementType);
+ }
+ if ((elementType = getCollectionElementType(collectionType)) == null) {
+ elementType = collectionType;
+ } else {
+ elementType = this.elementVariable.patchType(elementType);
+ }
}
TypeBinding expectedCollectionType = null;

Back to the top