diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 29e5a0173fc..9917a0b3755 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -31442,6 +31442,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.kt"); } + @Test + @TestMetadata("kFunctionalCST.kt") + public void testKFunctionalCST() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt"); + } + @Test @TestMetadata("kt2069.kt") public void testKt2069() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 5f04628a3ef..52d8786054f 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -31442,6 +31442,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.kt"); } + @Test + @TestMetadata("kFunctionalCST.kt") + public void testKFunctionalCST() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt"); + } + @Test @TestMetadata("kt2069.kt") public void testKt2069() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 91058492521..8b8149855be 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -31442,6 +31442,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.kt"); } + @Test + @TestMetadata("kFunctionalCST.kt") + public void testKFunctionalCST() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt"); + } + @Test @TestMetadata("kt2069.kt") public void testKt2069() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 134fbf8ed50..d10bfa2405d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -31538,6 +31538,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.kt"); } + @Test + @TestMetadata("kFunctionalCST.kt") + public void testKFunctionalCST() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt"); + } + @Test @TestMetadata("kt2069.kt") public void testKt2069() throws Exception { diff --git a/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.fir.kt b/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.fir.kt new file mode 100644 index 00000000000..1542006c5f9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.fir.kt @@ -0,0 +1,27 @@ +// INFERENCE_HELPERS +// ISSUE: KT-57036 + +abstract class Base(block: String.() -> Int) +class A(block: String.() -> Int) : Base(block) +class B(block: String.() -> Int) : Base(block) + +fun test_1() { + val c = select(::A, ::B) + c { length } + c { it.length } +} + +fun test_2(cond: Boolean) { + val c = if (cond) ::A else ::B + c { length } + c { it.length } +} + +fun test_3(cond: Boolean) { + val c = when(cond) { + true -> ::A + false -> ::B + } + c { length } + c { it.length } +} diff --git a/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt b/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt new file mode 100644 index 00000000000..b4a71b137c7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt @@ -0,0 +1,27 @@ +// INFERENCE_HELPERS +// ISSUE: KT-57036 + +abstract class Base(block: String.() -> Int) +class A(block: String.() -> Int) : Base(block) +class B(block: String.() -> Int) : Base(block) + +fun test_1() { + val c = select(::A, ::B) + c { length } + c { it.length } +} + +fun test_2(cond: Boolean) { + val c = if (cond) ::A else ::B + c { length } + c { it.length } +} + +fun test_3(cond: Boolean) { + val c = when(cond) { + true -> ::A + false -> ::B + } + c { length } + c { it.length } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 274f7e4cb40..b2c070969d8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -32280,6 +32280,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.kt"); } + @Test + @TestMetadata("kFunctionalCST.kt") + public void testKFunctionalCST() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kFunctionalCST.kt"); + } + @Test @TestMetadata("kt2069.kt") public void testKt2069() throws Exception {