From 197f19c627313c50f57b1ff7e14bd3a1bab17472 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 13 Feb 2023 12:33:04 +0200 Subject: [PATCH] [FIR] Add test for KT-43619 --- ...nosisCompilerFirTestdataTestGenerated.java | 6 +++++ ...TouchedTilContractsPhaseTestGenerated.java | 5 ++++ ...loadResolutionByLambdaArgumentType.fir.txt | 27 +++++++++++++++++++ .../overloadResolutionByLambdaArgumentType.kt | 11 ++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++++ 6 files changed, 61 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index f45dd11d013..92cfc4d55d9 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -3143,6 +3143,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt"); } + @Test + @TestMetadata("overloadResolutionByLambdaArgumentType.kt") + public void testOverloadResolutionByLambdaArgumentType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt"); + } + @Test @TestMetadata("receiverWithCapturedType.kt") public void testReceiverWithCapturedType() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 6cf546fd58f..f14214551c6 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2757,6 +2757,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt"); } + @TestMetadata("overloadResolutionByLambdaArgumentType.kt") + public void testOverloadResolutionByLambdaArgumentType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt"); + } + @TestMetadata("receiverWithCapturedType.kt") public void testReceiverWithCapturedType() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.fir.txt new file mode 100644 index 00000000000..668c46b4aa4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.fir.txt @@ -0,0 +1,27 @@ +FILE: overloadResolutionByLambdaArgumentType.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public final fun R|A|.foo(k: R|K|): R|K| { + ^foo R|/k| + } + public final fun R|A|.foo(a: R|A.() -> kotlin/Unit|): R|kotlin/Int| { + ^foo Int(2) + } + public final fun test(): R|kotlin/Unit| { + R|/A.A|().#( = foo@fun (): R|kotlin/Unit| { + ^@foo Unit + } + ) + R|/A.A|().R|/foo|( = foo@fun R|A|.(): R|kotlin/Unit| { + ^@foo Unit + } + ) + R|/A.A|().#( = foo@fun (): R|kotlin/Unit| { + ^@foo Unit + } + ) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt b/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt new file mode 100644 index 00000000000..7d6d47737b5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt @@ -0,0 +1,11 @@ +// ISSUE: KT-43619 + +class A +fun A.foo(k: K) = k // (1) +fun A.foo(a: A.() -> Unit) = 2 // (2) + +fun test(){ + A().foo {} // (1) + A().foo {} // (1) + A().foo {} // error +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index d87c807eb53..50b89336b22 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -3143,6 +3143,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt"); } + @Test + @TestMetadata("overloadResolutionByLambdaArgumentType.kt") + public void testOverloadResolutionByLambdaArgumentType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt"); + } + @Test @TestMetadata("receiverWithCapturedType.kt") public void testReceiverWithCapturedType() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index db17788cc53..7651d0e2f58 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -3143,6 +3143,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt"); } + @Test + @TestMetadata("overloadResolutionByLambdaArgumentType.kt") + public void testOverloadResolutionByLambdaArgumentType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/overloadResolutionByLambdaArgumentType.kt"); + } + @Test @TestMetadata("receiverWithCapturedType.kt") public void testReceiverWithCapturedType() throws Exception {