ZacSweers / kotlin-compile-testing

A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Mozilla Public License 2.0
109 stars 7 forks source link

Prep for Kotlin 2.0.20 #263

Closed ZacSweers closed 1 month ago

hfhbd commented 3 months ago

Do you have any snapshot releases with 2.0.20-Beta2 support?

ZacSweers commented 3 months ago

No as there are no API changes I've seen. Do you need one?

hfhbd commented 3 months ago

I think so, I get this error when using Kotlin 2.0.20-Beta2 (or 1) with a compiler plugin compiled with Kotlin 2.0.0 and using IrFactory:

java.lang.NoClassDefFoundError: org/jetbrains/kotlin/ir/declarations/IrFactory$DefaultImpls

caused by this line: https://github.com/hfhbd/validation/blob/9683018d1c39a2dd264a3474bdcc68573d4ae659/kotlin-plugin/src/main/kotlin/app/softwork/validation/plugin/kotlin/ValidationTransformer.kt#L39

ZacSweers commented 3 months ago

This library doesn't implement any IR plugins of its own. That's an issue you have to fix on your side

hfhbd commented 3 months ago

Yes I know, but there was an incompatible change (change of IrFactory from interface to open class) in the kotlin compiler so using the IrFactory compiled with 2.0.20-Beta2 throws a NoClassDefFoundError when using compiler testing using 2.0.0 because the default parameter class generated for the interface does not exist anymore.

ZacSweers commented 3 months ago

That class isn't implemented in this library, I'm really not following. Please be more specific (full trace pointing to where this library is responsible for providing that API). It sounds like you should just be forcing a newer version of the underlying compiler dependency.

hfhbd commented 3 months ago

It sounds like you should just be forcing a newer version of the underlying compiler dependency.

I didn't know this is possible, but yes I agree, sounds like the solution I am missing. Do you have any sample to override the Kotlin compiler dependency?

ZacSweers commented 3 months ago

It's a gradle dependency like any other. You can see its declaration here: https://github.com/ZacSweers/kotlin-compile-testing/blob/main/core/build.gradle.kts#L34

hfhbd commented 3 months ago

Thanks for your help, it does work, nice!