From 1b206b9c5f06d5a001075ad7d3e4eed40451f0eb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:59:46 +0000 Subject: [PATCH 1/5] Update Kotlin and KSP --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 83234912ea..7167398e63 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ androidx-compose = "1.7.5" compileSdk = "35" http4k = "4.48.0.0" -kotlin = "2.0.20" +kotlin = "2.1.0" kotlinx-coroutines = "1.9.0" kotlinx-serialization = "1.7.3" okHttp = "4.12.0" @@ -30,7 +30,7 @@ auto-service-annotations = { module = "com.google.auto.service:auto-service-anno binary-compatibility-validator-gradle-plugin = { module = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin", version = "0.16.3" } cklib-gradle-plugin = { module = "co.touchlab:cklib-gradle-plugin", version = "0.3.3" } dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.20" } -google-ksp = "com.google.devtools.ksp:symbol-processing-gradle-plugin:2.0.20-1.0.25" +google-ksp = "com.google.devtools.ksp:symbol-processing-gradle-plugin:2.1.0-1.0.29" http4k-core = { module = "org.http4k:http4k-core", version.ref = "http4k" } http4k-server-jetty = { module = "org.http4k:http4k-server-jetty", version.ref = "http4k" } http4k-client-websocket = { module = "org.http4k:http4k-client-websocket", version.ref = "http4k" } From 706920ff8afd74ae0436e3b9370c89e3f4921588 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Mon, 2 Dec 2024 11:02:56 -0500 Subject: [PATCH 2/5] KCT (fork) 0.7.0 --- 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 7167398e63..4f2aa2894c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -35,7 +35,7 @@ http4k-core = { module = "org.http4k:http4k-core", version.ref = "http4k" } http4k-server-jetty = { module = "org.http4k:http4k-server-jetty", version.ref = "http4k" } http4k-client-websocket = { module = "org.http4k:http4k-client-websocket", version.ref = "http4k" } junit = { module = "junit:junit", version = "4.13.2" } -kotlin-compile-testing = { module = "dev.zacsweers.kctfork:core", version = "0.6.0" } +kotlin-compile-testing = { module = "dev.zacsweers.kctfork:core", version = "0.7.0" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-compose-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" } From c9296ca5512d59a02c1a4b9d8e4ce3fffa928f0f Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Mon, 2 Dec 2024 14:58:47 -0500 Subject: [PATCH 3/5] Kotlin 2.1.0 updates --- .../api/validator/fir/FirZiplineApiReader.kt | 16 ++-------------- .../main/kotlin/app/cash/zipline/kotlin/ir.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/FirZiplineApiReader.kt b/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/FirZiplineApiReader.kt index 4c2b46b573..5e5852da06 100644 --- a/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/FirZiplineApiReader.kt +++ b/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/FirZiplineApiReader.kt @@ -18,7 +18,6 @@ package app.cash.zipline.api.validator.fir import java.io.File import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.checkers.isSupertypeOf -import org.jetbrains.kotlin.fir.analysis.checkers.toClassLikeSymbol import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirProperty @@ -27,12 +26,9 @@ import org.jetbrains.kotlin.fir.declarations.utils.isInterface import org.jetbrains.kotlin.fir.declarations.utils.isSuspend import org.jetbrains.kotlin.fir.pipeline.FirResult import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider -import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag +import org.jetbrains.kotlin.fir.resolve.toClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirStarProjection import org.jetbrains.kotlin.fir.types.FirTypeProjection @@ -41,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef import org.jetbrains.kotlin.fir.types.abbreviatedTypeOrSelf import org.jetbrains.kotlin.fir.types.coneType +import org.jetbrains.kotlin.fir.types.lookupTagIfAny import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -150,15 +147,6 @@ internal class FirZiplineApiReader( return FirZiplineFunction(signature) } - // TODO This is available natively in Kotlin 2.1.0 or newer and can be deleted after upgrading. - val ConeKotlinType.lookupTagIfAny: ConeClassifierLookupTag? - get() = (this as? ConeLookupTagBasedType)?.lookupTag - - // TODO This is available natively in Kotlin 2.1.0 or newer and can be deleted after upgrading. - fun ConeClassifierLookupTag.toClassLikeSymbol(useSiteSession: FirSession): FirClassLikeSymbol<*>? { - return toSymbol(useSiteSession) as? FirClassLikeSymbol<*> - } - /** See [app.cash.zipline.kotlin.asString]. */ private fun FirTypeRef.asString(): String { // Abbreviated type gets us the name of typealiases rather than what they expand to. diff --git a/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ir.kt b/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ir.kt index d1ca2a65dd..eead857bef 100644 --- a/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ir.kt +++ b/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ir.kt @@ -55,7 +55,7 @@ import org.jetbrains.kotlin.ir.expressions.IrInstanceInitializerCall import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression import org.jetbrains.kotlin.ir.expressions.IrReturn import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImplWithShape import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol @@ -209,13 +209,17 @@ fun DeclarationIrBuilder.irDelegatingConstructorCall( valueArgumentsCount: Int = 0, block: IrDelegatingConstructorCall.() -> Unit = {}, ): IrDelegatingConstructorCall { - val result = IrDelegatingConstructorCallImpl( + val result = IrDelegatingConstructorCallImplWithShape( startOffset = startOffset, endOffset = endOffset, type = context.irBuiltIns.unitType, symbol = symbol, typeArgumentsCount = typeArgumentsCount, valueArgumentsCount = valueArgumentsCount, + // Note: These three parameters are unused in the Kotlin 2.1.0 implementation of this factory. + contextParameterCount = 0, + hasDispatchReceiver = false, + hasExtensionReceiver = false, ) result.block() return result From d168e952642cfcbecdf24eceb22cea23f1a2752f Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Mon, 2 Dec 2024 15:16:18 -0500 Subject: [PATCH 4/5] Update Yarn lock --- kotlin-js-store/yarn.lock | 59 +++++++++++++++------------------------ 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 6945030e76..b1f416ed06 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -120,27 +120,6 @@ resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== -"@types/eslint-scope@^3.7.3": - version "3.7.4" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" - integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "8.4.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.1.tgz#c48251553e8759db9e656de3efc846954ac32304" - integrity sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== - "@types/estree@^1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" @@ -197,7 +176,7 @@ dependencies: "@types/node" "*" -"@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": +"@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.9" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== @@ -980,7 +959,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== @@ -1641,10 +1620,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" @@ -1676,6 +1655,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" + launch-editor@^2.6.0: version "2.8.1" resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.8.1.tgz#3bda72af213ec9b46b170e39661916ec66c2f463" @@ -1832,10 +1818,10 @@ mkdirp@^0.5.5: dependencies: minimist "^1.2.5" -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" @@ -2763,12 +2749,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" @@ -2777,7 +2762,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 609cd5cd6b6feee1027a229110fc3efb2d528cb1 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Mon, 2 Dec 2024 21:40:23 -0500 Subject: [PATCH 5/5] More Kotlin migrations --- .../api/validator/fir/KotlinFirLoader.kt | 34 +++++++++++-------- .../zipline/profiler/ProfilerClockUnix.kt | 1 + 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/KotlinFirLoader.kt b/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/KotlinFirLoader.kt index 452aa62d7c..5442c93255 100644 --- a/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/KotlinFirLoader.kt +++ b/zipline-api-validator/src/main/kotlin/app/cash/zipline/api/validator/fir/KotlinFirLoader.kt @@ -17,7 +17,6 @@ package app.cash.zipline.api.validator.fir import java.io.File import org.jetbrains.kotlin.KtVirtualFileSourceFile -import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.GroupedKtSources import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity @@ -29,8 +28,9 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.VfsBasedProjectEnvironment +import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.IncrementalCompilationApi import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.ModuleCompilerInput -import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.compileModuleToAnalyzedFir +import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.compileModuleToAnalyzedFirViaLightTreeIncrementally import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer import org.jetbrains.kotlin.com.intellij.openapi.vfs.StandardFileSystems @@ -43,8 +43,6 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory import org.jetbrains.kotlin.fir.pipeline.FirResult import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil import org.jetbrains.kotlin.modules.TargetId -import org.jetbrains.kotlin.platform.CommonPlatforms -import org.jetbrains.kotlin.platform.jvm.JvmPlatforms /** * Loads classes using the compiler tools into the Frontend Intermediate Representation (FIR), so @@ -85,7 +83,7 @@ internal class KotlinFirLoader( fun load(targetName: String): FirResult { val configuration = CompilerConfiguration() configuration.put(CommonConfigurationKeys.MODULE_NAME, targetName) - configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector) + configuration.put(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector) configuration.put(CommonConfigurationKeys.USE_FIR, true) configuration.put(JVMConfigurationKeys.JDK_HOME, javaHome) configuration.put(JVMConfigurationKeys.JDK_RELEASE, jdkRelease) @@ -118,12 +116,10 @@ internal class KotlinFirLoader( commonSources = emptyList(), sourcesByModuleName = mapOf(JvmProtoBufUtil.DEFAULT_MODULE_NAME to sourceFiles), ), - commonPlatform = CommonPlatforms.defaultCommonPlatform, - platform = JvmPlatforms.unspecifiedJvmPlatform, configuration = configuration, ) - val reporter = DiagnosticReporterFactory.createReporter() + val reporter = DiagnosticReporterFactory.createReporter(messageCollector) val globalScope = GlobalSearchScope.allScope(project) val packagePartProvider = environment.createPackagePartProvider(globalScope) @@ -133,12 +129,22 @@ internal class KotlinFirLoader( getPackagePartProviderFn = { packagePartProvider }, ) - return compileModuleToAnalyzedFir( - input = input, - projectEnvironment = projectEnvironment, - previousStepsSymbolProviders = emptyList(), - incrementalExcludesScope = null, - diagnosticsReporter = reporter, + /* + projectEnvironment: VfsBasedProjectEnvironment, + messageCollector: MessageCollector, + compilerConfiguration: CompilerConfiguration, + input: ModuleCompilerInput, + diagnosticsReporter: BaseDiagnosticsCollector, + incrementalExcludesScope: AbstractProjectFileSearchScope?, + */ + @OptIn(IncrementalCompilationApi::class) // We are not within the Kotlin compiler. + return compileModuleToAnalyzedFirViaLightTreeIncrementally( + projectEnvironment, + messageCollector, + configuration, + input, + reporter, + null, ) } diff --git a/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt b/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt index 0410fa2416..0b8f754e3f 100644 --- a/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt +++ b/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt @@ -16,5 +16,6 @@ package app.cash.zipline.profiler internal actual object DefaultProfilerClock : ProfilerClock { + @Suppress("DEPRECATION_ERROR") actual override val nanoTime: Long get() = kotlin.system.getTimeNanos() }