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

Update to Kotlin 2.0.0 #6640

Merged
merged 6 commits into from
May 22, 2024
Merged

Update to Kotlin 2.0.0 #6640

merged 6 commits into from
May 22, 2024

Conversation

3flex
Copy link
Member

@3flex 3flex commented Nov 23, 2023

Fixes #6715

This is safe to release with alpha/beta dependencies in my opinion. poko 0.16.0-beta01 is based on Kotlin 2.0.0-RC3 which is the same as 2.0.0. kctfork is only used in tests.

@detekt-ci detekt-ci added rules build dependencies Pull requests that update a dependency file compiler-plugin labels Nov 23, 2023
@3flex 3flex changed the title [WIP] Kotlin 2 [WIP] Kotlin 2.0 support Nov 23, 2023
@detekt-ci detekt-ci added the api label Nov 26, 2023
@jarroyoesp
Copy link

Hey @3flex after trying the commit 429a178 as you mentioned here #6715 (comment). I've been able to compile your branch and generate the library on my MavenLocal. But when I've run detekt in my project, I am getting the following errors:

> Task :build-conventions:compileKotlin FAILED
e: Pre-release classes were found in dependencies. Remove them from the classpath, recompile with a release compiler or use '-Xskip-prerelease-check' to suppress errors
e: file:///Users/javierarroyo/Projects/Personal/Forlago/build-conventions/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle/kotlin/dsl/accessors/_2fb462c0d2ba107f613d15985247d494/Accessors32ikgp1isdd8mwexzgbe6rirl.kt:65:44 Class 'io.gitlab.arturbosch.detekt.extensions.DetektExtension' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler

Thanks :)

@3flex
Copy link
Member Author

3flex commented Dec 20, 2023

You probably need to follow steps here: https://docs.gradle.org/8.3/release-notes.html#kotlin_k2 and be sure to use Gradle 8.3 or higher.

Also have a read of https://kotlinlang.org/docs/whatsnew-eap.html#current-k2-compiler-limitations

@3flex 3flex force-pushed the kotlin-2 branch 2 times, most recently from 8652daa to 68f3cc7 Compare December 22, 2023 05:17
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 84.36%. Comparing base (e79f038) to head (73c8d7e).

Files Patch % Lines
...lin/io/github/detekt/parser/BindingContextUtils.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6640      +/-   ##
============================================
- Coverage     84.68%   84.36%   -0.33%     
- Complexity     4001     4176     +175     
============================================
  Files           574      574              
  Lines         12011    11913      -98     
  Branches       2476     2458      -18     
============================================
- Hits          10172    10050     -122     
- Misses          598      613      +15     
- Partials       1241     1250       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@3flex 3flex changed the title [WIP] Kotlin 2.0 support (2.0.0-RC3) Kotlin 2.0.0 May 21, 2024
@3flex 3flex changed the title Kotlin 2.0.0 Update to Kotlin 2.0.0 May 21, 2024
Copy link
Member

@BraisGabin BraisGabin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@3flex
Copy link
Member Author

3flex commented May 22, 2024

If this is cherry picked into the 1.x branch, these PRs will also need to be picked:

@3flex 3flex merged commit c2aa7a2 into detekt:main May 22, 2024
19 of 21 checks passed
@3flex 3flex deleted the kotlin-2 branch May 22, 2024 01:42
@nebffa
Copy link

nebffa commented May 22, 2024

Kotlin 2.0 has just been released. I see this has been merged - are you planning to publish a release relatively soon? :)

@3flex
Copy link
Member Author

3flex commented May 22, 2024

I haven't made releases previously so I can't say, but you can try snapshots until a new one is pushed out.

@TWiStErRob
Copy link
Member

@cortinico are you planning a patch with Kotlin 2.0.0 support? (current 1.23.6 works, but I would assume that the K2 improvements propagate to compiler-embedded, so a detekt patch/minor release could benefit from a 2x speed improvement?)

@cortinico
Copy link
Member

@cortinico are you planning a patch with Kotlin 2.0.0 support? (current 1.23.6 works, but I would assume that the K2 improvements propagate to compiler-embedded, so a detekt patch/minor release could benefit from a 2x speed improvement?)

I was thinking we can cut a 2.0.0-alpha-01 or so from the main branch to overcome this. Wdyt @TWiStErRob @3flex ?

@TWiStErRob
Copy link
Member

It feels like that might be a long way away (from stable), there are still breaking changes coming in refractors, right? So alpha would require some to migrate again and again, and therefore I personally wouldn't actually use the alpha in a live project (e.g. at work) and miss out on speed of a stable compiler. I think @3flex can comment on the complexity of cherry, based on the above comment it's 3 small PRs, however with one of them forcing language version, does it mean we wouldn't benefit from K2's improvements?

@3flex
Copy link
Member Author

3flex commented Jun 9, 2024

Language version 1.9 limitation applies to compiler plugin only. The CLI and Gradle in theory get speedups but I haven't tested anything.

Cherry picking sounds like a good plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build dependencies Pull requests that update a dependency file notable changes Marker for notable changes in the changelog parser rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K2 compiler crashes Detekt
8 participants