diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt index 52297e4004b..ad1cb89afda 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* +import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticPropertiesScope import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.* @@ -82,6 +83,13 @@ class FakeOverrideGenerator( // This parameter is only needed for data-class methods that is irrelevant for lazy library classes realDeclarationSymbols = emptySet() ) + FirSyntheticPropertiesScope.createIfSyntheticNamesProviderIsDefined(session, firClass.defaultType(), useSiteMemberScope)?.let { + generateFakeOverridesForName( + irClass, it, name, firClass, this, + // This parameter is only needed for data-class methods that is irrelevant for lazy library classes + realDeclarationSymbols = emptySet() + ) + } if (firClass.isEnumClass) return@buildList // F/O for values/valueOf/entries aren't needed, for other members aren't possible val staticScope = firClass.scopeProvider.getStaticMemberScopeForCallables(firClass, session, scopeSession) if (staticScope != null) { diff --git a/compiler/fir/fir2ir/testData/codegen/box/properties/synthetic/kt56072.kt b/compiler/fir/fir2ir/testData/codegen/box/properties/synthetic/kt56072.kt new file mode 100644 index 00000000000..d1c9ac64884 --- /dev/null +++ b/compiler/fir/fir2ir/testData/codegen/box/properties/synthetic/kt56072.kt @@ -0,0 +1,31 @@ +// FILE: SuperClass.java + +public class SuperClass { + private String stringParam; + + public SuperClass(String stringParam) + { + this.stringParam = stringParam; + } + + public String getStringParam() + { + return stringParam; + } +} + +// FILE: InheritedClass.java + +public class InheritedClass extends SuperClass { + public InheritedClass(String stringParam) { + super(stringParam); + } +} + +// FILE: test.kt + +fun box(): String { + val superValue = (SuperClass::stringParam)(SuperClass("O")) + val inheritedValue = (InheritedClass("K")::stringParam)() + return superValue + inheritedValue +} diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java index 24f21ff2eec..b8c2ce5eb1f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java @@ -117,6 +117,22 @@ public class FirSpecificBlackBoxCodegenTestGenerated extends AbstractFirBlackBox runTest("compiler/fir/fir2ir/testData/codegen/box/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt"); } } + + @Nested + @TestMetadata("compiler/fir/fir2ir/testData/codegen/box/properties/synthetic") + @TestDataPath("$PROJECT_ROOT") + public class Synthetic { + @Test + public void testAllFilesPresentInSynthetic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/codegen/box/properties/synthetic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt56072.kt") + public void testKt56072() throws Exception { + runTest("compiler/fir/fir2ir/testData/codegen/box/properties/synthetic/kt56072.kt"); + } + } } } diff --git a/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt b/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt index 48b216bece1..b61887d84df 100644 --- a/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/kt45853.__AX.fir.ir.txt @@ -15,6 +15,16 @@ CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:AX modality:ABSTRACT visibili overridden: public abstract fun getA (): @[FlexibleNullability] .X? declared in .X $this: VALUE_PARAMETER FAKE_OVERRIDE name: type:.AX + PROPERTY IR_EXTERNAL_JAVA_DECLARATION_STUB name:a visibility:public modality:OPEN [val] + overridden: + public abstract a: .A? [val] + FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name: visibility:public modality:OPEN <> ($this:.AX) returnType:@[FlexibleNullability] .AX? + annotations: + Override + correspondingProperty: PROPERTY IR_EXTERNAL_JAVA_DECLARATION_STUB name:a visibility:public modality:OPEN [val] + overridden: + public abstract fun (): .A? declared in .A + $this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name: type:.AX FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:.AX, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A