diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 88aeabd49da..21806940488 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -50193,6 +50193,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/syntheticExtensions/kt56154.kt"); } + @Test + @TestMetadata("kt57103.kt") + public void testKt57103() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/kt57103.kt"); + } + @Test @TestMetadata("overrideKotlinPropertyByJavaMethod.kt") public void testOverrideKotlinPropertyByJavaMethod() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index c3584cb2ce7..5ae50c5eb2b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -50193,6 +50193,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/syntheticExtensions/kt56154.kt"); } + @Test + @TestMetadata("kt57103.kt") + public void testKt57103() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/kt57103.kt"); + } + @Test @TestMetadata("overrideKotlinPropertyByJavaMethod.kt") public void testOverrideKotlinPropertyByJavaMethod() throws Exception { diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt index 34db7d05a49..cc3a9cad304 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt @@ -78,8 +78,16 @@ private class InlineCallableReferenceToLambdaVisitor(val context: JvmBackendCont this is IrFunctionReference -> // ::function -> { args... -> function(args...) } wrapFunction(symbol.owner).toLambda(this, scope!!) - this is IrPropertyReference -> // ::property -> { receiver -> receiver.property }; prefer direct field access if allowed. - (if (field != null) wrapField(field!!.owner) else wrapFunction(getter!!.owner)).toLambda(this, scope!!) + this is IrPropertyReference -> + // References to generic synthetic Java properties aren't inlined in K1. Fixes KT-57103 + if (typeArgumentsCount > 0 && + symbol.owner.origin.let { + it == IrDeclarationOrigin.SYNTHETIC_JAVA_PROPERTY_DELEGATE || it == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB + } + ) this + // ::property -> { receiver -> receiver.property }; prefer direct field access if allowed. + else (if (field != null) wrapField(field!!.owner) else wrapFunction(getter!!.owner)).toLambda(this, scope!!) + else -> this // not an inline argument } diff --git a/compiler/testData/codegen/box/callableReference/referenceToGenericSyntheticProperty.kt b/compiler/testData/codegen/box/callableReference/referenceToGenericSyntheticProperty.kt index d5c9091eaee..2e3a073c8c9 100644 --- a/compiler/testData/codegen/box/callableReference/referenceToGenericSyntheticProperty.kt +++ b/compiler/testData/codegen/box/callableReference/referenceToGenericSyntheticProperty.kt @@ -1,6 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_K1: JVM_IR -// K1_STATUS: Broken because of KT-57103 // FILE: J.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/kt57103.kt b/compiler/testData/codegen/box/syntheticExtensions/kt57103.kt new file mode 100644 index 00000000000..91fcc3a88c1 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticExtensions/kt57103.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +ReferencesToSyntheticJavaProperties +// TARGET_BACKEND: JVM_IR + +// FILE: J.java + +public class J { + private final T value; + public J(T value) { + this.value = value; + } + public T getValue() { + return value; + } + + public T foo() { + return value; + } +} + +// FILE: test.kt + +fun box(): String { + val j = J("OK") + return run(j::value) +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index ada1b2cae19..08b2222a395 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -50193,6 +50193,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/syntheticExtensions/kt56154.kt"); } + @Test + @TestMetadata("kt57103.kt") + public void testKt57103() throws Exception { + runTest("compiler/testData/codegen/box/syntheticExtensions/kt57103.kt"); + } + @Test @TestMetadata("overrideKotlinPropertyByJavaMethod.kt") public void testOverrideKotlinPropertyByJavaMethod() throws Exception {