From 96d3a061296c663f206787e3ab0d6a34b0739380 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 26 Nov 2019 15:33:22 +0300 Subject: [PATCH] [FIR-TEST] Add test with hiding local functions --- .../resolve/problems/localFunctionsHiding.kt | 23 ++++++++++++++ .../resolve/problems/localFunctionsHiding.txt | 30 +++++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 ++++ 3 files changed, 58 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt create mode 100644 compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt diff --git a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt new file mode 100644 index 00000000000..8fdd15cda94 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt @@ -0,0 +1,23 @@ +interface A { + val x: Int +} + +fun test_1() { + fun Int.transform(): Int = 1 + fun A.transform(): Int { + return x.transform() + } + + val y = 1 + y.transform() +} + +fun test_2() { + fun Int.transform(): Int = 1 + fun A.transformX(): Int { + return x.transform() + } + + val y = 1 + y.transform() +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt new file mode 100644 index 00000000000..3b2a5e86ef5 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.txt @@ -0,0 +1,30 @@ +FILE: localFunctionsHiding.kt + public abstract interface A : R|kotlin/Any| { + public abstract val x: R|kotlin/Int| + public get(): R|kotlin/Int| + + } + public final fun test_1(): R|kotlin/Unit| { + local final fun R|kotlin/Int|.transform(): R|kotlin/Int| { + ^transform Int(1) + } + + local final fun R|A|.transform(): R|kotlin/Int| { + ^transform this@R|/A|.R|/A.x|./transform]>#() + } + + lval y: R|kotlin/Int| = Int(1) + R|/y|./transform]>#() + } + public final fun test_2(): R|kotlin/Unit| { + local final fun R|kotlin/Int|.transform(): R|kotlin/Int| { + ^transform Int(1) + } + + local final fun R|A|.transformX(): R|kotlin/Int| { + ^transformX this@R|/A|.R|/A.x|.R|/transform|() + } + + lval y: R|kotlin/Int| = Int(1) + R|/y|.R|/transform|() + } 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 08379404c2a..403323724bf 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -878,6 +878,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/problems/javaAccessorConversion.kt"); } + @TestMetadata("localFunctionsHiding.kt") + public void testLocalFunctionsHiding() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/localFunctionsHiding.kt"); + } + @TestMetadata("nestedClassContructor.kt") public void testNestedClassContructor() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/nestedClassContructor.kt");