From 5568ceef689c2a7a231457d4280c505b96fd385d Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Sat, 20 Feb 2021 11:33:09 +0300 Subject: [PATCH] Add test for KT-37056 (already fixed) --- ...TouchedTilContractsPhaseTestGenerated.java | 5 ++ .../resolve/callResolution/kt37056.fir.txt | 58 +++++++++++++++++++ .../resolve/callResolution/kt37056.kt | 32 ++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 ++ 5 files changed, 107 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt 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 a8cace9712f..20c20e84b29 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 @@ -715,6 +715,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt new file mode 100644 index 00000000000..f28f9da1a94 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt @@ -0,0 +1,58 @@ +FILE: kt37056.kt + public final fun case1(a: R|A?|): R|kotlin/Unit| { + lval test: R|kotlin/String?| = R|/a|?.{ $subj$.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/String| { + Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) + Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) + ^ Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) + } + ) } + Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) + Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|()) + } + public final class Case1 : R|kotlin/Any| { + private constructor(a: R|A|): R|Case1| { + super() + } + + public final val a: R|A| = R|/a| + public get(): R|A| + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|Case1.Companion| { + super() + } + + public final operator fun invoke(a: R|A|): R|kotlin/String| { + ^invoke String() + } + + } + + } + public final fun case2(a: R|A|): R|kotlin/Unit| { + Q|Case2|.R|/Case2.Companion.invoke|(R|/a|) + Q|Case2|.R|/Case2.Companion.invoke|(a = R|/a|) + } + public final class Case2 : R|kotlin/Any| { + public constructor(): R|Case2| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|Case2.Companion| { + super() + } + + public final operator fun invoke(a: R|A|): R|kotlin/String| { + ^invoke String() + } + + } + + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt new file mode 100644 index 00000000000..8258acf4bb3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt @@ -0,0 +1,32 @@ +fun case1(a: A?) { + val test = a?.let { + + Case1.invoke(it) + + Case1(it) + + Case1(A()) + } + + Case1(A()) + Case1(a = A()) +} + +class Case1 private constructor(val a: A) { + companion object { + operator fun invoke(a: A) = "" + } +} + +fun case2(a: A) { + Case2(a) + Case2(a =a) +} + +class Case2 { + companion object { + operator fun invoke(a: A) = "" //(1) + } +} + +class A() \ No newline at end of file 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 26d06adcd89..953aaffdbf1 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 @@ -827,6 +827,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @Test + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @Test @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() 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 739203e8fc7..694267105eb 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 @@ -834,6 +834,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @Test + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @Test @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() throws Exception {