diff options
author | Sasikanth Bharadwaj | 2018-03-30 04:44:34 +0000 |
---|---|---|
committer | Sasikanth Bharadwaj | 2018-04-02 04:14:58 +0000 |
commit | 1ef1f22abad429e9ccfbd8b23de626642cab48c7 (patch) | |
tree | 28a4469da9841bbe352951c9cb529f42b186154f /org.eclipse.jdt.core | |
parent | 40de434eadcf8e8504778f1afe4d03f4ca423453 (diff) | |
download | eclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.tar.gz eclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.tar.xz eclipse.jdt.core-1ef1f22abad429e9ccfbd8b23de626642cab48c7.zip |
Bug 532920: [10][compiler] NPE with var
Change-Id: I7e0e33e0566b1dd5aff661444e7f70fc22b9cd4c
Diffstat (limited to 'org.eclipse.jdt.core')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java | 9 |
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; |