nus-yam/ex-repair huggingface dataset:
Program: 29336
Project: 29336
Buggy source:
/** 
 * Returns true if a parameter or field of this type can be assigned from a value of   {@code srcType}.
 * @param srcType The type of the incoming value.
 * @return True if the assignment is valid.
 */
boolean isAssignableFrom(SoyType srcType);

Fixed version (ground truth):
/** 
 * Returns true if a parameter or field of this type can be assigned from a value of   {@code srcType}.
 * @param srcType The type of the incoming value.
 * @return True if the assignment is valid.
 */
public final boolean isAssignableFrom(SoyType srcType){
  if (srcType instanceof UnionType) {
    UnionType asUnion=(UnionType)srcType;
    for (    SoyType member : asUnion.getMembers()) {
      if (!doIsAssignableFromNonUnionType(member)) {
        return false;
      }
    }
    return true;
  }
 else {
    return doIsAssignableFromNonUnionType(srcType);
  }
}
Program: 29337
Project: 29337
Buggy source:
/** 
 * Ensures that the directories in the given path exist, creating them if necessary. <p>Note: If the path does not end with the separator char (slash in Linux), then the name at the end is assumed to be the file name, so directories are only created down to its parent.
 * @param path The path for which to ensure directories exist.
 */
public static void ensureDirsExistInPath(String path){
  if (path == null || path.length() == 0) {
    throw new AssertionError("String_Node_Str");
  }
  String dirPath=(path.charAt(path.length() - 1) == File.separatorChar) ? path.substring(0,path.length() - 1) : (new File(path)).getParent();
  if (dirPath == null || KNOWN_EXISTING_DIRS.contains(dirPath)) {
    return;
  }
 else {
    (new File(dirPath)).mkdirs();
    KNOWN_EXISTING_DIRS.add(dirPath);
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the directories in the given path exist, creating them if necessary. <p>Note: If the path does not end with the separator char (slash in Linux), then the name at the end is assumed to be the file name, so directories are only created down to its parent.
 * @param path The path for which to ensure directories exist.
 */
public static void ensureDirsExistInPath(String path){
  if (path == null || path.length() == 0) {
    throw new AssertionError("String_Node_Str");
  }
  String dirPath=(path.charAt(path.length() - 1) == File.separatorChar) ? path.substring(0,path.length() - 1) : (new File(path)).getParent();
  if (dirPath == null || knownExistingDirs.contains(dirPath)) {
    return;
  }
 else {
    (new File(dirPath)).mkdirs();
    knownExistingDirs.add(dirPath);
  }
}
Program: 29338
Project: 29338
Buggy source:
private SoyValue visitNullSafeFieldAccessNode(FieldAccessNode fieldAccess){
  SoyValue base=visitNullSafeNodeRecurse(fieldAccess.getBaseExprChild());
  if (!(base instanceof SoyRecord) && !(base instanceof SoyProtoValue)) {
    if (base == NullSafetySentinel.INSTANCE) {
      return NullSafetySentinel.INSTANCE;
    }
    if (fieldAccess.isNullSafe()) {
      if (isNullOrUndefinedBase(base)) {
        return NullSafetySentinel.INSTANCE;
      }
 else {
        throw RenderException.create(String.format("String_Node_Str",fieldAccess.toSourceString(),fieldAccess.getSourceStringSuffix()));
      }
    }
    return UndefinedData.INSTANCE;
  }
  if (fieldAccess.getBaseExprChild().getType().getKind() == Kind.PROTO) {
    return ((SoyProtoValue)base).getProtoField(fieldAccess.getFieldName());
  }
  maybeMarkBadProtoAccess(fieldAccess,base);
  SoyValue value=((SoyRecord)base).getField(fieldAccess.getFieldName());
  if (value != null && !TofuTypeChecks.isInstance(fieldAccess.getType(),value)) {
    throw RenderException.create(String.format("String_Node_Str",fieldAccess.getType(),value.getClass().getSimpleName()));
  }
  return (value != null) ? value : UndefinedData.INSTANCE;
}

Fixed version (ground truth):
private SoyValue visitNullSafeFieldAccessNode(FieldAccessNode fieldAccess){
  SoyValue base=visitNullSafeNodeRecurse(fieldAccess.getBaseExprChild());
  if (!(base instanceof SoyRecord) && !(base instanceof SoyProtoValue)) {
    if (base == NullSafetySentinel.INSTANCE) {
      return NullSafetySentinel.INSTANCE;
    }
    if (fieldAccess.isNullSafe()) {
      if (isNullOrUndefinedBase(base)) {
        return NullSafetySentinel.INSTANCE;
      }
 else {
        throw RenderException.create(String.format("String_Node_Str",fieldAccess.toSourceString(),fieldAccess.getSourceStringSuffix()));
      }
    }
    return UndefinedData.INSTANCE;
  }
  if (SoyTypes.tryRemoveNull(fieldAccess.getBaseExprChild().getType()).getKind() == Kind.PROTO) {
    return ((SoyProtoValue)base).getProtoField(fieldAccess.getFieldName());
  }
  maybeMarkBadProtoAccess(fieldAccess,base);
  SoyValue value=((SoyRecord)base).getField(fieldAccess.getFieldName());
  if (value != null && !TofuTypeChecks.isInstance(fieldAccess.getType(),value)) {
    throw RenderException.create(String.format("String_Node_Str",fieldAccess.getType(),value.getClass().getSimpleName()));
  }
  return (value != null) ? value : UndefinedData.INSTANCE;
}
Program: 29339
Project: 29339
Buggy source:
@VisibleForTesting SoyMsgBundleWithFullLocale(SoyMsgBundle delegate,ULocale locale,String localeString){
  this.delegate=delegate;
  this.locale=locale;
  this.localeString=localeString;
  this.isRtl=BidiGlobalDir.forStaticLocale(localeString) == BidiGlobalDir.RTL;
}

Fixed version (ground truth):
@VisibleForTesting SoyMsgBundleWithFullLocale(SoyMsgBundle delegate,ULocale locale,String localeString){
  while (delegate instanceof SoyMsgBundleWithFullLocale) {
    delegate=((SoyMsgBundleWithFullLocale)delegate).delegate;
  }
  this.delegate=delegate;
  this.locale=locale;
  this.localeString=localeString;
  this.isRtl=BidiGlobalDir.forStaticLocale(localeString) == BidiGlobalDir.RTL;
}
Program: 29340
Project: 29340
Buggy source:
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param basic The expression compiler to use for compiling the arguments
 * @param renderContext The render context for the plugins
 * @return The wrapped appendable
 */
static Expression applyStreamingPrintDirectives(List<PrintDirectiveNode> directives,Expression appendable,BasicExpressionCompiler basic,JbcSrcPluginContext renderContext){
  for (  PrintDirectiveNode directive : directives) {
    appendable=((SoyJbcSrcPrintDirective.Streamable)directive.getPrintDirective()).applyForJbcSrcStreaming(renderContext,appendable,basic.compileToList(directive.getArgs()));
  }
  return appendable;
}

Fixed version (ground truth):
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param basic The expression compiler to use for compiling the arguments
 * @param renderContext The render context for the plugins
 * @return The wrapped appendable
 */
static Expression applyStreamingPrintDirectives(List<PrintDirectiveNode> directives,Expression appendable,BasicExpressionCompiler basic,JbcSrcPluginContext renderContext){
  for (  PrintDirectiveNode directive : Lists.reverse(directives)) {
    appendable=((SoyJbcSrcPrintDirective.Streamable)directive.getPrintDirective()).applyForJbcSrcStreaming(renderContext,appendable,basic.compileToList(directive.getArgs()));
  }
  return appendable;
}
Program: 29341
Project: 29341
Buggy source:
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param context The render context for the plugins
 * @return The wrapped appendable
 */
static Expression applyStreamingEscapingDirectives(List<SoyPrintDirective> directives,Expression appendable,JbcSrcPluginContext context){
  for (  SoyPrintDirective directive : directives) {
    appendable=((SoyJbcSrcPrintDirective.Streamable)directive).applyForJbcSrcStreaming(context,appendable,ImmutableList.of());
  }
  return appendable;
}

Fixed version (ground truth):
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param context The render context for the plugins
 * @return The wrapped appendable
 */
static Expression applyStreamingEscapingDirectives(List<SoyPrintDirective> directives,Expression appendable,JbcSrcPluginContext context){
  for (  SoyPrintDirective directive : Lists.reverse(directives)) {
    appendable=((SoyJbcSrcPrintDirective.Streamable)directive).applyForJbcSrcStreaming(context,appendable,ImmutableList.of());
  }
  return appendable;
}
Program: 29342
Project: 29342
Buggy source:
@Override public LoggingAdvisingAppendable appendLoggingFunctionInvocation(LoggingFunctionInvocation funCall,ImmutableList<Function<String,String>> escapers) throws IOException {
  getDelegateForAppend().appendLoggingFunctionInvocation(funCall,escapers).append("String_Node_Str");
  return this;
}

Fixed version (ground truth):
@Override public LoggingAdvisingAppendable appendLoggingFunctionInvocation(LoggingFunctionInvocation funCall,ImmutableList<Function<String,String>> escapers) throws IOException {
  delegate.appendLoggingFunctionInvocation(funCall,escapers);
  return this;
}
Program: 29343
Project: 29343
Buggy source:
@Override public Expression applyForJbcSrcStreaming(JbcSrcPluginContext context,Expression delegateAppendable,List<SoyExpression> args){
  return ConstructorRef.create(AnnotatingAppendable.class,LoggingAdvisingAppendable.class).construct(delegateAppendable);
}

Fixed version (ground truth):
@Override public Expression applyForJbcSrcStreaming(JbcSrcPluginContext context,Expression delegateAppendable,List<SoyExpression> args){
  Expression wrapperText;
  if (!args.isEmpty()) {
    wrapperText=args.get(0).coerceToString();
  }
 else {
    wrapperText=BytecodeUtils.constant("String_Node_Str");
  }
  return ConstructorRef.create(AnnotatingAppendable.class,String.class,LoggingAdvisingAppendable.class).construct(wrapperText,delegateAppendable);
}
Program: 29344
Project: 29344
Buggy source:
public AnnotatingAppendable(LoggingAdvisingAppendable delegate){
  this.delegate=delegate;
}

Fixed version (ground truth):
public AnnotatingAppendable(String wrapperText,LoggingAdvisingAppendable delegate){
  this.delegate=delegate;
  this.wrapperText=wrapperText;
}
Program: 29346
Project: 29346
Buggy source:
private static <T>AppendableAndOptions applyStreamingPrintDirectivesTo(List<DirectiveWithArgs> directivesToApply,Expression appendable,JbcSrcPluginContext context){
  AppendableAndOptions prev=AppendableAndOptions.create(appendable);
  List<Expression> closeables=new ArrayList<>();
  for (  DirectiveWithArgs directiveToApply : Lists.reverse(directivesToApply)) {
    AppendableAndOptions curr=directiveToApply.apply(context,prev.appendable());
    if (curr.closeable()) {
      closeables.add(curr.appendable());
    }
    prev=curr;
  }
  if (closeables.isEmpty()) {
    return prev;
  }
  if (closeables.size() == 1 && prev.appendable() == closeables.get(0)) {
    return prev;
  }
  return AppendableAndOptions.createCloseable(RUNTIME_PROPAGATE_CLOSE.invoke(prev.appendable(),BytecodeUtils.asImmutableList(Lists.reverse(closeables))));
}

Fixed version (ground truth):
private static AppendableAndOptions applyStreamingPrintDirectivesTo(List<DirectiveWithArgs> directivesToApply,Expression appendable,JbcSrcPluginContext context,TemplateVariableManager variableManager){
  final List<LocalVariable> closeables=new ArrayList<>();
  final List<Variable> appendableVars=new ArrayList<>();
  Scope scope=variableManager.enterScope();
  AppendableAndOptions prev=AppendableAndOptions.create(appendable);
  Variable prevVar=scope.createTemporary("String_Node_Str",appendable);
  appendableVars.add(prevVar);
  for (  DirectiveWithArgs directiveToApply : Lists.reverse(directivesToApply)) {
    AppendableAndOptions curr=directiveToApply.apply(context,prevVar.local());
    Variable currVar=scope.createTemporary("String_Node_Str",curr.appendable());
    appendableVars.add(currVar);
    if (curr.closeable()) {
      closeables.add(currVar.local());
    }
    prev=curr;
    prevVar=currVar;
  }
  final Expression appendableExpression;
  final boolean closeable;
  if (closeables.isEmpty()) {
    appendableExpression=prev.appendable();
    closeable=false;
  }
 else   if (closeables.size() == 1 && prev.closeable()) {
    appendableExpression=prev.appendable();
    closeable=true;
  }
 else {
    appendableExpression=RUNTIME_PROPAGATE_CLOSE.invoke(Iterables.getLast(appendableVars).local(),BytecodeUtils.asImmutableList(Lists.reverse(closeables)));
    closeable=true;
  }
  final Statement exitScope=scope.exitScope();
  Expression result=new Expression(appendableExpression.resultType()){
    @Override protected void doGen(    CodeBuilder adapter){
      for (      Variable var : appendableVars) {
        var.initializer().gen(adapter);
      }
      appendableExpression.gen(adapter);
      exitScope.gen(adapter);
    }
  }
;
  if (closeable) {
    return AppendableAndOptions.createCloseable(result);
  }
 else {
    return AppendableAndOptions.create(result);
  }
}
Program: 29347
Project: 29347
Buggy source:
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param basic The expression compiler to use for compiling the arguments
 * @param renderContext The render context for the plugins
 * @return The wrapped appendable
 */
static AppendableAndOptions applyStreamingPrintDirectives(List<PrintDirectiveNode> directives,Expression appendable,BasicExpressionCompiler basic,JbcSrcPluginContext renderContext){
  List<DirectiveWithArgs> directivesToApply=new ArrayList<>();
  for (  PrintDirectiveNode directive : directives) {
    directivesToApply.add(DirectiveWithArgs.create((SoyJbcSrcPrintDirective.Streamable)directive.getPrintDirective(),basic.compileToList(directive.getArgs())));
  }
  return applyStreamingPrintDirectivesTo(directivesToApply,appendable,renderContext);
}

Fixed version (ground truth):
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param basic The expression compiler to use for compiling the arguments
 * @param renderContext The render context for the plugins
 * @param variables The local variable manager
 * @return The wrapped appendable
 */
static AppendableAndOptions applyStreamingPrintDirectives(List<PrintDirectiveNode> directives,Expression appendable,BasicExpressionCompiler basic,JbcSrcPluginContext renderContext,TemplateVariableManager variables){
  List<DirectiveWithArgs> directivesToApply=new ArrayList<>();
  for (  PrintDirectiveNode directive : directives) {
    directivesToApply.add(DirectiveWithArgs.create((SoyJbcSrcPrintDirective.Streamable)directive.getPrintDirective(),basic.compileToList(directive.getArgs())));
  }
  return applyStreamingPrintDirectivesTo(directivesToApply,appendable,renderContext,variables);
}
Program: 29348
Project: 29348
Buggy source:
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param context The render context for the plugins
 * @return The wrapped appendable
 */
static AppendableAndOptions applyStreamingEscapingDirectives(List<SoyPrintDirective> directives,Expression appendable,JbcSrcPluginContext context){
  List<DirectiveWithArgs> directivesToApply=new ArrayList<>();
  for (  SoyPrintDirective directive : directives) {
    directivesToApply.add(DirectiveWithArgs.create((SoyJbcSrcPrintDirective.Streamable)directive));
  }
  return applyStreamingPrintDirectivesTo(directivesToApply,appendable,context);
}

Fixed version (ground truth):
/** 
 * Applies all the streaming print directives to the appendable.
 * @param directives The directives. All are required to be {@link com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable streamable}
 * @param appendable The appendable to wrap
 * @param context The render context for the plugins
 * @param variables The local variable manager
 * @return The wrapped appendable
 */
static AppendableAndOptions applyStreamingEscapingDirectives(List<SoyPrintDirective> directives,Expression appendable,JbcSrcPluginContext context,TemplateVariableManager variables){
  List<DirectiveWithArgs> directivesToApply=new ArrayList<>();
  for (  SoyPrintDirective directive : directives) {
    directivesToApply.add(DirectiveWithArgs.create((SoyJbcSrcPrintDirective.Streamable)directive));
  }
  return applyStreamingPrintDirectivesTo(directivesToApply,appendable,context,variables);
}
Program: 29351
Project: 29351
Buggy source:
@Override public void close() throws IOException {
  delegate.append(suffix);
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (appendCalled) {
    delegate.append(suffix);
  }
}
Program: 29352
Project: 29352
Buggy source:
@Override public LoggingAdvisingAppendable append(char c) throws IOException {
  return append("String_Node_Str" + c);
}

Fixed version (ground truth):
@Override public LoggingAdvisingAppendable append(CharSequence csq,int start,int end) throws IOException {
  appendCalled=true;
  return super.append(csq,start,end);
}
Program: 29353
Project: 29353
Buggy source:
static boolean tryMatchCloseTag(ArrayDeque<HtmlTagEntry> openStack,HtmlTagEntry closeTag,Map<HtmlCloseTagNode,HtmlOpenTagNode> tagMatches,ErrorReporter errorReporter){
  if (closeTag.hasTagName()) {
    HtmlTagEntry entry=tryMatchCloseTag(openStack,closeTag.getTagName(),errorReporter);
    if (entry != null) {
      tagMatches.put((HtmlCloseTagNode)closeTag.getTagNode(),(HtmlOpenTagNode)entry.getTagNode());
    }
    return entry != null;
  }
  HtmlTagEntry openTag=openStack.peekFirst();
  if (openTag == null) {
    return false;
  }
 else   if (openTag.hasTagName()) {
    boolean matchCommonPrefix=tryMatchCommonPrefix(closeTag,openTag.getTagName());
    if (matchCommonPrefix && closeTag.hasEmptyBranches()) {
      return true;
    }
    if (!matchCommonPrefix) {
      return false;
    }
  }
 else {
    if (matchOrError(openTag,closeTag,errorReporter)) {
      openStack.pollFirst();
    }
 else {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Try to match a close tag with a stack of open tags, and report errors accordingly. <p>Return false if openStack is empty or we cannot find a common prefix for the current close tag. Notably returning true does not mean we find a match for the current close tag. When we definitely know there is a mismatch and report an error for that, we still return true. The return value is used by   {@code StrictHtmlValidationPass} to decide whether we should add thecloseTag to the queue. <p>TODO(b/65293620): Change the return results to an enum.
 */
static boolean tryMatchCloseTag(ArrayDeque<HtmlTagEntry> openStack,HtmlTagEntry closeTag,Map<HtmlCloseTagNode,HtmlOpenTagNode> tagMatches,ErrorReporter errorReporter){
  if (closeTag.hasTagName()) {
    HtmlTagEntry entry=tryMatchCloseTag(openStack,closeTag.getTagName(),errorReporter);
    if (entry != null) {
      tagMatches.put((HtmlCloseTagNode)closeTag.getTagNode(),(HtmlOpenTagNode)entry.getTagNode());
    }
    return entry != null;
  }
  HtmlTagEntry openTag=openStack.peekFirst();
  if (openTag == null) {
    return false;
  }
 else   if (openTag.hasTagName()) {
    boolean matchCommonPrefix=tryMatchCommonPrefix(closeTag,openTag.getTagName());
    if (matchCommonPrefix && closeTag.hasEmptyBranches()) {
      return true;
    }
    if (!matchCommonPrefix) {
      return false;
    }
  }
 else {
    if (matchOrError(openTag,closeTag,errorReporter)) {
      openStack.pollFirst();
    }
 else {
      return false;
    }
  }
  return true;
}
Program: 29354
Project: 29354
Buggy source:
/** 
 * {@code SwitchNode} is very similar with {@code IfNode}. The major difference is the way to generate conditions.
 */
@Override protected void visitSwitchNode(SwitchNode node){
  ConditionalBranches outerOpenTagBranches=new ConditionalBranches(openTagBranches);
  ConditionalBranches outerCloseTagBranches=new ConditionalBranches(closeTagBranches);
  openTagBranches.clear();
  closeTagBranches.clear();
  visitChildren(node);
  if (!openTagBranches.isEmpty() && !closeTagBranches.isEmpty()) {
    errorReporter.report(closeTagBranches.getSourceLocation(),UNEXPECTED_CLOSE_TAG);
    openTagBranches.clear();
    closeTagBranches.clear();
  }
  if (!openTagBranches.isEmpty()) {
    openTagStack.addFirst(new HtmlTagEntry(openTagBranches));
    openTagBranches.clear();
  }
  if (!closeTagBranches.isEmpty()) {
    closeTagQueue.addLast(new HtmlTagEntry(closeTagBranches));
    closeTagBranches.clear();
  }
  HtmlTagEntry.tryMatchOrError(openTagStack,closeTagQueue,errorReporter);
  openTagBranches.addAll(outerOpenTagBranches);
  closeTagBranches.addAll(outerCloseTagBranches);
}

Fixed version (ground truth):
/** 
 * {@code SwitchNode} is very similar with {@code IfNode}. The major difference is the way to generate conditions.
 */
@Override protected void visitSwitchNode(SwitchNode node){
  ConditionalBranches outerOpenTagBranches=new ConditionalBranches(openTagBranches);
  ConditionalBranches outerCloseTagBranches=new ConditionalBranches(closeTagBranches);
  openTagBranches.clear();
  closeTagBranches.clear();
  visitChildren(node);
  if (!openTagBranches.isEmpty() && !closeTagBranches.isEmpty()) {
    errorReporter.report(closeTagBranches.getSourceLocation(),UNEXPECTED_CLOSE_TAG_IN_CONTROL);
    openTagBranches.clear();
    closeTagBranches.clear();
  }
  if (!openTagBranches.isEmpty()) {
    openTagStack.addFirst(new HtmlTagEntry(openTagBranches));
    openTagBranches.clear();
  }
  if (!closeTagBranches.isEmpty()) {
    closeTagQueue.addLast(new HtmlTagEntry(closeTagBranches));
    closeTagBranches.clear();
  }
  HtmlTagEntry.tryMatchOrError(openTagStack,closeTagQueue,errorReporter);
  openTagBranches.addAll(outerOpenTagBranches);
  closeTagBranches.addAll(outerCloseTagBranches);
}
Program: 29355
Project: 29355
Buggy source:
/** 
 * When we visit IfNode, we do the following steps: <ul> <li>Create new   {@code ConditionalBranches} (and save old branches).<li>For each of its children, update the current conditions. <li>After visiting all children, check if branches are empty. If they are not empty (i.e., we find some HTML tags within this  {@code IfNode}), push the branches into corresponding stack or queue. <li>Restore the conditions and branches. </ul>
 */
@Override protected void visitIfNode(IfNode node){
  ConditionalBranches outerOpenTagBranches=new ConditionalBranches(openTagBranches);
  ConditionalBranches outerCloseTagBranches=new ConditionalBranches(closeTagBranches);
  openTagBranches.clear();
  closeTagBranches.clear();
  visitChildren(node);
  if (!openTagBranches.isEmpty() && !closeTagBranches.isEmpty()) {
    errorReporter.report(closeTagBranches.getSourceLocation(),UNEXPECTED_CLOSE_TAG);
    openTagBranches.clear();
    closeTagBranches.clear();
  }
  if (!openTagBranches.isEmpty()) {
    openTagStack.addFirst(new HtmlTagEntry(openTagBranches));
    openTagBranches.clear();
  }
  if (!closeTagBranches.isEmpty()) {
    closeTagQueue.addLast(new HtmlTagEntry(closeTagBranches));
    closeTagBranches.clear();
  }
  HtmlTagEntry.tryMatchOrError(openTagStack,closeTagQueue,errorReporter);
  openTagBranches.addAll(outerOpenTagBranches);
  closeTagBranches.addAll(outerCloseTagBranches);
}

Fixed version (ground truth):
/** 
 * When we visit IfNode, we do the following steps: <ul> <li>Create new   {@code ConditionalBranches} (and save old branches).<li>For each of its children, update the current conditions. <li>After visiting all children, check if branches are empty. If they are not empty (i.e., we find some HTML tags within this  {@code IfNode}), push the branches into corresponding stack or queue. <li>Restore the conditions and branches. </ul>
 */
@Override protected void visitIfNode(IfNode node){
  ConditionalBranches outerOpenTagBranches=new ConditionalBranches(openTagBranches);
  ConditionalBranches outerCloseTagBranches=new ConditionalBranches(closeTagBranches);
  openTagBranches.clear();
  closeTagBranches.clear();
  visitChildren(node);
  if (!openTagBranches.isEmpty() && !closeTagBranches.isEmpty()) {
    errorReporter.report(closeTagBranches.getSourceLocation(),UNEXPECTED_CLOSE_TAG_IN_CONTROL);
    openTagBranches.clear();
    closeTagBranches.clear();
  }
  if (!openTagBranches.isEmpty()) {
    openTagStack.addFirst(new HtmlTagEntry(openTagBranches));
    openTagBranches.clear();
  }
  if (!closeTagBranches.isEmpty()) {
    closeTagQueue.addLast(new HtmlTagEntry(closeTagBranches));
    closeTagBranches.clear();
  }
  HtmlTagEntry.tryMatchOrError(openTagStack,closeTagQueue,errorReporter);
  openTagBranches.addAll(outerOpenTagBranches);
  closeTagBranches.addAll(outerCloseTagBranches);
}
Program: 29356
Project: 29356
Buggy source:
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  HtmlTagEntry entry=new HtmlTagEntry(node);
  if (closeTag.isDefinitelyVoid()) {
    errorReporter.report(node.getSourceLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  if (!HtmlTagEntry.tryMatchCloseTag(openTagStack,entry,tagMatches,errorReporter)) {
    closeTagQueue.addLast(entry);
  }
}

Fixed version (ground truth):
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  HtmlTagEntry entry=new HtmlTagEntry(node);
  if (closeTag.isDefinitelyVoid()) {
    errorReporter.report(closeTag.getTagLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  if (!HtmlTagEntry.tryMatchCloseTag(openTagStack,entry,tagMatches,errorReporter)) {
    if (isInControlBlock(node)) {
      closeTagQueue.addLast(entry);
    }
 else {
      errorReporter.report(closeTag.getTagLocation(),UNEXPECTED_CLOSE_TAG);
    }
  }
}
Program: 29357
Project: 29357
Buggy source:
@Override public void run(SoyFileNode file,IdGenerator nodeIdGen){
  for (  TemplateNode template : file.getChildren()) {
    for (    TemplateParam param : template.getAllParams()) {
      if (param.isInjected() && param.name().equals(CSP_NONCE_VARIABLE_NAME)) {
        errorReporter.report(param.nameLocation(),IJ_CSP_NONCE_REFERENCE);
      }
    }
  }
  for (  VarRefNode var : SoyTreeUtils.getAllNodesOfType(file,VarRefNode.class)) {
    if (var.isDollarSignIjParameter() && var.getName().equals(CSP_NONCE_VARIABLE_NAME)) {
      errorReporter.report(var.getSourceLocation(),IJ_CSP_NONCE_REFERENCE);
    }
  }
  for (  HtmlOpenTagNode openTag : SoyTreeUtils.getAllNodesOfType(file,HtmlOpenTagNode.class)) {
    RcDataTagName rcDataTagName=openTag.getTagName().getRcDataTagName();
    if (rcDataTagName == RcDataTagName.SCRIPT || rcDataTagName == RcDataTagName.STYLE) {
      SourceLocation insertionLocation=openTag.getSourceLocation().getEndPoint().offset(0,openTag.isSelfClosing() ? 2 : -1).asLocation(openTag.getSourceLocation().getFilePath());
      openTag.addChild(createCspInjection(insertionLocation,nodeIdGen));
    }
  }
}

Fixed version (ground truth):
@Override public void run(SoyFileNode file,IdGenerator nodeIdGen){
  for (  TemplateNode template : file.getChildren()) {
    for (    TemplateParam param : template.getAllParams()) {
      if (param.isInjected() && param.name().equals(CSP_NONCE_VARIABLE_NAME)) {
        errorReporter.report(param.nameLocation(),IJ_CSP_NONCE_REFERENCE);
      }
    }
  }
  for (  VarRefNode var : SoyTreeUtils.getAllNodesOfType(file,VarRefNode.class)) {
    if (var.isDollarSignIjParameter() && var.getName().equals(CSP_NONCE_VARIABLE_NAME)) {
      errorReporter.report(var.getSourceLocation(),IJ_CSP_NONCE_REFERENCE);
    }
  }
  for (  HtmlOpenTagNode openTag : SoyTreeUtils.getAllNodesOfType(file,HtmlOpenTagNode.class)) {
    RcDataTagName rcDataTagName=openTag.getTagName().getRcDataTagName();
    if (rcDataTagName == RcDataTagName.SCRIPT || rcDataTagName == RcDataTagName.STYLE) {
      SourceLocation insertionLocation=openTag.getSourceLocation().getEndPoint().offset(0,openTag.isSelfClosing() ? -2 : -1).asLocation(openTag.getSourceLocation().getFilePath());
      openTag.addChild(createCspInjection(insertionLocation,nodeIdGen));
    }
  }
}
Program: 29358
Project: 29358
Buggy source:
/** 
 * Extends the access chain with a bracket access to the given value.
 * @param nullSafe If true, code will be generated to ensure the chain is non-null beforedereferencing  {@code arg}.
 */
NullSafeAccumulator bracketAccess(CodeChunk.WithValue arg,boolean nullSafe){
  chain.add(new Bracket(arg,nullSafe));
  return this;
}

Fixed version (ground truth):
/** 
 * Extends the access chain with a bracket access to the given value.
 * @param nullSafe If true, code will be generated to ensure the chain is non-null beforedereferencing  {@code arg}.
 */
NullSafeAccumulator bracketAccess(CodeChunk.WithValue arg,boolean nullSafe){
  chain.add(new Bracket(arg,nullSafe));
  isRepeated=false;
  return this;
}
Program: 29359
Project: 29359
Buggy source:
/** 
 * Extends the access chain with a dot access to the given value.
 * @param nullSafe If true, code will be generated to ensure the chain is non-null beforedereferencing  {@code arg}.
 */
NullSafeAccumulator dotAccess(FieldAccess arg,boolean nullSafe){
  if (arg instanceof CallAndUnpack) {
    Preconditions.checkState(unpackFunction == null,"String_Node_Str",unpackFunction);
    unpackFunction=((CallAndUnpack)arg).unpackFunctionName();
    isRepeated=((CallAndUnpack)arg).isRepeated();
  }
  chain.add(arg.toChainAccess(nullSafe));
  return this;
}

Fixed version (ground truth):
/** 
 * Extends the access chain with a dot access to the given value.
 * @param nullSafe If true, code will be generated to ensure the chain is non-null beforedereferencing  {@code arg}.
 */
NullSafeAccumulator dotAccess(FieldAccess arg,boolean nullSafe){
  if (arg instanceof CallAndUnpack) {
    Preconditions.checkState(unpackFunction == null,"String_Node_Str",unpackFunction);
    CallAndUnpack callAndUnpack=(CallAndUnpack)arg;
    unpackFunction=callAndUnpack.unpackFunctionName();
    isRepeated=callAndUnpack.isRepeated();
  }
  chain.add(arg.toChainAccess(nullSafe));
  return this;
}
Program: 29360
Project: 29360
Buggy source:
/** 
 * See   {@link NullSafeAccumulator} for discussion. 
 */
private NullSafeAccumulator visitNullSafeNode(ExprNode node){
switch (node.getKind()) {
case FIELD_ACCESS_NODE:
    FieldAccessNode fieldAccess=(FieldAccessNode)node;
  NullSafeAccumulator base=visitNullSafeNode(fieldAccess.getBaseExprChild());
FieldAccess access=genCodeForFieldAccess(fieldAccess.getBaseExprChild().getType(),fieldAccess,fieldAccess.getFieldName());
return base.dotAccess(access,fieldAccess.isNullSafe());
case ITEM_ACCESS_NODE:
ItemAccessNode itemAccess=(ItemAccessNode)node;
base=visitNullSafeNode(itemAccess.getBaseExprChild());
CodeChunk.WithValue key=visit(itemAccess.getKeyExprChild());
return base.bracketAccess(key,itemAccess.isNullSafe());
default :
return new NullSafeAccumulator(visit(node));
}
}

Fixed version (ground truth):
/** 
 * See   {@link NullSafeAccumulator} for discussion. 
 */
private NullSafeAccumulator visitNullSafeNode(ExprNode node){
switch (node.getKind()) {
case FIELD_ACCESS_NODE:
{
      FieldAccessNode fieldAccess=(FieldAccessNode)node;
      NullSafeAccumulator base=visitNullSafeNode(fieldAccess.getBaseExprChild());
      FieldAccess access=genCodeForFieldAccess(fieldAccess.getBaseExprChild().getType(),fieldAccess,fieldAccess.getFieldName());
      return base.dotAccess(access,fieldAccess.isNullSafe());
    }
case ITEM_ACCESS_NODE:
{
    ItemAccessNode itemAccess=(ItemAccessNode)node;
    NullSafeAccumulator base=visitNullSafeNode(itemAccess.getBaseExprChild());
    CodeChunk.WithValue key=visit(itemAccess.getKeyExprChild());
    return base.bracketAccess(key,itemAccess.isNullSafe());
  }
default :
return new NullSafeAccumulator(visit(node));
}
}
Program: 29361
Project: 29361
Buggy source:
/** 
 * Convert this expression to a statement, by executing it and throwing away the result. <p>This is useful for invoking non-void methods when we don't care about the result.
 */
Statement toStatement(){
  return new Statement(){
    @Override void doGen(    CodeBuilder adapter){
      Expression.this.gen(adapter);
switch (resultType().getSize()) {
case 0:
        throw new AssertionError("String_Node_Str");
case 1:
      adapter.pop();
    break;
case 2:
  adapter.pop2();
break;
}
}
}
;
}

Fixed version (ground truth):
/** 
 * Convert this expression to a statement, by executing it and throwing away the result. <p>This is useful for invoking non-void methods when we don't care about the result.
 */
Statement toStatement(){
  return new Statement(){
    @Override void doGen(    CodeBuilder adapter){
      Expression.this.gen(adapter);
switch (resultType().getSize()) {
case 0:
        throw new AssertionError("String_Node_Str");
case 1:
      adapter.pop();
    break;
case 2:
  adapter.pop2();
break;
default :
throw new AssertionError();
}
}
}
;
}
Program: 29362
Project: 29362
Buggy source:
@Override public String toString(){
  String name=getClass().getSimpleName();
  if (name.isEmpty()) {
    name="String_Node_Str";
  }
  name=name + "String_Node_Str" + resultType+ "String_Node_Str";
  boolean needsLeadingSpace=false;
  if (features.has(Feature.CHEAP)) {
    name+="String_Node_Str";
    needsLeadingSpace=true;
  }
  if (features.has(Feature.NON_NULLABLE) && !BytecodeUtils.isPrimitive(resultType)) {
    name+=(needsLeadingSpace ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str";
  }
  return name + "String_Node_Str" + resultType()+ "String_Node_Str"+ trace();
}

Fixed version (ground truth):
@Override public String toString(){
  String name=getClass().getSimpleName();
  if (name.isEmpty()) {
    name="String_Node_Str";
  }
  MoreObjects.ToStringHelper helper=MoreObjects.toStringHelper(name).omitNullValues();
  helper.add("String_Node_Str",resultType());
  extraToStringProperties(helper);
  helper.add("String_Node_Str",features.has(Feature.CHEAP) ? "String_Node_Str" : null);
  helper.add("String_Node_Str",features.has(Feature.NON_NULLABLE) && !BytecodeUtils.isPrimitive(resultType) ? "String_Node_Str" : null);
  return helper + "String_Node_Str" + trace();
}
Program: 29364
Project: 29364
Buggy source:
/** 
 * Write a local variable table entry for every registered variable. 
 */
void generateTableEntries(CodeBuilder ga){
  for (  Variable var : allVariables) {
    var.local.tableEntry(ga);
  }
}

Fixed version (ground truth):
/** 
 * Write a local variable table entry for every registered variable. 
 */
void generateTableEntries(CodeBuilder ga){
  for (  Variable var : allVariables) {
    try {
      var.local.tableEntry(ga);
    }
 catch (    Throwable t) {
      throw new RuntimeException("String_Node_Str" + var.local,t);
    }
  }
}
Program: 29365
Project: 29365
Buggy source:
@Override Variable createSynthetic(SyntheticVarName varName,Expression initExpr,SaveStrategy strategy){
  VarKey key=VarKey.create(Kind.SYNTHETIC,varName.name());
  String name=fieldNames.generateName("String_Node_Str" + varName.name());
  return doCreate(name,new Label(),scopeExit,initExpr,key,strategy);
}

Fixed version (ground truth):
@Override Variable createSynthetic(SyntheticVarName varName,Expression initExpr,SaveStrategy strategy){
  checkState(!exited,"String_Node_Str");
  VarKey key=VarKey.create(Kind.SYNTHETIC,varName.name());
  String name=fieldNames.generateName("String_Node_Str" + varName.name());
  return doCreate(name,new Label(),scopeExit,initExpr,key,strategy);
}
Program: 29366
Project: 29366
Buggy source:
@Override Variable createTemporary(String name,Expression initExpr){
  VarKey key=VarKey.create(Kind.TEMPORARY,name);
  name=fieldNames.generateName("String_Node_Str" + name);
  return doCreate(name,new Label(),scopeExit,initExpr,key,SaveStrategy.NEVER);
}

Fixed version (ground truth):
@Override Variable createTemporary(String name,Expression initExpr){
  checkState(!exited,"String_Node_Str");
  VarKey key=VarKey.create(Kind.TEMPORARY,name);
  name=fieldNames.generateName("String_Node_Str" + name);
  return doCreate(name,new Label(),scopeExit,initExpr,key,SaveStrategy.NEVER);
}
Program: 29367
Project: 29367
Buggy source:
@Override Variable create(String name,Expression initExpr,SaveStrategy strategy){
  VarKey key=VarKey.create(Kind.USER_DEFINED,name);
  name=fieldNames.generateName(name);
  return doCreate(name,new Label(),scopeExit,initExpr,key,strategy);
}

Fixed version (ground truth):
@Override Variable create(String name,Expression initExpr,SaveStrategy strategy){
  checkState(!exited,"String_Node_Str");
  VarKey key=VarKey.create(Kind.USER_DEFINED,name);
  name=fieldNames.generateName(name);
  return doCreate(name,new Label(),scopeExit,initExpr,key,strategy);
}
Program: 29369
Project: 29369
Buggy source:
@Override Statement exitScope(){
  frames.pop();
  final Set<Label> endLabels=Sets.newIdentityHashSet();
  for (  Variable var : currentFrame.values()) {
    endLabels.add(var.local.end());
    availableSlots.clear(var.local.index(),var.local.index() + var.local.resultType().getSize());
  }
  return new Statement(){
    @Override void doGen(    CodeBuilder adapter){
      for (      Label label : endLabels) {
        adapter.visitLabel(label);
      }
    }
  }
;
}

Fixed version (ground truth):
@Override Statement exitScope(){
  checkState(!exited,"String_Node_Str");
  exited=true;
  frames.pop();
  final Set<Label> endLabels=Sets.newIdentityHashSet();
  for (  Variable var : currentFrame.values()) {
    endLabels.add(var.local.end());
    availableSlots.clear(var.local.index(),var.local.index() + var.local.resultType().getSize());
  }
  return new Statement(){
    @Override void doGen(    CodeBuilder adapter){
      for (      Label label : endLabels) {
        adapter.visitLabel(label);
      }
    }
  }
;
}
Program: 29370
Project: 29370
Buggy source:
private static void checkIntComparisonOpcode(Type comparisonType,int opcode){
switch (opcode) {
case Opcodes.IFEQ:
case Opcodes.IFNE:
    return;
case Opcodes.IFGT:
case Opcodes.IFGE:
case Opcodes.IFLT:
case Opcodes.IFLE:
  if (comparisonType.getSort() == Type.ARRAY || comparisonType.getSort() == Type.OBJECT) {
    throw new IllegalArgumentException("String_Node_Str" + comparisonType + "String_Node_Str"+ Printer.OPCODES[opcode]);
  }
return;
}
throw new IllegalArgumentException("String_Node_Str" + opcode);
}

Fixed version (ground truth):
private static void checkIntComparisonOpcode(Type comparisonType,int opcode){
switch (opcode) {
case Opcodes.IFEQ:
case Opcodes.IFNE:
    return;
case Opcodes.IFGT:
case Opcodes.IFGE:
case Opcodes.IFLT:
case Opcodes.IFLE:
  if (comparisonType.getSort() == Type.ARRAY || comparisonType.getSort() == Type.OBJECT) {
    throw new IllegalArgumentException("String_Node_Str" + comparisonType + "String_Node_Str"+ Printer.OPCODES[opcode]);
  }
return;
default :
throw new IllegalArgumentException("String_Node_Str" + opcode);
}
}
Program: 29372
Project: 29372
Buggy source:
/** 
 * Generate bytecode that coerces the top of stack to the correct type for the given field setter.
 */
private static void coerce(CodeBuilder cb,Type currentType,FieldDescriptor field){
switch (field.getJavaType()) {
case BOOLEAN:
case DOUBLE:
case STRING:
    break;
case FLOAT:
  if (!currentType.equals(Type.FLOAT_TYPE)) {
    cb.cast(currentType,Type.FLOAT_TYPE);
  }
break;
case INT:
if (!currentType.equals(Type.INT_TYPE)) {
cb.cast(currentType,Type.INT_TYPE);
}
break;
case LONG:
if (shouldConvertBetweenStringAndLong(field)) {
MethodRef.LONG_PARSE_LONG.invokeUnchecked(cb);
}
break;
case BYTE_STRING:
BASE_ENCODING_BASE_64.invokeUnchecked(cb);
cb.swap();
BASE_ENCODING_DECODE.invokeUnchecked(cb);
BYTE_STRING_COPY_FROM.invokeUnchecked(cb);
break;
case MESSAGE:
coerceToMessage(cb,field);
break;
case ENUM:
if (!currentType.equals(Type.INT_TYPE)) {
cb.cast(currentType,Type.INT_TYPE);
}
if (!isProto3EnumField(field)) {
getForNumberMethod(field.getEnumType()).invokeUnchecked(cb);
}
return;
default :
throw new AssertionError("String_Node_Str" + field);
}
if (field.isExtension()) {
Type fieldType=getRuntimeType(field);
if (isPrimitive(fieldType)) {
cb.valueOf(fieldType);
}
}
}

Fixed version (ground truth):
/** 
 * Generate bytecode that coerces the top of stack to the correct type for the given field setter.
 */
private static void coerce(CodeBuilder cb,Type currentType,FieldDescriptor field){
switch (field.getJavaType()) {
case BOOLEAN:
case DOUBLE:
case STRING:
    break;
case FLOAT:
  if (!currentType.equals(Type.FLOAT_TYPE)) {
    cb.cast(currentType,Type.FLOAT_TYPE);
  }
break;
case INT:
if (!currentType.equals(Type.INT_TYPE)) {
cb.cast(currentType,Type.INT_TYPE);
}
break;
case LONG:
if (shouldConvertBetweenStringAndLong(field)) {
MethodRef.LONG_PARSE_LONG.invokeUnchecked(cb);
}
break;
case BYTE_STRING:
BASE_ENCODING_BASE_64.invokeUnchecked(cb);
cb.swap();
BASE_ENCODING_DECODE.invokeUnchecked(cb);
BYTE_STRING_COPY_FROM.invokeUnchecked(cb);
break;
case MESSAGE:
coerceToMessage(cb,currentType,field);
break;
case ENUM:
if (!currentType.equals(Type.INT_TYPE)) {
cb.cast(currentType,Type.INT_TYPE);
}
if (!isProto3EnumField(field)) {
getForNumberMethod(field.getEnumType()).invokeUnchecked(cb);
}
return;
default :
throw new AssertionError("String_Node_Str" + field);
}
if (field.isExtension()) {
Type fieldType=getRuntimeType(field);
if (isPrimitive(fieldType)) {
cb.valueOf(fieldType);
}
}
}
Program: 29373
Project: 29373
Buggy source:
private static void coerceToMessage(CodeBuilder cb,FieldDescriptor field){
  if (isSafeProto(field)) {
    MethodRef toProto=SANITIZED_CONTENT_TO_PROTO.get(field.getMessageType().getFullName());
    toProto.invokeUnchecked(cb);
  }
  cb.checkCast(getRuntimeType(field));
}

Fixed version (ground truth):
private static void coerceToMessage(CodeBuilder cb,Type currentType,FieldDescriptor field){
  Type runtimeFieldType=getRuntimeType(field);
  if (isSafeProto(field)) {
    MethodRef toProto=SANITIZED_CONTENT_TO_PROTO.get(field.getMessageType().getFullName());
    if (!currentType.equals(BytecodeUtils.SANITIZED_CONTENT_TYPE)) {
      cb.checkCast(BytecodeUtils.SANITIZED_CONTENT_TYPE);
    }
    toProto.invokeUnchecked(cb);
    currentType=toProto.returnType();
  }
  if (!currentType.equals(runtimeFieldType)) {
    cb.checkCast(runtimeFieldType);
  }
}
Program: 29374
Project: 29374
Buggy source:
@Override void doGen(CodeBuilder cb){
  cb.checkCast(EXTENDABLE_BUILDER_TYPE);
  baseArg.gen(cb);
  Label argIsNull=null;
  Label end=null;
  if (isNullable) {
    argIsNull=new Label();
    end=new Label();
    cb.dup();
    cb.ifNull(argIsNull);
  }
  unboxAndCoerce(cb,baseArg,field);
  extensionIdentifier.gen(cb);
  cb.swap();
  setterMethod.invokeUnchecked(cb);
  if (isNullable) {
    cb.goTo(end);
    cb.mark(argIsNull);
    cb.pop();
    cb.mark(end);
  }
  cb.checkCast(builderRuntimeType(descriptor).type());
}

Fixed version (ground truth):
@Override void doGen(CodeBuilder cb){
  baseArg.gen(cb);
  Label argIsNull=null;
  Label end=null;
  if (isNullable) {
    argIsNull=new Label();
    end=new Label();
    cb.dup();
    cb.ifNull(argIsNull);
  }
  unboxAndCoerce(cb,baseArg,field);
  extensionIdentifier.gen(cb);
  cb.swap();
  setterMethod.invokeUnchecked(cb);
  if (isNullable) {
    cb.goTo(end);
    cb.mark(argIsNull);
    cb.pop();
    cb.mark(end);
  }
  cb.checkCast(builderRuntimeType(descriptor).type());
}
Program: 29375
Project: 29375
Buggy source:
/** 
 * Assuming that the value of   {@code baseArg} is on the top of the stack. unbox and coerce it tobe compatible with the given field descriptor.
 */
private static void unboxAndCoerce(CodeBuilder cb,SoyExpression baseArg,FieldDescriptor field){
  Type currentType;
  if (!isSafeProto(field)) {
    if (baseArg.isBoxed()) {
      currentType=unboxUnchecked(cb,baseArg.soyRuntimeType(),classToUnboxTo(field));
    }
 else {
      currentType=baseArg.resultType();
    }
  }
 else {
    currentType=SANITIZED_CONTENT_TYPE;
  }
  coerce(cb,currentType,field);
}

Fixed version (ground truth):
/** 
 * Assuming that the value of   {@code baseArg} is on the top of the stack. unbox and coerce it tobe compatible with the given field descriptor.
 */
private static void unboxAndCoerce(CodeBuilder cb,SoyExpression baseArg,FieldDescriptor field){
  Type currentType;
  if (!isSafeProto(field)) {
    if (baseArg.isBoxed()) {
      currentType=unboxUnchecked(cb,baseArg.soyRuntimeType(),classToUnboxTo(field));
    }
 else {
      currentType=baseArg.resultType();
    }
  }
 else {
    currentType=baseArg.resultType();
  }
  coerce(cb,currentType,field);
}
Program: 29376
Project: 29376
Buggy source:
private Statement handleExtension(final SoyExpression baseArg,final FieldDescriptor field){
  final Expression extensionIdentifier=getExtensionField(field).accessor();
  final MethodRef setterMethod=field.isRepeated() ? EXTENDABLE_BUILDER_ADD_EXTENSION : EXTENDABLE_BUILDER_SET_EXTENSION;
  final boolean isNullable=!baseArg.isNonNullable();
  return new Statement(){
    @Override void doGen(    CodeBuilder cb){
      cb.checkCast(EXTENDABLE_BUILDER_TYPE);
      baseArg.gen(cb);
      Label argIsNull=null;
      Label end=null;
      if (isNullable) {
        argIsNull=new Label();
        end=new Label();
        cb.dup();
        cb.ifNull(argIsNull);
      }
      unboxAndCoerce(cb,baseArg,field);
      extensionIdentifier.gen(cb);
      cb.swap();
      setterMethod.invokeUnchecked(cb);
      if (isNullable) {
        cb.goTo(end);
        cb.mark(argIsNull);
        cb.pop();
        cb.mark(end);
      }
      cb.checkCast(builderRuntimeType(descriptor).type());
    }
  }
;
}

Fixed version (ground truth):
private Statement handleExtension(final SoyExpression baseArg,final FieldDescriptor field){
  final Expression extensionIdentifier=getExtensionField(field).accessor();
  final MethodRef setterMethod=field.isRepeated() ? EXTENDABLE_BUILDER_ADD_EXTENSION : EXTENDABLE_BUILDER_SET_EXTENSION;
  final boolean isNullable=!baseArg.isNonNullable();
  return new Statement(){
    @Override void doGen(    CodeBuilder cb){
      baseArg.gen(cb);
      Label argIsNull=null;
      Label end=null;
      if (isNullable) {
        argIsNull=new Label();
        end=new Label();
        cb.dup();
        cb.ifNull(argIsNull);
      }
      unboxAndCoerce(cb,baseArg,field);
      extensionIdentifier.gen(cb);
      cb.swap();
      setterMethod.invokeUnchecked(cb);
      if (isNullable) {
        cb.goTo(end);
        cb.mark(argIsNull);
        cb.pop();
        cb.mark(end);
      }
      cb.checkCast(builderRuntimeType(descriptor).type());
    }
  }
;
}