Program: 12188
Project: 12188
Buggy source:
private void generateRequiredImportDeclarationsBasedOnSignature(){
  List<ITypeBinding> typeBindings=new ArrayList<ITypeBinding>();
  if (returnedVariable != null) {
    Type returnType=null;
    if (returnedVariable instanceof SingleVariableDeclaration) {
      SingleVariableDeclaration singleVariableDeclaration=(SingleVariableDeclaration)returnedVariable;
      returnType=singleVariableDeclaration.getType();
    }
 else     if (returnedVariable instanceof VariableDeclarationFragment) {
      VariableDeclarationFragment variableDeclarationFragment=(VariableDeclarationFragment)returnedVariable;
      VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)variableDeclarationFragment.getParent();
      returnType=variableDeclarationStatement.getType();
    }
    ITypeBinding returnTypeBinding=returnType.resolveBinding();
    if (!typeBindings.contains(returnTypeBinding))     typeBindings.add(returnTypeBinding);
  }
  Set<SingleVariableDeclaration> parameters=typeCheckElimination.getAccessedParameters();
  for (  SingleVariableDeclaration parameter : parameters) {
    Type parameterType=parameter.getType();
    ITypeBinding parameterTypeBinding=parameterType.resolveBinding();
    if (!typeBindings.contains(parameterTypeBinding))     typeBindings.add(parameterTypeBinding);
  }
  Set<VariableDeclarationFragment> accessedLocalVariables=typeCheckElimination.getAccessedLocalVariables();
  for (  VariableDeclarationFragment fragment : accessedLocalVariables) {
    if (!fragment.equals(returnedVariable)) {
      VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)fragment.getParent();
      Type variableType=variableDeclarationStatement.getType();
      ITypeBinding variableTypeBinding=variableType.resolveBinding();
      if (!typeBindings.contains(variableTypeBinding))       typeBindings.add(variableTypeBinding);
    }
  }
  if (typeCheckElimination.getAccessedFields().size() > 0 || typeCheckElimination.getAssignedFields().size() > 0 || typeCheckElimination.getAccessedMethods().size() > 0 || typeCheckElimination.getSuperAccessedMethods().size() > 0) {
    if (!typeBindings.contains(sourceTypeDeclaration.resolveBinding()))     typeBindings.add(sourceTypeDeclaration.resolveBinding());
  }
  for (  ITypeBinding typeBinding : thrownExceptions) {
    if (!typeBindings.contains(typeBinding))     typeBindings.add(typeBinding);
  }
  getSimpleTypeBindings(typeBindings,requiredImportDeclarationsBasedOnSignature);
}

Fixed version (ground truth):
private void generateRequiredImportDeclarationsBasedOnSignature(){
  List<ITypeBinding> typeBindings=new ArrayList<ITypeBinding>();
  if (returnedVariable != null) {
    Type returnType=null;
    if (returnedVariable instanceof SingleVariableDeclaration) {
      SingleVariableDeclaration singleVariableDeclaration=(SingleVariableDeclaration)returnedVariable;
      returnType=singleVariableDeclaration.getType();
    }
 else     if (returnedVariable instanceof VariableDeclarationFragment) {
      VariableDeclarationFragment variableDeclarationFragment=(VariableDeclarationFragment)returnedVariable;
      VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)variableDeclarationFragment.getParent();
      returnType=variableDeclarationStatement.getType();
    }
    ITypeBinding returnTypeBinding=returnType.resolveBinding();
    if (!typeBindings.contains(returnTypeBinding))     typeBindings.add(returnTypeBinding);
  }
  Set<SingleVariableDeclaration> parameters=typeCheckElimination.getAccessedParameters();
  for (  SingleVariableDeclaration parameter : parameters) {
    if (!parameter.equals(returnedVariable) && !parameter.equals(typeVariable)) {
      Type parameterType=parameter.getType();
      ITypeBinding parameterTypeBinding=parameterType.resolveBinding();
      if (!typeBindings.contains(parameterTypeBinding))       typeBindings.add(parameterTypeBinding);
    }
  }
  Set<VariableDeclarationFragment> accessedLocalVariables=typeCheckElimination.getAccessedLocalVariables();
  for (  VariableDeclarationFragment fragment : accessedLocalVariables) {
    if (!fragment.equals(returnedVariable) && !fragment.equals(typeVariable)) {
      VariableDeclarationStatement variableDeclarationStatement=(VariableDeclarationStatement)fragment.getParent();
      Type variableType=variableDeclarationStatement.getType();
      ITypeBinding variableTypeBinding=variableType.resolveBinding();
      if (!typeBindings.contains(variableTypeBinding))       typeBindings.add(variableTypeBinding);
    }
  }
  if (typeCheckElimination.getAccessedFields().size() > 0 || typeCheckElimination.getAssignedFields().size() > 0 || typeCheckElimination.getAccessedMethods().size() > 0 || typeCheckElimination.getSuperAccessedMethods().size() > 0) {
    if (!typeBindings.contains(sourceTypeDeclaration.resolveBinding()))     typeBindings.add(sourceTypeDeclaration.resolveBinding());
  }
  for (  ITypeBinding typeBinding : thrownExceptions) {
    if (!typeBindings.contains(typeBinding))     typeBindings.add(typeBinding);
  }
  getSimpleTypeBindings(typeBindings,requiredImportDeclarationsBasedOnSignature);
}