Program: 29345
Project: 29345
Buggy source:
/** 
 * Handles a complex message with placeholders. 
 */
private Statement handleTranslationWithPlaceholders(MsgNode msg,ImmutableList<SoyPrintDirective> escapingDirectives,Expression soyMsgParts,Expression locale,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 (areAllPrintDirectivesStreamable(escapingDirectives)) {
    AppendableAndOptions wrappedAppendable=applyStreamingEscapingDirectives(escapingDirectives,appendableExpression,parameterLookup.getRenderContext());
    Statement initAppendable=Statement.NULL_STATEMENT;
    Statement clearAppendable=Statement.NULL_STATEMENT;
    Expression appendableExpression=wrappedAppendable.appendable();
    if (wrappedAppendable.closeable()) {
      Scope scope=variables.enterScope();
      Variable appendableVar=scope.createTemporary("String_Node_Str",wrappedAppendable.appendable());
      initAppendable=appendableVar.initializer();
      appendableExpression=appendableVar.local();
      clearAppendable=Statement.concat(appendableVar.local().checkedCast(BytecodeUtils.CLOSEABLE_TYPE).invokeVoid(MethodRef.CLOSEABLE_CLOSE),scope.exitScope());
    }
    render=Statement.concat(initAppendable,MethodRef.RUNTIME_RENDER_SOY_MSG_PARTS_WITH_PLACEHOLDERS.invokeVoid(soyMsgParts,locale,placeholderMap,appendableExpression),clearAppendable);
  }
 else {
    Statement renderToBuffer=MethodRef.RUNTIME_RENDER_SOY_MSG_PARTS_WITH_PLACEHOLDERS.invokeVoid(soyMsgParts,locale,placeholderMap,tempBuffer());
    SoyExpression value=SoyExpression.forString(tempBuffer().invoke(MethodRef.ADVISING_STRING_BUILDER_GET_AND_CLEAR));
    for (    SoyPrintDirective directive : escapingDirectives) {
      value=parameterLookup.getRenderContext().applyPrintDirective(directive,value);
    }
    render=Statement.concat(renderToBuffer,appendableExpression.appendString(value.coerceToString()).toStatement());
  }
  return Statement.concat(populateMap,render,clearMap);
}

Fixed version (ground truth):
/** 
 * Handles a complex message with placeholders. 
 */
private Statement handleTranslationWithPlaceholders(MsgNode msg,ImmutableList<SoyPrintDirective> escapingDirectives,Expression soyMsgParts,Expression locale,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 (areAllPrintDirectivesStreamable(escapingDirectives)) {
    AppendableAndOptions wrappedAppendable=applyStreamingEscapingDirectives(escapingDirectives,appendableExpression,parameterLookup.getRenderContext(),variables);
    Statement initAppendable=Statement.NULL_STATEMENT;
    Statement clearAppendable=Statement.NULL_STATEMENT;
    Expression appendableExpression=wrappedAppendable.appendable();
    if (wrappedAppendable.closeable()) {
      Scope scope=variables.enterScope();
      Variable appendableVar=scope.createTemporary("String_Node_Str",wrappedAppendable.appendable());
      initAppendable=appendableVar.initializer();
      appendableExpression=appendableVar.local();
      clearAppendable=Statement.concat(appendableVar.local().checkedCast(BytecodeUtils.CLOSEABLE_TYPE).invokeVoid(MethodRef.CLOSEABLE_CLOSE),scope.exitScope());
    }
    render=Statement.concat(initAppendable,MethodRef.RUNTIME_RENDER_SOY_MSG_PARTS_WITH_PLACEHOLDERS.invokeVoid(soyMsgParts,locale,placeholderMap,appendableExpression),clearAppendable);
  }
 else {
    Statement renderToBuffer=MethodRef.RUNTIME_RENDER_SOY_MSG_PARTS_WITH_PLACEHOLDERS.invokeVoid(soyMsgParts,locale,placeholderMap,tempBuffer());
    SoyExpression value=SoyExpression.forString(tempBuffer().invoke(MethodRef.ADVISING_STRING_BUILDER_GET_AND_CLEAR));
    for (    SoyPrintDirective directive : escapingDirectives) {
      value=parameterLookup.getRenderContext().applyPrintDirective(directive,value);
    }
    render=Statement.concat(renderToBuffer,appendableExpression.appendString(value.coerceToString()).toStatement());
  }
  return Statement.concat(populateMap,render,clearMap);
}