From bddea7d163857dfed9fa3cf5cbdc3309eb862d8c Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 16 Apr 2020 18:28:20 +0300 Subject: [PATCH] FIR: Adjust testData for spec tests: local scopes in overload resolution The behavior of FIR seems to be the correct one ^KT-36475 --- .../p-6/pos/2.2.fir.kt | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/2.2.fir.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/2.2.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/2.2.fir.kt new file mode 100644 index 00000000000..2696cf3b014 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/2.2.fir.kt @@ -0,0 +1,71 @@ +// !LANGUAGE: +NewInference +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * RELEVANT PLACES: overload-resolution, c-level-partition -> paragraph 1 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 3 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 3 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 2 -> sentence 1 + * NUMBER: 2 + * DESCRIPTION: extension calls with explicit and implicit receiver + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36475 + */ + +// TESTCASE NUMBER: 1 +class Case1 { + fun bar() { + val foo: String.() -> Unit = {} // (1) + fun String.foo(): Unit {} // (2) + "1".foo() // resolves to (2) + with("2") { + foo() //resolves to (1) !!! + this.foo() //resolves to (2) + } + "".run { + foo() //resolves to (1) !!! + this.foo() //resolves to (2) + } + "".apply { + foo() //resolves to (1) !!! + this.foo() //resolves to (2) + } + "".also { + it.foo() //resolves to (2) + } + "".let { + it.foo() //resolves to (2) + } + } +} + +class B { + val foo: String.() -> Unit = {} // (1) + fun String.foo(): Unit {} // (2) + fun bar() { + "1".foo() // resolves to (2) + val str = "1" + with("2") { + foo() //resolves to (2) + this.foo() //resolves to (2) + } + "".run { + foo() //resolves to (2) + this.foo() //resolves to (2) + } + "".apply { + foo() //resolves to (2) + this.foo() //resolves to (2) + } + "".also { + it.foo() //resolves to (2) + } + "".let { + it.foo() //resolves to (2) + } + } +}