diff options
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java | 23 |
1 files changed, 18 insertions, 5 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 6985b7b1..05947811 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 @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * + * http://www.eclipse.org/legal/epl-v10.html + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -180,7 +180,7 @@ public class ForeachStatement extends Statement { case GENERIC_ITERABLE : collection.generateCode(scope, codeStream, true); // declaringClass.iterator(); - final TypeBinding collectionTypeBinding = collection.resolvedType; + final TypeBinding collectionTypeBinding = collection.resolvedType.erasure(); MethodBinding iteratorMethodBinding = new MethodBinding( AccPublic, @@ -244,6 +244,19 @@ public class ForeachStatement extends Statement { currentScope, this.postCollectionInitStateIndex); } + } else { + // if unused variable, some side effects still need to be performed (86487) + switch(this.kind) { + case ARRAY : + break; + case RAW_ITERABLE : + case GENERIC_ITERABLE : + // still advance in iterator to prevent infinite loop + codeStream.load(this.indexVariable); + codeStream.invokeJavaUtilIteratorNext(); + codeStream.pop(); + break; + } } this.action.generateCode(scope, codeStream); |