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

Kotlin 1.9.20 #233

Merged
merged 10 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exclusively compatible with specific versions of Poko.

| Kotlin version | Poko version |
|-----------------|--------------|
| 1.9.0 | 0.15.0 |
| 1.9.0 – 1.9.20 | 0.15.0 |
| 1.8.20 – 1.8.22 | 0.13.1 |
| 1.8.0 – 1.8.10 | 0.12.0 |
| 1.7.0 – 1.7.21 | 0.11.0 |
Expand Down
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[versions]

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

[libraries]

Expand Down
13 changes: 12 additions & 1 deletion poko-compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ dependencies {

testImplementation(project(":poko-annotations"))
testImplementation(libs.kotlin.embeddableCompiler)
testImplementation(libs.kotlin.compileTesting)
testImplementation(libs.junit)
testImplementation(libs.assertk)
testImplementation(libs.testParameterInjector)
val kctVersion = libs.versions.kotlinCompileTesting.get()
if (kctVersion.endsWith("-local")) {
// Include the local KCT jar and its copied dependencies
val kctName = libs.kotlin.compileTesting.get().name
testImplementation(files("libs/$kctName-$kctVersion.jar"))
// Copied from KCT's build.gradle:
testImplementation("com.squareup.okio:okio:3.3.0")
testImplementation("io.github.classgraph:classgraph:4.8.158")
testImplementation("org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:${libs.versions.kotlin.get()}")
} else {
testImplementation(libs.kotlin.compileTesting)
}
}

tasks.withType<KotlinCompile>().configureEach {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.drewhamilton.poko.ir
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.builders.IrBlockBodyBuilder
import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope
import org.jetbrains.kotlin.ir.builders.IrGeneratorContextInterface
Expand Down Expand Up @@ -32,8 +31,6 @@ import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.util.OperatorNameConventions

context(IrGeneratorContextInterface)
internal fun IrFunction.isToString(): Boolean {
Expand Down Expand Up @@ -156,28 +153,14 @@ private fun IrBlockBodyBuilder.irRuntimeArrayContentDeepToString(

irElseBranch(
irCallToStringFunction(
toStringFunctionSymbol = context.irBuiltIns.extensionToStringSafe(),
toStringFunctionSymbol = context.irBuiltIns.extensionToString,
value = value,
),
),
),
)
}

// TODO: Remove when https://youtrack.jetbrains.com/issue/KT-61616 is fixed
private fun IrBuiltIns.extensionToStringSafe(): IrSimpleFunctionSymbol {
return try {
extensionToString
} catch (exception: IllegalArgumentException) {
findFunctions(
OperatorNameConventions.TO_STRING,
StandardClassIds.BASE_KOTLIN_PACKAGE,
).first { function ->
function.owner.extensionReceiverParameter?.type == anyNType
}
}
}

/**
* Generates a runtime `when` branch computing the content deep toString of [value]. The branch is
* only executed if [value] is an instance of [classSymbol].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package dev.drewhamilton.poko

import assertk.all
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.doesNotContain
import assertk.assertions.isEqualTo
import com.google.testing.junit.testparameterinjector.TestParameter
import com.google.testing.junit.testparameterinjector.TestParameterInjector
Expand Down Expand Up @@ -184,7 +182,6 @@ class PokoCompilerPluginTest(
sources = sourceFiles.asList()
verbose = false
jvmTarget = JvmTarget.JVM_1_8.description
useIR = true
if (k2) {
languageVersion = "2.0"
}
Expand Down
5 changes: 2 additions & 3 deletions poko-tests/src/commonTest/kotlin/GenericArrayHolderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import kotlin.test.Test
import poko.GenericArrayHolder

class GenericArrayHolderTest {
@Suppress("RemoveExplicitTypeArguments") // https://youtrack.jetbrains.com/issue/KT-61627
@Test fun two_GenericArrayHolder_instances_with_equivalent_typed_arrays_are_equals() {
val a = GenericArrayHolder(arrayOf<Any>(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
val b = GenericArrayHolder(arrayOf<Any>(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
val a = GenericArrayHolder(arrayOf(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
val b = GenericArrayHolder(arrayOf(arrayOf("5%, 10%"), intArrayOf(5, 10), booleanArrayOf(false, true)))
assertThat(a).isEqualTo(b)
assertThat(b).isEqualTo(a)
assertThat(a).hashCodeFun().isEqualTo(b.hashCode())
Expand Down
5 changes: 5 additions & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ allprojects {
}
}
mavenCentral()

if (rootProject.property("kotlin_dev_version_enabled") == "true") {
logger.lifecycle("Adding Kotlin dev repository for ${this@allprojects}")
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
}
}

plugins.withId("org.jetbrains.kotlin.jvm") {
Expand Down
5 changes: 5 additions & 0 deletions sample/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ pluginManagement {
}
mavenCentral()
google()

if (extra["kotlin_dev_version_enabled"] == "true") {
logger.lifecycle("Adding Kotlin dev repository for plugins")
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
}
}

resolutionStrategy {
Expand Down
16 changes: 16 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
pluginManagement {
includeBuild("build-support")

//region TODO: Move this to build-support
val file: File = file("gradle.properties")
val properties = java.util.Properties()
file.inputStream().use {
properties.load(it)
}
properties.forEach { (key, value) ->
extra[key.toString()] = value
}
//endregion

repositories {
mavenCentral()

// KSP:
google()

if (extra["kotlin_dev_version_enabled"] == "true") {
logger.lifecycle("Adding Kotlin dev repository for plugins")
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
}
}
}

Expand Down