Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-961

[K2] IllegalStateException: Multiple plugins generated nested class with same name Companion for class

      How frequently does the bug occur?

      Always

      Description

      Compiling a Realm model object with with Kotlin's K2 support will fail if other plugins adds a companion object too.

      This is due to different compiler plugins not being able to detect additions made by other plugins. Filed in this issues.

      The current workaround is to define a custom empty companion object. This will enable the plugins to augment the classes without causing conflicts.

      @Serializable
      class Sample: RealmObject {
         ....
      
         companion object
      }
      

      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
      IllegalStateException: Multiple plugins generated nested class with same name Companion for class /Sample:
      public final companion object Companion : R|kotlin/Any| {
      }
      
      public final companion object Companion : R|kotlin/Any| {
      }
      

      Can you reproduce the bug?

      Always

      Reproduction Steps

      Compile a project that has multiple compiler plugins that adds a companion object with K2 support. One example could be to make a RealmObject @Serialziable.

      @Serializable
      class Sample: RealmObject {
         ...
      }
      

      Version

      1.12+ with K2 support

      What Atlas App Services are you using?

      Both Atlas Device Sync and Atlas App Services

      Are you using encryption?

      No

      Platform OS and version(s)

      All platforms

      Build environment

      Kotlin version: 1.9.0 with kotlin.experimental.tryK2=true

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: