Skip to content

Commit

Permalink
Upgrade to Kotlin 1.9.20 (#1158)
Browse files Browse the repository at this point in the history
* Upgrade to Kotlin 1.9.20

* Track some changes in IR APIs

* cklib 0.3.0

* Patch quickjs.c to work around an error in Clang

    error: implicit conversion from 'long long' to 'double' changes
           value from 9223372036854775807 to 9223372036854775808
           [-Werror,-Wimplicit-const-int-float-conversion]
                    else if (d > INT64_MAX)
                               ~ ^~~~~~~~~

* Track a Fir API change in KotlinFirLoader

* Track JS module dependency changes

* apiDump

* Update kctfork

https://github.com/ZacSweers/kotlin-compile-testing/blob/main/CHANGELOG.md#040

* Use a pre-release Compose compiler with the WorldClock sample
  • Loading branch information
squarejesse authored Nov 2, 2023
1 parent 4273fed commit 6ff33bb
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ components.

| Component | Supported Version | Notes |
|:---------------------|:------------------|:----------------------------------------------------------------------------|
| Kotlin Compiler | 1.9.0 | Kotlin compiler plugins do not yet have a stable API. |
| Kotlin Serialization | 1.5.1 | For `decodeFromDynamic()`, `encodeToDynamic()`, and `ContextualSerializer`. |
| Kotlin Compiler | 1.9.20 | Kotlin compiler plugins do not yet have a stable API. |
| Kotlin Serialization | 1.6.0 | For `decodeFromDynamic()`, `encodeToDynamic()`, and `ContextualSerializer`. |
| Kotlin Coroutines | 1.7.3 | For `transformLatest()` and `Deferred.getCompleted()`. |

We intend to use stable APIs as soon as they are available.
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
androidx-compose = "1.5.4"
androidx-compose-compiler = "1.5.2"
androidx-compose-compiler = "1.5.4-dev-k1.9.20-50f08dfa4b4"
auto-service="1.1.1"
compileSdk = "34"
http4k = "4.48.0.0"
kotlin = "1.9.0"
kotlin = "1.9.20"
kotlinx-coroutines = "1.7.3"
kotlinx-serialization = "1.6.0"
okHttp = "4.12.0"
Expand Down Expand Up @@ -32,15 +32,15 @@ assertk = "com.willowtreeapps.assertk:assertk:0.27.0"
auto-service-compiler = { module = "com.google.auto.service:auto-service", version.ref = "auto-service" }
auto-service-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "auto-service" }
binary-compatibility-validator-gradle-plugin = { module = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin", version = "0.13.2" }
cklib-gradle-plugin = { module = "co.touchlab:cklib-gradle-plugin", version = "0.2.4" }
cklib-gradle-plugin = { module = "co.touchlab:cklib-gradle-plugin", version = "0.3.0" }
coil-compose = { module = "io.coil-kt:coil-compose", version = "2.5.0" }
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.10" }
duktape = { module = "com.squareup.duktape:duktape-android", version = "1.4.0" }
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.3.2" }
kotlin-compile-testing = { module = "dev.zacsweers.kctfork:core", version = "0.4.0" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect" }
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
Expand Down
6 changes: 6 additions & 0 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ buildscript {
mavenCentral()
google()
gradlePluginPortal()

// TODO: remove this once a stable Compose compiler is released for Kotlin 1.9.20.
maven(url = "https://androidx.dev/storage/compose-compiler/repository/")
}
}

allprojects {
repositories {
mavenCentral()
google()

// TODO: remove this once a stable Compose compiler is released for Kotlin 1.9.20.
maven(url = "https://androidx.dev/storage/compose-compiler/repository/")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
Expand All @@ -28,7 +29,6 @@ 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.GroupedKtSources
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.ModuleCompilerEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.ModuleCompilerInput
import org.jetbrains.kotlin.cli.jvm.compiler.pipeline.compileModuleToAnalyzedFir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ fun compile(
): JvmCompilationResult {
return KotlinCompilation().apply {
sources = sourceFiles
useIR = true
compilerPluginRegistrars = listOf(plugin)
inheritClassPath = true
}.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.createBlockBody
import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
Expand Down Expand Up @@ -302,24 +303,24 @@ fun irVal(
this.initializer = initializerBuilder.initializer()
}

result.getter = irFactory.createFunction(
result.getter = irFactory.createSimpleFunction(
startOffset = declaringClass.startOffset,
endOffset = declaringClass.endOffset,
origin = IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR,
name = Name.special("<get-${propertyName.identifier}>"),
visibility = overriddenProperty?.owner?.getter?.visibility ?: DescriptorVisibilities.PRIVATE,
isExternal = false,
symbol = IrSimpleFunctionSymbolImpl(),
modality = Modality.FINAL,
returnType = propertyType,
isInline = false,
isExpect = false,
returnType = propertyType,
modality = Modality.FINAL,
symbol = IrSimpleFunctionSymbolImpl(),
isTailrec = false,
isSuspend = false,
isOperator = false,
isInfix = false,
isExpect = false,
isFakeOverride = false,
isExternal = false,
containerSource = null,
isFakeOverride = false,
).apply {
parent = declaringClass
correspondingPropertySymbol = result.symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ internal expect fun getEnv(name: String): String?
@OptIn(EngineApi::class)
fun Zipline.loadTestingJs() {
// Load modules in topologically-sorted order. In production the zipline-manifest does this.
loadJsModuleFromResource("./kotlin-kotlin-stdlib-js-ir.js")
loadJsModuleFromResource("./kotlin-kotlin-stdlib.js")
loadJsModuleFromResource("./88b0986a7186d029-atomicfu-js-ir.js")
loadJsModuleFromResource("./kotlin-kotlinx-atomicfu-runtime-js-ir.js")
loadJsModuleFromResource("./kotlinx-serialization-kotlinx-serialization-core.js")
loadJsModuleFromResource("./kotlinx-serialization-kotlinx-serialization-json.js")
loadJsModuleFromResource("./kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js")
loadJsModuleFromResource("./kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.js")
loadJsModuleFromResource("./zipline-root-zipline.js")
loadJsModuleFromResource("./zipline-root-zipline-testing.js")
quickJs.evaluate("globalThis['testing'] = require('./zipline-root-zipline-testing.js');")
Expand Down
6 changes: 0 additions & 6 deletions zipline/api/android/zipline.api
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public abstract interface class app/cash/zipline/ZiplineFunction {

public final class app/cash/zipline/ZiplineManifest {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Companion;
public synthetic fun <init> (ILapp/cash/zipline/ZiplineManifest$Unsigned;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public synthetic fun <init> (Lapp/cash/zipline/ZiplineManifest$Unsigned;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lapp/cash/zipline/ZiplineManifest$Unsigned;
public final fun component2 ()Ljava/util/Map;
Expand Down Expand Up @@ -233,7 +232,6 @@ public final class app/cash/zipline/ZiplineManifest {
public final fun getVersion ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand All @@ -258,7 +256,6 @@ public final class app/cash/zipline/ZiplineManifest$Companion {

public final class app/cash/zipline/ZiplineManifest$Module {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Module$Companion;
public synthetic fun <init> (ILjava/lang/String;Lokio/ByteString;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Lokio/ByteString;Ljava/util/List;)V
public synthetic fun <init> (Ljava/lang/String;Lokio/ByteString;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/lang/String;
Expand All @@ -272,7 +269,6 @@ public final class app/cash/zipline/ZiplineManifest$Module {
public final fun getUrl ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest$Module;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$Module$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand All @@ -293,7 +289,6 @@ public final class app/cash/zipline/ZiplineManifest$Module$Companion {
public final class app/cash/zipline/ZiplineManifest$Unsigned {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Unsigned$Companion;
public fun <init> ()V
public synthetic fun <init> (ILjava/util/Map;Ljava/lang/Long;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/util/Map;Ljava/lang/Long;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/util/Map;Ljava/lang/Long;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
Expand All @@ -307,7 +302,6 @@ public final class app/cash/zipline/ZiplineManifest$Unsigned {
public final fun getSignatures ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest$Unsigned;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$Unsigned$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand Down
6 changes: 0 additions & 6 deletions zipline/api/jvm/zipline.api
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public abstract interface class app/cash/zipline/ZiplineFunction {

public final class app/cash/zipline/ZiplineManifest {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Companion;
public synthetic fun <init> (ILapp/cash/zipline/ZiplineManifest$Unsigned;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public synthetic fun <init> (Lapp/cash/zipline/ZiplineManifest$Unsigned;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lapp/cash/zipline/ZiplineManifest$Unsigned;
public final fun component2 ()Ljava/util/Map;
Expand Down Expand Up @@ -233,7 +232,6 @@ public final class app/cash/zipline/ZiplineManifest {
public final fun getVersion ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand All @@ -258,7 +256,6 @@ public final class app/cash/zipline/ZiplineManifest$Companion {

public final class app/cash/zipline/ZiplineManifest$Module {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Module$Companion;
public synthetic fun <init> (ILjava/lang/String;Lokio/ByteString;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/lang/String;Lokio/ByteString;Ljava/util/List;)V
public synthetic fun <init> (Ljava/lang/String;Lokio/ByteString;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/lang/String;
Expand All @@ -272,7 +269,6 @@ public final class app/cash/zipline/ZiplineManifest$Module {
public final fun getUrl ()Ljava/lang/String;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest$Module;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$Module$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand All @@ -293,7 +289,6 @@ public final class app/cash/zipline/ZiplineManifest$Module$Companion {
public final class app/cash/zipline/ZiplineManifest$Unsigned {
public static final field Companion Lapp/cash/zipline/ZiplineManifest$Unsigned$Companion;
public fun <init> ()V
public synthetic fun <init> (ILjava/util/Map;Ljava/lang/Long;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
public fun <init> (Ljava/util/Map;Ljava/lang/Long;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/util/Map;Ljava/lang/Long;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
Expand All @@ -307,7 +302,6 @@ public final class app/cash/zipline/ZiplineManifest$Unsigned {
public final fun getSignatures ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public static final synthetic fun write$Self (Lapp/cash/zipline/ZiplineManifest$Unsigned;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
}

public final class app/cash/zipline/ZiplineManifest$Unsigned$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
Expand Down
6 changes: 4 additions & 2 deletions zipline/native/quickjs/quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
#define CONFIG_STACK_CHECK
#endif

/* Zipline-patched for https://github.com/bellard/quickjs/pull/196 */
static double const INT64_MAX_PLUS_ONE_AS_DOUBLE = 9223372036854775808.0;

/* dump object free */
//#define DUMP_FREE
Expand Down Expand Up @@ -10738,7 +10740,7 @@ static int JS_ToInt64SatFree(JSContext *ctx, int64_t *pres, JSValue val)
} else {
if (d < INT64_MIN)
*pres = INT64_MIN;
else if (d > INT64_MAX)
else if (d >= INT64_MAX_PLUS_ONE_AS_DOUBLE)
*pres = INT64_MAX;
else
*pres = (int64_t)d;
Expand Down Expand Up @@ -53819,7 +53821,7 @@ static JSValue js_atomics_wait(JSContext *ctx,
}
if (JS_ToFloat64(ctx, &d, argv[3]))
return JS_EXCEPTION;
if (isnan(d) || d > INT64_MAX)
if (isnan(d) || d >= INT64_MAX_PLUS_ONE_AS_DOUBLE)
timeout = INT64_MAX;
else if (d < 0)
timeout = 0;
Expand Down

0 comments on commit 6ff33bb

Please sign in to comment.