diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt index f1029cad92c..6e7e9b7bd2b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt @@ -87,4 +87,7 @@ class JvmStubGeneratorExtensions : StubGeneratorExtensions() { classNameOverride[it] = facadeName } } + + override fun isPropertyWithPlatformField(descriptor: PropertyDescriptor): Boolean = + descriptor.hasJvmFieldAnnotation() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt index 70568968ff4..4aec82905b5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt @@ -39,7 +39,7 @@ class IrLazyProperty( override val isFakeOverride: Boolean, stubGenerator: DeclarationStubGenerator, typeTranslator: TypeTranslator, - private val bindingContext: BindingContext? = null + bindingContext: BindingContext? = null ) : IrLazyDeclarationBase(startOffset, endOffset, origin, stubGenerator, typeTranslator), IrProperty { @@ -72,11 +72,14 @@ class IrLazyProperty( symbol.bind(this) } + private val hasBackingField: Boolean = + descriptor.hasBackingField(bindingContext) || stubGenerator.extensions.isPropertyWithPlatformField(descriptor) + override val descriptor: PropertyDescriptor get() = symbol.descriptor override var backingField: IrField? by lazyVar { - if (descriptor.hasBackingField(bindingContext)) { + if (hasBackingField) { stubGenerator.generateFieldStub(descriptor).apply { correspondingPropertySymbol = this@IrLazyProperty.symbol } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt index 49ac971458c..63dd8a798fb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt @@ -37,7 +37,7 @@ class DeclarationStubGenerator( val symbolTable: SymbolTable, languageVersionSettings: LanguageVersionSettings, private val irProviders: List = emptyList(), - private val extensions: StubGeneratorExtensions = StubGeneratorExtensions.EMPTY + val extensions: StubGeneratorExtensions = StubGeneratorExtensions.EMPTY ) { private val lazyTable = symbolTable.lazyWrapper diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt index 20ae0f08504..753d498968d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.ir.util import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource @@ -15,6 +16,8 @@ open class StubGeneratorExtensions { open fun generateFacadeClass(source: DeserializedContainerSource): IrClass? = null + open fun isPropertyWithPlatformField(descriptor: PropertyDescriptor): Boolean = false + companion object { @JvmField val EMPTY = StubGeneratorExtensions() diff --git a/compiler/testData/codegen/boxInline/callableReference/bound/jvmFieldProperty.kt b/compiler/testData/codegen/boxInline/callableReference/bound/jvmFieldProperty.kt index ea0ee31c708..24aceecd031 100644 --- a/compiler/testData/codegen/boxInline/callableReference/bound/jvmFieldProperty.kt +++ b/compiler/testData/codegen/boxInline/callableReference/bound/jvmFieldProperty.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_MULTI_MODULE: JVM_IR // WITH_RUNTIME // FILE: 1.kt @@ -17,4 +16,4 @@ import test.* fun box(): String { return test(Foo("OK")::a) -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxInline/callableReference/jvmFieldProperty.kt b/compiler/testData/codegen/boxInline/callableReference/jvmFieldProperty.kt index 696307f9024..45a6a2f6c42 100644 --- a/compiler/testData/codegen/boxInline/callableReference/jvmFieldProperty.kt +++ b/compiler/testData/codegen/boxInline/callableReference/jvmFieldProperty.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_MULTI_MODULE: JVM_IR // WITH_RUNTIME // FILE: 1.kt @@ -17,4 +16,4 @@ import test.* fun box(): String { return test(Foo::a) -} \ No newline at end of file +} diff --git a/compiler/testData/compileKotlinAgainstKotlin/jvmField.kt b/compiler/testData/compileKotlinAgainstKotlin/jvmField.kt index 38b82205caa..ef858b2058b 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/jvmField.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/jvmField.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // FILE: A.kt diff --git a/compiler/testData/compileKotlinAgainstKotlin/jvmFieldInConstructor.kt b/compiler/testData/compileKotlinAgainstKotlin/jvmFieldInConstructor.kt index 4bdeb0f093d..620e47f36b0 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/jvmFieldInConstructor.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/jvmFieldInConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // FILE: A.kt