Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.1.0 (2025-05-15)

### Breaking Changes
* None.

### Enhancements
* None.

### Fixed
Fix compiler crash after update to Kotlin 2.1.21 (Issue [#1857](https://github.com/realm/realm-kotlin/issues/1857))

## 3.0.0 (2024-10-03)

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ tasks {
register<GradleBuild>("mavenCentralUpload") {
description = "Push all Realm artifacts to Maven Central"
group = "Publishing"
buildFile = file("${rootDir}/packages/build.gradle.kts")
dir = file("${rootDir}/packages/build.gradle.kts")
tasks = listOf("publishToSonatype")
copyProperties(this)
}

// TODO Verify we can actually use these debug symbols
val archiveDebugSymbols by register("archiveDebugSymbols", Zip::class) {
archiveName = "realm-kotlin-jni-libs-unstripped-${currentVersion}.zip"
destinationDir = releaseMetaDataDir
archiveFileName.set("realm-kotlin-jni-libs-unstripped-${currentVersion}.zip")
destinationDirectory.set(releaseMetaDataDir)
from("${rootDir}/packages/cinterop/build/intermediates/merged_native_libs/release/out/lib") {
include("**/*.so")
}
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ val HOST_OS: OperatingSystem = findHostOs()

object Realm {
val ciBuild = (System.getenv("CI") != null)
const val version = "3.0.0"
const val version = "3.1.0"
const val group = "io.realm.kotlin"
const val projectUrl = "https://realm.io"
const val pluginPortalId = "io.realm.kotlin"
Expand Down Expand Up @@ -123,18 +123,18 @@ 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.20" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details
const val kotlin = "2.1.21" // 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.20" // https://kotlinlang.org/docs/eap.html#build-details
const val kotlinCompileTesting = "0.5.1" // https://github.com/zacsweers/kotlin-compile-testing
const val latestKotlin = "2.1.21" // https://kotlinlang.org/docs/eap.html#build-details
const val kotlinCompileTesting = "0.7.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.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
const val shadowJar = "8.1.1" // https://mvnrepository.com/artifact/com.github.johnrengelman.shadow/com.github.johnrengelman.shadow.gradle.plugin?repo=gradle-plugins
const val snakeYaml = "1.33" // https://github.com/snakeyaml/snakeyaml
val sourceCompatibilityVersion = JavaVersion.VERSION_1_8 // Language level of any Java source code.
val targetCompatibilityVersion = JavaVersion.VERSION_1_8 // Version of generated JVM bytecode from Java files.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion examples/min-android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.20")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.21")
classpath("io.realm.kotlin:gradle-plugin:${rootProject.extra["realmVersion"]}")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 24 additions & 0 deletions packages/cinterop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,28 @@ abstract class CmakeVersionProvider : ValueSource<String, ValueSourceParameters.
// enable execution optimizations for generateSdkVersionConstant
afterEvaluate {
tasks.getByName("sourcesJar").dependsOn(generateSdkVersionConstant)
tasks.named("androidDebugSourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("androidReleaseSourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("jvmSourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("iosX64SourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("iosArm64SourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("iosSimulatorArm64SourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("macosArm64SourcesJar") {
dependsOn("generateSdkVersionConstant")
}
tasks.named("macosX64SourcesJar") {
dependsOn("generateSdkVersionConstant")
}
}
2 changes: 1 addition & 1 deletion packages/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
Expand Down Expand Up @@ -222,7 +223,7 @@ val FirClassSymbol<*>.isBaseRealmObject: Boolean
)
}
// After SUPERTYPES stage
is FirResolvedTypeRef -> typeRef.type.classId in realmObjectClassIds
is FirResolvedTypeRef -> typeRef.coneType.classId in realmObjectClassIds
else -> false
}
}
Expand Down Expand Up @@ -414,7 +415,7 @@ data class SchemaProperty(
companion object {
fun getPersistedName(declaration: IrProperty): String {
@Suppress("UNCHECKED_CAST")
return (declaration.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl<String>).value
return (declaration.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConst).value!!.toString()
}
}
}
Expand All @@ -436,9 +437,6 @@ internal fun <T : IrExpression> buildOf(
type = containerType.typeWith(elementType),
symbol = function,
typeArgumentsCount = 1,
valueArgumentsCount = 1,
origin = null,
superQualifierSymbol = null
).apply {
putTypeArgument(index = 0, type = elementType)
putValueArgument(
Expand Down Expand Up @@ -583,11 +581,11 @@ fun IrBlockBuilder.createSafeCallConstruction(
statements += receiverVariable
statements += IrWhenImpl(startOffset, endOffset, resultType).apply {
val condition = IrCallImpl(
startOffset, endOffset, context.irBuiltIns.booleanType,
context.irBuiltIns.eqeqSymbol,
valueArgumentsCount = 2,
typeArgumentsCount = 0,
origin = IrStatementOrigin.EQEQ
startOffset = startOffset,
endOffset = endOffset,
type = context.irBuiltIns.booleanType,
origin = IrStatementOrigin.EQEQ,
symbol = context.irBuiltIns.eqeqSymbol,
).apply {
putValueArgument(0, IrGetValueImpl(startOffset, endOffset, receiverVariableSymbol))
putValueArgument(
Expand Down Expand Up @@ -674,7 +672,7 @@ fun getLinkingObjectPropertyName(backingField: IrField): String {
fun getSchemaClassName(clazz: IrClass): String {
return if (clazz.hasAnnotation(PERSISTED_NAME_ANNOTATION)) {
@Suppress("UNCHECKED_CAST")
return (clazz.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl<String>).value
return (clazz.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConst).value!!.toString()
} else {
clazz.name.identifier
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte
type = pluginContext.irBuiltIns.booleanType,
symbol = realmEquals.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 2
).apply {
dispatchReceiver = irGetObject(realmObjectHelper.symbol)
putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol))
Expand All @@ -96,7 +95,6 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte
type = pluginContext.irBuiltIns.intType,
symbol = realmHashCode.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 1
).apply {
dispatchReceiver = irGetObject(realmObjectHelper.symbol)
putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol))
Expand All @@ -115,7 +113,6 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte
type = pluginContext.irBuiltIns.stringType,
symbol = realmToString.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 1
).apply {
dispatchReceiver = irGetObject(realmObjectHelper.symbol)
putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.fromSymbolOwner
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.defaultType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrPropertyReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.expressions.impl.fromSymbolOwner
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
Expand Down Expand Up @@ -303,7 +304,6 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi
type = companionFieldsType,
symbol = mapOf,
typeArgumentsCount = 2,
valueArgumentsCount = 1,
origin = null,
superQualifierSymbol = null
).apply {
Expand Down Expand Up @@ -503,7 +503,6 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi
type = classInfoClass.defaultType,
symbol = classInfoCreateMethod.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 4
).apply {
dispatchReceiver = irGetObject(classInfoClass.companionObject()!!.symbol)
var arg = 0
Expand Down Expand Up @@ -677,7 +676,7 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi
} ?: irNull(pluginContext.irBuiltIns.kClassClass.typeWith(typedRealmObjectInterface.defaultType).makeNullable())

// Define the link target. Empty string if there is none.
val linkPropertyName: IrConst<String> = if (type == linkingObjectType) {
val linkPropertyName: IrConst = if (type == linkingObjectType) {
val targetPropertyName = getLinkingObjectPropertyName(backingField)
irString(targetPropertyName)
} else {
Expand All @@ -690,7 +689,6 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi
type = propertyClass.defaultType,
symbol = propertyCreateMethod,
typeArgumentsCount = 0,
valueArgumentsCount = 10
).apply {
var arg = 0
// Persisted name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio
classSymbol: FirClassSymbol<*>,
context: MemberGenerationContext
): Set<Name> {
if (classSymbol.isCompanion && (classSymbol.getContainingClassSymbol(session) as? FirClassSymbol<*>)?.isBaseRealmObject == true) {
if (classSymbol.isCompanion && (classSymbol.getContainingClassSymbol() as? FirClassSymbol<*>)?.isBaseRealmObject == true) {
return setOf(
Names.REALM_OBJECT_COMPANION_SCHEMA_METHOD,
Names.REALM_OBJECT_COMPANION_NEW_INSTANCE_METHOD,
Expand All @@ -88,7 +88,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio
owner,
RealmPluginGeneratorKey,
callableId.callableName,
session.builtinTypes.anyType.type,
session.builtinTypes.anyType.coneType,
).symbol
)

Expand All @@ -98,7 +98,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio
owner,
RealmPluginGeneratorKey,
callableId.callableName,
session.builtinTypes.anyType.type
session.builtinTypes.anyType.coneType
).symbol
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s
owner,
RealmPluginGeneratorKey,
callableId.callableName,
session.builtinTypes.stringType.type,
session.builtinTypes.stringType.coneType,
) {
modality = Modality.OPEN
}.symbol
Expand All @@ -78,10 +78,10 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s
owner,
RealmPluginGeneratorKey,
callableId.callableName,
session.builtinTypes.booleanType.type,
session.builtinTypes.booleanType.coneType,
) {
modality = Modality.OPEN
valueParameter(Name.identifier("other"), session.builtinTypes.nullableAnyType.type)
valueParameter(Name.identifier("other"), session.builtinTypes.nullableAnyType.coneType)
}.symbol
)
Names.REALM_OBJECT_HASH_CODE ->
Expand All @@ -90,7 +90,7 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s
owner,
RealmPluginGeneratorKey,
callableId.callableName,
session.builtinTypes.intType.type,
session.builtinTypes.intType.coneType,
) {
modality = Modality.OPEN
}.symbol
Expand Down