Program: 73153
Project: 73153
Buggy source:
/** 
 * If this port has parameters whose values are tokens that contain an object implementing   {@link QuantityManager}, then wrap the receiver specified in the argument using those quantity managers. If there are no such parameters, then simply return the specified receiver. If there is one such parameter, then use the quantity manager to wrap the specified receiver in a new receiver, and return that receiver. If there are two such parameters, then use the second quantity manager to create a receiver that wraps that created by the first quantity manager. Etc.
 * @see QuantityManager
 * @param receiver The receiver to wrap.
 * @param channel Channel id used to determine the source port.
 * @return Either a new receiver wrapping the specified receiver,or the specified receiver.
 * @exception IllegalActionException If any parameter of the portcannot be evaluated.
 */
protected Receiver _wrapReceiver(Receiver receiver,int channel) throws IllegalActionException {
  Receiver result=receiver;
  List qmList=getQuantityManagers();
  if (isInput()) {
    for (int i=qmList.size() - 1; i >= 0; i--) {
      Object object=qmList.get(i);
      if (object instanceof QuantityManager) {
        result=((QuantityManager)object).getReceiver(result);
      }
 else       if (object instanceof IOPort) {
        result=((QuantityManager)((IOPort)object).getContainer()).getReceiver(result,((IOPort)object));
      }
    }
    if (result instanceof IntermediateReceiver) {
      IntermediateReceiver intermediateReceiver=(IntermediateReceiver)result;
      intermediateReceiver.source=(Actor)((IOPort)this.sourcePortList().get(channel)).getContainer();
    }
  }
 else {
    for (int i=0; i < qmList.size(); i++) {
      Object object=qmList.get(i);
      if (object instanceof QuantityManager) {
        result=((QuantityManager)object).getReceiver(result);
      }
 else       if (object instanceof IOPort) {
        IntermediateReceiver ir=(IntermediateReceiver)((QuantityManager)((IOPort)object).getContainer()).getReceiver(result,((IOPort)object));
        _farReceiver=ir;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * If this port has parameters whose values are tokens that contain an object implementing   {@link QuantityManager}, then wrap the receiver specified in the argument using those quantity managers. If there are no such parameters, then simply return the specified receiver. If there is one such parameter, then use the quantity manager to wrap the specified receiver in a new receiver, and return that receiver. If there are two such parameters, then use the second quantity manager to create a receiver that wraps that created by the first quantity manager. Etc.
 * @see QuantityManager
 * @param receiver The receiver to wrap.
 * @param channel Channel id used to determine the source port.
 * @return Either a new receiver wrapping the specified receiver,or the specified receiver.
 * @exception IllegalActionException If any parameter of the portcannot be evaluated.
 */
protected Receiver _wrapReceiver(Receiver receiver,int channel) throws IllegalActionException {
  Receiver result=receiver;
  List qmList=getQuantityManagers();
  if (isInput()) {
    for (int i=qmList.size() - 1; i >= 0; i--) {
      Object object=qmList.get(i);
      if (object instanceof QuantityManager) {
        result=((QuantityManager)object).getReceiver(result);
      }
 else       if (object instanceof IOPort) {
        result=((QuantityManager)((IOPort)object).getContainer()).getReceiver(result,((IOPort)object));
      }
    }
    if (result instanceof IntermediateReceiver) {
      IntermediateReceiver intermediateReceiver=(IntermediateReceiver)result;
      intermediateReceiver.source=(Actor)((IOPort)this.sourcePortList().get(channel)).getContainer();
    }
  }
 else {
    for (int i=0; i < qmList.size(); i++) {
      Object object=qmList.get(i);
      if (object instanceof QuantityManager) {
        result=((QuantityManager)object).getReceiver(result);
      }
 else       if (object instanceof IOPort) {
        IntermediateReceiver ir=(IntermediateReceiver)((QuantityManager)((IOPort)object).getContainer()).getReceiver(result,((IOPort)object));
        _intermediateFarReceiver=ir;
      }
    }
  }
  return result;
}