Buggy code:
List < JCStatement > transform ( Tree . WhileStatement stmt ) { } private List < JCStatement > transformCondition ( Tree . Condition cond , int tag , Tree . Block thenPart , Tree . Block elsePart ) { JCExpression test ; JCVariableDecl decl = null ; JCBlock thenBlock = null ; JCBlock elseBlock = null ; if ( ( ( cond instanceof Tree . IsCondition ) || ( cond instanceof Tree . NonemptyCondition ) ) || ( cond instanceof Tree . ExistsCondition ) ) { String name ; ProducedType toType ; Expression specifierExpr ; if ( cond instanceof Tree . IsCondition ) { Tree . IsCondition isdecl = ( ( Tree . IsCondition ) ( cond ) ) ; name = isdecl . getVariable ( ) . getIdentifier ( ) . getText ( ) ; toType = isdecl . getType ( ) . getTypeModel ( ) ; specifierExpr = isdecl . getVariable ( ) . getSpecifierExpression ( ) . getExpression ( ) ; } else if ( cond instanceof Tree . NonemptyCondition ) { Tree . NonemptyCondition nonempty = ( ( Tree . NonemptyCondition ) ( cond ) ) ; name = nonempty . getVariable ( ) . getIdentifier ( ) . getText ( ) ; toType = nonempty . getVariable ( ) . getType ( ) . getTypeModel ( ) ; specifierExpr = nonempty . getVariable ( ) . getSpecifierExpression ( ) . getExpression ( ) ; } else { Tree . ExistsCondition exists = ( ( Tree . ExistsCondition ) ( cond ) ) ; name = exists . getVariable ( ) . getIdentifier ( ) . getText ( ) ; toType = exists . getVariable ( ) . getType ( ) . getTypeModel ( ) ; specifierExpr = exists . getVariable ( ) . getSpecifierExpression ( ) . getExpression ( ) ; } JCExpression expr = expressionGen ( ) . transformExpression ( specifierExpr ) ; at ( cond ) ; if ( ( cond instanceof Tree . IsCondition ) && ( isNothing ( toType ) ) ) { test = make ( ) . Binary ( EQ , expr , makeNull ( ) ) ; } else { toType = simplifyType ( toType ) ; JCExpression toTypeExpr = makeJavaType ( toType ) ; String tmpVarName = aliasName ( name ) ; Name origVarName = names ( ) . fromString ( name ) ; Name substVarName = names ( ) . fromString ( aliasName ( name ) ) ; ProducedType tmpVarType = specifierExpr . getTypeModel ( ) ; JCExpression tmpVarTypeExpr ; JCExpression rawToTypeExpr = makeJavaType ( toType , ( ( NO_PRIMITIVES ) | ( WANT_RAW_TYPE ) ) ) ; JCExpression tmpVarExpr = makeIdent ( tmpVarName ) ; if ( cond instanceof Tree . ExistsCondition ) { tmpVarExpr = unboxType ( tmpVarExpr , toType ) ; tmpVarTypeExpr = makeJavaType ( tmpVarType ) ; } else if ( cond instanceof Tree . IsCondition ) { tmpVarExpr = unboxType ( at ( cond ) . TypeCast ( rawToTypeExpr , tmpVarExpr ) , toType ) ; tmpVarTypeExpr = make ( ) . Type ( syms ( ) . objectType ) ; } else { tmpVarExpr = at ( cond ) . TypeCast ( toTypeExpr , tmpVarExpr ) ; tmpVarTypeExpr = makeJavaType ( tmpVarType ) ; } decl = makeVar ( tmpVarName , tmpVarTypeExpr , null ) ; JCVariableDecl decl2 = at ( cond ) . VarDef ( make ( ) . Modifiers ( FINAL ) , substVarName , toTypeExpr , tmpVarExpr ) ; String prevSubst = addVariableSubst ( origVarName . toString ( ) , substVarName . toString ( ) ) ; thenBlock = transform ( thenPart ) ; List < JCStatement > stats = List . < JCStatement > of ( decl2 ) ; stats = stats . appendList ( thenBlock . getStatements ( ) ) ; thenBlock = at ( cond ) . Block ( 0 , stats ) ; removeVariableSubst ( origVarName . toString ( ) , prevSubst ) ; at ( cond ) ; JCExpression testExpr = make ( ) . Assign ( makeIdent ( tmpVarName ) , expr ) ; if ( cond instanceof Tree . ExistsCondition ) { test = make ( ) . Binary ( NE , testExpr , makeNull ( ) ) ; } else { <START_BUG> test = makeTypeTest ( testExpr , toType ) ; <END_BUG> } } } else if ( cond instanceof Tree . BooleanCondition ) { Tree . BooleanCondition booleanCondition = ( ( Tree . BooleanCondition ) ( cond ) ) ; test = expressionGen ( ) . transformExpression ( booleanCondition . getExpression ( ) , UNBOXED , null ) ; } else { throw new RuntimeException ( ( "Not<seq2seq4repair_space>implemented:<seq2seq4repair_space>" + ( cond . getNodeType ( ) ) ) ) ; } at ( cond ) ; if ( ( thenPart != null ) && ( thenBlock == null ) ) { thenBlock = transform ( thenPart ) ; } if ( ( elsePart != null ) && ( elseBlock == null ) ) { elseBlock = transform ( elsePart ) ; } JCStatement cond1 ; switch ( tag ) { case JCTree . IF : cond1 = make ( ) . If ( test , thenBlock , elseBlock ) ; break ; case JCTree . WHILELOOP : cond1 = make ( ) . WhileLoop ( makeLetExpr ( make ( ) . TypeIdent ( BOOLEAN ) , test ) , thenBlock ) ; break ; default : throw new RuntimeException ( ) ; } if ( decl != null ) { return List . < JCStatement > of ( decl , cond1 ) ; } else { return List . < JCStatement > of ( cond1 ) ; } } List < JCStatement > transform ( Tree . ForStatement stmt ) { } public JCStatement transform ( AttributeDeclaration decl ) { } List < JCStatement > transform ( Tree . Break stmt ) { } JCStatement transform ( Tree . Return ret ) { }

Fix:
test = makeTypeTest ( testExpr , expr , toType ) ;