Buggy code:
public class ForeachStatement extends Statement { public LocalDeclaration elementVariable ; public int elementVariableImplicitWidening = - 1 ; public Expression collection ; public Statement action ; private int kind ; private static final int ARRAY = 0 ; private static final int RAW_ITERABLE = 1 ; private static final int GENERIC_ITERABLE = 2 ; private TypeBinding iteratorReceiverType ; private TypeBinding collectionElementType ; private Label breakLabel ; private Label continueLabel ; public BlockScope scope ; public LocalVariableBinding indexVariable ; public LocalVariableBinding collectionVariable ; public LocalVariableBinding maxVariable ; private static final char [ ] SecretIndexVariableName = "<seq2seq4repair_space>index" . toCharArray ( ) ; private static final char [ ] SecretCollectionVariableName = "<seq2seq4repair_space>collection" . toCharArray ( ) ; private static final char [ ] SecretMaxVariableName = "<seq2seq4repair_space>max" . toCharArray ( ) ; int postCollectionInitStateIndex = - 1 ; int mergedInitStateIndex = - 1 ; public ForeachStatement ( LocalDeclaration elementVariable , int start ) { } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo ) { } public void generateCode ( BlockScope currentScope , CodeStream codeStream ) { } public StringBuffer printStatement ( int indent , StringBuffer output ) { } public void resolve ( BlockScope upperScope ) { scope = new BlockScope ( upperScope ) ; this . elementVariable . resolve ( scope ) ; TypeBinding elementType = this . elementVariable . type . resolvedType ; <START_BUG> TypeBinding collectionType = this . collection . resolveType ( scope ) ; <END_BUG> boolean hasError = ( elementType == null ) || ( collectionType == null ) ; if ( ! hasError ) { if ( collectionType . isArrayType ( ) ) { this . kind = ForeachStatement . ARRAY ; this . collection . computeConversion ( scope , collectionType , collectionType ) ; this . collectionElementType = ( ( ArrayBinding ) ( collectionType ) ) . elementsType ( ) ; if ( ( ! ( collectionElementType . isCompatibleWith ( elementType ) ) ) && ( ! ( scope . isBoxingCompatibleWith ( collectionElementType , elementType ) ) ) ) { scope . problemReporter ( ) . notCompatibleTypesErrorInForeach ( collection , collectionElementType , elementType ) ; } int compileTimeTypeID = collectionElementType . id ; if ( elementType . isBaseType ( ) ) { if ( ! ( collectionElementType . isBaseType ( ) ) ) { compileTimeTypeID = scope . environment ( ) . computeBoxingType ( collectionElementType ) . id ; this . elementVariableImplicitWidening = TypeIds . UNBOXING ; if ( elementType . isBaseType ( ) ) { this . elementVariableImplicitWidening |= ( ( elementType . id ) << 4 ) + compileTimeTypeID ; scope . problemReporter ( ) . autoboxing ( collection , collectionElementType , elementType ) ; } } else { this . elementVariableImplicitWidening = ( ( elementType . id ) << 4 ) + compileTimeTypeID ; } } else { if ( collectionElementType . isBaseType ( ) ) { int boxedID = scope . environment ( ) . computeBoxingType ( collectionElementType ) . id ; this . elementVariableImplicitWidening = ( ( TypeIds . BOXING ) | ( compileTimeTypeID << 4 ) ) | compileTimeTypeID ; compileTimeTypeID = boxedID ; scope . problemReporter ( ) . autoboxing ( collection , collectionElementType , elementType ) ; } } } else if ( collectionType instanceof ReferenceBinding ) { ReferenceBinding iterableType = ( ( ReferenceBinding ) ( collectionType ) ) . findSuperTypeErasingTo ( TypeIds . T_JavaLangIterable , false ) ; checkIterable : { if ( iterableType == null ) break checkIterable ; this . iteratorReceiverType = collectionType . erasure ( ) ; if ( ( ( ( ReferenceBinding ) ( iteratorReceiverType ) ) . findSuperTypeErasingTo ( TypeIds . T_JavaLangIterable , false ) ) == null ) { this . iteratorReceiverType = iterableType ; this . collection . computeConversion ( scope , iterableType , collectionType ) ; } else { this . collection . computeConversion ( scope , collectionType , collectionType ) ; } TypeBinding [ ] arguments = null ; switch ( iterableType . kind ( ) ) { case Binding . RAW_TYPE : this . kind = ForeachStatement . RAW_ITERABLE ; this . collectionElementType = scope . getJavaLangObject ( ) ; if ( ( ! ( collectionElementType . isCompatibleWith ( elementType ) ) ) && ( ! ( scope . isBoxingCompatibleWith ( collectionElementType , elementType ) ) ) ) { scope . problemReporter ( ) . notCompatibleTypesErrorInForeach ( collection , collectionElementType , elementType ) ; } break checkIterable ; case Binding . GENERIC_TYPE : arguments = iterableType . typeVariables ( ) ; break ; case Binding . PARAMETERIZED_TYPE : arguments = ( ( ParameterizedTypeBinding ) ( iterableType ) ) . arguments ; break ; default : break checkIterable ; } if ( ( arguments . length ) != 1 ) break checkIterable ; this . kind = ForeachStatement . GENERIC_ITERABLE ; this . collectionElementType = arguments [ 0 ] ; if ( ( ! ( collectionElementType . isCompatibleWith ( elementType ) ) ) && ( ! ( scope . isBoxingCompatibleWith ( collectionElementType , elementType ) ) ) ) { scope . problemReporter ( ) . notCompatibleTypesErrorInForeach ( collection , collectionElementType , elementType ) ; } int compileTimeTypeID = collectionElementType . id ; if ( elementType . isBaseType ( ) ) { if ( ! ( collectionElementType . isBaseType ( ) ) ) { compileTimeTypeID = scope . environment ( ) . computeBoxingType ( collectionElementType ) . id ; this . elementVariableImplicitWidening = TypeIds . UNBOXING ; if ( elementType . isBaseType ( ) ) { this . elementVariableImplicitWidening |= ( ( elementType . id ) << 4 ) + compileTimeTypeID ; } } else { this . elementVariableImplicitWidening = ( ( elementType . id ) << 4 ) + compileTimeTypeID ; } } else { if ( collectionElementType . isBaseType ( ) ) { int boxedID = scope . environment ( ) . computeBoxingType ( collectionElementType ) . id ; this . elementVariableImplicitWidening = ( ( TypeIds . BOXING ) | ( compileTimeTypeID << 4 ) ) | compileTimeTypeID ; compileTimeTypeID = boxedID ; } }

Fix:
TypeBinding collectionType = ( ( this . collection ) == null ) ? null : this . collection . resolveType ( scope ) ;