From ace5d0357c86973279f057a2ea5e9959e90495d9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 20 Feb 2020 17:37:09 +0300 Subject: [PATCH] [FIR TEST] Add problematic test describing KT-36881 --- .../resolve/problems/typesInLocalFunctions.kt | 10 ++++++ .../problems/typesInLocalFunctions.txt | 33 +++++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 5 +++ 4 files changed, 53 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.txt diff --git a/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt b/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt new file mode 100644 index 00000000000..943cf93e42d --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt @@ -0,0 +1,10 @@ +class Some + +fun foo(): () -> Boolean { + val s = Some() + if (true) { + return { if (s is Some) true else false } + } else { + return { true } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.txt b/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.txt new file mode 100644 index 00000000000..1f324e1353e --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.txt @@ -0,0 +1,33 @@ +FILE: typesInLocalFunctions.kt + public final class Some : R|kotlin/Any| { + public constructor(): R|Some| { + super() + } + + } + public final fun foo(): R|() -> kotlin/Boolean| { + lval s: R|Some| = R|/Some.Some|() + when () { + Boolean(true) -> { + ^foo fun .(): { + when () { + (s# is Some) -> { + Boolean(true) + } + else -> { + Boolean(false) + } + } + + } + + } + else -> { + ^foo fun .(): { + Boolean(true) + } + + } + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 36d68d1d40c..b892e3d3692 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1303,6 +1303,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { public void testJavaAccessorConversion() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt"); } + + @TestMetadata("typesInLocalFunctions.kt") + public void testTypesInLocalFunctions() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt"); + } } @TestMetadata("compiler/fir/resolve/testData/resolve/references") diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 146000f7fa0..5ff29d97353 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1303,6 +1303,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testJavaAccessorConversion() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt"); } + + @TestMetadata("typesInLocalFunctions.kt") + public void testTypesInLocalFunctions() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/typesInLocalFunctions.kt"); + } } @TestMetadata("compiler/fir/resolve/testData/resolve/references")