Skip to content

Commit fb438a9

Browse files
authored
Kotlin 1.9.20 (#233)
* Fully support use of Kotlin EAP versions * Remove workaround for failing K2 toString on native target (KT-61616) * Remove explicit declarations workaround (KT-61627) * Use a local copy of Kotlin Compile Testing: tschuchortdev/kotlin-compile-testing#394 works as needed, but isn't released * Update version table
1 parent b5a344b commit fb438a9

File tree

11 files changed

+49
-31
lines changed

11 files changed

+49
-31
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ exclusively compatible with specific versions of Poko.
7171

7272
| Kotlin version | Poko version |
7373
|-----------------|--------------|
74-
| 1.9.0 | 0.15.0 |
74+
| 1.9.0 – 1.9.20 | 0.15.0 |
7575
| 1.8.20 – 1.8.22 | 0.13.1 |
7676
| 1.8.0 – 1.8.10 | 0.12.0 |
7777
| 1.7.0 – 1.7.21 | 0.11.0 |

gradle/libs.versions.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[versions]
22

33
# https://androidx.dev/storage/compose-compiler/repository for versions matching new Kotlin versions:
4-
androidx-compose-compiler = "1.5.3"
4+
androidx-compose-compiler = "1.5.4-dev-k1.9.20-50f08dfa4b4"
55
androidx-compose-runtime = "1.5.4"
6-
kotlin = "1.9.10"
7-
kotlinCompileTesting = "1.5.0"
6+
kotlin = "1.9.20"
7+
# If this ends with "-local", we use a checked-in jar instead of the public artifact:
8+
kotlinCompileTesting = "1.5.1-pr394-local"
89
kotlinCompileTestingFork = "0.3.2"
9-
ksp = "1.9.10-1.0.13"
10+
# https://github.com/google/ksp/releases:
11+
ksp = "1.9.20-1.0.13"
1012

1113
[libraries]
1214

poko-compiler-plugin/build.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,21 @@ dependencies {
2020

2121
testImplementation(project(":poko-annotations"))
2222
testImplementation(libs.kotlin.embeddableCompiler)
23-
testImplementation(libs.kotlin.compileTesting)
2423
testImplementation(libs.junit)
2524
testImplementation(libs.assertk)
2625
testImplementation(libs.testParameterInjector)
26+
val kctVersion = libs.versions.kotlinCompileTesting.get()
27+
if (kctVersion.endsWith("-local")) {
28+
// Include the local KCT jar and its copied dependencies
29+
val kctName = libs.kotlin.compileTesting.get().name
30+
testImplementation(files("libs/$kctName-$kctVersion.jar"))
31+
// Copied from KCT's build.gradle:
32+
testImplementation("com.squareup.okio:okio:3.3.0")
33+
testImplementation("io.github.classgraph:classgraph:4.8.158")
34+
testImplementation("org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:${libs.versions.kotlin.get()}")
35+
} else {
36+
testImplementation(libs.kotlin.compileTesting)
37+
}
2738
}
2839

2940
tasks.withType<KotlinCompile>().configureEach {
Binary file not shown.

poko-compiler-plugin/src/main/kotlin/dev/drewhamilton/poko/ir/toStringGeneration.kt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.drewhamilton.poko.ir
33
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
44
import org.jetbrains.kotlin.builtins.PrimitiveType
55
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
6-
import org.jetbrains.kotlin.ir.IrBuiltIns
76
import org.jetbrains.kotlin.ir.builders.IrBlockBodyBuilder
87
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
98
import org.jetbrains.kotlin.ir.builders.IrGeneratorContextInterface
@@ -32,8 +31,6 @@ import org.jetbrains.kotlin.ir.util.render
3231
import org.jetbrains.kotlin.name.CallableId
3332
import org.jetbrains.kotlin.name.FqName
3433
import org.jetbrains.kotlin.name.Name
35-
import org.jetbrains.kotlin.name.StandardClassIds
36-
import org.jetbrains.kotlin.util.OperatorNameConventions
3734

3835
context(IrGeneratorContextInterface)
3936
internal fun IrFunction.isToString(): Boolean {
@@ -156,28 +153,14 @@ private fun IrBlockBodyBuilder.irRuntimeArrayContentDeepToString(
156153

157154
irElseBranch(
158155
irCallToStringFunction(
159-
toStringFunctionSymbol = context.irBuiltIns.extensionToStringSafe(),
156+
toStringFunctionSymbol = context.irBuiltIns.extensionToString,
160157
value = value,
161158
),
162159
),
163160
),
164161
)
165162
}
166163

167-
// TODO: Remove when https://youtrack.jetbrains.com/issue/KT-61616 is fixed
168-
private fun IrBuiltIns.extensionToStringSafe(): IrSimpleFunctionSymbol {
169-
return try {
170-
extensionToString
171-
} catch (exception: IllegalArgumentException) {
172-
findFunctions(
173-
OperatorNameConventions.TO_STRING,
174-
StandardClassIds.BASE_KOTLIN_PACKAGE,
175-
).first { function ->
176-
function.owner.extensionReceiverParameter?.type == anyNType
177-
}
178-
}
179-
}
180-
181164
/**
182165
* Generates a runtime `when` branch computing the content deep toString of [value]. The branch is
183166
* only executed if [value] is an instance of [classSymbol].

poko-compiler-plugin/src/test/kotlin/dev/drewhamilton/poko/PokoCompilerPluginTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package dev.drewhamilton.poko
22

3-
import assertk.all
43
import assertk.assertThat
54
import assertk.assertions.contains
6-
import assertk.assertions.doesNotContain
75
import assertk.assertions.isEqualTo
86
import com.google.testing.junit.testparameterinjector.TestParameter
97
import com.google.testing.junit.testparameterinjector.TestParameterInjector
@@ -184,7 +182,6 @@ class PokoCompilerPluginTest(
184182
sources = sourceFiles.asList()
185183
verbose = false
186184
jvmTarget = JvmTarget.JVM_1_8.description
187-
useIR = true
188185
if (k2) {
189186
languageVersion = "2.0"
190187
}

poko-tests/src/commonTest/kotlin/GenericArrayHolderTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import kotlin.test.Test
77
import poko.GenericArrayHolder
88

99
class GenericArrayHolderTest {
10-
@Suppress("RemoveExplicitTypeArguments") // https://youtrack.jetbrains.com/issue/KT-61627
1110
@Test fun two_GenericArrayHolder_instances_with_equivalent_typed_arrays_are_equals() {
12-
val a = GenericArrayHolder(arrayOf<Any>(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
13-
val b = GenericArrayHolder(arrayOf<Any>(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
11+
val a = GenericArrayHolder(arrayOf(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
12+
val b = GenericArrayHolder(arrayOf(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
1413
assertThat(a).isEqualTo(b)
1514
assertThat(b).isEqualTo(a)
1615
assertThat(a).hashCodeFun().isEqualTo(b.hashCode())

sample/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ allprojects {
3030
}
3131
}
3232
mavenCentral()
33+
34+
if (rootProject.property("kotlin_dev_version_enabled") == "true") {
35+
logger.lifecycle("Adding Kotlin dev repository for ${this@allprojects}")
36+
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
37+
}
3338
}
3439

3540
plugins.withId("org.jetbrains.kotlin.jvm") {

sample/settings.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ pluginManagement {
2020
}
2121
mavenCentral()
2222
google()
23+
24+
if (extra["kotlin_dev_version_enabled"] == "true") {
25+
logger.lifecycle("Adding Kotlin dev repository for plugins")
26+
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
27+
}
2328
}
2429

2530
resolutionStrategy {

0 commit comments

Comments
 (0)