Program: 73885
Project: 73885
Buggy source:
/** 
 * Infer the interface of a composite actor from its contained actors.
 * @param container The composite actor whose interface we are querying.
 * @return The inferred interface.
 * @throws IllegalActionException 
 */
private RelationalInterface _getCompositeInterface(CompositeActor container) throws IllegalActionException {
  final Set<String> newConstraints=new HashSet<String>();
  final Set<String> inputNames=new HashSet<String>();
  final List<IOPort> inputPorts=container.inputPortList();
  for (  final IOPort compositeIn : inputPorts) {
    inputNames.add(compositeIn.getName());
    for (    final IOPort insideIn : compositeIn.insideSinkPortList()) {
      newConstraints.add("String_Node_Str" + insideIn.getName() + "String_Node_Str"+ compositeIn.getName()+ "String_Node_Str");
    }
  }
  final Set<String> outputNames=new HashSet<String>();
  final List<IOPort> outputPorts=container.outputPortList();
  for (  final IOPort compositeOut : outputPorts) {
    outputNames.add(compositeOut.getName());
    for (    final IOPort insideOut : compositeOut.insideSourcePortList()) {
      newConstraints.add("String_Node_Str" + insideOut.getName() + "String_Node_Str"+ compositeOut.getName()+ "String_Node_Str");
    }
  }
  List<Entity> actors=container.entityList();
  if (actors.size() == 1) {
    final Actor actor=(Actor)actors.get(0);
    Set<Connection> connections=_getConnectionsBetween(actor,actor);
    RelationalInterface actorInterface=_getInterface(actor);
    System.err.println("String_Node_Str");
    if (!connections.isEmpty()) {
      actorInterface.addFeedback(connections);
    }
    newConstraints.add(actorInterface.getContract());
    outputNames.addAll(actorInterface.getVariables());
  }
 else   if (actors.size() == 2) {
    Set<Connection> selfLoop1=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(0));
    Set<Connection> selfLoop2=_getConnectionsBetween((Actor)actors.get(1),(Actor)actors.get(1));
    Set<Connection> connection1=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(1));
    Set<Connection> connection2=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(1));
    if (!selfLoop1.isEmpty() || !selfLoop2.isEmpty() || (!connection1.isEmpty() && !connection2.isEmpty())) {
      throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str");
    }
    final Actor actor0;
    final Actor actor1;
    if (connection2.isEmpty()) {
      actor0=(Actor)actors.get(0);
      actor1=(Actor)actors.get(1);
    }
 else {
      actor0=(Actor)actors.get(1);
      actor1=(Actor)actors.get(0);
    }
    Set<Connection> connections=_getConnectionsBetween(actor0,actor1);
    RelationalInterface compositeInterface;
    if (connections.isEmpty()) {
      compositeInterface=_getInterface(actor0).cascadeComposeWith(_getInterface(actor1),connections);
    }
 else {
      compositeInterface=_getInterface(actor0).parallelComposeWith(_getInterface(actor1));
    }
    newConstraints.add(compositeInterface.getContract());
    outputNames.addAll(compositeInterface.getVariables());
  }
 else   if (actors.size() > 2) {
    throw new IllegalActionException(container,"String_Node_Str");
  }
  final String contract=LispExpression.conjunction(newConstraints);
  return new RelationalInterface(inputNames,outputNames,contract);
}

Fixed version (ground truth):
/** 
 * Infer the interface of a composite actor from its contained actors.
 * @param container The composite actor whose interface we are querying.
 * @return The inferred interface.
 * @throws IllegalActionException 
 */
private RelationalInterface _getCompositeInterface(CompositeActor container) throws IllegalActionException {
  final Set<String> newConstraints=new HashSet<String>();
  final Set<String> inputNames=new HashSet<String>();
  final List<IOPort> inputPorts=container.inputPortList();
  for (  final IOPort compositeIn : inputPorts) {
    inputNames.add(compositeIn.getName());
    final List<IOPort> linkedPorts=compositeIn.insidePortList();
    for (    final IOPort insideIn : linkedPorts) {
      newConstraints.add("String_Node_Str" + insideIn.getName() + "String_Node_Str"+ compositeIn.getName()+ "String_Node_Str");
    }
  }
  final Set<String> outputNames=new HashSet<String>();
  final List<IOPort> outputPorts=container.outputPortList();
  for (  final IOPort compositeOut : outputPorts) {
    outputNames.add(compositeOut.getName());
    final List<IOPort> linkedPorts=compositeOut.insidePortList();
    for (    final IOPort insideOut : linkedPorts) {
      newConstraints.add("String_Node_Str" + insideOut.getName() + "String_Node_Str"+ compositeOut.getName()+ "String_Node_Str");
    }
  }
  List<Entity> actors=container.entityList();
  if (actors.size() == 1) {
    final Actor actor=(Actor)actors.get(0);
    Set<Connection> connections=_getConnectionsBetween(actor,actor);
    RelationalInterface actorInterface=_getInterface(actor);
    if (!connections.isEmpty()) {
      actorInterface.addFeedback(connections);
    }
    newConstraints.add(actorInterface.getContract());
    outputNames.addAll(actorInterface.getVariables());
  }
 else   if (actors.size() == 2) {
    Set<Connection> selfLoop1=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(0));
    Set<Connection> selfLoop2=_getConnectionsBetween((Actor)actors.get(1),(Actor)actors.get(1));
    Set<Connection> connection1=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(1));
    Set<Connection> connection2=_getConnectionsBetween((Actor)actors.get(0),(Actor)actors.get(1));
    if (!selfLoop1.isEmpty() || !selfLoop2.isEmpty() || (!connection1.isEmpty() && !connection2.isEmpty())) {
      throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str");
    }
    final Actor actor0;
    final Actor actor1;
    if (connection2.isEmpty()) {
      actor0=(Actor)actors.get(0);
      actor1=(Actor)actors.get(1);
    }
 else {
      actor0=(Actor)actors.get(1);
      actor1=(Actor)actors.get(0);
    }
    Set<Connection> connections=_getConnectionsBetween(actor0,actor1);
    RelationalInterface compositeInterface;
    if (connections.isEmpty()) {
      compositeInterface=_getInterface(actor0).cascadeComposeWith(_getInterface(actor1),connections);
    }
 else {
      compositeInterface=_getInterface(actor0).parallelComposeWith(_getInterface(actor1));
    }
    newConstraints.add(compositeInterface.getContract());
    outputNames.addAll(compositeInterface.getVariables());
  }
 else   if (actors.size() > 2) {
    throw new IllegalActionException(container,"String_Node_Str");
  }
  final String contract=LispExpression.conjunction(newConstraints);
  return new RelationalInterface(inputNames,outputNames,contract);
}