Program: 29539
Project: 29539
Buggy source:
/** 
 * Constructor.
 * @param soyTree The Soy tree from which to build a template registry.
 */
public TemplateRegistry(SoyFileSetNode soyTree){
  Map<String,TemplateBasicNode> tempBasicTemplatesMap=Maps.newHashMap();
  Map<String,Set<DelTemplateKey>> tempDelTemplateNameToKeysMap=Maps.newHashMap();
  Map<DelTemplateKey,Map<Integer,Map<String,TemplateDelegateNode>>> tempDelTemplatesMap=Maps.newHashMap();
  for (  SoyFileNode soyFile : soyTree.getChildren()) {
    for (    TemplateNode template : soyFile.getChildren()) {
      if (template instanceof TemplateBasicNode) {
        tempBasicTemplatesMap.put(template.getTemplateName(),(TemplateBasicNode)template);
      }
 else {
        TemplateDelegateNode delTemplate=(TemplateDelegateNode)template;
        DelTemplateKey delTemplateKey=delTemplate.getDelTemplateKey();
        String delTemplateName=delTemplate.getDelTemplateName();
        Set<DelTemplateKey> keys=tempDelTemplateNameToKeysMap.get(delTemplateName);
        if (keys == null) {
          keys=Sets.newLinkedHashSet();
          tempDelTemplateNameToKeysMap.put(delTemplateName,keys);
        }
        keys.add(delTemplateKey);
        int delPriority=delTemplate.getDelPriority();
        String delPackageName=delTemplate.getDelPackageName();
        Map<Integer,Map<String,TemplateDelegateNode>> tempDivisions=tempDelTemplatesMap.get(delTemplateKey);
        if (tempDivisions == null) {
          tempDivisions=Maps.newHashMap();
          tempDelTemplatesMap.put(delTemplateKey,tempDivisions);
        }
        Map<String,TemplateDelegateNode> tempDivision=tempDivisions.get(delPriority);
        if (tempDivision == null) {
          tempDivision=Maps.newHashMap();
          tempDivisions.put(delPriority,tempDivision);
        }
        if (tempDivision.containsKey(delPackageName)) {
          TemplateDelegateNode prevTemplate=tempDivision.get(delPackageName);
          String prevTemplateFilePath=prevTemplate.getNearestAncestor(SoyFileNode.class).getFilePath();
          String currTemplateFilePath=delTemplate.getNearestAncestor(SoyFileNode.class).getFilePath();
          String errorMsgPrefix=(delPackageName == null) ? "String_Node_Str" : "String_Node_Str";
          if (currTemplateFilePath != null && currTemplateFilePath.equals(prevTemplateFilePath)) {
            throw SoySyntaxException.createWithoutMetaInfo(String.format(errorMsgPrefix + "String_Node_Str",delTemplateKey,currTemplateFilePath));
          }
 else {
            throw SoySyntaxException.createWithoutMetaInfo(String.format(errorMsgPrefix + "String_Node_Str",delTemplateKey,prevTemplateFilePath,currTemplateFilePath));
          }
        }
        tempDivision.put(delPackageName,delTemplate);
      }
    }
  }
  basicTemplatesMap=Collections.unmodifiableMap(tempBasicTemplatesMap);
  ImmutableMap.Builder<DelTemplateKey,List<DelegateTemplateDivision>> delTemplatesMapBuilder=ImmutableMap.builder();
  for (  DelTemplateKey delTemplateKey : tempDelTemplatesMap.keySet()) {
    Map<Integer,Map<String,TemplateDelegateNode>> tempDivisions=tempDelTemplatesMap.get(delTemplateKey);
    ImmutableList.Builder<DelegateTemplateDivision> divisionsBuilder=ImmutableList.builder();
    for (int priority=TemplateNode.MAX_PRIORITY; priority >= 0; priority--) {
      if (!tempDivisions.containsKey(priority)) {
        continue;
      }
      Map<String,TemplateDelegateNode> tempDivision=tempDivisions.get(priority);
      DelegateTemplateDivision division=new DelegateTemplateDivision(priority,tempDivision);
      divisionsBuilder.add(division);
    }
    delTemplatesMapBuilder.put(delTemplateKey,divisionsBuilder.build());
  }
  delTemplatesMap=delTemplatesMapBuilder.build();
  delTemplateNameToKeysMap=Collections.unmodifiableMap(tempDelTemplateNameToKeysMap);
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param soyTree The Soy tree from which to build a template registry.
 */
public TemplateRegistry(SoyFileSetNode soyTree){
  Map<String,TemplateBasicNode> tempBasicTemplatesMap=new LinkedHashMap<>();
  Map<String,Set<DelTemplateKey>> tempDelTemplateNameToKeysMap=new LinkedHashMap<>();
  Map<DelTemplateKey,Map<Integer,Map<String,TemplateDelegateNode>>> tempDelTemplatesMap=new LinkedHashMap<>();
  for (  SoyFileNode soyFile : soyTree.getChildren()) {
    for (    TemplateNode template : soyFile.getChildren()) {
      if (template instanceof TemplateBasicNode) {
        tempBasicTemplatesMap.put(template.getTemplateName(),(TemplateBasicNode)template);
      }
 else {
        TemplateDelegateNode delTemplate=(TemplateDelegateNode)template;
        DelTemplateKey delTemplateKey=delTemplate.getDelTemplateKey();
        String delTemplateName=delTemplate.getDelTemplateName();
        Set<DelTemplateKey> keys=tempDelTemplateNameToKeysMap.get(delTemplateName);
        if (keys == null) {
          keys=Sets.newLinkedHashSet();
          tempDelTemplateNameToKeysMap.put(delTemplateName,keys);
        }
        keys.add(delTemplateKey);
        int delPriority=delTemplate.getDelPriority();
        String delPackageName=delTemplate.getDelPackageName();
        Map<Integer,Map<String,TemplateDelegateNode>> tempDivisions=tempDelTemplatesMap.get(delTemplateKey);
        if (tempDivisions == null) {
          tempDivisions=new LinkedHashMap<>();
          tempDelTemplatesMap.put(delTemplateKey,tempDivisions);
        }
        Map<String,TemplateDelegateNode> tempDivision=tempDivisions.get(delPriority);
        if (tempDivision == null) {
          tempDivision=new LinkedHashMap<>();
          tempDivisions.put(delPriority,tempDivision);
        }
        if (tempDivision.containsKey(delPackageName)) {
          TemplateDelegateNode prevTemplate=tempDivision.get(delPackageName);
          String prevTemplateFilePath=prevTemplate.getNearestAncestor(SoyFileNode.class).getFilePath();
          String currTemplateFilePath=delTemplate.getNearestAncestor(SoyFileNode.class).getFilePath();
          String errorMsgPrefix=(delPackageName == null) ? "String_Node_Str" : "String_Node_Str";
          if (currTemplateFilePath != null && currTemplateFilePath.equals(prevTemplateFilePath)) {
            throw SoySyntaxException.createWithoutMetaInfo(String.format(errorMsgPrefix + "String_Node_Str",delTemplateKey,currTemplateFilePath));
          }
 else {
            throw SoySyntaxException.createWithoutMetaInfo(String.format(errorMsgPrefix + "String_Node_Str",delTemplateKey,prevTemplateFilePath,currTemplateFilePath));
          }
        }
        tempDivision.put(delPackageName,delTemplate);
      }
    }
  }
  basicTemplatesMap=Collections.unmodifiableMap(tempBasicTemplatesMap);
  ImmutableMap.Builder<DelTemplateKey,List<DelegateTemplateDivision>> delTemplatesMapBuilder=ImmutableMap.builder();
  for (  DelTemplateKey delTemplateKey : tempDelTemplatesMap.keySet()) {
    Map<Integer,Map<String,TemplateDelegateNode>> tempDivisions=tempDelTemplatesMap.get(delTemplateKey);
    ImmutableList.Builder<DelegateTemplateDivision> divisionsBuilder=ImmutableList.builder();
    for (int priority=TemplateNode.MAX_PRIORITY; priority >= 0; priority--) {
      if (!tempDivisions.containsKey(priority)) {
        continue;
      }
      Map<String,TemplateDelegateNode> tempDivision=tempDivisions.get(priority);
      DelegateTemplateDivision division=new DelegateTemplateDivision(priority,tempDivision);
      divisionsBuilder.add(division);
    }
    delTemplatesMapBuilder.put(delTemplateKey,divisionsBuilder.build());
  }
  delTemplatesMap=delTemplatesMapBuilder.build();
  delTemplateNameToKeysMap=Collections.unmodifiableMap(tempDelTemplateNameToKeysMap);
}