Program: 12191
Project: 12191
Buggy source:
public void processTypeCheckCodeFragmentBranches(){
  ExpressionExtractor expressionExtractor=new ExpressionExtractor();
  List<ArrayList<Statement>> allTypeCheckStatements=typeCheckElimination.getTypeCheckStatements();
  if (!typeCheckElimination.getDefaultCaseStatements().isEmpty()) {
    allTypeCheckStatements.add(typeCheckElimination.getDefaultCaseStatements());
  }
  StatementExtractor statementExtractor=new StatementExtractor();
  List<Statement> variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment=statementExtractor.getVariableDeclarations(typeCheckMethod.getBody());
  for (  ArrayList<Statement> typeCheckStatementList : allTypeCheckStatements) {
    for (    Statement statement : typeCheckStatementList) {
      variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment.removeAll(statementExtractor.getVariableDeclarations(statement));
    }
  }
  for (  ArrayList<Statement> typeCheckStatementList : allTypeCheckStatements) {
    for (    Statement statement : typeCheckStatementList) {
      List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
      for (      Expression expression : methodInvocations) {
        if (expression instanceof MethodInvocation) {
          MethodInvocation methodInvocation=(MethodInvocation)expression;
          IMethodBinding methodBinding=methodInvocation.resolveMethodBinding();
          if (methodBinding.getDeclaringClass().isEqualTo(typeDeclaration.resolveBinding())) {
            for (            MethodDeclaration method : methods) {
              if (method.resolveBinding().isEqualTo(methodBinding)) {
                typeCheckElimination.addAccessedMethod(method);
              }
            }
          }
 else {
            ITypeBinding superclassTypeBinding=typeDeclaration.resolveBinding().getSuperclass();
            while (superclassTypeBinding != null && !superclassTypeBinding.isEqualTo(methodBinding.getDeclaringClass())) {
              superclassTypeBinding=superclassTypeBinding.getSuperclass();
            }
            if (methodBinding.getDeclaringClass().isEqualTo(superclassTypeBinding))             typeCheckElimination.addSuperAccessedMethod(methodBinding);
          }
        }
      }
      List<Expression> variableInstructions=expressionExtractor.getVariableInstructions(statement);
      for (      Expression variableInstruction : variableInstructions) {
        SimpleName simpleName=(SimpleName)variableInstruction;
        IBinding variableInstructionBinding=simpleName.resolveBinding();
        if (variableInstructionBinding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableInstructionVariableBinding=(IVariableBinding)variableInstructionBinding;
          if (variableInstructionVariableBinding.isField()) {
            if (variableInstructionVariableBinding.getDeclaringClass() != null && variableInstructionVariableBinding.getDeclaringClass().isEqualTo(typeDeclaration.resolveBinding())) {
              for (              FieldDeclaration field : fields) {
                List<VariableDeclarationFragment> fragments=field.fragments();
                for (                VariableDeclarationFragment fragment : fragments) {
                  IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
                  if (fragmentVariableBinding.isEqualTo(variableInstructionVariableBinding)) {
                    Expression parentExpression=null;
                    if (simpleName.getParent() instanceof QualifiedName) {
                      parentExpression=(QualifiedName)simpleName.getParent();
                    }
 else                     if (simpleName.getParent() instanceof FieldAccess) {
                      parentExpression=(FieldAccess)simpleName.getParent();
                    }
 else {
                      parentExpression=simpleName;
                    }
                    boolean isLeftHandOfAssignment=false;
                    if (parentExpression.getParent() instanceof Assignment) {
                      Assignment assignment=(Assignment)parentExpression.getParent();
                      Expression leftHandSide=assignment.getLeftHandSide();
                      SimpleName leftHandSideName=null;
                      if (leftHandSide instanceof SimpleName) {
                        leftHandSideName=(SimpleName)leftHandSide;
                      }
 else                       if (leftHandSide instanceof QualifiedName) {
                        QualifiedName leftHandSideQualifiedName=(QualifiedName)leftHandSide;
                        leftHandSideName=leftHandSideQualifiedName.getName();
                      }
 else                       if (leftHandSide instanceof FieldAccess) {
                        FieldAccess leftHandSideFieldAccess=(FieldAccess)leftHandSide;
                        leftHandSideName=leftHandSideFieldAccess.getName();
                      }
                      if (leftHandSideName != null && leftHandSideName.equals(simpleName)) {
                        isLeftHandOfAssignment=true;
                        typeCheckElimination.addAssignedField(fragment);
                      }
                    }
                    if (!isLeftHandOfAssignment)                     typeCheckElimination.addAccessedField(fragment);
                  }
                }
              }
            }
          }
 else           if (variableInstructionVariableBinding.isParameter()) {
            List<SingleVariableDeclaration> parameters=typeCheckMethod.parameters();
            for (            SingleVariableDeclaration parameter : parameters) {
              IVariableBinding parameterVariableBinding=parameter.resolveBinding();
              if (parameterVariableBinding.isEqualTo(variableInstructionVariableBinding))               typeCheckElimination.addAccessedParameter(parameter);
            }
          }
 else {
            for (            Statement vDStatement : variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment) {
              VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)vDStatement;
              List<VariableDeclarationFragment> fragments=variableDeclarationStatement.fragments();
              for (              VariableDeclarationFragment fragment : fragments) {
                IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
                if (fragmentVariableBinding.isEqualTo(variableInstructionVariableBinding)) {
                  typeCheckElimination.addAccessedLocalVariable(fragment);
                  break;
                }
              }
            }
          }
        }
      }
    }
  }
  processRemainingIfStatementExpressions(variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment);
}

