Program: 155818
Project: 155818
Buggy source:
private void emitCopyMethod(JavaWriter writer) throws IOException {
  writer.beginMethod(className,"String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.STATIC),"String_Node_Str","String_Node_Str",className,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  writer.emitStatement("String_Node_Str",className,className);
  writer.emitStatement("String_Node_Str");
  for (  VariableElement field : metadata.getFields()) {
    String fieldName=field.getSimpleName().toString();
    String fieldType=field.asType().toString();
    if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.emitEmptyLine().emitStatement("String_Node_Str",fieldType,fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",fieldType,fieldName,fieldType,fieldName).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",metadata.getSetter(fieldName),fieldName).nextControlFlow("String_Node_Str").emitStatement("String_Node_Str",metadata.getSetter(fieldName),Utils.getProxyClassSimpleName(field),fieldName).endControlFlow().endControlFlow();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      writer.emitEmptyLine().emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,Utils.getGenericType(field),fieldName).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",fieldName,fieldName).nextControlFlow("String_Node_Str").emitStatement("String_Node_Str",fieldName,Utils.getProxyClassSimpleName(field),fieldName).endControlFlow().endControlFlow().endControlFlow().emitEmptyLine();
    }
 else {
      if (NULLABLE_JAVA_TYPES.containsKey(fieldType)) {
        writer.emitStatement("String_Node_Str",metadata.getSetter(fieldName),metadata.getGetter(fieldName),metadata.getGetter(fieldName),NULLABLE_JAVA_TYPES.get(fieldType));
      }
 else {
        writer.emitStatement("String_Node_Str",metadata.getSetter(fieldName),metadata.getGetter(fieldName));
      }
    }
  }
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
}

Fixed version (ground truth):
private void emitCopyMethod(JavaWriter writer) throws IOException {
  writer.beginMethod(className,"String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.STATIC),"String_Node_Str","String_Node_Str",className,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  if (metadata.hasPrimaryKey()) {
    writer.emitStatement("String_Node_Str",className,className,metadata.getPrimaryKeyGetter());
  }
 else {
    writer.emitStatement("String_Node_Str",className,className);
  }
  writer.emitStatement("String_Node_Str");
  for (  VariableElement field : metadata.getFields()) {
    String fieldName=field.getSimpleName().toString();
    String fieldType=field.asType().toString();
    if (typeUtils.isAssignable(field.asType(),realmObject)) {
      writer.emitEmptyLine().emitStatement("String_Node_Str",fieldType,fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",fieldType,fieldName,fieldType,fieldName).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",metadata.getSetter(fieldName),fieldName).nextControlFlow("String_Node_Str").emitStatement("String_Node_Str",metadata.getSetter(fieldName),Utils.getProxyClassSimpleName(field),fieldName).endControlFlow().endControlFlow();
    }
 else     if (typeUtils.isAssignable(field.asType(),realmList)) {
      writer.emitEmptyLine().emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,metadata.getGetter(fieldName)).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,fieldName).emitStatement("String_Node_Str",Utils.getGenericType(field),fieldName,Utils.getGenericType(field),fieldName).beginControlFlow("String_Node_Str",fieldName).emitStatement("String_Node_Str",fieldName,fieldName).nextControlFlow("String_Node_Str").emitStatement("String_Node_Str",fieldName,Utils.getProxyClassSimpleName(field),fieldName).endControlFlow().endControlFlow().endControlFlow().emitEmptyLine();
    }
 else {
      if (NULLABLE_JAVA_TYPES.containsKey(fieldType)) {
        writer.emitStatement("String_Node_Str",metadata.getSetter(fieldName),metadata.getGetter(fieldName),metadata.getGetter(fieldName),NULLABLE_JAVA_TYPES.get(fieldType));
      }
 else {
        writer.emitStatement("String_Node_Str",metadata.getSetter(fieldName),metadata.getGetter(fieldName));
      }
    }
  }
  writer.emitStatement("String_Node_Str");
  writer.endMethod();
  writer.emitEmptyLine();
}