openrewrite / rewrite-kotlin

Work-in-progress implementation of Kotlin language support for OpenRewrite.
Apache License 2.0
38 stars 11 forks source link

Bump Kotlin to 1.9.22 #586

Closed radoslaw-panuszewski closed 5 months ago

radoslaw-panuszewski commented 5 months ago

What's changed?

What's your motivation?

Between Kotlin 1.9.0 and 1.9.10 the signature of FirSessionFactoryHelper.createSessionWithDependencies method was changed. In our projects we use the newest Kotlin and ./gradlew rewriteRun fails with NoSuchMethodError.

Anything in particular you'd like reviewers to focus on?

According to the test case AnnotationTest.arrayOfCallWithInAnnotation the FirArrayOfCall was replaced with FirArrayLiteral. Do you think any additional handling is needed for that?

Additional context

My local build resolved the snapshot dependency of rewrite-java so I fixed the compilation errors. Should I do that? I assume rewrite-kotlin and rewrite-java will be released together, right?

Checklist

traceyyoshima commented 5 months ago

Hi @radoslaw-panuszewski, thank you for the PR!

I've seen a similar issue before between 1.8.0 and 1.9.0, but haven't been able to reproduce the problem. Do you have a public project where the error occurs so that I can take a look?

My concern is that updating to 1.9.20 might cause incompatibility with 1.9.0. If so, we'll need multiple versions of the KotlinParser instead of bumping the version up to 1.9.20.

radoslaw-panuszewski commented 5 months ago

Hi @radoslaw-panuszewski, thank you for the PR!

I've seen a similar issue before between 1.8.0 and 1.9.0, but haven't been able to reproduce the problem. Do you have a public project where the error occurs so that I can take a look?

My concern is that updating to 1.9.20 might cause incompatibility with 1.9.0. If so, we'll need multiple versions of the KotlinParser instead of bumping the version up to 1.9.20.

Hi @traceyyoshima, I realized what was the problem in my configuration. Accidentally, the Gradle build with my custom recipe applied the spring-boot-dependencies like this:

implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.0"))

so after adding it to the rewrite configuration:

rewrite("com.example.my-custom-recipe")

the platform dependency for spring-boot-dependencies was transitively resolved and it constrained version of the kotlin-compiler-embeddable to 1.9.20.

After removing the platform dependency, the NoSuchMethodException is no longer thrown. The kotlin-stdlib is still in version 1.9.20 (because my recipe is written in Kotlin) but the kotlin-compiler-embeddable is at 1.9.0 (because rewrite-kotlin brings it transitively). It also works in the opposite way: rewrite-kotlin built with Kotlin 1.9.20 can be applied for project using Kotlin 1.9.0.

To conclude: my problem is already solved, but since I already opened this PR, maybe we can just merge it? 😉

radoslaw-panuszewski commented 5 months ago

@traceyyoshima @kunli2 @knutwannheden please take a look :)