diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt index 6464c4398a8..8c86ce9e85b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt @@ -55,12 +55,13 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte } override fun visitFunctionReference(expression: IrFunctionReference): IrExpression { + expression.transformChildrenVoid(this) if (expression !in inlinableReferences || expression.origin.isLambda) return expression - return expandInlineFunctionReferenceToLambda(expression, expression.symbol.owner) } override fun visitPropertyReference(expression: IrPropertyReference): IrExpression { + expression.transformChildrenVoid(this) if (expression !in inlinableReferences) return expression return if (expression.field?.owner == null) { diff --git a/compiler/testData/codegen/box/callableReference/nested.kt b/compiler/testData/codegen/box/callableReference/nested.kt new file mode 100644 index 00000000000..3350c8c3474 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/nested.kt @@ -0,0 +1,9 @@ +inline fun String.takeRef(ref: () -> Unit) = this + +fun f1() {} +fun String.f2() {} + +fun problematic(s: String) = + s.takeRef(s.takeRef(::f1)::f2) + +fun box() = problematic("OK") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJvmIrBackendGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJvmIrBackendGenerated.java index 824b16c02c6..9b25f98f782 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJvmIrBackendGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJvmIrBackendGenerated.java @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.checkers; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -21,11 +22,11 @@ import java.util.regex.Pattern; @RunWith(JUnit3RunnerWithInners.class) public class DiagnosticsTestWithJvmIrBackendGenerated extends AbstractDiagnosticsTestWithJvmIrBackend { private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } public void testAllFilesPresentInTestsWithJvmBackend() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, true); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @TestMetadata("inlineCycle.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithOldJvmBackendGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithOldJvmBackendGenerated.java index 08e9c3db78f..c11d275d037 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithOldJvmBackendGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithOldJvmBackendGenerated.java @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.checkers; import com.intellij.testFramework.TestDataPath; import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.test.TestMetadata; import org.junit.runner.RunWith; @@ -21,11 +22,11 @@ import java.util.regex.Pattern; @RunWith(JUnit3RunnerWithInners.class) public class DiagnosticsTestWithOldJvmBackendGenerated extends AbstractDiagnosticsTestWithOldJvmBackend { private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } public void testAllFilesPresentInTestsWithJvmBackend() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, true); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJvmBackend"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } @TestMetadata("inlineCycle.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 27a6e5d879c..d5fb44de169 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -1975,6 +1975,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt"); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9880966039e..2ec5e8bbe83 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -1975,6 +1975,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt"); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14723,11 +14728,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class NotNullAssertions extends AbstractLightAnalysisModeTest { - @TestMetadata("paramAssertionMessage.kt") - public void ignoreParamAssertionMessage() throws Exception { - runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt"); - } - private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -14811,6 +14811,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullableTypeParameter.kt"); } + @TestMetadata("paramAssertionMessage.kt") + public void testParamAssertionMessage() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/paramAssertionMessage.kt"); + } + @TestMetadata("staticCallErrorMessage.kt") public void testStaticCallErrorMessage() throws Exception { runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/staticCallErrorMessage.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 6c60e4ea8f8..6242791bf57 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -1955,6 +1955,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt"); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index b75f50376f0..6bcb388ff2a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -1955,6 +1955,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt"); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 1109f19b8a3..960c970a7b1 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1410,6 +1410,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 5252e8a073e..d745000cbed 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1410,6 +1410,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("nested.kt") + public void testNested() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/nested.kt"); + } + @TestMetadata("compiler/testData/codegen/box/callableReference/bound") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)