diff --git a/CHANGELOG.md b/CHANGELOG.md
index ddc4f44200..9c8e07bc60 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 2.2.0 (2024-09-13)
+## 2.3.0-SNAPSHOT (YYYY-MM-DD)
### Breaking Changes
* None.
@@ -19,6 +19,7 @@
* [Sync] Client reset cycle detection now checks if the previous recovery attempt was made by the same core version, and if not attempts recovery again (Core issue [realm/realm-core#7944](https://github.com/realm/realm-core/pull/7944)).
### Fixed
+* Via https://github.com/realm/realm-kotlin/pull/1826. Fix compiler crash caused by a change in Kotlin 2.0.20. (Issue [#1825](https://github.com/realm/realm-kotlin/issues/1825)). Thanks @KitsuneAlex.
* Comparing a numeric property with an argument list containing a string would throw. (Core issue [realm/realm-core#7714](https://github.com/realm/realm-core/issues/7714), since v2.0.0).
* After compacting, a file upgrade would be triggered. This could cause loss of data if schema mode is SoftResetFile (Core issue [realm/realm-core#7747](https://github.com/realm/realm-core/issues/7747), since v1.15.0).
* Encrypted files on Windows had a maximum size of 2GB even on x64 due to internal usage of `off_t`, which is a 32-bit type on 64-bit Windows (Core issue [realm/realm-core#7698](https://github.com/realm/realm-core/pull/7698)).
@@ -46,7 +47,7 @@
* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
* Realm Studio 15.0.0 or above is required to open Realms created by this version.
* This release is compatible with the following Kotlin releases:
- * Kotlin 2.0.0 and above. Support for experimental K2-compilation with `kotlin.experimental.tryK2=true`.
+ * Kotlin 2.0.20 and above. Support for experimental K2-compilation with `kotlin.experimental.tryK2=true`.
* Ktor 2.1.2 and above.
* Coroutines 1.7.0 and above.
* AtomicFu 0.18.3 and above.
diff --git a/README.md b/README.md
index f6bce16713..83478678f9 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/io/realm/kotlin/io.realm.kotlin.gradle.plugin/maven-metadata.xml.svg?colorB=ff6b00&label=Gradle%20Plugin%20Portal)](https://plugins.gradle.org/plugin/io.realm.kotlin)
[![Maven Central](https://img.shields.io/maven-central/v/io.realm.kotlin/gradle-plugin?colorB=4dc427&label=Maven%20Central)](https://search.maven.org/artifact/io.realm.kotlin/gradle-plugin)
-[![Kotlin](https://img.shields.io/badge/kotlin-2.0.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
+[![Kotlin](https://img.shields.io/badge/kotlin-2.0.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![License](https://img.shields.io/badge/License-Apache-blue.svg)](https://github.com/realm/realm-kotlin/blob/master/LICENSE)
@@ -328,6 +328,7 @@ SDK supports. In the matrix below, you will find the minimum supported version f
| Realm Version | Requirements |
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| 2.3.0 |
- Kotlin 2.0.20+
- AtomicFu 0.18.3+.
- Ktor 2.1.2+.
- Coroutines 1.7.0+.
- Gradle 7.2 - 8.5
- The new memory model only.
|
| 2.0.0 | - Kotlin 2.0.0+
- AtomicFu 0.18.3+.
- Ktor 2.1.2+.
- Coroutines 1.7.0+.
- Gradle 7.2 - 8.5
- The new memory model only.
|
| 1.16.0 | - Kotlin 1.9.0+
- AtomicFu 0.18.3+.
- Ktor 2.1.2+.
- Coroutines 1.7.0+.
- Gradle 6.8.3 - 8.5
- The new memory model only.
|
| 1.15.0 | - Kotlin 1.9.0+
- AtomicFu 0.18.3+.
- Ktor 2.1.2+.
- Coroutines 1.7.0+.
- Gradle 6.8.3 - 8.5
- The new memory model only.
|
diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt
index bc894e6954..8c259ea770 100644
--- a/buildSrc/src/main/kotlin/Config.kt
+++ b/buildSrc/src/main/kotlin/Config.kt
@@ -62,7 +62,7 @@ val HOST_OS: OperatingSystem = findHostOs()
object Realm {
val ciBuild = (System.getenv("CI") != null)
- const val version = "2.2.0"
+ const val version = "2.3.0-SNAPSHOT"
const val group = "io.realm.kotlin"
const val projectUrl = "https://realm.io"
const val pluginPortalId = "io.realm.kotlin"
@@ -123,15 +123,15 @@ object Versions {
const val junit = "4.13.2" // https://mvnrepository.com/artifact/junit/junit
const val kbson = "0.4.0" // https://github.com/mongodb/kbson
// When updating the Kotlin version, also remember to update /examples/min-android-sample/build.gradle.kts
- const val kotlin = "2.0.0" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details
+ const val kotlin = "2.0.20" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details
const val kotlinJvmTarget = "1.8" // Which JVM bytecode version is kotlin compiled to.
- const val latestKotlin = "2.0.0" // https://kotlinlang.org/docs/eap.html#build-details
- const val kotlinCompileTesting = "0.5.0-alpha07" // https://github.com/zacsweers/kotlin-compile-testing
+ const val latestKotlin = "2.0.20" // https://kotlinlang.org/docs/eap.html#build-details
+ const val kotlinCompileTesting = "0.5.1" // https://github.com/zacsweers/kotlin-compile-testing
const val ktlint = "0.45.2" // https://github.com/pinterest/ktlint
const val ktor = "2.3.12" // https://github.com/ktorio/ktor
const val multidex = "2.0.1" // https://developer.android.com/jetpack/androidx/releases/multidex
- const val nexusPublishPlugin = "1.1.0" // https://github.com/gradle-nexus/publish-plugin
- const val okio = "3.2.0" // https://square.github.io/okio/#releases
+ const val nexusPublishPlugin = "1.3.0" // https://github.com/gradle-nexus/publish-plugin
+ const val okio = "3.9.0" // https://square.github.io/okio/#releases
const val relinker = "1.4.5" // https://github.com/KeepSafe/ReLinker
const val serialization = "1.7.1" // https://kotlinlang.org/docs/releases.html#release-details
const val shadowJar = "6.1.0" // https://mvnrepository.com/artifact/com.github.johnrengelman.shadow/com.github.johnrengelman.shadow.gradle.plugin?repo=gradle-plugins
diff --git a/examples/min-android-sample/build.gradle.kts b/examples/min-android-sample/build.gradle.kts
index a42d343dd7..a5bacf7088 100644
--- a/examples/min-android-sample/build.gradle.kts
+++ b/examples/min-android-sample/build.gradle.kts
@@ -16,7 +16,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.3")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.20")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
diff --git a/integration-tests/gradle/gradle72-test/build.gradle.kts b/integration-tests/gradle/gradle72-test/build.gradle.kts
index 377571d6c5..6b3b4ecafa 100644
--- a/integration-tests/gradle/gradle72-test/build.gradle.kts
+++ b/integration-tests/gradle/gradle72-test/build.gradle.kts
@@ -26,6 +26,13 @@ buildscript {
it.substringAfter("\"").substringBefore("\"")
}
+ extra["kotlinVersion"] = file("${rootProject.rootDir.absolutePath}/../../../buildSrc/src/main/kotlin/Config.kt")
+ .readLines()
+ .first { it.contains("const val kotlin") }
+ .let {
+ it.substringAfter("\"").substringBefore("\"")
+ }
+
repositories {
maven(url = "file://${rootProject.rootDir.absolutePath}/../../../packages/build/m2-buildrepo")
gradlePluginPortal()
@@ -34,7 +41,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.3")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["kotlinVersion"]}")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
diff --git a/integration-tests/gradle/gradle75-test/build.gradle.kts b/integration-tests/gradle/gradle75-test/build.gradle.kts
index 67f40a8d13..816b752028 100644
--- a/integration-tests/gradle/gradle75-test/build.gradle.kts
+++ b/integration-tests/gradle/gradle75-test/build.gradle.kts
@@ -26,6 +26,13 @@ buildscript {
it.substringAfter("\"").substringBefore("\"")
}
+ extra["kotlinVersion"] = file("${rootProject.rootDir.absolutePath}/../../../buildSrc/src/main/kotlin/Config.kt")
+ .readLines()
+ .first { it.contains("const val kotlin") }
+ .let {
+ it.substringAfter("\"").substringBefore("\"")
+ }
+
repositories {
maven(url = "file://${rootProject.rootDir.absolutePath}/../../../packages/build/m2-buildrepo")
gradlePluginPortal()
@@ -34,7 +41,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.0")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["kotlinVersion"]}")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
diff --git a/integration-tests/gradle/gradle8-test/build.gradle.kts b/integration-tests/gradle/gradle8-test/build.gradle.kts
index 43dc5ee957..767b12cee9 100644
--- a/integration-tests/gradle/gradle8-test/build.gradle.kts
+++ b/integration-tests/gradle/gradle8-test/build.gradle.kts
@@ -26,6 +26,13 @@ buildscript {
it.substringAfter("\"").substringBefore("\"")
}
+ extra["kotlinVersion"] = file("${rootProject.rootDir.absolutePath}/../../../buildSrc/src/main/kotlin/Config.kt")
+ .readLines()
+ .first { it.contains("const val kotlin") }
+ .let {
+ it.substringAfter("\"").substringBefore("\"")
+ }
+
repositories {
maven(url = "file://${rootProject.rootDir.absolutePath}/../../../packages/build/m2-buildrepo")
gradlePluginPortal()
@@ -34,7 +41,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.0")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["kotlinVersion"]}")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
diff --git a/integration-tests/gradle/gradle85-test/build.gradle.kts b/integration-tests/gradle/gradle85-test/build.gradle.kts
index 43dc5ee957..767b12cee9 100644
--- a/integration-tests/gradle/gradle85-test/build.gradle.kts
+++ b/integration-tests/gradle/gradle85-test/build.gradle.kts
@@ -26,6 +26,13 @@ buildscript {
it.substringAfter("\"").substringBefore("\"")
}
+ extra["kotlinVersion"] = file("${rootProject.rootDir.absolutePath}/../../../buildSrc/src/main/kotlin/Config.kt")
+ .readLines()
+ .first { it.contains("const val kotlin") }
+ .let {
+ it.substringAfter("\"").substringBefore("\"")
+ }
+
repositories {
maven(url = "file://${rootProject.rootDir.absolutePath}/../../../packages/build/m2-buildrepo")
gradlePluginPortal()
@@ -34,7 +41,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.0")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["kotlinVersion"]}")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/IrUtils.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/IrUtils.kt
index 2fe6836975..8c8d6d617b 100644
--- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/IrUtils.kt
+++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/IrUtils.kt
@@ -97,7 +97,6 @@ import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.IrTypeArgument
import org.jetbrains.kotlin.ir.types.getClass
import org.jetbrains.kotlin.ir.types.impl.IrAbstractSimpleType
-import org.jetbrains.kotlin.ir.types.impl.IrTypeBase
import org.jetbrains.kotlin.ir.types.makeNullable
import org.jetbrains.kotlin.ir.types.typeWith
import org.jetbrains.kotlin.ir.util.classId
@@ -633,7 +632,7 @@ fun getCollectionElementType(backingFieldType: IrType): IrType? {
@Suppress("UNCHECKED_CAST")
val values: List = args.get(backingFieldType) as List
if (values.isNotEmpty()) {
- return (values[0] as IrTypeBase).type
+ return (values[0] as IrType).type
}
}
return null
diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt
index c01a74dbcd..91e726f159 100644
--- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt
+++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.backend.common.CompilationException
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.runOnFilePostfix
-import org.jetbrains.kotlin.backend.common.wrapWithCompilationException
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFile
@@ -76,15 +75,25 @@ private class RealmModelLowering(private val pluginContext: IrPluginContext) : C
// Unfortunately we cannot access the IR element of e uniformly across 1.9 and 2.0 so
// leaving it as null. Hopefully the embedded cause will give the appropriate pointers
// to fix this.
- throw e.wrapWithCompilationException("Internal error in realm lowering", it, null)
+ throw CompilationException(
+ "Internal error in realm lowering : ${this::class.qualifiedName}: ${e.message}",
+ it,
+ null,
+ cause = e
+ ).apply {
+ stackTrace = e.stackTrace
+ }
} catch (e: KotlinExceptionWithAttachments) {
throw e
} catch (e: Throwable) {
- throw e.wrapWithCompilationException(
- "Internal error in file lowering",
+ throw CompilationException(
+ "Internal error in file lowering : ${this::class.qualifiedName}: ${e.message}",
it,
- null
- )
+ null,
+ cause = e
+ ).apply {
+ stackTrace = e.stackTrace
+ }
}
}
diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt
index c85173b3f1..d5a11767f2 100644
--- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt
+++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.backend.common.DeclarationContainerLoweringPass
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.runOnFilePostfix
-import org.jetbrains.kotlin.backend.common.wrapWithCompilationException
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclarationContainer
import org.jetbrains.kotlin.ir.declarations.IrFile
@@ -180,15 +179,25 @@ private class SyncLowering(private val pluginContext: IrPluginContext, private v
// Unfortunately we cannot access the IR element of e uniformly across 1.9 and 2.0 so
// leaving it as null. Hopefully the embedded cause will give the appropriate pointers
// to fix this.
- throw e.wrapWithCompilationException("Internal error in realm lowering", it, null)
+ throw CompilationException(
+ "Internal error in realm lowering : ${this::class.qualifiedName}: ${e.message}",
+ it,
+ null,
+ cause = e
+ ).apply {
+ stackTrace = e.stackTrace
+ }
} catch (e: KotlinExceptionWithAttachments) {
throw e
} catch (e: Throwable) {
- throw e.wrapWithCompilationException(
- "Internal error in file lowering",
+ throw CompilationException(
+ "Internal error in file lowering : ${this::class.qualifiedName}: ${e.message}",
it,
- null
- )
+ null,
+ cause = e
+ ).apply {
+ stackTrace = e.stackTrace
+ }
}
}