Program: 83537
Project: 83537
Buggy source:
private void write(MethodWriter writer,boolean expr) throws BytecodeException {
  int varIndex=writer.localCount();
  IType type=this.value.getType();
  this.value.writeExpression(writer);
  writer.writeVarInsn(type.getStoreOpcode(),varIndex);
  int localCount=writer.localCount();
  Label elseLabel=new Label();
  Label endLabel=new Label();
  Label destLabel=null;
  for (int i=0; i < this.caseCount; ) {
    CaseStatement c=this.cases[i];
    IPattern pattern=c.pattern;
    IValue condition=c.condition;
    IValue value=c.value;
    if (value == null) {
      if (destLabel == null) {
        destLabel=new Label();
      }
      if (condition != null) {
        pattern.writeInvJump(writer,varIndex,elseLabel);
        condition.writeJump(writer,destLabel);
      }
 else {
        pattern.writeJump(writer,varIndex,destLabel);
      }
      writer.resetLocals(localCount);
      ++i;
      continue;
    }
    pattern.writeInvJump(writer,varIndex,elseLabel);
    if (condition != null) {
      condition.writeInvJump(writer,elseLabel);
    }
    if (destLabel != null) {
      writer.writeLabel(destLabel);
      destLabel=null;
    }
    if (expr) {
      value.writeExpression(writer);
    }
 else {
      value.writeStatement(writer);
    }
    writer.resetLocals(localCount);
    writer.writeJumpInsn(Opcodes.GOTO,endLabel);
    writer.writeLabel(elseLabel);
    if (++i < this.caseCount) {
      elseLabel=new Label();
    }
  }
  writer.writeLabel(elseLabel);
  if (!this.exhaustive) {
    writer.writeTypeInsn(Opcodes.NEW,"String_Node_Str");
    writer.writeInsn(Opcodes.DUP);
    writer.writeVarInsn(type.getLoadOpcode(),varIndex);
    String desc="String_Node_Str" + (type.isPrimitive() ? type.getExtendedName() + "String_Node_Str" : "String_Node_Str");
    writer.writeInvokeInsn(Opcodes.INVOKESPECIAL,"String_Node_Str","String_Node_Str",desc,false);
    writer.writeInsn(Opcodes.ATHROW);
    writer.resetLocals(varIndex);
  }
  writer.writeLabel(endLabel);
}

Fixed version (ground truth):
private void write(MethodWriter writer,boolean expr) throws BytecodeException {
  int varIndex=writer.localCount();
  IType type=this.value.getType();
  this.value.writeExpression(writer);
  writer.writeVarInsn(type.getStoreOpcode(),varIndex);
  int localCount=writer.localCount();
  Object frameType=expr ? this.type.getFrameType() : null;
  Label elseLabel=new Label();
  Label endLabel=new Label();
  Label destLabel=null;
  for (int i=0; i < this.caseCount; ) {
    CaseStatement c=this.cases[i];
    IPattern pattern=c.pattern;
    IValue condition=c.condition;
    IValue value=c.value;
    if (value == null) {
      if (destLabel == null) {
        destLabel=new Label();
      }
      if (condition != null) {
        pattern.writeInvJump(writer,varIndex,elseLabel);
        condition.writeJump(writer,destLabel);
      }
 else {
        pattern.writeJump(writer,varIndex,destLabel);
      }
      writer.resetLocals(localCount);
      ++i;
      continue;
    }
    pattern.writeInvJump(writer,varIndex,elseLabel);
    if (condition != null) {
      condition.writeInvJump(writer,elseLabel);
    }
    if (destLabel != null) {
      writer.writeLabel(destLabel);
      destLabel=null;
    }
    if (expr) {
      value.writeExpression(writer);
      writer.getFrame().set(frameType);
    }
 else {
      value.writeStatement(writer);
    }
    writer.resetLocals(localCount);
    writer.writeJumpInsn(Opcodes.GOTO,endLabel);
    writer.writeLabel(elseLabel);
    if (++i < this.caseCount) {
      elseLabel=new Label();
    }
  }
  writer.writeLabel(elseLabel);
  if (!this.exhaustive) {
    writer.writeTypeInsn(Opcodes.NEW,"String_Node_Str");
    writer.writeInsn(Opcodes.DUP);
    writer.writeVarInsn(type.getLoadOpcode(),varIndex);
    String desc="String_Node_Str" + (type.isPrimitive() ? type.getExtendedName() + "String_Node_Str" : "String_Node_Str");
    writer.writeInvokeInsn(Opcodes.INVOKESPECIAL,"String_Node_Str","String_Node_Str",desc,false);
    writer.writeInsn(Opcodes.ATHROW);
    writer.setHasReturn(false);
  }
  writer.writeLabel(endLabel);
  writer.resetLocals(varIndex);
}