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.4.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.4.fir.kt new file mode 100644 index 00000000000..e84eb3f1b62 --- /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.4.fir.kt @@ -0,0 +1,120 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// 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, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 3 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 4 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 5 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 11 -> sentence 1 + * overload-resolution, receivers -> paragraph 5 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-trailing-lambda-expressions -> paragraph 1 -> sentence 2 + * NUMBER: 4 + * DESCRIPTION: sets of local, explicitly imported, declared in the package scope and star-imported extension callables + */ + +// FILE: Extensions.kt +package libPackage + +public fun String?.orEmpty(): String = "my Extension for $this" +/* a call with trailing lambda expression */ +public fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + +// FILE: TestCase1.kt + +package sentence3 + +import libPackage.* +import libPackage.orEmpty +import libPackage.funWithTrailingLambda + +private fun String?.orEmpty(): String = "my top-level (pack scope) Extension for $this" +/* a call with trailing lambda expression */ +private fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + +// TESTCASE NUMBER: 1 +class Case1() { + fun String?.orEmpty(): String = "my local extension for $this" + fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + + fun case1(s: String?) { + s.orEmpty() + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + } +} + +// FILE: TestCase2.kt +package sentence3 +import libPackage.* +//import libPackage.orEmpty + +private fun String?.orEmpty(): String = "my top-level (pack scope) Extension for $this" +private fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + +// TESTCASE NUMBER: 2 +class Case2() { + fun String?.orEmpty(): String = "my local extension for $this" + fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + + fun case2(s: String?) { + s.orEmpty() + + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + } +} + +// TESTCASE NUMBER: 3 +class Case3() { + fun String?.orEmpty(): String = "my local extension for $this" + fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + + fun case3(s: String?) { + s.orEmpty() + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + + fun innerFirst(s: String?){ + fun String?.orEmpty(): String = "my local inner extension for $this" + fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + + s?.orEmpty() + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + } + fun innerSecond(){ + fun String?.orEmpty(): String = "my local inner extension for $this" + fun String?.funWithTrailingLambda( x : Any? = null, body : ()-> String = {""} ): String = body() + + s.orEmpty() + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + } + s.orEmpty() + //trailing lambda + s.funWithTrailingLambda { "ss" } + s.funWithTrailingLambda (x= 1) { "ss" } + s.funWithTrailingLambda (body = { "ss" }) + s.funWithTrailingLambda (body = { "ss" }, x = '1') + } +}