Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rorbech opened this issue Nov 10, 2023 · 2 comments
Labels

Comments

@rorbech
Copy link
Contributor

rorbech commented Nov 10, 2023

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

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

@rorbech rorbech added the T-Bug label Nov 10, 2023
@rorbech rorbech mentioned this issue Nov 10, 2023
4 tasks
@sync-by-unito sync-by-unito bot assigned rorbech and unassigned rorbech Nov 13, 2023
@rorbech rorbech pinned this issue Nov 15, 2023
@Ynnck123
Copy link

Will this bug be addressed in the future or will it always be required to add an empty companion object as soon as we use other plugins like kotlinx.serialization ?

@rorbech
Copy link
Contributor Author

rorbech commented Jun 10, 2024

@Ynnck123 It has been reported to Jetbrains and their current target is 2.1.0, but don't know the timeline and is also not any guarantee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants