Program: 132916
Project: 132916
Buggy source:
private void callFunction(Context context,String function,FunctionType concrete,List<Var> oList,List<Var> iList,TaskProps props) throws UndefinedTypeException, UserException {
  ArrayList<Var> realIList=new ArrayList<Var>(iList.size());
  ArrayList<Var> derefVars=new ArrayList<Var>();
  ArrayList<Var> waitVars=new ArrayList<Var>();
  Context waitContext=null;
  assert(concrete.getInputs().size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Var input=iList.get(i);
    Type inputType=input.type();
    Type expType=concrete.getInputs().get(i);
    if (inputType.getImplType().assignableTo(expType.getImplType())) {
      realIList.add(input);
    }
 else     if (Types.isRefTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Var derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      realIList.add(snapshotUpdateable(context,input));
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    TaskProps waitProps=props.filter(TaskPropKey.PRIORITY);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,WaitMode.WAIT_ONLY,false,false,TaskMode.LOCAL_CONTROL,waitProps);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Var derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).type())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  backendFunctionCall(context,function,oList,realIList,props);
  if (waitContext != null) {
    backend.endWaitStatement();
  }
}

Fixed version (ground truth):
private void callFunction(Context context,String function,FunctionType concrete,List<Var> oList,List<Var> iList,TaskProps props) throws UndefinedTypeException, UserException {
  ArrayList<Var> realIList=new ArrayList<Var>(iList.size());
  ArrayList<Var> derefVars=new ArrayList<Var>();
  ArrayList<Var> waitVars=new ArrayList<Var>();
  Context waitContext=null;
  assert(concrete.getInputs().size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Var input=iList.get(i);
    Type inputType=input.type();
    Type expType=concrete.getInputs().get(i);
    if (inputType.getImplType().assignableTo(expType.getImplType())) {
      realIList.add(input);
    }
 else     if (Types.isAssignableRefTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Var derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      realIList.add(snapshotUpdateable(context,input));
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    TaskProps waitProps=props.filter(TaskPropKey.PRIORITY);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,WaitMode.WAIT_ONLY,false,false,TaskMode.LOCAL_CONTROL,waitProps);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Var derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).type())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  backendFunctionCall(context,function,oList,realIList,props);
  if (waitContext != null) {
    backend.endWaitStatement();
  }
}