Realm Compiler Plugin does not correctly detect the use of nullable lists: RealmList<*>?

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

      How frequently does the bug occur?

      Always

      Description

      With this Realm entities:

      class EntityRm(
          @PrimaryKey var id: String,
          var optionalCars: RealmList<CarRm>? = realmListOf(),
      ): RealmObject {
          constructor() : this(id = "")
      }
      
      class CarRm(
          var name: String = "",
          var description: String = "",
      ): RealmObject {
          constructor() : this(name = "")
      }
      

      When I try to save a null list, it crash:

      var entity = EntityRm("1", null)
      dataBase.write {
          copyToRealm(entity, UpdatePolicy.ALL)
      }
      

      Moreover, this error isn't controlled by Realm, because Transaction keeps running. When this error ocurrs, If I try to perform any other operation, it throws a IllegalStateException.

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Error: null cannot be cast to non-null type io.realm.kotlin.types.RealmList<*>
      	java.lang.NullPointerException: null cannot be cast to non-null type io.realm.kotlin.types.RealmList<*>
      		at io.realm.kotlin.internal.RealmObjectHelper.assignTyped$io_realm_kotlin_library(RealmObjectHelper.kt:800)
      		at io.realm.kotlin.internal.RealmObjectHelper.assign$io_realm_kotlin_library(RealmObjectHelper.kt:734)
      		at io.realm.kotlin.internal.RealmUtilsKt.copyToRealm(RealmUtils.kt:220)
      		at io.realm.kotlin.internal.RealmUtilsKt.copyToRealm$default(RealmUtils.kt:144)
      		at io.realm.kotlin.internal.InternalMutableRealm$DefaultImpls.copyToRealm(InternalMutableRealm.kt:57)
      		at io.realm.kotlin.internal.SuspendableWriter$WriterRealm.copyToRealm(SuspendableWriter.kt:58)
      

      Can you reproduce the bug?

      Always

      Reproduction Steps

      No response

      Version

      1.10.0 and 1.11.1

      What Atlas App Services are you using?

      Local Database only

      Are you using encryption?

      No

      Platform OS and version(s)

      Android 34

      Build environment

      Android Studio version: Giraffe | 2022.3.1 Patch
      Android Build Tools version: 8.1.2
      Gradle version: 8.3

              Assignee:
              Unassigned
              Reporter:
              Unito Sync Bot
              Archiver:
              Marc Greenfield

                Created:
                Updated:
                Resolved:
                Archived: