Poko icon indicating copy to clipboard operation
Poko copied to clipboard

Kotlin 2.0

Open drewhamilton opened this issue 2 years ago • 6 comments

Kotlin 2.0 enables the new K2 compiler by default, so non-K2 code paths can be removed.

drewhamilton avatar Nov 16 '23 23:11 drewhamilton

Can you still opt out though? Or did they completely eliminate the old compiler?

JakeWharton avatar Nov 17 '23 00:11 JakeWharton

Hmm possibly setting an old language version like 1.9 would use the non-K2 compiler. I'll test that out.

drewhamilton avatar Nov 17 '23 00:11 drewhamilton

Confirmed that non-K2 compilation is still possible with language version 1.9. Unfortunately, adding configurations targeting 1.9 in the existing :poko-tests module caused errors like the one pasted below, so I had to copy/paste a separate :poko-tests-without-k2 module. Is there a better approach than having a separate module to test this?

A problem occurred configuring project ':poko-tests'.
> Inconsistent settings for Kotlin source sets: 'jvmWithoutK2Main' depends on 'commonMain'
  'jvmWithoutK2Main': language version is KOTLIN_1_9
  'commonMain': language version is KOTLIN_2_0
  The language version of the dependent source set must be greater than or equal to that of its dependency.

drewhamilton avatar Nov 17 '23 18:11 drewhamilton

Probably not. Although a separate module might be nice because it can be deleted as a unit more easily once the old compiler is gone for good.

JakeWharton avatar Nov 17 '23 18:11 JakeWharton

2.0.0-Beta3 doesn't like the way we're setting the JVM toolchain in :poko-tests:

e: file:///.../Poko/poko-tests/build.gradle.kts:16:7: Using 'jvmToolchain(Int): Unit' is an error. Configuring JVM toolchain in the Kotlin target level DSL is prohibited. JVM toolchain feature should be configured in the extension scope as it affects all JVM targets (JVM, Android).

drewhamilton avatar Jan 18 '24 19:01 drewhamilton

Found KT-64629: Seems like we can't have multiple JVM targets compiled with different JDKs anymore.

Thinking the best bet will be to build the :poko-tests JVM target multiple times with a build matrix, and to reduce the sample build to a single JDK to keep the total builds per PR at a reasonable level.

drewhamilton avatar Jan 31 '24 00:01 drewhamilton

Since it looks like Kotlin 2.0.0 will be based on the same commit as 2.0.0-RC3, would it be possible to get a rebase & a proper release published to Maven Central, even if it's an alpha/beta version?

It will allow upgrades for dependents when Kotlin 2.0.0 drops without having to add snapshot repos. Thanks!

3flex avatar May 18 '24 02:05 3flex

Can do. Since 0.15 is unlikely to need any more releases, I'll merge this PR with Kotlin 2.0.0-RC3 to main and release a 0.16 beta version.

drewhamilton avatar May 20 '24 00:05 drewhamilton