Program: 187309
Project: 187309
Buggy source:
private StateClass convertBlock(BlockOutline block){
  StateClass topLevel;
  String blockName=block.getName();
  Set<MethodOutline> requiredMethods=block.getRequiredMethods();
  Set<MethodOutline> dynamicMethods=block.getDynamicMethods();
  Set<MethodOutline> triggeredMethods=block.getTriggeredMethods();
  if (blocks.containsKey(block.getName())) {
    return blocks.get(block.getName());
  }
 else   if (block instanceof BlockReference) {
    BlockOutline resolved=referenceMap.get(block);
    return convertBlock(resolved);
  }
 else {
    topLevel=getStateFromBlockAndMethods(block,dynamicMethods);
    topLevel.setIsTopLevel();
    blocks.put(blockName,topLevel);
  }
  StateClass baseState=getStateFromBlockAndMethods(block,requiredMethods);
  baseState.setName(blockName);
  for (  MethodOutline requiredMethod : requiredMethods) {
    addTransition(baseState,block,requiredMethods,null,requiredMethod);
  }
  Set<Set<MethodOutline>> workingSet=makeCombinations(dynamicMethods);
  while (!workingSet.isEmpty()) {
    Set<Set<MethodOutline>> nextSet=new HashSet<Set<MethodOutline>>();
    for (    Set<MethodOutline> combination : workingSet) {
      StateClass theState=getStateFromBlockAndMethods(block,combination);
      if (theState != baseState) {
        theState.setBaseState(baseState);
      }
 else {
        continue;
      }
      for (      MethodOutline dynamicMethod : combination) {
        Set<MethodOutline> next;
        next=addTransition(theState,block,combination,triggeredMethods,dynamicMethod);
        if (next != null) {
          nextSet.add(next);
        }
      }
    }
    workingSet=nextSet;
  }
  for (  BlockOutline child : block.getBlocks()) {
    StateClass childState=convertBlock(child);
    childState.setParentState(topLevel);
  }
  return topLevel;
}

Fixed version (ground truth):
private StateClass convertBlock(BlockOutline block){
  StateClass topLevel;
  String blockName=block.getName();
  Set<MethodOutline> requiredMethods=block.getRequiredMethods();
  Set<MethodOutline> dynamicMethods=block.getDynamicMethods();
  Set<MethodOutline> triggeredMethods=block.getTriggeredMethods();
  if (blocks.containsKey(block.getName())) {
    return blocks.get(block.getName());
  }
 else   if (block instanceof BlockReference) {
    BlockOutline resolved=referenceMap.get(block);
    return convertBlock(resolved);
  }
 else {
    topLevel=getStateFromBlockAndMethods(block,dynamicMethods);
    topLevel.setIsTopLevel();
    blocks.put(blockName,topLevel);
  }
  StateClass baseState=getStateFromBlockAndMethods(block,requiredMethods);
  baseState.setName(blockName);
  for (  MethodOutline requiredMethod : requiredMethods) {
    addTransition(baseState,block,requiredMethods,null,requiredMethod);
  }
  Set<Set<MethodOutline>> workingSet=makeCombinations(dynamicMethods);
  Set<StateClass> seen=Collections.newSetFromMap(new IdentityHashMap<StateClass,Boolean>());
  while (!workingSet.isEmpty()) {
    Set<Set<MethodOutline>> nextSet=new HashSet<Set<MethodOutline>>();
    for (    Set<MethodOutline> combination : workingSet) {
      StateClass theState=getStateFromBlockAndMethods(block,combination);
      if (seen.contains(theState)) {
        continue;
      }
 else {
        seen.add(theState);
      }
      if (theState != baseState) {
        theState.setBaseState(baseState);
      }
 else {
        continue;
      }
      for (      MethodOutline dynamicMethod : combination) {
        Set<MethodOutline> next;
        next=addTransition(theState,block,combination,triggeredMethods,dynamicMethod);
        if (next != null) {
          nextSet.add(next);
        }
      }
    }
    workingSet=nextSet;
  }
  for (  BlockOutline child : block.getBlocks()) {
    StateClass childState=convertBlock(child);
    childState.setParentState(topLevel);
  }
  return topLevel;
}