Skip to content

Commit

Permalink
Fix compiler issue with Kotlin 1.9 and Backlinks (#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelchior authored Aug 2, 2023
1 parent 80313b9 commit e8bff87
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixed
* Rare corruption causing 'Invalid streaming format cookie'-exception. Typically following compact, convert or copying to a new file. (Issue [#1440](https://github.com/realm/realm-kotlin/issues/1440))
* Compiler error when using Kotlin 1.9.0 and backlinks. (Issue [#1469](https://github.com/realm/realm-kotlin/issues/1469))

### Compatibility
* File format: Generates Realms with file format v23.
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object Versions {
const val jvmTarget = "1.8"
// When updating the Kotlin version, also remember to update /examples/min-android-sample/build.gradle.kts
const val kotlin = "1.8.21" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details
const val latestKotlin = "1.9.0-Beta" // https://kotlinlang.org/docs/eap.html#build-details
const val latestKotlin = "1.9.0" // https://kotlinlang.org/docs/eap.html#build-details
const val kotlinCompileTesting = "1.5.0" // https://github.com/tschuchortdev/kotlin-compile-testing
const val ktlint = "0.45.2" // https://github.com/pinterest/ktlint
const val ktor = "2.1.2" // https://github.com/ktorio/ktor
Expand Down
1 change: 1 addition & 0 deletions examples/kmm-sample/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false

kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package io.realm.example.kmmsample

import io.realm.kotlin.ext.backlinks
import io.realm.kotlin.ext.realmListOf
import io.realm.kotlin.types.ObjectId
import io.realm.kotlin.types.RealmInstant
Expand Down Expand Up @@ -83,4 +84,7 @@ class AllTypes : RealmObject {
var objectIdRealmList: RealmList<ObjectId> = realmListOf(ObjectId.create())
var objectIdRealmListNullable: RealmList<ObjectId?> = realmListOf(null)
var objectRealmList: RealmList<AllTypes> = realmListOf()

// Special types
val parent by backlinks(AllTypes::objectField)
}
2 changes: 1 addition & 1 deletion packages/plugin-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "${Versions.jvmTarget}"
freeCompilerArgs = listOf("-Xjvm-default=enable")
freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ fun getBacklinksTargetPropertyType(declaration: IrProperty): IrType? {
fun getLinkingObjectPropertyName(backingField: IrField): String {
(backingField.initializer!!.expression as IrCall).let { irCall ->
val propertyReference = irCall.getValueArgument(0) as IrPropertyReference
val targetProperty = propertyReference.symbol.owner
val targetProperty: IrProperty = propertyReference.symbol.owner
return if (targetProperty.hasAnnotation(PERSISTED_NAME_ANNOTATION)) {
SchemaProperty.getPersistedName(targetProperty)
} else {
propertyReference.referencedName.identifier
targetProperty.name.identifier
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class GenerationExtensionTest {
componentRegistrars = plugins
inheritClassPath = true
kotlincArguments = listOf(
"-Xjvm-default=enable",
"-Xjvm-default=all-compatibility",
"-Xdump-directory=${inputs.outputDir()}",
"-Xphases-to-dump-after=ValidateIrBeforeLowering"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ object Compiler {
messageOutputStream = System.out
componentRegistrars = plugins
inheritClassPath = true
kotlincArguments = listOf("-Xjvm-default=enable")
kotlincArguments = listOf("-Xjvm-default=all-compatibility")
}.compile()
}

0 comments on commit e8bff87

Please sign in to comment.