Program: 29526
Project: 29526
Buggy source:
/** 
 * Handles a translation consisting of raw text with placeholders.
 */
private Statement handleTranslationWithPlaceholders(MsgNode msg,List<String> escapingDirectives,Expression soyMsg){
  Expression placeholderMap=variables.getMsgPlaceholderMapField().accessor(thisVar);
  Map<String,Statement> placeholderNameToPutStatement=new LinkedHashMap<>();
  putPlaceholdersIntoMap(placeholderMap,msg,placeholderNameToPutStatement);
  checkState(!placeholderNameToPutStatement.isEmpty());
  variables.setMsgPlaceholderMapMinSize(placeholderNameToPutStatement.size());
  Statement populateMap=Statement.concat(placeholderNameToPutStatement.values());
  Statement clearMap=placeholderMap.invokeVoid(MethodRef.LINKED_HASH_MAP_CLEAR);
  Statement render;
  if (escapingDirectives.isEmpty()) {
    render=MethodRef.RUNTIME_RENDER_SOY_MSG_WITH_PLACEHOLDERS.invokeVoid(soyMsg,placeholderMap,appendableExpression);
  }
 else {
    Statement renderToBuffer=MethodRef.RUNTIME_RENDER_SOY_MSG_WITH_PLACEHOLDERS.invokeVoid(soyMsg,placeholderMap,tempBuffer());
    SoyExpression value=SoyExpression.forString(tempBuffer().invoke(MethodRef.ADVISING_STRING_BUILDER_GET_AND_CLEAR));
    for (    String directive : escapingDirectives) {
      value=value.applyPrintDirective(variableLookup.getRenderContext(),directive);
    }
    render=Statement.concat(renderToBuffer,appendableExpression.appendString(value.coerceToString()).toStatement());
  }
  Statement detach=detachState.detachLimited(appendableExpression);
  return Statement.concat(populateMap,render,clearMap,detach).withSourceLocation(msg.getSourceLocation());
}

Fixed version (ground truth):
/** 
 * Handles a complex message with placeholders.
 */
private Statement handleTranslationWithPlaceholders(MsgNode msg,List<String> escapingDirectives,Expression soyMsg,ImmutableList<SoyMsgPart> parts){
  Expression placeholderMap=variables.getMsgPlaceholderMapField().accessor(thisVar);
  Map<String,Statement> placeholderNameToPutStatement=new LinkedHashMap<>();
  putPlaceholdersIntoMap(placeholderMap,msg,parts,placeholderNameToPutStatement);
  checkState(!placeholderNameToPutStatement.isEmpty());
  variables.setMsgPlaceholderMapMinSize(placeholderNameToPutStatement.size());
  Statement populateMap=Statement.concat(placeholderNameToPutStatement.values());
  Statement clearMap=placeholderMap.invokeVoid(MethodRef.LINKED_HASH_MAP_CLEAR);
  Statement render;
  if (escapingDirectives.isEmpty()) {
    render=MethodRef.RUNTIME_RENDER_SOY_MSG_WITH_PLACEHOLDERS.invokeVoid(soyMsg,placeholderMap,appendableExpression);
  }
 else {
    Statement renderToBuffer=MethodRef.RUNTIME_RENDER_SOY_MSG_WITH_PLACEHOLDERS.invokeVoid(soyMsg,placeholderMap,tempBuffer());
    SoyExpression value=SoyExpression.forString(tempBuffer().invoke(MethodRef.ADVISING_STRING_BUILDER_GET_AND_CLEAR));
    for (    String directive : escapingDirectives) {
      value=value.applyPrintDirective(variableLookup.getRenderContext(),directive);
    }
    render=Statement.concat(renderToBuffer,appendableExpression.appendString(value.coerceToString()).toStatement());
  }
  Statement detach=detachState.detachLimited(appendableExpression);
  return Statement.concat(populateMap,render,clearMap,detach).withSourceLocation(msg.getSourceLocation());
}