[Spec tests] Add tests for call-without-an-explicit-receiver, receivers

This commit is contained in:
anastasiia.spaseeva
2020-03-02 17:19:11 +03:00
committed by Victor Petukhov
parent 35de6a3f6e
commit bb1ee952ba
23 changed files with 2191 additions and 43 deletions
@@ -0,0 +1,93 @@
// !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-278
* PLACE: overload-resolution, receivers -> paragraph 5 -> sentence 2
* RELEVANT PLACES: overload-resolution, receivers -> paragraph 5 -> sentence 1
* overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 5 -> sentence 2
* NUMBER: 1
* DESCRIPTION: The implicit this receiver has higher priority than phantom static implicit this
*/
// FILE: TestCase.kt
// TESTCASE NUMBER: 1
package testsCase1
open class A {
operator fun invoke() = print("invoke")
}
open class B {
operator fun invoke() = print("invoke")
}
enum class Super_2 {
V1, V2;
val values = A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.A.invoke; typeCall: variable&invoke")!>values()<!>
}
enum class NestedWithCompanion {
V1;
val values = B()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.B.invoke; typeCall: variable&invoke")!>values()<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_2.Nested.values; typeCall: function")!>values()<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 2
package testsCase2
open class A {
operator fun invoke(value: String) = print("invoke $value")
}
open class B {
operator fun invoke(value: String) = print("invoke $value")
}
enum class Super_2 {
V1, V2;
val valueOf = A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.A.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
enum class NestedWithCompanion {
V1;
val valueOf = B()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.B.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_2.Nested.valueOf; typeCall: function")!>valueOf("")<!>
}
}
}
@@ -0,0 +1,163 @@
// !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-278
* PLACE: overload-resolution, receivers -> paragraph 5 -> sentence 3
* RELEVANT PLACES: overload-resolution, receivers -> paragraph 5 -> sentence 1
* overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 5 -> sentence 2
* NUMBER: 1
* DESCRIPTION: The phantom static implicit this receiver has higher priority than the current class companion object receiver
*/
// FILE: TestCase.kt
// TESTCASE NUMBER: 1
package testsCase1
open class A {
operator fun invoke() = print("invoke")
}
enum class Super_2 {
V1, V2;
companion object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_2.values; typeCall: function")!>values()<!>
}
enum class NestedWithCompanion {
V1;
companion object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_2.NestedWithCompanion.values; typeCall: function")!>values()<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_2.Nested.values; typeCall: function")!>values()<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 2
package testsCase2
open class A {
operator fun invoke(value: String) = print("invoke $value")
}
enum class Super_2 {
V1, V2;
companion object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_2.valueOf; typeCall: function")!>valueOf("")<!>
}
enum class NestedWithCompanion {
V1;
companion object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_2.NestedWithCompanion.valueOf; typeCall: function")!>valueOf("")<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_2.Nested.valueOf; typeCall: function")!>valueOf("")<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 3
package testsCase3
open class A {
operator fun invoke() = print("invoke")
}
enum class Super_2 {
V1, V2;
object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_2.values; typeCall: function")!>values()<!>
}
enum class NestedWithCompanion {
V1;
object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_2.NestedWithCompanion.values; typeCall: function")!>values()<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_2.Nested.values; typeCall: function")!>values()<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 4
package testsCase4
open class A {
operator fun invoke(value: String) = print("invoke $value")
}
open class B {
operator fun invoke(value: String) = print("invoke $value")
}
enum class Super_2 {
V1, V2;
object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_2.valueOf; typeCall: function")!>valueOf("")<!>
}
enum class NestedWithCompanion {
V1;
object valueOf : B() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_2.NestedWithCompanion.valueOf; typeCall: function")!>valueOf("")<!>
}
}
enum class Nested {
V1;
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_2.Nested.valueOf; typeCall: function")!>valueOf("")<!>
}
}
}
@@ -0,0 +1,202 @@
// !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-278
* PLACE: overload-resolution, receivers -> paragraph 5 -> sentence 5
* RELEVANT PLACES: overload-resolution, receivers -> paragraph 5 -> sentence 4
* overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 5 -> sentence 2
* NUMBER: 1
* DESCRIPTION: Superclass companion object receivers are prioritized according to the inheritance order
*/
// FILE: TestCase.kt
// TESTCASE NUMBER: 1
package testsCase1
open class A {
operator fun invoke() = print("invoke")
}
interface Super_0 {
companion object values : A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_0.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
open class Super_1 : Super_0 {
companion object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
open class Super_2 : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
class Nested : Super_1() {
companion object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_2.Nested.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
inner class Inner : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase1.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 2
package testsCase2
open class A {
operator fun invoke(value: String) = print("invoke $value")
}
interface Super_0 {
companion object valueOf : A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_0.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
open class Super_1 : Super_0 {
companion object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
open class Super_2 : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
class Nested : Super_1() {
companion object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_2.Nested.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
inner class Inner : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase2.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 3
package testsCase3
open class A {
operator fun invoke() = print("invoke")
}
interface Super_0 {
object values : A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_0.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
open class Super_1 : Super_0 {
object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
open class Super_2 : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
class Nested : Super_1() {
object values : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_2.Nested.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
inner class Inner : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase3.Super_1.values.invoke; typeCall: variable&invoke")!>values()<!>
}
}
}
// FILE: TestCase.kt
// TESTCASE NUMBER: 4
package testsCase4
open class A {
operator fun invoke(value: String) = print("invoke $value")
}
interface Super_0 {
object valueOf : A()
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_0.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
open class Super_1 : Super_0 {
object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
open class Super_2 : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
class Nested : Super_1() {
object valueOf : A() {}
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_2.Nested.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
inner class Inner : Super_1() {
private fun case() {
<!DEBUG_INFO_CALL("fqName: testsCase4.Super_1.valueOf.invoke; typeCall: variable&invoke")!>valueOf("")<!>
}
}
}
@@ -0,0 +1,55 @@
{
"5": {
"pos": {
"2": [
{
"specVersion": "0.1-278",
"casesNumber": 2,
"description": "The implicit this receiver has higher priority than phantom static implicit this",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-278",
"casesNumber": 2,
"description": "The implicit this receiver has higher priority than phantom static implicit this",
"path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/2.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-278",
"casesNumber": 4,
"description": "The phantom static implicit this receiver has higher priority than the current class companion object receiver",
"path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.kt",
"unexpectedBehaviour": false
}
],
"3": [
{
"specVersion": "0.1-278",
"casesNumber": 4,
"description": "The phantom static implicit this receiver has higher priority than the current class companion object receiver",
"unexpectedBehaviour": false
}
],
"5": [
{
"specVersion": "0.1-278",
"casesNumber": 4,
"description": "Superclass companion object receivers are prioritized according to the inheritance order",
"unexpectedBehaviour": false
}
],
"4": [
{
"specVersion": "0.1-278",
"casesNumber": 4,
"description": "Superclass companion object receivers are prioritized according to the inheritance order",
"path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/5.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}