From c9bb994fb50b019398d348d193645f76f4e2a3f6 Mon Sep 17 00:00:00 2001 From: "anastasiia.spaseeva" Date: Fri, 14 Feb 2020 18:51:12 +0300 Subject: [PATCH] [Spec tests] Add tests to check overload resolution for implicitly imported infix functions --- .../infix-function-call/p-2/neg/1.1.kt | 96 ++++++++++++ .../infix-function-call/p-2/neg/1.2.kt | 117 ++++++++++++++ .../infix-function-call/p-2/neg/1.3.kt | 62 ++++++++ .../infix-function-call/p-2/neg/1.4.kt | 58 +++++++ .../infix-function-call/p-2/neg/3.5.kt | 33 ++++ .../infix-function-call/p-2/pos/3.1.kt | 122 +++++++++++++++ .../infix-function-call/p-2/pos/3.2.kt | 117 ++++++++++++++ .../infix-function-call/p-2/pos/3.3.kt | 61 ++++++++ .../infix-function-call/p-2/pos/3.4.kt | 59 +++++++ .../infix-function-call/p-2/pos/3.5.kt | 36 +++++ .../infix-function-call/testsMap.json | 148 ++++++++++++++++++ .../DiagnosticsTestSpecGenerated.java | 102 ++++++++++++ 12 files changed, 1011 insertions(+) create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt create mode 100644 compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/testsMap.json diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt new file mode 100644 index 00000000000..ed74412d609 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt @@ -0,0 +1,96 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: Implicitly imported extension callable without infix modifier + */ + +// FILE: Extensions.kt +package libPackage + +class A() { + fun foo(x: Int) = "member fun foo" +} + +// FILE: Extensions.kt +// TESTCASE NUMBER: 1, 2, 3, 4 + +package sentence3 +import libPackage.A + +fun A.foo(x: Int) = "pack scope extension fun foo" + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.A + +class Case1() { + fun A.foo(x: Int) = "local extension fun foo" + + fun case1() { + val a = A() + a foo 1 + A() foo 1 + } +} +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.A + +interface Case2 { + fun A.foo(x: Int) = "local extension fun foo" + + fun case2() { + val a = A() + a foo 1 + A() foo 1 + } +} + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPack +import libPackage.A + +fun A.foo(x: Int) = "my package scope top level contains" + + +fun case3() { + fun A.foo(x: Int) ="my local scope contains" + + val a = A() + a foo 1 + A() foo 1 +} + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackNew +import libPackage.A + +fun A.foo(x: Int) = "my package scope top level contains" + + +fun case4() { + + fun A.foo(x: Int) = "my local contains" + + fun subfun() { + fun A.foo(x: Int) = "my local contains" + val a = A() + a foo 1 + A() foo 1 + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt new file mode 100644 index 00000000000..685d04475fe --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt @@ -0,0 +1,117 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * NUMBER: 2 + * DESCRIPTION: Local extension infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.contains + +class Case1() { + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local class scope contains") + return true + } + + fun case1() { + val regex = Regex("") + "" contains regex + } +} +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.contains + +interface Case2 { + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local interface scope contains") + return true + } + + fun case2() { + val regex = Regex("") + "" contains regex + } +} + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPack +import libPackage.contains + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case3() { + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true + } + + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackNew +import libPackage.contains + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case4() { + + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + fun subfun() { + + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + val regex = Regex("") + "" contains regex + + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt new file mode 100644 index 00000000000..93b4eca16c0 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt @@ -0,0 +1,62 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 3 + * NUMBER: 3 + * DESCRIPTION: Explicitly imported infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + +operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.contains + + +fun case1() { + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.contains + + +fun case2() { + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + val regex = Regex("") + "" contains regex +} + diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt new file mode 100644 index 00000000000..d693fef9b13 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt @@ -0,0 +1,58 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 4 + * NUMBER: 4 + * DESCRIPTION: Star-imported infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.* + + +fun case1() { + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 +package testPack +import libPackage.* + + operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case2() { + val regex = Regex("") + "" contains regex +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt new file mode 100644 index 00000000000..13043f7fb50 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt @@ -0,0 +1,33 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + +/* + * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 5 + * NUMBER: 5 + * DESCRIPTION: Star-imported extension callable only + */ + +// FILE: Extensions.kt +package libPackage + +private infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} + +// FILE: TestCase2.kt +package sentence3 +import libPackage.* //nothing to import, extension is private + +// TESTCASE NUMBER: 1 +fun case1() { + val regex = Regex("") + "" contains regex +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt new file mode 100644 index 00000000000..f0342fb6e29 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt @@ -0,0 +1,122 @@ +// !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, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: Local extension infix extension callables + */ + +// TESTCASE NUMBER: 0, 1, 2, 3, 4 +// FILE: Extensions.kt +package libPackage + +class A() { + infix fun foo(x: Int) = "member fun foo" +} + +// FILE: Extensions.kt +// TESTCASE NUMBER: 0 + +package sentence3 +import libPackage.A +infix fun A.foo(x: Int) = "pack scope extension fun foo" + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.A + +class Case1() { + infix fun A.foo(x: Int) = "local extension fun foo" + + fun case1() { + val a = A() + a foo 1 + A() foo 1 + } +} +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.A + +interface Case2 { + infix fun A.foo(x: Int) = "local extension fun foo" + + fun case2() { + val a = A() + a foo 1 + A() foo 1 + } +} + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPack +import libPackage.A + +infix fun A.foo(x: Int) = "my package scope top level contains" + + +fun case3() { + infix fun A.foo(x: Int) = "my local scope contains" + + val a = A() + a foo 1 + A() foo 1 +} + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackNew +import libPackage.A + +infix fun A.foo(x: Int) = "my package scope top level contains" + + +fun case4() { + + infix fun A.foo(x: Int) = "my local contains" + + fun subfun() { + infix fun A.foo(x: Int) = "my local contains" + val a = A() + a foo 1 + A() foo 1 + } +} + +// FILE: TestCase5.kt +// TESTCASE NUMBER: 5 +package testPackNew + +class A() { + fun foo(i: Int) {} + infix fun A.foo(i: Int) {} + + fun bar(a: A) { + //todo: add info if function is infix one + a foo 1 + } + + fun buz(a: A){ + fun foo(i: Int) {} + //todo: add info if function is infix one + a foo 1 + } + + fun boo(a: A){ + infix fun A.foo(i: Int) {} + a foo 1 + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt new file mode 100644 index 00000000000..f07bb9f913d --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt @@ -0,0 +1,117 @@ +// !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, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * + * NUMBER: 2 + * DESCRIPTION: Local extension infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.contains + +class Case1() { + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local class scope contains") + return true + } + + fun case1() { + val regex = Regex("") + "" contains regex + } +} +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.contains + +interface Case2 { + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local interface scope contains") + return true + } + + fun case2() { + val regex = Regex("") + "" contains regex + } +} + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPack +import libPackage.contains + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case3() { + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackNew +import libPackage.contains + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case4() { + + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + fun subfun() { + + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + + val regex = Regex("") + "" contains regex + + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt new file mode 100644 index 00000000000..5e90aaf15a7 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt @@ -0,0 +1,61 @@ +// !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, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 3 + * + * NUMBER: 3 + * DESCRIPTION: Explicitly imported infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.contains + + +fun case1() { + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 + +package sentence3 +import libPackage.contains + + +fun case2() { + infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my local contains") + return true + } + val regex = Regex("") + "" contains regex +} + diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt new file mode 100644 index 00000000000..ff808d40f81 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt @@ -0,0 +1,59 @@ +// !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, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 4 + * + * NUMBER: 4 + * DESCRIPTION: Star-imported infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} +// FILE: Extensions.kt + +package sentence3 + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.* + + +fun case1() { + val regex = Regex("") + "" contains regex +} + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 +package testPack +import libPackage.* + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my package scope top level contains") + return true +} + +fun case2() { + val regex = Regex("") + "" contains regex +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt new file mode 100644 index 00000000000..d44b9d28e24 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt @@ -0,0 +1,36 @@ +// !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, infix-function-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, infix-function-call -> paragraph 2 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 5 + * + * NUMBER: 5 + * DESCRIPTION: Star-imported infix extension callables + */ + +// FILE: Extensions.kt +package libPackage + +infix operator fun CharSequence.contains(regex: Regex): Boolean { + println("my contains") + return true +} + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 + +package sentence3 +import libPackage.* + +fun case1() { + val regex = Regex("") + "" contains regex +} + diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/testsMap.json new file mode 100644 index 00000000000..2c339c20f1f --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/testsMap.json @@ -0,0 +1,148 @@ +{ + "2": { + "neg": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Local extension infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported extension callable only", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Explicitly imported infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Star-imported infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Star-imported infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Implicitly imported extension callable without infix modifier", + "unexpectedBehaviour": false + } + ], + "2": [ + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Local extension infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Explicitly imported infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Implicitly imported extension callable without infix modifier", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt", + "unexpectedBehaviour": false + } + ], + "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported extension callable only", + "unexpectedBehaviour": false + } + ] + }, + "pos": { + "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Star-imported infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 6, + "description": "Local extension infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Local extension infix extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Explicitly imported infix extension callables", + "unexpectedBehaviour": false + } + ], + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Star-imported infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 6, + "description": "Local extension infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Local extension infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 2, + "description": "Explicitly imported infix extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java index 70963950d80..db91824df27 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java @@ -3503,6 +3503,108 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } } } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Infix_function_call extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInfix_function_call() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class P_2 extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInP_2() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Neg extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("1.1.kt") + public void test1_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.1.kt"); + } + + @TestMetadata("1.2.kt") + public void test1_2() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.2.kt"); + } + + @TestMetadata("1.3.kt") + public void test1_3() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.3.kt"); + } + + @TestMetadata("1.4.kt") + public void test1_4() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/1.4.kt"); + } + + @TestMetadata("3.5.kt") + public void test3_5() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg/3.5.kt"); + } + + public void testAllFilesPresentInNeg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/neg"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Pos extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("3.1.kt") + public void test3_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.1.kt"); + } + + @TestMetadata("3.2.kt") + public void test3_2() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.2.kt"); + } + + @TestMetadata("3.3.kt") + public void test3_3() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.3.kt"); + } + + @TestMetadata("3.4.kt") + public void test3_4() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.4.kt"); + } + + @TestMetadata("3.5.kt") + public void test3_5() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos/3.5.kt"); + } + + public void testAllFilesPresentInPos() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + } } @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention")