diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index fdefdfce2a0..28b17b49f19 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -686,7 +686,8 @@ fun FirSession.createFilesWithGeneratedDeclarations(): List { fun FirDeclaration?.computeIrOrigin( predefinedOrigin: IrDeclarationOrigin? = null, - parentOrigin: IrDeclarationOrigin? = null + parentOrigin: IrDeclarationOrigin? = null, + fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag? = null ): IrDeclarationOrigin { if (this == null) { return predefinedOrigin ?: parentOrigin ?: IrDeclarationOrigin.DEFINED @@ -703,6 +704,7 @@ fun FirDeclaration?.computeIrOrigin( } this is FirCallableDeclaration -> when { + fakeOverrideOwnerLookupTag != null && fakeOverrideOwnerLookupTag != containingClassLookupTag() -> IrDeclarationOrigin.FAKE_OVERRIDE symbol.fir.isIntersectionOverride || symbol.fir.isSubstitutionOverride -> IrDeclarationOrigin.FAKE_OVERRIDE parentOrigin == IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB && symbol.isJavaOrEnhancement -> { IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/Fir2IrCallableDeclarationsGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/Fir2IrCallableDeclarationsGenerator.kt index acc7b4379bf..0e89a1eca20 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/Fir2IrCallableDeclarationsGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/Fir2IrCallableDeclarationsGenerator.kt @@ -105,7 +105,11 @@ class Fir2IrCallableDeclarationsGenerator(val components: Fir2IrComponents) : Fi // See org.jetbrains.kotlin.backend.jvm.lower.InheritedDefaultMethodsOnClassesLoweringKt.isDefinitelyNotDefaultImplsMethod (irParent as? IrClass)?.origin == IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB && function.isJavaOrEnhancement -> IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB - else -> function.computeIrOrigin(predefinedOrigin, parentOrigin = (irParent as? IrDeclaration)?.origin) + else -> function.computeIrOrigin( + predefinedOrigin, + parentOrigin = (irParent as? IrDeclaration)?.origin, + fakeOverrideOwnerLookupTag + ) } val parentIsExternal = irParent.isExternalParent() // We don't generate signatures for local classes @@ -268,15 +272,18 @@ class Fir2IrCallableDeclarationsGenerator(val components: Fir2IrComponents) : Fi isLocal: Boolean = false, fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag? = null, ): IrProperty = convertCatching(property) { - val origin = - when { - !predefinedOrigin.isExternal && - property.isStatic && - property.name in Fir2IrDeclarationStorage.ENUM_SYNTHETIC_NAMES - -> IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER + val origin = when { + !predefinedOrigin.isExternal && + property.isStatic && + property.name in Fir2IrDeclarationStorage.ENUM_SYNTHETIC_NAMES + -> IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER - else -> property.computeIrOrigin(predefinedOrigin, parentOrigin = (irParent as? IrDeclaration)?.origin) - } + else -> property.computeIrOrigin( + predefinedOrigin, + parentOrigin = (irParent as? IrDeclaration)?.origin, + fakeOverrideOwnerLookupTag + ) + } // See similar comments in createIrFunction above val parentIsExternal = irParent.isExternalParent() val signature = diff --git a/compiler/testData/codegen/box/multiplatform/hmpp/simple.kt b/compiler/testData/codegen/box/multiplatform/hmpp/simple.kt index b3b6678e19b..771865e9d15 100644 --- a/compiler/testData/codegen/box/multiplatform/hmpp/simple.kt +++ b/compiler/testData/codegen/box/multiplatform/hmpp/simple.kt @@ -5,9 +5,10 @@ // WITH_STDLIB // !LANGUAGE: +MultiPlatformProjects - +// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535 // TARGET_BACKEND: JVM - +// IGNORE_BACKEND_K2: JVM_IR +// REASON: K2 incorrectly generates IR for B.bar f/o // MODULE: common // TARGET_PLATFORM: Common diff --git a/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes.kt b/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes.kt index 0503b686df7..5a3a349fbde 100644 --- a/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes.kt +++ b/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes.kt @@ -1,6 +1,9 @@ // IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6, NATIVE, WASM // WITH_STDLIB // !LANGUAGE: +MultiPlatformProjects +// IGNORE_BACKEND_K2: JVM_IR +// REASON: K2 incorrectly generates IR for S1.p f/o +// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535 // MODULE: common // TARGET_PLATFORM: Common @@ -41,4 +44,4 @@ fun box(): String { } else { "FAIL" } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes2.kt b/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes2.kt index 073ce871860..baa1fcef6b1 100644 --- a/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes2.kt +++ b/compiler/testData/codegen/box/multiplatform/k2/basic/expectInterfaceInSupertypes2.kt @@ -1,6 +1,9 @@ // IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6, NATIVE, WASM // WITH_STDLIB +// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535 // !LANGUAGE: +MultiPlatformProjects +// IGNORE_BACKEND_K2: ANY +// REASON: K2 incorrectly generates IR for S2.s3 f/o // MODULE: common // TARGET_PLATFORM: Common @@ -39,4 +42,4 @@ actual interface S : S1, S2 { fun s3() = s1() + s2() } -fun box() = B().s3() \ No newline at end of file +fun box() = B().s3()