bazelbuild / rules_kotlin

Bazel rules for Kotlin
Apache License 2.0
334 stars 211 forks source link

[K2] Kotlinx serialization plugin is not compatible with experimental_use_abi_jars #1233

Open zalewskise opened 1 month ago

zalewskise commented 1 month ago

After updating Kotlin to 2.0, compilation of target that uses kotlinx serialization plugin, started failing with: error: serializer has not been found for type `FooType`. To use context serializer as fallback, explicitly annotate type or property with @Contextual, where FooType comes from a different target. It fails only with experimental_use_abi_jars = True.

Repro

  1. Apply the diff (https://github.com/bazelbuild/rules_kotlin/commit/20dcc94381aea063444dc3f1054d3c24c949a27d)
  2. Change dir to: examples/plugin/serialization
  3. Build data target: bazel build data

Expected

Build completed successfully

Actual

src/serialization/Data.kt:6:78: error: serializer has not been found for type 'plugin.serialization.AnotherData'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
data class Data(val stringValue: String, val intValue: Int, val anotherData: AnotherData)
                                                                             ^^^^^^^^^^^
agluszak commented 2 weeks ago

I reproduced it, changing api_version and language_version to 1.9 indeed fixes it