Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler issue with Kotlin 1.9 and Backlinks #1470

Merged
merged 3 commits into from
Aug 2, 2023
Merged
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
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()
}