https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
c

Claus Rørbech

09/25/2023, 12:53 PM
As part of implementing K2 support in a compiler plugin that generates a
Companion
object I get the following error when combining the plugin with
kotlinx.serialization
.
Copy code
java.lang.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| {
}
Seems like both plugins are generating a
Companion
. For user-defined companions the
FirRegularClassSymbol.companionObjectSymbol
will be non-null, but I have tried debugging and cannot find any information to indentify and prevent this situation in my
FirDeclarationGenerationExtension.getNestedClassifiersNames
and/or
FirDeclarationGenerationExtension.generateNestedClassLikeDeclaration
. Also tried debugging the
kotlinx.serialization
-plugin and there is also no visibility of my generated companion, so does not look like an ordering issue and even with both plugins setting their appropriate
GeneratedDeclarationKey
there is no way to detect each others additions. Anybody with a suggestion to identify this situation, or how are plugins supposed to coexist?
d

dmitriy.novozhilov

09/25/2023, 1:08 PM
Hey Such plugins interaction actually just want considered when API was designed Could you please report an issue?
👍 1
I'm not sure that it can be fixed in the nearest future As a workaround I can suggest to temporary force to declare empty companion for classes with such clashes
c

Claus Rørbech

09/27/2023, 12:37 PM
I have created this youtrack issue
d

dmitriy.novozhilov

09/27/2023, 1:31 PM
Thank you!