Program: 74728
Project: 74728
Buggy source:
/** 
 * Generate the type conversion statement for the particular offset of the two given channels. This assumes that the offset is the same for both channel. Advancing the offset of one has to advance the offset of the other.
 * @param source The given source channel.
 * @param sink The given sink channel.
 * @param offset The given offset.
 * @return The type convert statement for assigning the converted sourcevariable to the sink variable with the given offset. 
 * @exception IllegalActionException If there is a problem getting thehelpers for the ports or if the conversion cannot be handled.
 */
protected String _generateTypeConvertStatement(Channel source,Channel sink,int offset) throws IllegalActionException {
  Type sourceType=((TypedIOPort)source.port).getType();
  Type sinkType=((TypedIOPort)sink.port).getType();
  if (sourceType == BaseType.UNKNOWN) {
    return "String_Node_Str";
  }
  String sourcePortChannel=source.port.getName() + "String_Node_Str" + source.channelNumber+ "String_Node_Str"+ offset;
  String sourceRef=((CodeGeneratorHelper)_getHelper(source.port.getContainer())).getReference(sourcePortChannel);
  String sinkPortChannel=sink.port.getName() + "String_Node_Str" + sink.channelNumber+ "String_Node_Str"+ offset;
  if (sink.port.getContainer() instanceof CompositeActor && sink.port.isInput()) {
    sinkPortChannel="String_Node_Str" + sinkPortChannel;
  }
  String sinkRef=((CodeGeneratorHelper)_getHelper(sink.port.getContainer())).getReference(sinkPortChannel,true);
  if (sink.port.getContainer() instanceof ModalController) {
    sinkRef=generateName(sink.port);
    if (sink.port.isMultiport()) {
      sinkRef=sinkRef + "String_Node_Str" + sink.channelNumber+ "String_Node_Str";
    }
  }
  String result=sourceRef;
  if (sinkType != sourceType) {
    if (isPrimitive(sinkType)) {
      result=codeGenType(sourceType) + "String_Node_Str" + codeGenType(sinkType)+ "String_Node_Str"+ result+ "String_Node_Str";
    }
 else     if (isPrimitive(sourceType)) {
      result="String_Node_Str" + codeGenType(sourceType) + "String_Node_Str"+ result+ "String_Node_Str";
    }
    if (sinkType != BaseType.SCALAR && sinkType != BaseType.GENERAL && !isPrimitive(sinkType)) {
      if (sinkType instanceof ArrayType) {
        if (isPrimitive(sourceType)) {
          result="String_Node_Str" + result + "String_Node_Str"+ codeGenType(sourceType)+ "String_Node_Str";
        }
        Type elementType=((ArrayType)sinkType).getElementType();
        if (elementType != BaseType.SCALAR) {
          result="String_Node_Str" + codeGenType(sinkType) + "String_Node_Str"+ result+ "String_Node_Str"+ codeGenType(((ArrayType)sinkType).getElementType())+ "String_Node_Str";
        }
      }
 else {
        result="String_Node_Str" + codeGenType(sinkType) + "String_Node_Str"+ result+ "String_Node_Str";
      }
    }
  }
  return sinkRef + "String_Node_Str" + result+ "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Generate the type conversion statement for the particular offset of the two given channels. This assumes that the offset is the same for both channel. Advancing the offset of one has to advance the offset of the other.
 * @param source The given source channel.
 * @param sink The given sink channel.
 * @param offset The given offset.
 * @return The type convert statement for assigning the converted sourcevariable to the sink variable with the given offset. 
 * @exception IllegalActionException If there is a problem getting thehelpers for the ports or if the conversion cannot be handled.
 */
protected String _generateTypeConvertStatement(Channel source,Channel sink,int offset) throws IllegalActionException {
  Type sourceType=((TypedIOPort)source.port).getType();
  Type sinkType=((TypedIOPort)sink.port).getType();
  if (sourceType == BaseType.UNKNOWN) {
    return "String_Node_Str";
  }
  String sourcePortChannel=source.port.getName() + "String_Node_Str" + source.channelNumber+ "String_Node_Str"+ offset;
  String sourceRef=((CodeGeneratorHelper)_getHelper(source.port.getContainer())).getReference(sourcePortChannel);
  String sinkPortChannel=sink.port.getName() + "String_Node_Str" + sink.channelNumber+ "String_Node_Str"+ offset;
  if (sink.port.getContainer() instanceof CompositeActor && sink.port.isOutput()) {
    sinkPortChannel="String_Node_Str" + sinkPortChannel;
  }
  String sinkRef=((CodeGeneratorHelper)_getHelper(sink.port.getContainer())).getReference(sinkPortChannel,true);
  if (sink.port.getContainer() instanceof ModalController) {
    sinkRef=generateName(sink.port);
    if (sink.port.isMultiport()) {
      sinkRef=sinkRef + "String_Node_Str" + sink.channelNumber+ "String_Node_Str";
    }
  }
  String result=sourceRef;
  if (sinkType != sourceType) {
    if (isPrimitive(sinkType)) {
      result=codeGenType(sourceType) + "String_Node_Str" + codeGenType(sinkType)+ "String_Node_Str"+ result+ "String_Node_Str";
    }
 else     if (isPrimitive(sourceType)) {
      result="String_Node_Str" + codeGenType(sourceType) + "String_Node_Str"+ result+ "String_Node_Str";
    }
    if (sinkType != BaseType.SCALAR && sinkType != BaseType.GENERAL && !isPrimitive(sinkType)) {
      if (sinkType instanceof ArrayType) {
        if (isPrimitive(sourceType)) {
          result="String_Node_Str" + result + "String_Node_Str"+ codeGenType(sourceType)+ "String_Node_Str";
        }
        Type elementType=((ArrayType)sinkType).getElementType();
        if (elementType != BaseType.SCALAR) {
          result="String_Node_Str" + codeGenType(sinkType) + "String_Node_Str"+ result+ "String_Node_Str"+ codeGenType(((ArrayType)sinkType).getElementType())+ "String_Node_Str";
        }
      }
 else {
        result="String_Node_Str" + codeGenType(sinkType) + "String_Node_Str"+ result+ "String_Node_Str";
      }
    }
  }
  return sinkRef + "String_Node_Str" + result+ "String_Node_Str";
}