Buggy code:
public class CastExpression extends Expression { public Expression expression ; public Expression type ; public TypeBinding expectedType ; public CastExpression ( Expression expression , Expression type ) { } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo ) { } public static void checkNeedForAssignedCast ( BlockScope scope , TypeBinding expectedType , CastExpression rhs ) { } public static void checkNeedForEnclosingInstanceCast ( BlockScope scope , Expression enclosingInstance , TypeBinding enclosingInstanceType , TypeBinding memberType ) { } public static void checkNeedForArgumentCast ( BlockScope scope , int operator , int operatorSignature , Expression expression , int expressionTypeId ) { } public static void checkNeedForArgumentCasts ( BlockScope scope , Expression receiver , TypeBinding receiverType , MethodBinding binding , Expression [ ] arguments , TypeBinding [ ] argumentTypes , final InvocationSite invocationSite ) { } public static void checkNeedForArgumentCasts ( BlockScope scope , int operator , int operatorSignature , Expression left , int leftTypeId , boolean leftIsCast , Expression right , int rightTypeId , boolean rightIsCast ) { } private static void checkAlternateBinding ( BlockScope scope , Expression receiver , TypeBinding receiverType , MethodBinding binding , Expression [ ] arguments , TypeBinding [ ] originalArgumentTypes , TypeBinding [ ] alternateArgumentTypes , final InvocationSite invocationSite ) { } public boolean checkUnsafeCast ( Scope scope , TypeBinding castType , TypeBinding expressionType , TypeBinding match , boolean isNarrowing ) { } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; boolean needRuntimeCheckcast = ( ( this . bits ) & ( ASTNode . GenerateCheckcast ) ) != 0 ; if ( ( constant ) != ( Constant . NotAConstant ) ) { if ( valueRequired || needRuntimeCheckcast ) { codeStream . generateConstant ( constant , implicitConversion ) ; if ( needRuntimeCheckcast ) { codeStream . checkcast ( this . resolvedType ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( this . implicitConversion ) ; } else { codeStream . pop ( ) ; } } } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; return ; } expression . generateCode ( currentScope , codeStream , ( valueRequired || needRuntimeCheckcast ) ) ; <START_BUG> if ( needRuntimeCheckcast && ( ( this . expression . generatedType ( currentScope ) ) != ( this . resolvedType ) ) ) { <END_BUG> codeStream . checkcast ( this . resolvedType ) ; if ( valueRequired ) { codeStream . generateImplicitConversion ( implicitConversion ) ; } else { codeStream . pop ( ) ; } } else { if ( valueRequired ) codeStream . generateImplicitConversion ( implicitConversion ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public Expression innermostCastedExpression ( ) { } public LocalVariableBinding localVariableBinding ( ) { } public int nullStatus ( FlowInfo flowInfo ) { } public Constant optimizedBooleanConstant ( ) { } public StringBuffer printExpression ( int indent , StringBuffer output ) { } public TypeBinding resolveType ( BlockScope scope ) { } public void setExpectedType ( TypeBinding expectedType ) { } private boolean isIndirectlyUsed ( ) { } public void tagAsNeedCheckCast ( ) { } public void tagAsUnnecessaryCast ( Scope scope , TypeBinding castType ) { } public void traverse ( ASTVisitor visitor , BlockScope blockScope ) { } }

Fix:
if ( needRuntimeCheckcast && ( ( this . expression . postConversionType ( currentScope ) ) != ( this . resolvedType ) ) ) {