From 2c918d27879baefbb010be8d2d4217efeffc6d09 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 7 Feb 2020 18:17:41 +0300 Subject: [PATCH] [FIR TEST] Add example with invoke priority inconsistent with old FE --- .../resolve/stdlib/problems/invokePriority.kt | 20 +++++++++ .../stdlib/problems/invokePriority.txt | 45 +++++++++++++++++++ ...FirDiagnosticsWithStdlibTestGenerated.java | 5 +++ 3 files changed, 70 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.kt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.txt diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.kt b/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.kt new file mode 100644 index 00000000000..84e575655d5 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.kt @@ -0,0 +1,20 @@ +class A { + fun bar() { + val foo: String.() -> Unit = {} // (1) + fun String.foo(): Unit {} // (2) + "1".foo() // resolves to (2) + with("2") { + foo() // BUG: resolves to (1) in old FE, but to (2) in FIR + } + } +} +class B { + val foo: String.() -> Unit = {} // (1) + fun String.foo(): Unit {} // (2) + fun bar() { + "1".foo() // resolves to (2) + with("2") { + foo() // resolves to (2) + } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.txt new file mode 100644 index 00000000000..2aa6fd20a2d --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.txt @@ -0,0 +1,45 @@ +FILE: invokePriority.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final fun bar(): R|kotlin/Unit| { + lval foo: R|kotlin/String.() -> kotlin/Unit| = fun R|kotlin/String|.(): R|kotlin/Unit| { + Unit + } + + local final fun R|kotlin/String|.foo(): R|kotlin/Unit| { + } + + String(1).R|/foo|() + R|kotlin/with|(String(2), = with@fun R|kotlin/String|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/foo|() + } + ) + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + public final val foo: R|kotlin/String.() -> kotlin/Unit| = fun R|kotlin/String|.(): R|kotlin/Unit| { + Unit + } + + public get(): R|kotlin/String.() -> kotlin/Unit| + + public final fun R|kotlin/String|.foo(): R|kotlin/Unit| { + } + + public final fun bar(): R|kotlin/Unit| { + (this@R|/B|, String(1)).R|/B.foo|() + R|kotlin/with|(String(2), = with@fun R|kotlin/String|.(): R|kotlin/Unit| { + (this@R|/B|, this@R|special/anonymous|).R|/B.foo|() + } + ) + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index 92dfcd7c811..22902f391d4 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -642,6 +642,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/inapplicableRemoveAll.kt"); } + @TestMetadata("invokePriority.kt") + public void testInvokePriority() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/invokePriority.kt"); + } + @TestMetadata("KJKComplexHierarchyNestedLoop.kt") public void testKJKComplexHierarchyNestedLoop() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/KJKComplexHierarchyNestedLoop.kt");