Fixed version (ground truth):
private void processTypeCheckCodeFragmentBranches(){
  ExpressionExtractor expressionExtractor=new ExpressionExtractor();
  List<ArrayList<Statement>> allTypeCheckStatements=typeCheckElimination.getTypeCheckStatements();
  if (!typeCheckElimination.getDefaultCaseStatements().isEmpty()) {
    allTypeCheckStatements.add(typeCheckElimination.getDefaultCaseStatements());
  }
  StatementExtractor statementExtractor=new StatementExtractor();
  List<Statement> variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment=statementExtractor.getVariableDeclarations(typeCheckMethod.getBody());
  for (  ArrayList<Statement> typeCheckStatementList : allTypeCheckStatements) {
    for (    Statement statement : typeCheckStatementList) {
      variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment.removeAll(statementExtractor.getVariableDeclarations(statement));
    }
  }
  for (  ArrayList<Statement> typeCheckStatementList : allTypeCheckStatements) {
    for (    Statement statement : typeCheckStatementList) {
      List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
      for (      Expression expression : methodInvocations) {
        if (expression instanceof MethodInvocation) {
          MethodInvocation methodInvocation=(MethodInvocation)expression;
          IMethodBinding methodBinding=methodInvocation.resolveMethodBinding();
          if (methodBinding.getDeclaringClass().isEqualTo(typeDeclaration.resolveBinding())) {
            for (            MethodDeclaration method : methods) {
              if (method.resolveBinding().isEqualTo(methodBinding)) {
                typeCheckElimination.addAccessedMethod(method);
              }
            }
          }
 else           if (methodInvocation.getExpression() == null || (methodInvocation.getExpression() != null && methodInvocation.getExpression() instanceof ThisExpression)) {
            ITypeBinding superclassTypeBinding=typeDeclaration.resolveBinding().getSuperclass();
            while (superclassTypeBinding != null && !superclassTypeBinding.isEqualTo(methodBinding.getDeclaringClass())) {
              superclassTypeBinding=superclassTypeBinding.getSuperclass();
            }
            if (methodBinding.getDeclaringClass().isEqualTo(superclassTypeBinding))             typeCheckElimination.addSuperAccessedMethod(methodBinding);
          }
        }
      }
      List<Expression> variableInstructions=expressionExtractor.getVariableInstructions(statement);
      for (      Expression variableInstruction : variableInstructions) {
        SimpleName simpleName=(SimpleName)variableInstruction;
        IBinding variableInstructionBinding=simpleName.resolveBinding();
        if (variableInstructionBinding.getKind() == IBinding.VARIABLE) {
          IVariableBinding variableInstructionVariableBinding=(IVariableBinding)variableInstructionBinding;
          if (variableInstructionVariableBinding.isField()) {
            if (variableInstructionVariableBinding.getDeclaringClass() != null && variableInstructionVariableBinding.getDeclaringClass().isEqualTo(typeDeclaration.resolveBinding())) {
              for (              FieldDeclaration field : fields) {
                List<VariableDeclarationFragment> fragments=field.fragments();
                for (                VariableDeclarationFragment fragment : fragments) {
                  IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
                  if (fragmentVariableBinding.isEqualTo(variableInstructionVariableBinding)) {
                    Expression parentExpression=null;
                    if (simpleName.getParent() instanceof QualifiedName) {
                      parentExpression=(QualifiedName)simpleName.getParent();
                    }
 else                     if (simpleName.getParent() instanceof FieldAccess) {
                      parentExpression=(FieldAccess)simpleName.getParent();
                    }
 else {
                      parentExpression=simpleName;
                    }
                    boolean isLeftHandOfAssignment=false;
                    if (parentExpression.getParent() instanceof Assignment) {
                      Assignment assignment=(Assignment)parentExpression.getParent();
                      Expression leftHandSide=assignment.getLeftHandSide();
                      SimpleName leftHandSideName=null;
                      if (leftHandSide instanceof SimpleName) {
                        leftHandSideName=(SimpleName)leftHandSide;
                      }
 else                       if (leftHandSide instanceof QualifiedName) {
                        QualifiedName leftHandSideQualifiedName=(QualifiedName)leftHandSide;
                        leftHandSideName=leftHandSideQualifiedName.getName();
                      }
 else                       if (leftHandSide instanceof FieldAccess) {
                        FieldAccess leftHandSideFieldAccess=(FieldAccess)leftHandSide;
                        leftHandSideName=leftHandSideFieldAccess.getName();
                      }
                      if (leftHandSideName != null && leftHandSideName.equals(simpleName)) {
                        isLeftHandOfAssignment=true;
                        typeCheckElimination.addAssignedField(fragment);
                      }
                    }
                    if (!isLeftHandOfAssignment)                     typeCheckElimination.addAccessedField(fragment);
                  }
                }
              }
            }
          }
 else           if (variableInstructionVariableBinding.isParameter()) {
            List<SingleVariableDeclaration> parameters=typeCheckMethod.parameters();
            for (            SingleVariableDeclaration parameter : parameters) {
              IVariableBinding parameterVariableBinding=parameter.resolveBinding();
              if (parameterVariableBinding.isEqualTo(variableInstructionVariableBinding)) {
                boolean isLeftHandOfAssignment=false;
                if (simpleName.getParent() instanceof Assignment) {
                  Assignment assignment=(Assignment)simpleName.getParent();
                  Expression leftHandSide=assignment.getLeftHandSide();
                  if (leftHandSide instanceof SimpleName) {
                    SimpleName leftHandSideName=(SimpleName)leftHandSide;
                    if (leftHandSideName.equals(simpleName)) {
                      isLeftHandOfAssignment=true;
                      typeCheckElimination.addAssignedParameter(parameter);
                    }
                  }
                }
                if (!isLeftHandOfAssignment)                 typeCheckElimination.addAccessedParameter(parameter);
                break;
              }
            }
          }
 else {
            for (            Statement vDStatement : variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment) {
              VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)vDStatement;
              List<VariableDeclarationFragment> fragments=variableDeclarationStatement.fragments();
              for (              VariableDeclarationFragment fragment : fragments) {
                IVariableBinding fragmentVariableBinding=fragment.resolveBinding();
                if (fragmentVariableBinding.isEqualTo(variableInstructionVariableBinding)) {
                  boolean isLeftHandOfAssignment=false;
                  if (simpleName.getParent() instanceof Assignment) {
                    Assignment assignment=(Assignment)simpleName.getParent();
                    Expression leftHandSide=assignment.getLeftHandSide();
                    if (leftHandSide instanceof SimpleName) {
                      SimpleName leftHandSideName=(SimpleName)leftHandSide;
                      if (leftHandSideName.equals(simpleName)) {
                        isLeftHandOfAssignment=true;
                        typeCheckElimination.addAssignedLocalVariable(fragment);
                      }
                    }
                  }
                  if (!isLeftHandOfAssignment)                   typeCheckElimination.addAccessedLocalVariable(fragment);
                  break;
                }
              }
            }
          }
        }
      }
    }
  }
  processRemainingIfStatementExpressions(variableDeclarationStatementsInsideTypeCheckMethodApartFromTypeCheckCodeFragment);
}