From c5b310bc45cc4651467e0f37aa04ce7e9535c928 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 7 Feb 2024 21:35:23 -0500 Subject: [PATCH 01/18] Enable KSP2 --- gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- .../src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 24e9516d..f30109b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ org.gradle.parallel=true kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true org.gradle.jvmargs=-Xmx4G -ksp.useKSP2=false +ksp.useKSP2=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8e3a0cde..c0845203 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.4.1" } +kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.5.0" } kotlin-metadata-jvm = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.0" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" } diff --git a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt index 42be0652..a136ea11 100644 --- a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt +++ b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt @@ -6,7 +6,7 @@ import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.tschuchort.compiletesting.CompilationResult import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile -import com.tschuchort.compiletesting.kspArgs +import com.tschuchort.compiletesting.kspProcessorOptions import com.tschuchort.compiletesting.kspWithCompilation import com.tschuchort.compiletesting.symbolProcessorProviders import me.tatarka.inject.compiler.Options @@ -47,7 +47,7 @@ class ProjectCompiler( sources = sourceFiles when (target) { Target.KSP -> { - options?.toMap()?.let { kspArgs.putAll(it) } + options?.toMap()?.let { kspProcessorOptions.putAll(it) } symbolProcessorProviders = mutableListOf().apply { add(InjectProcessorProvider()) addAll(symbolProcessors) @@ -107,5 +107,6 @@ class TestCompilationResult(private val result: CompilationResult) { val success: Boolean get() = result.exitCode == KotlinCompilation.ExitCode.OK + @OptIn(ExperimentalCompilerApi::class) fun output(kind: Diagnostic.Kind): String = result.messages.filterByKind(kind) } \ No newline at end of file From 206ce8c753e526c6d66f33a0e700119e685ab4ba Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Thu, 7 Mar 2024 21:26:51 -0500 Subject: [PATCH 02/18] Remove val from function parameter in test --- .../test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt index b6359a41..c9033937 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt @@ -948,7 +948,7 @@ class FailureTest { import me.tatarka.inject.annotations.Assisted @Inject class Bar - @Inject fun Foo(val bar: Bar, @Assisted assisted: String): String = assisted + @Inject fun Foo(bar: Bar, @Assisted assisted: String): String = assisted typealias Foo = () -> String @Component abstract class MyComponent { From 2478e98008c0bca13cf507911459a049e1fe3b5a Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 10 Jul 2024 18:56:36 -0400 Subject: [PATCH 03/18] Use messagesWithSeverity for tests --- gradle/libs.versions.toml | 2 +- .../me/tatarka/inject/ProjectCompiler.kt | 41 ++++--------------- .../kotlin/me/tatarka/inject/test/Utils.kt | 4 +- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c0845203..d66b63c7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.5.0" } +kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.5.1" } kotlin-metadata-jvm = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.0" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" } diff --git a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt index a136ea11..8284b9b4 100644 --- a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt +++ b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt @@ -4,6 +4,7 @@ package me.tatarka.inject import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.tschuchort.compiletesting.CompilationResult +import com.tschuchort.compiletesting.DiagnosticSeverity import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspProcessorOptions @@ -14,7 +15,6 @@ import me.tatarka.inject.compiler.ksp.InjectProcessorProvider import org.intellij.lang.annotations.Language import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import java.io.File -import javax.tools.Diagnostic class ProjectCompiler( private val target: Target, @@ -63,42 +63,12 @@ class ProjectCompiler( if (!result.success) { @Suppress("TooGenericExceptionThrown") - throw Exception(result.output(Diagnostic.Kind.ERROR)) + throw Exception(result.output(DiagnosticSeverity.ERROR)) } return result } } -private fun String.filterByKind(kind: Diagnostic.Kind): String = buildString { - var currentKind: Diagnostic.Kind? = null - for (line in this@filterByKind.lineSequence()) { - val lineKind = line.matchLine() - if (lineKind != null) { - currentKind = lineKind - } - if (currentKind == kind) { - append(line) - append('\n') - } - } -} - -private fun String.matchLine(): Diagnostic.Kind? { - if (length < 2) return null - val matchedKind = when (get(0)) { - 'e' -> Diagnostic.Kind.ERROR - 'w' -> Diagnostic.Kind.WARNING - 'v' -> Diagnostic.Kind.NOTE - else -> null - } ?: return null - - return if (get(1) == ':') { - matchedKind - } else { - null - } -} - enum class Target { KSP } @@ -108,5 +78,8 @@ class TestCompilationResult(private val result: CompilationResult) { get() = result.exitCode == KotlinCompilation.ExitCode.OK @OptIn(ExperimentalCompilerApi::class) - fun output(kind: Diagnostic.Kind): String = result.messages.filterByKind(kind) -} \ No newline at end of file + fun output(vararg severities: DiagnosticSeverity): String = when { + severities.isEmpty() -> result.messages + else -> result.messagesWithSeverity(*severities) + } +} diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/Utils.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/Utils.kt index 7ed4abe5..04b7c81e 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/Utils.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/Utils.kt @@ -4,10 +4,10 @@ import assertk.Assert import assertk.assertions.isNotNull import assertk.assertions.message import assertk.assertions.prop +import com.tschuchort.compiletesting.DiagnosticSeverity import me.tatarka.inject.TestCompilationResult -import javax.tools.Diagnostic fun Assert.output(): Assert = message().isNotNull() fun Assert.warnings(): Assert = - prop("warnings") { it.output(Diagnostic.Kind.WARNING) } \ No newline at end of file + prop("warnings") { it.output(DiagnosticSeverity.WARNING) } From 48cb7ca70464b3c2e4d38b61e08369096ac00200 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Thu, 14 Nov 2024 19:13:56 -0500 Subject: [PATCH 04/18] Kotlin 2.0.21 --- .../kotlin/kotlin-inject.multiplatform.gradle.kts | 2 +- gradle/libs.versions.toml | 6 +++--- .../main/kotlin/me/tatarka/inject/ProjectCompiler.kt | 11 +++++------ .../test/kotlin/me/tatarka/inject/test/FailureTest.kt | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build-logic/src/main/kotlin/kotlin-inject.multiplatform.gradle.kts b/build-logic/src/main/kotlin/kotlin-inject.multiplatform.gradle.kts index d46b833d..4edcbd7d 100644 --- a/build-logic/src/main/kotlin/kotlin-inject.multiplatform.gradle.kts +++ b/build-logic/src/main/kotlin/kotlin-inject.multiplatform.gradle.kts @@ -1,8 +1,8 @@ import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.kotlin.dsl.assign +import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d66b63c7..43a03128 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlin-inject = "0.7.3-SNAPSHOT" -kotlin = "2.0.10" -ksp = "2.0.10-1.0.24" +kotlin = "2.0.21" +ksp = "2.0.21-1.0.28" kotlinpoet = "2.0.0" junit5 = "5.9.3" jvmTarget = "11" @@ -13,7 +13,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.5.1" } +kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.6.0" } kotlin-metadata-jvm = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.0" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" } diff --git a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt index 8284b9b4..259335de 100644 --- a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt +++ b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt @@ -7,9 +7,9 @@ import com.tschuchort.compiletesting.CompilationResult import com.tschuchort.compiletesting.DiagnosticSeverity import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile +import com.tschuchort.compiletesting.configureKsp import com.tschuchort.compiletesting.kspProcessorOptions import com.tschuchort.compiletesting.kspWithCompilation -import com.tschuchort.compiletesting.symbolProcessorProviders import me.tatarka.inject.compiler.Options import me.tatarka.inject.compiler.ksp.InjectProcessorProvider import org.intellij.lang.annotations.Language @@ -47,10 +47,10 @@ class ProjectCompiler( sources = sourceFiles when (target) { Target.KSP -> { - options?.toMap()?.let { kspProcessorOptions.putAll(it) } - symbolProcessorProviders = mutableListOf().apply { - add(InjectProcessorProvider()) - addAll(symbolProcessors) + configureKsp(useKsp2 = true) { + options?.toMap()?.let { kspProcessorOptions.putAll(it) } + symbolProcessorProviders.add(InjectProcessorProvider()) + symbolProcessorProviders.addAll(symbolProcessors) } } } @@ -77,7 +77,6 @@ class TestCompilationResult(private val result: CompilationResult) { val success: Boolean get() = result.exitCode == KotlinCompilation.ExitCode.OK - @OptIn(ExperimentalCompilerApi::class) fun output(vararg severities: DiagnosticSeverity): String = when { severities.isEmpty() -> result.messages else -> result.messagesWithSeverity(*severities) diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt index c9033937..06151316 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt @@ -1495,7 +1495,7 @@ class FailureTest { """.trimIndent() ).compile() }.output().all { - contains("e: [ksp] Cannot find an @Inject constructor or provider for: Foo") + contains("Cannot find an @Inject constructor or provider for: Foo") } } From e41462dd2f9b75a5f8a184f45d92325da226c6dc Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Thu, 14 Nov 2024 19:19:09 -0500 Subject: [PATCH 05/18] Update yarn.lock --- kotlin-js-store/yarn.lock | 231 +++++++++++++++++--------------------- 1 file changed, 102 insertions(+), 129 deletions(-) diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 14455494..62678ccb 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -256,10 +256,10 @@ accepts@~1.3.4: mime-types "~2.1.34" negotiator "0.6.3" -acorn-import-assertions@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" - integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== +acorn-import-attributes@^1.9.5: + version "1.9.5" + resolved "https://registry.yarnpkg.com/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz#7eb1557b1ba05ef18b5ed0ec67591bfab04688ef" + integrity sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ== acorn@^8.7.1, acorn@^8.8.2: version "8.11.3" @@ -281,10 +281,10 @@ ajv@^6.12.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-colors@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== +ansi-colors@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" + integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== ansi-regex@^5.0.1: version "5.0.1" @@ -366,7 +366,7 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -browser-stdout@1.3.1: +browser-stdout@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== @@ -420,22 +420,7 @@ chalk@^4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chokidar@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -chokidar@^3.5.1: +chokidar@^3.5.1, chokidar@^3.5.3: version "3.6.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== @@ -559,13 +544,20 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4.3.4, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: +debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" +debug@^4.3.5: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + decamelize@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" @@ -595,10 +587,10 @@ di@^0.0.1: resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" integrity sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA== -diff@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" - integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== +diff@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.2.0.tgz#26ded047cd1179b78b9537d5ef725503ce1ae531" + integrity sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A== dom-serialize@^2.2.1: version "2.2.1" @@ -651,10 +643,10 @@ engine.io@~6.5.2: engine.io-parser "~5.2.1" ws "~8.11.0" -enhanced-resolve@^5.16.0: - version "5.16.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.16.0.tgz#65ec88778083056cb32487faa9aef82ed0864787" - integrity sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA== +enhanced-resolve@^5.17.0: + version "5.17.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" + integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -696,7 +688,7 @@ escape-html@~1.0.3: resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== -escape-string-regexp@4.0.0: +escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== @@ -776,14 +768,6 @@ finalhandler@1.1.2: statuses "~1.5.0" unpipe "~1.0.0" -find-up@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^6.0.0" - path-exists "^4.0.0" - find-up@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -792,6 +776,14 @@ find-up@^4.0.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + flat@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" @@ -864,17 +856,6 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== -glob@8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" - integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^5.0.1" - once "^1.3.0" - glob@^7.1.3, glob@^7.1.7: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -887,6 +868,17 @@ glob@^7.1.3, glob@^7.1.7: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + gopd@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" @@ -928,7 +920,7 @@ hasown@^2.0.0: dependencies: function-bind "^1.1.2" -he@1.2.0: +he@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== @@ -1070,7 +1062,7 @@ jest-worker@^27.4.5: merge-stream "^2.0.0" supports-color "^8.0.0" -js-yaml@4.1.0: +js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== @@ -1183,7 +1175,7 @@ lodash@^4.17.15, lodash@^4.17.21: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log-symbols@4.1.0: +log-symbols@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== @@ -1229,13 +1221,6 @@ mime@^2.5.2: resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== -minimatch@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" - integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== - dependencies: - brace-expansion "^2.0.1" - minimatch@^3.0.4, minimatch@^3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -1243,7 +1228,7 @@ minimatch@^3.0.4, minimatch@^3.1.1: dependencies: brace-expansion "^1.1.7" -minimatch@^5.0.1: +minimatch@^5.0.1, minimatch@^5.1.6: version "5.1.6" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== @@ -1269,31 +1254,31 @@ mkdirp@^0.5.5: dependencies: minimist "^1.2.6" -mocha@10.3.0: - version "10.3.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.3.0.tgz#0e185c49e6dccf582035c05fa91084a4ff6e3fe9" - integrity sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg== - dependencies: - ansi-colors "4.1.1" - browser-stdout "1.3.1" - chokidar "3.5.3" - debug "4.3.4" - diff "5.0.0" - escape-string-regexp "4.0.0" - find-up "5.0.0" - glob "8.1.0" - he "1.2.0" - js-yaml "4.1.0" - log-symbols "4.1.0" - minimatch "5.0.1" - ms "2.1.3" - serialize-javascript "6.0.0" - strip-json-comments "3.1.1" - supports-color "8.1.1" - workerpool "6.2.1" - yargs "16.2.0" - yargs-parser "20.2.4" - yargs-unparser "2.0.0" +mocha@10.7.0: + version "10.7.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a" + integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA== + dependencies: + ansi-colors "^4.1.3" + browser-stdout "^1.3.1" + chokidar "^3.5.3" + debug "^4.3.5" + diff "^5.2.0" + escape-string-regexp "^4.0.0" + find-up "^5.0.0" + glob "^8.1.0" + he "^1.2.0" + js-yaml "^4.1.0" + log-symbols "^4.1.0" + minimatch "^5.1.6" + ms "^2.1.3" + serialize-javascript "^6.0.2" + strip-json-comments "^3.1.1" + supports-color "^8.1.1" + workerpool "^6.5.1" + yargs "^16.2.0" + yargs-parser "^20.2.9" + yargs-unparser "^2.0.0" ms@2.0.0: version "2.0.0" @@ -1305,7 +1290,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3: +ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -1551,14 +1536,7 @@ schema-utils@^3.1.1, schema-utils@^3.2.0: ajv "^6.12.5" ajv-keywords "^3.5.2" -serialize-javascript@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -serialize-javascript@^6.0.1: +serialize-javascript@^6.0.1, serialize-javascript@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== @@ -1701,18 +1679,11 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" -strip-json-comments@3.1.1: +strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -supports-color@8.1.1, supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - supports-color@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" @@ -1720,6 +1691,13 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" +supports-color@^8.0.0, supports-color@^8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + supports-preserve-symlinks-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" @@ -1776,10 +1754,10 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typescript@5.4.3: - version "5.4.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff" - integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg== +typescript@5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== ua-parser-js@^0.7.30: version "0.7.37" @@ -1879,10 +1857,10 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@5.91.0: - version "5.91.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.91.0.tgz#ffa92c1c618d18c878f06892bbdc3373c71a01d9" - integrity sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw== +webpack@5.93.0: + version "5.93.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.93.0.tgz#2e89ec7035579bdfba9760d26c63ac5c3462a5e5" + integrity sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA== dependencies: "@types/eslint-scope" "^3.7.3" "@types/estree" "^1.0.5" @@ -1890,10 +1868,10 @@ webpack@5.91.0: "@webassemblyjs/wasm-edit" "^1.12.1" "@webassemblyjs/wasm-parser" "^1.12.1" acorn "^8.7.1" - acorn-import-assertions "^1.9.0" + acorn-import-attributes "^1.9.5" browserslist "^4.21.10" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.16.0" + enhanced-resolve "^5.17.0" es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" @@ -1928,10 +1906,10 @@ wildcard@^2.0.0: resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== -workerpool@6.2.1: - version "6.2.1" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" - integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== +workerpool@^6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544" + integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA== wrap-ansi@^7.0.0: version "7.0.0" @@ -1957,17 +1935,12 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yargs-parser@20.2.4: - version "20.2.4" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" - integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== - -yargs-parser@^20.2.2: +yargs-parser@^20.2.2, yargs-parser@^20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs-unparser@2.0.0: +yargs-unparser@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== @@ -1977,7 +1950,7 @@ yargs-unparser@2.0.0: flat "^5.0.2" is-plain-obj "^2.1.0" -yargs@16.2.0, yargs@^16.1.1: +yargs@^16.1.1, yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== From bb607205e580db7d52adf3607f83b9d926456101 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Tue, 19 Nov 2024 19:59:56 -0500 Subject: [PATCH 06/18] Don't cache elements across rounds --- .../compiler/KmpComponentCreateGenerator.kt | 48 +++++++++++++------ .../inject/compiler/TypeResultResolver.kt | 2 +- .../inject/compiler/ksp/InjectProcessor.kt | 7 +-- .../compiler/ksp/ProcessKmpComponentCreate.kt | 29 +++++++++-- 4 files changed, 65 insertions(+), 21 deletions(-) diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt index 1eba5f91..75ac91e2 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt @@ -1,20 +1,39 @@ package me.tatarka.inject.compiler +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier -import me.tatarka.kotlin.ast.AstClass -import me.tatarka.kotlin.ast.AstFunction +import com.squareup.kotlinpoet.TypeName import me.tatarka.kotlin.ast.AstProvider +data class ComponentClassInfo( + val packageName: String, + val name: String, + val companionClassName: ClassName?, + val typeName: TypeName, + val className: ClassName, +) + +data class KmpComponentCreateFunctionInfo( + val name: String, + val annotations: List, + val visibility: KModifier, + val receiverParameterType: TypeName?, + val parameters: List>, + val parametersTemplate: String, + val parameterNames: List, +) + class KmpComponentCreateGenerator( private val provider: AstProvider, private val options: Options, ) { fun generate( - componentClass: AstClass, - kmpComponentCreateFunctions: List, + componentClass: ComponentClassInfo, + kmpComponentCreateFunctions: List, ) = with(provider) { FileSpec.builder( packageName = componentClass.packageName, @@ -24,36 +43,37 @@ class KmpComponentCreateGenerator( addFunction( FunSpec .builder(kmpComponentCreateFunction.name) - .addOriginatingElement(kmpComponentCreateFunction) +// .addOriginatingElement(kmpComponentCreateFunction) .apply { kmpComponentCreateFunction.annotations.forEach { annotation -> - addAnnotation(annotation.toAnnotationSpec()) + addAnnotation(annotation) } addModifiers( - kmpComponentCreateFunction.visibility.toKModifier(), + kmpComponentCreateFunction.visibility, KModifier.ACTUAL, ) - kmpComponentCreateFunction.receiverParameterType?.toTypeName()?.let(::receiver) + kmpComponentCreateFunction.receiverParameterType?.let(::receiver) for (param in kmpComponentCreateFunction.parameters) { - addParameter(param.name, param.type.toTypeName()) + val (name, typeName) = param + addParameter(name, typeName) } val funcParams = kmpComponentCreateFunction.parameters.joinToString { "%N" } - val funcParamsNames = kmpComponentCreateFunction.parameters.map { it.name }.toTypedArray() + val funcParamsNames = kmpComponentCreateFunction.parameterNames.toTypedArray() val returnTypeCompanion = when { - options.generateCompanionExtensions -> componentClass.companion?.type + options.generateCompanionExtensions -> componentClass.companionClassName else -> null } - val returnTypeName = componentClass.type.toTypeName() + val returnTypeName = componentClass.typeName val (createReceiver, createReceiverClassName) = when (returnTypeCompanion) { - null -> "%T::class" to componentClass.toClassName() - else -> "%T" to returnTypeCompanion.toAstClass().toClassName() + null -> "%T::class" to componentClass.className + else -> "%T" to returnTypeCompanion } addCode( CodeBlock.of( diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index 71ddced1..66b3e428 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -654,4 +654,4 @@ class TypeResultResolver(private val provider: AstProvider, private val options: // default values are present. val args: List>, ) -} \ No newline at end of file +} diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt index 809be48b..d49b5ca2 100644 --- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt +++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt @@ -11,12 +11,12 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSName import me.tatarka.inject.compiler.COMPONENT +import me.tatarka.inject.compiler.ComponentClassInfo import me.tatarka.inject.compiler.InjectGenerator import me.tatarka.inject.compiler.KMP_COMPONENT_CREATE +import me.tatarka.inject.compiler.KmpComponentCreateFunctionInfo import me.tatarka.inject.compiler.KmpComponentCreateGenerator import me.tatarka.inject.compiler.Options -import me.tatarka.kotlin.ast.AstClass -import me.tatarka.kotlin.ast.AstFunction import me.tatarka.kotlin.ast.KSAstProvider class InjectProcessor( @@ -32,7 +32,8 @@ class InjectProcessor( private var deferredClassNames: List = mutableListOf() private var deferredFunctionNames: List = mutableListOf() - private val kmpComponentCreateFunctionsByComponentType = mutableMapOf>() + private val kmpComponentCreateFunctionsByComponentType = + mutableMapOf>() override fun process(resolver: Resolver): List { lastResolver = resolver diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt index 8c823fb7..a48d4975 100644 --- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt +++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt @@ -4,15 +4,20 @@ import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.squareup.kotlinpoet.ksp.writeTo import me.tatarka.inject.compiler.COMPONENT +import me.tatarka.inject.compiler.ComponentClassInfo +import me.tatarka.inject.compiler.KmpComponentCreateFunctionInfo import me.tatarka.inject.compiler.KmpComponentCreateGenerator import me.tatarka.kotlin.ast.AstClass import me.tatarka.kotlin.ast.AstFunction import me.tatarka.kotlin.ast.KSAstProvider +private typealias KmpComponentCreateFunctionsByComponentType = + MutableMap> + internal fun processKmpComponentCreate( element: KSFunctionDeclaration, provider: KSAstProvider, - kmpComponentCreateFunctionsByComponentType: MutableMap> + kmpComponentCreateFunctionsByComponentType: KmpComponentCreateFunctionsByComponentType ): Boolean = with(provider) { val astFunction = element.toAstFunction() val returnType = astFunction.returnType @@ -26,7 +31,25 @@ internal fun processKmpComponentCreate( val returnTypeClass = returnType.resolvedType().toAstClass() if (!astFunction.validateReturnType(returnTypeClass, provider)) return true - kmpComponentCreateFunctionsByComponentType.getOrPut(returnTypeClass, ::ArrayList).add(astFunction) + val returnTypeClassInfo = ComponentClassInfo( + packageName = returnTypeClass.packageName, + name = returnTypeClass.name, + companionClassName = returnTypeClass.companion?.type?.toAstClass()?.toClassName(), + typeName = returnTypeClass.type.toTypeName(), + className = returnTypeClass.toClassName(), + ) + + val functionInfo = KmpComponentCreateFunctionInfo( + name = astFunction.name, + annotations = astFunction.annotations.map { it.toAnnotationSpec() }.toList(), + visibility = astFunction.visibility.toKModifier(), + receiverParameterType = astFunction.receiverParameterType?.toTypeName(), + parameters = astFunction.parameters.map { it.name to it.type.toTypeName() }, + parametersTemplate = astFunction.parameters.joinToString { "%N" }, + parameterNames = astFunction.parameters.map { it.name }, + ) + + kmpComponentCreateFunctionsByComponentType.getOrPut(returnTypeClassInfo, ::ArrayList).add(functionInfo) true } @@ -34,7 +57,7 @@ internal fun processKmpComponentCreate( internal fun generateKmpComponentCreateFiles( codeGenerator: CodeGenerator, generator: KmpComponentCreateGenerator, - kmpComponentCreateFunctionsByComponentType: Map> + kmpComponentCreateFunctionsByComponentType: Map> ) { kmpComponentCreateFunctionsByComponentType.forEach { (componentType, kmpComponentCreateFunctions) -> val file = generator.generate(componentType, kmpComponentCreateFunctions) From 108a409cc2b5ba90b59aee6952049f25d854da4f Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Tue, 19 Nov 2024 21:42:47 -0500 Subject: [PATCH 07/18] Fix test failures due to logging --- .../me/tatarka/inject/ProjectCompiler.kt | 36 ++++++++++++++++--- .../me/tatarka/inject/test/RoundsTest.kt | 34 +++++++++--------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt index 259335de..0d4ef760 100644 --- a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt +++ b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt @@ -69,6 +69,36 @@ class ProjectCompiler( } } +private fun String.filterByKind(vararg kind: DiagnosticSeverity): String = buildString { + var currentKind: DiagnosticSeverity? = null + for (line in this@filterByKind.lineSequence()) { + val lineKind = line.matchLine() + if (lineKind != null) { + currentKind = lineKind + } + if (currentKind in kind) { + append(line) + append('\n') + } + } +} + +private fun String.matchLine(): DiagnosticSeverity? { + if (length < 2) return null + val matchedKind = when (get(0)) { + 'e' -> DiagnosticSeverity.ERROR + 'w' -> DiagnosticSeverity.WARNING + 'v' -> DiagnosticSeverity.LOGGING + else -> null + } ?: return null + + return if (get(1) == ':') { + matchedKind + } else { + null + } +} + enum class Target { KSP } @@ -77,8 +107,6 @@ class TestCompilationResult(private val result: CompilationResult) { val success: Boolean get() = result.exitCode == KotlinCompilation.ExitCode.OK - fun output(vararg severities: DiagnosticSeverity): String = when { - severities.isEmpty() -> result.messages - else -> result.messagesWithSeverity(*severities) - } + fun output(vararg severities: DiagnosticSeverity): String = + result.messages.filterByKind(*severities) } diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt index d923383d..ca1cc65c 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt @@ -86,8 +86,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Invalid") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Invalid'") + doesNotContain("Unresolved reference 'create'") } } @@ -133,8 +133,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Foo'") + doesNotContain("Unresolved reference 'create'") } } @@ -157,8 +157,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Foo'") + doesNotContain("Unresolved reference 'create'") } } @@ -181,8 +181,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Foo'") + doesNotContain("Unresolved reference 'create'") } } @@ -205,8 +205,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Foo'") + doesNotContain("Unresolved reference 'create'") } } @@ -230,7 +230,7 @@ class RoundsTest { ).compile() }.message().isNotNull().all { contains("@Provides method must not be private") - doesNotContain("Unresolved reference: create") + doesNotContain("Unresolved reference 'create'") } } @@ -256,9 +256,9 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - doesNotContain("Unresolved reference: Bar") - doesNotContain("Unresolved reference: create") + contains("Unresolved reference 'Foo'") + doesNotContain("Unresolved reference 'Bar'") + doesNotContain("Unresolved reference 'create'") } } @@ -284,8 +284,8 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: Foo") - contains("Unresolved reference: Bar") + contains("Unresolved reference 'Foo'") + contains("Unresolved reference 'Bar'") doesNotContain("Cannot provide", "as it is already provided") } } @@ -305,7 +305,7 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference: MyMissingComponent") + contains("Unresolved reference 'MyMissingComponent'") } } } From d6b8dbce199f7cb1b7e35506c9ebbda630b2f439 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 20 Nov 2024 00:24:18 -0500 Subject: [PATCH 08/18] Fix typealiases for function injection --- .../kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt | 2 +- .../core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index 66b3e428..9665b936 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -232,7 +232,7 @@ class TypeResultResolver(private val provider: AstProvider, private val options: return map(key) } - if (key.type.isFunction()) { + if (key.type.isFunctionOrTypeAliasOfFunction()) { return functionType(element, key) } diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt index 47ee9957..7fce2a3c 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt @@ -72,4 +72,5 @@ private fun renderTree(node: T, visitor: TreeVisitor, indent: String, isL fun AstType.isSet(): Boolean = packageName == "kotlin.collections" && simpleName == "Set" fun AstType.isMap(): Boolean = packageName == "kotlin.collections" && simpleName == "Map" -fun AstType.isPair(): Boolean = packageName == "kotlin" && simpleName == "Pair" \ No newline at end of file +fun AstType.isPair(): Boolean = packageName == "kotlin" && simpleName == "Pair" +fun AstType.isFunctionOrTypeAliasOfFunction() = isFunction() || isTypeAlias() && resolvedType().isFunction() From 19cfbefb3d5b7e777cc77a46b99abb921796031e Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 20 Nov 2024 00:24:39 -0500 Subject: [PATCH 09/18] Fix typealiases with type parameters --- ast/ksp/src/main/kotlin/me/tatarka/kotlin/ast/KSAst.kt | 6 +++++- .../me/tatarka/inject/compiler/TypeResultResolver.kt | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ast/ksp/src/main/kotlin/me/tatarka/kotlin/ast/KSAst.kt b/ast/ksp/src/main/kotlin/me/tatarka/kotlin/ast/KSAst.kt index 0d61f0b9..7f1fccdc 100644 --- a/ast/ksp/src/main/kotlin/me/tatarka/kotlin/ast/KSAst.kt +++ b/ast/ksp/src/main/kotlin/me/tatarka/kotlin/ast/KSAst.kt @@ -496,7 +496,11 @@ private class KSAstType private constructor( override fun resolvedType(): AstType { val declaration = type.declaration return if (declaration is KSTypeAlias) { - KSAstType(resolver, declaration.type.resolve().replace(type.arguments)) + if (type.arguments.isEmpty()) { + KSAstType(resolver, declaration.type.resolve()) + } else { + KSAstType(resolver, declaration.type.resolve().replace(type.arguments)) + } } else { this } diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index 9665b936..f5fb325f 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -91,11 +91,9 @@ class TypeResultResolver(private val provider: AstProvider, private val options: var assistedFailed = false val args = context.args.toMutableList() for (param in params) { - val type = if (param.type.isPlatform()) { - param.type.makeNonNullable() - } else { - param.type - } + val resolvedType = if (param.type.isTypeAlias()) param.type.resolvedType() else param.type + val type = if (resolvedType.isPlatform()) resolvedType.makeNonNullable() else resolvedType + val qualifier = qualifier(provider, options, param, type) val key = TypeKey(type, qualifier) if (param.isAssisted()) { From 243b9bdcbbdb99a9474eaa8b88dac221c432f8e7 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 20 Nov 2024 00:25:06 -0500 Subject: [PATCH 10/18] KSP2 returns synthetic constructors for objects --- .../me/tatarka/inject/compiler/TypeResultResolver.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index f5fb325f..d9a9e80a 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -242,15 +242,16 @@ class TypeResultResolver(private val provider: AstProvider, private val options: } val astClass = key.type.toAstClass() + + if (astClass.isObject && astClass.isInject()) { + return Object(astClass.type) + } + val injectCtor = astClass.findInjectConstructors(provider.messenger, options) if (injectCtor != null) { return constructor(key, injectCtor, astClass) } - if (astClass.isInject() && astClass.isObject) { - return Object(astClass.type) - } - if (astClass.isAssistedFactory()) { return assistedFactory(astClass, key) } From 319a8f8eb1a488f5218ee5a437ae09c1f9b21d84 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Fri, 22 Nov 2024 00:14:46 -0500 Subject: [PATCH 11/18] Defer all KmpComponentCreate functions to the last round --- .../compiler/KmpComponentCreateGenerator.kt | 48 ++++++------------- .../inject/compiler/ksp/InjectProcessor.kt | 34 ++++--------- .../compiler/ksp/ProcessKmpComponentCreate.kt | 29 ++--------- 3 files changed, 26 insertions(+), 85 deletions(-) diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt index 75ac91e2..1eba5f91 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/KmpComponentCreateGenerator.kt @@ -1,39 +1,20 @@ package me.tatarka.inject.compiler -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.TypeName +import me.tatarka.kotlin.ast.AstClass +import me.tatarka.kotlin.ast.AstFunction import me.tatarka.kotlin.ast.AstProvider -data class ComponentClassInfo( - val packageName: String, - val name: String, - val companionClassName: ClassName?, - val typeName: TypeName, - val className: ClassName, -) - -data class KmpComponentCreateFunctionInfo( - val name: String, - val annotations: List, - val visibility: KModifier, - val receiverParameterType: TypeName?, - val parameters: List>, - val parametersTemplate: String, - val parameterNames: List, -) - class KmpComponentCreateGenerator( private val provider: AstProvider, private val options: Options, ) { fun generate( - componentClass: ComponentClassInfo, - kmpComponentCreateFunctions: List, + componentClass: AstClass, + kmpComponentCreateFunctions: List, ) = with(provider) { FileSpec.builder( packageName = componentClass.packageName, @@ -43,37 +24,36 @@ class KmpComponentCreateGenerator( addFunction( FunSpec .builder(kmpComponentCreateFunction.name) -// .addOriginatingElement(kmpComponentCreateFunction) + .addOriginatingElement(kmpComponentCreateFunction) .apply { kmpComponentCreateFunction.annotations.forEach { annotation -> - addAnnotation(annotation) + addAnnotation(annotation.toAnnotationSpec()) } addModifiers( - kmpComponentCreateFunction.visibility, + kmpComponentCreateFunction.visibility.toKModifier(), KModifier.ACTUAL, ) - kmpComponentCreateFunction.receiverParameterType?.let(::receiver) + kmpComponentCreateFunction.receiverParameterType?.toTypeName()?.let(::receiver) for (param in kmpComponentCreateFunction.parameters) { - val (name, typeName) = param - addParameter(name, typeName) + addParameter(param.name, param.type.toTypeName()) } val funcParams = kmpComponentCreateFunction.parameters.joinToString { "%N" } - val funcParamsNames = kmpComponentCreateFunction.parameterNames.toTypedArray() + val funcParamsNames = kmpComponentCreateFunction.parameters.map { it.name }.toTypedArray() val returnTypeCompanion = when { - options.generateCompanionExtensions -> componentClass.companionClassName + options.generateCompanionExtensions -> componentClass.companion?.type else -> null } - val returnTypeName = componentClass.typeName + val returnTypeName = componentClass.type.toTypeName() val (createReceiver, createReceiverClassName) = when (returnTypeCompanion) { - null -> "%T::class" to componentClass.className - else -> "%T" to returnTypeCompanion + null -> "%T::class" to componentClass.toClassName() + else -> "%T" to returnTypeCompanion.toAstClass().toClassName() } addCode( CodeBlock.of( diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt index d49b5ca2..b1fb4b54 100644 --- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt +++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt @@ -11,12 +11,12 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSName import me.tatarka.inject.compiler.COMPONENT -import me.tatarka.inject.compiler.ComponentClassInfo import me.tatarka.inject.compiler.InjectGenerator import me.tatarka.inject.compiler.KMP_COMPONENT_CREATE -import me.tatarka.inject.compiler.KmpComponentCreateFunctionInfo import me.tatarka.inject.compiler.KmpComponentCreateGenerator import me.tatarka.inject.compiler.Options +import me.tatarka.kotlin.ast.AstClass +import me.tatarka.kotlin.ast.AstFunction import me.tatarka.kotlin.ast.KSAstProvider class InjectProcessor( @@ -32,9 +32,6 @@ class InjectProcessor( private var deferredClassNames: List = mutableListOf() private var deferredFunctionNames: List = mutableListOf() - private val kmpComponentCreateFunctionsByComponentType = - mutableMapOf>() - override fun process(resolver: Resolver): List { lastResolver = resolver provider = KSAstProvider(resolver, logger) @@ -66,16 +63,7 @@ class InjectProcessor( val kmpComponentCreateSymbols = resolver.getSymbolsWithAnnotation(KMP_COMPONENT_CREATE.canonicalName) .filterIsInstance() - val deferredFunctions = kmpComponentCreateSymbols.filterNot { element -> - processKmpComponentCreate(element, provider, kmpComponentCreateFunctionsByComponentType) - }.toList() - deferredFunctionNames = deferredFunctions.mapNotNull { - val name = it.qualifiedName - if (name == null) { - logger.warn("Unable to defer symbol: ${it.simpleName.asString()}, no qualified name", it) - } - name - } + val deferredFunctions = kmpComponentCreateSymbols.toList() return deferredClasses + deferredFunctions } @@ -99,17 +87,13 @@ class InjectProcessor( ) } - for (name in deferredFunctionNames) { - val element = resolver.getFunctionDeclarationsByName( - name, - includeTopLevel = true - ).firstOrNull() - if (element == null) { - logger.error("Failed to resolve: ${name.asString()}") - continue + val kmpComponentCreateFunctionsByComponentType = mutableMapOf>() + + resolver.getSymbolsWithAnnotation(KMP_COMPONENT_CREATE.canonicalName) + .filterIsInstance() + .forEach { element -> + processKmpComponentCreate(element, provider, kmpComponentCreateFunctionsByComponentType) } - processKmpComponentCreate(element, provider, kmpComponentCreateFunctionsByComponentType) - } generateKmpComponentCreateFiles( codeGenerator, diff --git a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt index a48d4975..8c823fb7 100644 --- a/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt +++ b/kotlin-inject-compiler/ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/ProcessKmpComponentCreate.kt @@ -4,20 +4,15 @@ import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.squareup.kotlinpoet.ksp.writeTo import me.tatarka.inject.compiler.COMPONENT -import me.tatarka.inject.compiler.ComponentClassInfo -import me.tatarka.inject.compiler.KmpComponentCreateFunctionInfo import me.tatarka.inject.compiler.KmpComponentCreateGenerator import me.tatarka.kotlin.ast.AstClass import me.tatarka.kotlin.ast.AstFunction import me.tatarka.kotlin.ast.KSAstProvider -private typealias KmpComponentCreateFunctionsByComponentType = - MutableMap> - internal fun processKmpComponentCreate( element: KSFunctionDeclaration, provider: KSAstProvider, - kmpComponentCreateFunctionsByComponentType: KmpComponentCreateFunctionsByComponentType + kmpComponentCreateFunctionsByComponentType: MutableMap> ): Boolean = with(provider) { val astFunction = element.toAstFunction() val returnType = astFunction.returnType @@ -31,25 +26,7 @@ internal fun processKmpComponentCreate( val returnTypeClass = returnType.resolvedType().toAstClass() if (!astFunction.validateReturnType(returnTypeClass, provider)) return true - val returnTypeClassInfo = ComponentClassInfo( - packageName = returnTypeClass.packageName, - name = returnTypeClass.name, - companionClassName = returnTypeClass.companion?.type?.toAstClass()?.toClassName(), - typeName = returnTypeClass.type.toTypeName(), - className = returnTypeClass.toClassName(), - ) - - val functionInfo = KmpComponentCreateFunctionInfo( - name = astFunction.name, - annotations = astFunction.annotations.map { it.toAnnotationSpec() }.toList(), - visibility = astFunction.visibility.toKModifier(), - receiverParameterType = astFunction.receiverParameterType?.toTypeName(), - parameters = astFunction.parameters.map { it.name to it.type.toTypeName() }, - parametersTemplate = astFunction.parameters.joinToString { "%N" }, - parameterNames = astFunction.parameters.map { it.name }, - ) - - kmpComponentCreateFunctionsByComponentType.getOrPut(returnTypeClassInfo, ::ArrayList).add(functionInfo) + kmpComponentCreateFunctionsByComponentType.getOrPut(returnTypeClass, ::ArrayList).add(astFunction) true } @@ -57,7 +34,7 @@ internal fun processKmpComponentCreate( internal fun generateKmpComponentCreateFiles( codeGenerator: CodeGenerator, generator: KmpComponentCreateGenerator, - kmpComponentCreateFunctionsByComponentType: Map> + kmpComponentCreateFunctionsByComponentType: Map> ) { kmpComponentCreateFunctionsByComponentType.forEach { (componentType, kmpComponentCreateFunctions) -> val file = generator.generate(componentType, kmpComponentCreateFunctions) From 7e2924a729a14cc2443767d402eafc67c2f90b14 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Fri, 22 Nov 2024 01:48:25 -0500 Subject: [PATCH 12/18] Handle typealias to typealias --- .../me/tatarka/inject/test/TypeAliasTest.kt | 29 +++++++++++++++++++ .../me/tatarka/inject/test/TypeAlias.kt | 28 ++++++++++++++++++ .../inject/compiler/TypeResultResolver.kt | 4 ++- .../kotlin/me/tatarka/inject/compiler/Util.kt | 12 +++++++- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 integration-tests/common-test/src/test/kotlin/me/tatarka/inject/test/TypeAliasTest.kt create mode 100644 integration-tests/common/src/main/kotlin/me/tatarka/inject/test/TypeAlias.kt diff --git a/integration-tests/common-test/src/test/kotlin/me/tatarka/inject/test/TypeAliasTest.kt b/integration-tests/common-test/src/test/kotlin/me/tatarka/inject/test/TypeAliasTest.kt new file mode 100644 index 00000000..1bd3dd74 --- /dev/null +++ b/integration-tests/common-test/src/test/kotlin/me/tatarka/inject/test/TypeAliasTest.kt @@ -0,0 +1,29 @@ +package me.tatarka.inject.test + +import assertk.assertThat +import assertk.assertions.isNotNull +import kotlin.test.Test + +class TypeAliasTest { + + @Test + fun can_generate_for_typealias_on_typealias_function() { + val component = TypeAliasesComponent::class.create() + + assertThat(component.typeAliasFoo()).isNotNull() + } + + @Test + fun can_generate_for_typealias_on_typealias_to_typealias_function() { + val component = TypeAliasesComponent::class.create() + + assertThat(component.typeAliasToTypeAliasFoo()).isNotNull() + } + + @Test + fun can_generate_for_typealias_on_typealias_to_typealias_to_typealias_function() { + val component = TypeAliasesComponent::class.create() + + assertThat(component.typeAliasToTypeAliasToTypeAliasFoo()).isNotNull() + } +} diff --git a/integration-tests/common/src/main/kotlin/me/tatarka/inject/test/TypeAlias.kt b/integration-tests/common/src/main/kotlin/me/tatarka/inject/test/TypeAlias.kt new file mode 100644 index 00000000..01fa71f9 --- /dev/null +++ b/integration-tests/common/src/main/kotlin/me/tatarka/inject/test/TypeAlias.kt @@ -0,0 +1,28 @@ +package me.tatarka.inject.test + +import me.tatarka.inject.annotations.Component +import me.tatarka.inject.annotations.Inject + +@Inject +class TypeAliasBar + +typealias TypeAliasToTypeAliasBar = TypeAliasBar +typealias TypeAliasToTypeAliasToTypeAliasBar = TypeAliasToTypeAliasBar + +@Inject +fun TypeAliasFoo( + bar: TypeAliasBar, + typeAliasToBar: TypeAliasToTypeAliasBar, + typeAliasToTypeAliasToBar: TypeAliasToTypeAliasToTypeAliasBar, +) {} +typealias TypeAliasFoo = () -> Unit + +typealias TypeAliasToTypeAliasFoo = TypeAliasFoo +typealias TypeAliasToTypeAliasToTypeAliasFoo = TypeAliasToTypeAliasFoo + +@Component +abstract class TypeAliasesComponent { + abstract fun typeAliasFoo(): TypeAliasFoo + abstract fun typeAliasToTypeAliasFoo(): TypeAliasToTypeAliasFoo + abstract fun typeAliasToTypeAliasToTypeAliasFoo(): TypeAliasToTypeAliasToTypeAliasFoo +} diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt index d9a9e80a..32ad1ccf 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt @@ -382,8 +382,10 @@ class TypeResultResolver(private val provider: AstProvider, private val options: val resolveType = key.type.resolvedType() val args = resolveType.arguments.dropLast(1) if (key.type.isTypeAlias()) { + val resolvedTypeAlias = key.type.resolveToHighestTypeAlias() + // Check to see if we have a function matching the type alias - val functions = provider.findFunctions(key.type.packageName, key.type.simpleName) + val functions = provider.findFunctions(resolvedTypeAlias.packageName, resolvedTypeAlias.simpleName) val injectedFunction = functions.find { it.isInject() } if (injectedFunction != null) { return NamedFunction( diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt index 7fce2a3c..842e22b4 100644 --- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt +++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/Util.kt @@ -73,4 +73,14 @@ private fun renderTree(node: T, visitor: TreeVisitor, indent: String, isL fun AstType.isSet(): Boolean = packageName == "kotlin.collections" && simpleName == "Set" fun AstType.isMap(): Boolean = packageName == "kotlin.collections" && simpleName == "Map" fun AstType.isPair(): Boolean = packageName == "kotlin" && simpleName == "Pair" -fun AstType.isFunctionOrTypeAliasOfFunction() = isFunction() || isTypeAlias() && resolvedType().isFunction() +fun AstType.isFunctionOrTypeAliasOfFunction(): Boolean = isFunction() || isTypeAlias() && + resolvedType().isFunctionOrTypeAliasOfFunction() + +tailrec fun AstType.resolveToHighestTypeAlias(): AstType { + check(isTypeAlias()) { + "resolveToHighestTypeAlias should only be called on a typealias AstType" + } + + val resolvedType = resolvedType() + return if (resolvedType.isTypeAlias()) resolvedType.resolveToHighestTypeAlias() else this +} From 3b5f7a1cb4e499bfbd19801bd6899703ac81922c Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Fri, 22 Nov 2024 14:11:29 -0500 Subject: [PATCH 13/18] Added a KSP1 target for unit tests --- .../me/tatarka/inject/ProjectCompiler.kt | 24 +++-- .../me/tatarka/inject/test/InheritanceTest.kt | 10 +- .../me/tatarka/inject/test/RoundsTest.kt | 102 ++++++++++-------- 3 files changed, 81 insertions(+), 55 deletions(-) diff --git a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt index 0d4ef760..7cf7f516 100644 --- a/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt +++ b/kotlin-inject-compiler/test/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt @@ -6,6 +6,7 @@ import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.tschuchort.compiletesting.CompilationResult import com.tschuchort.compiletesting.DiagnosticSeverity import com.tschuchort.compiletesting.KotlinCompilation +import com.tschuchort.compiletesting.KspTool import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.configureKsp import com.tschuchort.compiletesting.kspProcessorOptions @@ -45,14 +46,20 @@ class ProjectCompiler( KotlinCompilation().apply { workingDir = this@ProjectCompiler.workingDir sources = sourceFiles + + if (target == Target.KSP1) { + languageVersion = "1.9" + } + + val ksp: KspTool.() -> Unit = { + options?.toMap()?.let { kspProcessorOptions.putAll(it) } + symbolProcessorProviders.add(InjectProcessorProvider()) + symbolProcessorProviders.addAll(symbolProcessors) + } + when (target) { - Target.KSP -> { - configureKsp(useKsp2 = true) { - options?.toMap()?.let { kspProcessorOptions.putAll(it) } - symbolProcessorProviders.add(InjectProcessorProvider()) - symbolProcessorProviders.addAll(symbolProcessors) - } - } + Target.KSP1 -> configureKsp(useKsp2 = false, ksp) + Target.KSP2 -> configureKsp(useKsp2 = true, ksp) } inheritClassPath = true // work-around for https://github.com/ZacSweers/kotlin-compile-testing/issues/197 @@ -100,7 +107,8 @@ private fun String.matchLine(): DiagnosticSeverity? { } enum class Target { - KSP + KSP1, + KSP2 } class TestCompilationResult(private val result: CompilationResult) { diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/InheritanceTest.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/InheritanceTest.kt index 8b2b9eec..3fd92c5c 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/InheritanceTest.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/InheritanceTest.kt @@ -2,20 +2,22 @@ package me.tatarka.inject.test import me.tatarka.inject.ProjectCompiler import me.tatarka.inject.Target -import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.io.TempDir +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource import java.io.File class InheritanceTest { - private val target = Target.KSP + private val target = Target.KSP2 @TempDir lateinit var workingDir: File - @Test - fun abstract_functions_can_be_implemented_by_parent_component_interfaces() { + @ParameterizedTest + @EnumSource(Target::class) + fun abstract_functions_can_be_implemented_by_parent_component_interfaces(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertDoesNotThrow { diff --git a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt index ca1cc65c..7562d8da 100644 --- a/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt +++ b/kotlin-inject-compiler/test/src/test/kotlin/me/tatarka/inject/test/RoundsTest.kt @@ -9,20 +9,25 @@ import assertk.assertions.message import me.tatarka.inject.ProjectCompiler import me.tatarka.inject.SimpleClassProcessor import me.tatarka.inject.Target -import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.api.io.TempDir +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource import java.io.File -class RoundsTest { +private fun Target.unresolvedReference(reference: String) = when (this) { + Target.KSP1 -> "Unresolved reference: $reference" + Target.KSP2 -> "Unresolved reference '$reference'" +} - private val target = Target.KSP +class RoundsTest { @TempDir lateinit var workingDir: File - @Test - fun can_reference_generated_interface_as_parent() { + @ParameterizedTest + @EnumSource(Target::class) + fun can_reference_generated_interface_as_parent(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) .symbolProcessor(SimpleClassProcessor.Provider("Source", "Generated")) @@ -44,8 +49,9 @@ class RoundsTest { } } - @Test - fun can_reference_generated_class_in_supertype() { + @ParameterizedTest + @EnumSource(Target::class) + fun can_reference_generated_class_in_supertype(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) .symbolProcessor(SimpleClassProcessor.Provider("Source", "Generated")) @@ -70,8 +76,9 @@ class RoundsTest { } } - @Test - fun errors_on_missing_parent_interface() { + @ParameterizedTest + @EnumSource(Target::class) + fun errors_on_missing_parent_interface(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -86,13 +93,14 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Invalid'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Invalid")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun errors_on_missing_provider_type() { + @ParameterizedTest + @EnumSource(Target::class) + fun errors_on_missing_provider_type(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -114,8 +122,9 @@ class RoundsTest { } } - @Test - fun errors_on_missing_provides_return_type() { + @ParameterizedTest + @EnumSource(Target::class) + fun errors_on_missing_provides_return_type(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -133,13 +142,14 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Foo")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun errors_on_missing_provides_arg() { + @ParameterizedTest + @EnumSource(Target::class) + fun errors_on_missing_provides_arg(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -157,13 +167,14 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Foo")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun ignores_invalid_references_in_private_declarations() { + @ParameterizedTest + @EnumSource(Target::class) + fun ignores_invalid_references_in_private_declarations(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -181,13 +192,14 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Foo")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun ignores_invalid_references_in_non_provides_declaration() { + @ParameterizedTest + @EnumSource(Target::class) + fun ignores_invalid_references_in_non_provides_declaration(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -205,13 +217,14 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Foo")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun includes_invalid_provides_on_method_with_invalid_reference() { + @ParameterizedTest + @EnumSource(Target::class) + fun includes_invalid_provides_on_method_with_invalid_reference(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -234,8 +247,9 @@ class RoundsTest { } } - @Test - fun ignores_invalid_wrapped_type() { + @ParameterizedTest + @EnumSource(Target::class) + fun ignores_invalid_wrapped_type(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -256,14 +270,15 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - doesNotContain("Unresolved reference 'Bar'") - doesNotContain("Unresolved reference 'create'") + contains(target.unresolvedReference("Foo")) + doesNotContain(target.unresolvedReference("Bar")) + doesNotContain(target.unresolvedReference("create")) } } - @Test - fun multiple_invalid_types_only_show_unresolved_reference_error() { + @ParameterizedTest + @EnumSource(Target::class) + fun multiple_invalid_types_only_show_unresolved_reference_error(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) assertFailure { projectCompiler.source( @@ -284,14 +299,15 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'Foo'") - contains("Unresolved reference 'Bar'") + contains(target.unresolvedReference("Foo")) + contains(target.unresolvedReference("Bar")) doesNotContain("Cannot provide", "as it is already provided") } } - @Test - fun errors_on_missing_target_component_accessor_return_type() { + @ParameterizedTest + @EnumSource(Target::class) + fun errors_on_missing_target_component_accessor_return_type(target: Target) { val projectCompiler = ProjectCompiler(target, workingDir) .symbolProcessor(SimpleClassProcessor.Provider("Source", "Generated")) assertFailure { @@ -305,7 +321,7 @@ class RoundsTest { """.trimIndent() ).compile() }.message().isNotNull().all { - contains("Unresolved reference 'MyMissingComponent'") + contains(target.unresolvedReference("MyMissingComponent")) } } } From 89dfb8a735e2b3285c8561d5fbcce75b731a1d90 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Fri, 22 Nov 2024 14:34:56 -0500 Subject: [PATCH 14/18] Add KSP1 integration tests --- integration-tests/ksp1-companion/.gitignore | 1 + .../ksp1-companion/build.gradle.kts | 48 ++++++++++++ integration-tests/ksp1/.gitignore | 1 + integration-tests/ksp1/build.gradle.kts | 76 +++++++++++++++++++ .../kotlin/me/tatarka/inject/test/runTest.kt | 8 ++ .../kotlin/me/tatarka/inject/test/runTest.kt | 14 ++++ .../kotlin/me/tatarka/inject/test/runTest.kt | 9 +++ .../kotlin/me/tatarka/inject/test/runTest.kt | 9 +++ .../kotlin/me/tatarka/inject/test/runTest.kt | 14 ++++ settings.gradle.kts | 2 + 10 files changed, 182 insertions(+) create mode 100644 integration-tests/ksp1-companion/.gitignore create mode 100644 integration-tests/ksp1-companion/build.gradle.kts create mode 100644 integration-tests/ksp1/.gitignore create mode 100644 integration-tests/ksp1/build.gradle.kts create mode 100644 integration-tests/ksp1/src/commonTest/kotlin/me/tatarka/inject/test/runTest.kt create mode 100644 integration-tests/ksp1/src/jsTest/kotlin/me/tatarka/inject/test/runTest.kt create mode 100644 integration-tests/ksp1/src/jvmTest/kotlin/me/tatarka/inject/test/runTest.kt create mode 100644 integration-tests/ksp1/src/nativeTest/kotlin/me/tatarka/inject/test/runTest.kt create mode 100644 integration-tests/ksp1/src/wasmJsTest/kotlin/me/tatarka/inject/test/runTest.kt diff --git a/integration-tests/ksp1-companion/.gitignore b/integration-tests/ksp1-companion/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/integration-tests/ksp1-companion/.gitignore @@ -0,0 +1 @@ +/build diff --git a/integration-tests/ksp1-companion/build.gradle.kts b/integration-tests/ksp1-companion/build.gradle.kts new file mode 100644 index 00000000..cd99087f --- /dev/null +++ b/integration-tests/ksp1-companion/build.gradle.kts @@ -0,0 +1,48 @@ +import com.google.devtools.ksp.KspExperimental + +plugins { + id("kotlin-inject.multiplatform") + id("kotlin-inject.detekt") + id("kotlin-inject.merge-tests") + id("com.google.devtools.ksp") +} + +dependencies { + addAllKspTargets(kotlin, project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) +} + +kotlin { + jvm { + withJava() + } + + sourceSets { + commonMain { + kotlin.srcDir("../common-companion/src/main/kotlin") + kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") + dependencies { + implementation(project(":kotlin-inject-runtime-kmp")) + implementation(project(":integration-tests:module")) + } + } + commonTest { + kotlin.srcDir("../common-companion-test/src/test/kotlin") + dependencies { + implementation(libs.kotlin.test) + implementation(libs.assertk) + } + } + nativeMain { + kotlin.srcDir("../common-native/src/main/kotlin") + } + nativeTest { + kotlin.srcDir("../common-native/src/test/kotlin") + } + } +} + +ksp { + arg("me.tatarka.inject.generateCompanionExtensions", "true") + @OptIn(KspExperimental::class) + useKsp2 = false +} diff --git a/integration-tests/ksp1/.gitignore b/integration-tests/ksp1/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/integration-tests/ksp1/.gitignore @@ -0,0 +1 @@ +/build diff --git a/integration-tests/ksp1/build.gradle.kts b/integration-tests/ksp1/build.gradle.kts new file mode 100644 index 00000000..f9651303 --- /dev/null +++ b/integration-tests/ksp1/build.gradle.kts @@ -0,0 +1,76 @@ +import com.google.devtools.ksp.KspExperimental + +plugins { + id("kotlin-inject.multiplatform") + id("kotlin-inject.detekt") + id("kotlin-inject.merge-tests") + id("com.google.devtools.ksp") +} + +dependencies { + addAllKspTargets(kotlin, project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) + kspJvmTest(project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) +} + +kotlin { + jvm { + withJava() + } + + sourceSets { + commonMain { + kotlin.srcDir("../common/src/main/kotlin") + kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") + dependencies { + implementation(project(":kotlin-inject-runtime-kmp")) + implementation(project(":integration-tests:module")) + } + } + commonTest { + kotlin.srcDir("../common-test/src/test/kotlin") + dependencies { + implementation(kotlin("test")) + implementation(libs.kotlinx.coroutines) + implementation(libs.assertk) + } + } + nativeMain { + kotlin.srcDir("../common-native/src/main/kotlin") + } + nativeTest { + kotlin.srcDir("../common-native/src/test/kotlin") + } + jvmMain { + kotlin.srcDir("../common-jvm/src/main/kotlin") + dependencies { + api(libs.javax.inject) + } + } + jvmTest { + kotlin.srcDir("../common-jvm/src/test/kotlin") + dependencies { + implementation(libs.kotlin.reflect) + } + } + } + + targets.all { + compilations.all { + compileTaskProvider.configure { + compilerOptions.allWarningsAsErrors = true + } + } + } +} + +java { + val test by sourceSets.existing { + java.srcDir("../common-jvm/src/test/java") + } +} + +ksp { + arg("me.tatarka.inject.enableJavaxAnnotations", "true") + @OptIn(KspExperimental::class) + useKsp2 = false +} diff --git a/integration-tests/ksp1/src/commonTest/kotlin/me/tatarka/inject/test/runTest.kt b/integration-tests/ksp1/src/commonTest/kotlin/me/tatarka/inject/test/runTest.kt new file mode 100644 index 00000000..5c4295b6 --- /dev/null +++ b/integration-tests/ksp1/src/commonTest/kotlin/me/tatarka/inject/test/runTest.kt @@ -0,0 +1,8 @@ +package me.tatarka.inject.test + +import kotlinx.coroutines.CoroutineScope + +/** + * Workaround to use suspending functions in unit tests + */ +expect fun runTest(block: suspend (scope: CoroutineScope) -> Unit) \ No newline at end of file diff --git a/integration-tests/ksp1/src/jsTest/kotlin/me/tatarka/inject/test/runTest.kt b/integration-tests/ksp1/src/jsTest/kotlin/me/tatarka/inject/test/runTest.kt new file mode 100644 index 00000000..afba9632 --- /dev/null +++ b/integration-tests/ksp1/src/jsTest/kotlin/me/tatarka/inject/test/runTest.kt @@ -0,0 +1,14 @@ +package me.tatarka.inject.test + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.promise + +/** + * Workaround to use suspending functions in unit tests + */ +@OptIn(DelicateCoroutinesApi::class) +actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) { + GlobalScope.promise { block(this) } +} diff --git a/integration-tests/ksp1/src/jvmTest/kotlin/me/tatarka/inject/test/runTest.kt b/integration-tests/ksp1/src/jvmTest/kotlin/me/tatarka/inject/test/runTest.kt new file mode 100644 index 00000000..2033e24d --- /dev/null +++ b/integration-tests/ksp1/src/jvmTest/kotlin/me/tatarka/inject/test/runTest.kt @@ -0,0 +1,9 @@ +package me.tatarka.inject.test + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking + +/** + * Workaround to use suspending functions in unit tests + */ +actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) } \ No newline at end of file diff --git a/integration-tests/ksp1/src/nativeTest/kotlin/me/tatarka/inject/test/runTest.kt b/integration-tests/ksp1/src/nativeTest/kotlin/me/tatarka/inject/test/runTest.kt new file mode 100644 index 00000000..2033e24d --- /dev/null +++ b/integration-tests/ksp1/src/nativeTest/kotlin/me/tatarka/inject/test/runTest.kt @@ -0,0 +1,9 @@ +package me.tatarka.inject.test + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking + +/** + * Workaround to use suspending functions in unit tests + */ +actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) } \ No newline at end of file diff --git a/integration-tests/ksp1/src/wasmJsTest/kotlin/me/tatarka/inject/test/runTest.kt b/integration-tests/ksp1/src/wasmJsTest/kotlin/me/tatarka/inject/test/runTest.kt new file mode 100644 index 00000000..27537935 --- /dev/null +++ b/integration-tests/ksp1/src/wasmJsTest/kotlin/me/tatarka/inject/test/runTest.kt @@ -0,0 +1,14 @@ +package me.tatarka.inject.test + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.promise + +/** + * Workaround to use suspending functions in unit tests + */ +@OptIn(DelicateCoroutinesApi::class) +actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) { + GlobalScope.promise { block(this) } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f1a07d35..4fb24210 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,6 +27,8 @@ project(":ast:core").name = "ast-core" include(":ast:ksp") project(":ast:ksp").name = "ast-ksp" include(":integration-tests:ksp") +include(":integration-tests:ksp1") include(":integration-tests:module") include(":integration-tests:ksp-companion") +include(":integration-tests:ksp1-companion") include(":integration-tests:jmh") From 80d2e88f675956efadf6fafb07318856fd1fb3a2 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Sat, 23 Nov 2024 18:12:01 -0500 Subject: [PATCH 15/18] Clean in between assemble and check on CI - Avoids issues until https://github.com/google/ksp/pull/2231 is released --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 84eead05..343dd740 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,6 +64,9 @@ jobs: - run: name: Build command: ./gradlew assemble + - run: # clean to avoid issues until https://github.com/google/ksp/pull/2231 is released + name: Clean + command: ./gradlew clean - run: name: Run Tests command: ./gradlew check --continue @@ -84,6 +87,9 @@ jobs: - run: name: Build command: ./gradlew assemble + - run: # clean to avoid issues until https://github.com/google/ksp/pull/2231 is released + name: Clean + command: ./gradlew clean - run: name: Run Tests command: ./gradlew checkApple --continue From 148b8b9bcfc65e42e3fdc6caf0fa5dbedf07e8c1 Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 27 Nov 2024 18:52:32 -0500 Subject: [PATCH 16/18] Update Kotlin to 2.1.0 --- gradle/libs.versions.toml | 5 ++- integration-tests/ksp/build.gradle.kts | 5 +++ integration-tests/ksp1/build.gradle.kts | 5 +++ kotlin-js-store/yarn.lock | 56 ++++++++++--------------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 43a03128..04b1deba 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlin-inject = "0.7.3-SNAPSHOT" -kotlin = "2.0.21" -ksp = "2.0.21-1.0.28" +kotlin = "2.1.0" +ksp = "2.1.0-1.0.28" kotlinpoet = "2.0.0" junit5 = "5.9.3" jvmTarget = "11" @@ -17,6 +17,7 @@ kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.6. kotlin-metadata-jvm = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.0" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" } +kotlinx-wasm-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.3" jdk-compiler = { module = "io.earcam.wrapped:jdk.compiler", version = "1.8.132" } assertk = { module = "com.willowtreeapps.assertk:assertk", version = "0.28.0" } burst-junit4 = { module = "com.squareup.burst:burst-junit4", version = "1.2.0" } diff --git a/integration-tests/ksp/build.gradle.kts b/integration-tests/ksp/build.gradle.kts index 59fefe92..e543c5e3 100644 --- a/integration-tests/ksp/build.gradle.kts +++ b/integration-tests/ksp/build.gradle.kts @@ -50,6 +50,11 @@ kotlin { implementation(libs.kotlin.reflect) } } + wasmJsMain { + dependencies { + implementation(libs.kotlinx.wasm.browser) + } + } } targets.all { diff --git a/integration-tests/ksp1/build.gradle.kts b/integration-tests/ksp1/build.gradle.kts index f9651303..188e74ea 100644 --- a/integration-tests/ksp1/build.gradle.kts +++ b/integration-tests/ksp1/build.gradle.kts @@ -52,6 +52,11 @@ kotlin { implementation(libs.kotlin.reflect) } } + wasmJsMain { + dependencies { + implementation(libs.kotlinx.wasm.browser) + } + } } targets.all { diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 62678ccb..72d84969 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -69,28 +69,12 @@ dependencies: "@types/node" "*" -"@types/eslint-scope@^3.7.3": - version "3.7.7" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" - integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.56.10" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.10.tgz#eb2370a73bf04a901eeba8f22595c7ee0f7eb58d" - integrity sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^1.0.5": +"@types/estree@^1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== -"@types/json-schema@*", "@types/json-schema@^7.0.8": +"@types/json-schema@^7.0.8": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -643,7 +627,7 @@ engine.io@~6.5.2: engine.io-parser "~5.2.1" ws "~8.11.0" -enhanced-resolve@^5.17.0: +enhanced-resolve@^5.17.1: version "5.17.1" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz#67bfbbcc2f81d511be77d686a90267ef7f898a15" integrity sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg== @@ -1116,10 +1100,10 @@ karma-webpack@5.0.1: minimatch "^9.0.3" webpack-merge "^4.1.5" -karma@6.4.3: - version "6.4.3" - resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.3.tgz#763e500f99597218bbb536de1a14acc4ceea7ce8" - integrity sha512-LuucC/RE92tJ8mlCwqEoRWXP38UMAqpnq98vktmS9SznSoUPPUJQbc91dHcxcunROvfQjdORVA/YFviH+Xci9Q== +karma@6.4.4: + version "6.4.4" + resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.4.tgz#dfa5a426cf5a8b53b43cd54ef0d0d09742351492" + integrity sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w== dependencies: "@colors/colors" "1.5.0" body-parser "^1.19.0" @@ -1151,6 +1135,13 @@ kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +kotlin-web-helpers@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286" + integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw== + dependencies: + format-util "^1.0.5" + loader-runner@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" @@ -1254,10 +1245,10 @@ mkdirp@^0.5.5: dependencies: minimist "^1.2.6" -mocha@10.7.0: - version "10.7.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a" - integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA== +mocha@10.7.3: + version "10.7.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752" + integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A== dependencies: ansi-colors "^4.1.3" browser-stdout "^1.3.1" @@ -1857,12 +1848,11 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@5.93.0: - version "5.93.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.93.0.tgz#2e89ec7035579bdfba9760d26c63ac5c3462a5e5" - integrity sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA== +webpack@5.94.0: + version "5.94.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.94.0.tgz#77a6089c716e7ab90c1c67574a28da518a20970f" + integrity sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg== dependencies: - "@types/eslint-scope" "^3.7.3" "@types/estree" "^1.0.5" "@webassemblyjs/ast" "^1.12.1" "@webassemblyjs/wasm-edit" "^1.12.1" @@ -1871,7 +1861,7 @@ webpack@5.93.0: acorn-import-attributes "^1.9.5" browserslist "^4.21.10" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.17.0" + enhanced-resolve "^5.17.1" es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" From 5d530bad424faac5207f5caf1af5b115fededb4c Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Wed, 27 Nov 2024 20:55:47 -0500 Subject: [PATCH 17/18] Update KSP to 2.1.0-1.0.29 --- .circleci/config.yml | 6 ------ gradle/libs.versions.toml | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 343dd740..84eead05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,9 +64,6 @@ jobs: - run: name: Build command: ./gradlew assemble - - run: # clean to avoid issues until https://github.com/google/ksp/pull/2231 is released - name: Clean - command: ./gradlew clean - run: name: Run Tests command: ./gradlew check --continue @@ -87,9 +84,6 @@ jobs: - run: name: Build command: ./gradlew assemble - - run: # clean to avoid issues until https://github.com/google/ksp/pull/2231 is released - name: Clean - command: ./gradlew clean - run: name: Run Tests command: ./gradlew checkApple --continue diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 04b1deba..abc1c29e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlin-inject = "0.7.3-SNAPSHOT" kotlin = "2.1.0" -ksp = "2.1.0-1.0.28" +ksp = "2.1.0-1.0.29" kotlinpoet = "2.0.0" junit5 = "5.9.3" jvmTarget = "11" From dc5fa706c1938b9c0e05fc9e8da332c78a91620a Mon Sep 17 00:00:00 2001 From: Eliezer Graber Date: Fri, 29 Nov 2024 00:41:44 -0500 Subject: [PATCH 18/18] Update kotlin-compile-testing --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index abc1c29e..35b860fc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.6.0" } +kotlin-compile-testing = { module = "dev.zacsweers.kctfork:ksp", version = "0.7.0" } kotlin-metadata-jvm = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.0" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" }