Program: 61502
Project: 61502
Buggy source:
public ScriptInfo generateScriptInfo(SourceGeneratorLocalData localData,List<GraphTargetItem> commands,int classPos) throws AVM2ParseException, CompilationException {
  Reference<Integer> class_index=new Reference<>(classPos);
  ScriptInfo si=new ScriptInfo();
  localData.currentScript=si;
  Trait[] traitArr=generateTraitsPhase1(null,null,true,localData,commands,si.traits,class_index);
  generateTraitsPhase2(new ArrayList<>(),null,commands,traitArr,new ArrayList<>(),localData);
  MethodInfo mi=new MethodInfo(new int[0],0,0,0,new ValueKind[0],new int[0]);
  MethodBody mb=new MethodBody(abc);
  mb.method_info=abc.addMethodInfo(mi);
  mb.setCode(new AVM2Code());
  List<AVM2Instruction> mbCode=mb.getCode().code;
  mbCode.add(ins(AVM2Instructions.GetLocal0));
  mbCode.add(ins(AVM2Instructions.PushScope));
  int traitScope=2;
  Map<Trait,Integer> initScopes=new HashMap<>();
  for (  Trait t : si.traits.traits) {
    if (t instanceof TraitClass) {
      TraitClass tc=(TraitClass)t;
      List<Integer> parents=new ArrayList<>();
      if (localData.documentClass) {
        mbCode.add(ins(AVM2Instructions.GetScopeObject,0));
        traitScope++;
      }
 else {
        NamespaceSet nsset=new NamespaceSet(new int[]{abc.constants.constant_multiname.get(tc.name_index).namespace_index});
        mbCode.add(ins(AVM2Instructions.FindPropertyStrict,abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME,abc.constants.constant_multiname.get(tc.name_index).name_index,0,abc.constants.getNamespaceSetId(nsset,true),0,new ArrayList<>()),true)));
      }
      if (abc.instance_info.get(tc.class_info).isInterface()) {
        mbCode.add(ins(AVM2Instructions.PushNull));
      }
 else {
        parentNamesAddNames(abc,allABCs,abc.instance_info.get(tc.class_info).name_index,parents,new ArrayList<>(),new ArrayList<>());
        for (int i=parents.size() - 1; i >= 0; i--) {
          mbCode.add(ins(AVM2Instructions.GetLex,parents.get(i)));
          mbCode.add(ins(AVM2Instructions.PushScope));
          traitScope++;
        }
        mbCode.add(ins(AVM2Instructions.GetLex,parents.get(0)));
      }
      mbCode.add(ins(AVM2Instructions.NewClass,tc.class_info));
      if (!abc.instance_info.get(tc.class_info).isInterface()) {
        for (int i=parents.size() - 1; i >= 1; i--) {
          mbCode.add(ins(AVM2Instructions.PopScope));
        }
      }
      mbCode.add(ins(AVM2Instructions.InitProperty,tc.name_index));
      initScopes.put(t,traitScope);
      traitScope=1;
    }
  }
  mbCode.add(ins(AVM2Instructions.ReturnVoid));
  mb.autoFillStats(abc,1,false);
  abc.addMethodBody(mb);
  si.init_index=mb.method_info;
  localData.pkg=null;
  generateTraitsPhase3(1,false,null,null,true,localData,commands,si.traits,traitArr,initScopes,class_index);
  return si;
}

Fixed version (ground truth):
public ScriptInfo generateScriptInfo(SourceGeneratorLocalData localData,List<GraphTargetItem> commands,int classPos) throws AVM2ParseException, CompilationException {
  Reference<Integer> class_index=new Reference<>(classPos);
  ScriptInfo si=new ScriptInfo();
  localData.currentScript=si;
  Trait[] traitArr=generateTraitsPhase1(null,null,true,localData,commands,si.traits,class_index);
  generateTraitsPhase2(new ArrayList<>(),null,commands,traitArr,new ArrayList<>(),localData);
  MethodInfo mi=new MethodInfo(new int[0],0,0,0,new ValueKind[0],new int[0]);
  MethodBody mb=new MethodBody(abc,new Traits(),new byte[0],new ABCException[0]);
  mb.method_info=abc.addMethodInfo(mi);
  mb.setCode(new AVM2Code());
  List<AVM2Instruction> mbCode=mb.getCode().code;
  mbCode.add(ins(AVM2Instructions.GetLocal0));
  mbCode.add(ins(AVM2Instructions.PushScope));
  int traitScope=2;
  Map<Trait,Integer> initScopes=new HashMap<>();
  for (  Trait t : si.traits.traits) {
    if (t instanceof TraitClass) {
      TraitClass tc=(TraitClass)t;
      List<Integer> parents=new ArrayList<>();
      if (localData.documentClass) {
        mbCode.add(ins(AVM2Instructions.GetScopeObject,0));
        traitScope++;
      }
 else {
        NamespaceSet nsset=new NamespaceSet(new int[]{abc.constants.constant_multiname.get(tc.name_index).namespace_index});
        mbCode.add(ins(AVM2Instructions.FindPropertyStrict,abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME,abc.constants.constant_multiname.get(tc.name_index).name_index,0,abc.constants.getNamespaceSetId(nsset,true),0,new ArrayList<>()),true)));
      }
      if (abc.instance_info.get(tc.class_info).isInterface()) {
        mbCode.add(ins(AVM2Instructions.PushNull));
      }
 else {
        parentNamesAddNames(abc,allABCs,abc.instance_info.get(tc.class_info).name_index,parents,new ArrayList<>(),new ArrayList<>());
        parents.remove(0);
        for (int i=parents.size() - 1; i >= 0; i--) {
          mbCode.add(ins(AVM2Instructions.GetLex,parents.get(i)));
          mbCode.add(ins(AVM2Instructions.PushScope));
          traitScope++;
        }
        mbCode.add(ins(AVM2Instructions.GetLex,parents.get(0)));
      }
      mbCode.add(ins(AVM2Instructions.NewClass,tc.class_info));
      for (int i=0; i < parents.size(); i++) {
        mbCode.add(ins(AVM2Instructions.PopScope));
      }
      mbCode.add(ins(AVM2Instructions.InitProperty,tc.name_index));
      initScopes.put(t,traitScope);
      traitScope=1;
    }
  }
  mbCode.add(ins(AVM2Instructions.ReturnVoid));
  mb.autoFillStats(abc,1,false);
  abc.addMethodBody(mb);
  si.init_index=mb.method_info;
  localData.pkg=null;
  generateTraitsPhase3(1,false,null,null,true,localData,commands,si.traits,traitArr,initScopes,class_index);
  return si;
}