diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json new file mode 100644 index 00000000000..3358abcec25 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json @@ -0,0 +1,86 @@ +{ + "6": { + "pos": { + "4": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Extension callables, declared in the package scope, for for-loop operator iterator call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Star-imported extension callables for for-loop operator iterator call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Extension callables, declared in the package scope, for delegated properties call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.9.kt", + "unexpectedBehaviour": false + } + ], + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Non-extension member callables for for-loop operator iterator call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Non-extension member callables for delegated properties call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Star-imported extension callables for delegated properties call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.10.kt", + "unexpectedBehaviour": false + } + ], + "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Explicitly imported extension callables for delegated properties call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.8.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Explicitly imported extension callables for for-loop operator iterator call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt", + "unexpectedBehaviour": false + } + ], + "2": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Local extension callables for for-loop operator iterator call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "local extension callables for delegated properties call", + "path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.7.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt new file mode 100644 index 00000000000..e084d1d1a99 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt @@ -0,0 +1,75 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: Non-extension member callables for for-loop operator iterator call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var flag = false + +class MyIterator(shouldBeCalled: Boolean = false) : CharIterator() { + init { + flag = shouldBeCalled + } + private var index = 0 + override fun nextChar(): Char { index++; return 'd'} + override fun hasNext(): Boolean = index < 5 +} + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.iterator +import libPackage1.invoke +import libPackage2.* + + +class Iterable(iterator: Inv) { + operator fun iterator(): CharIterator = MyIterator(true) +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = MyIterator() +} + +operator fun Iterable.iterator(): CharIterator = MyIterator() + +fun box(): String { + operator fun Iterable.iterator(): CharIterator = MyIterator() + + for (i in Iterable(Inv('c'))) { + println(i) + } + return if (flag) + "OK" + else "NOK" +} + diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.10.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.10.kt new file mode 100644 index 00000000000..bce2543a579 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.10.kt @@ -0,0 +1,71 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 10 + * DESCRIPTION: Star-imported extension callables for delegated properties call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var isGetCalled = false +var isSetCalled = false + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + isGetCalled = true + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { + isSetCalled = true +} + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +//import libPackage1.getValue +//import libPackage1.setValue +import libPackage2.* +import kotlin.reflect.KProperty + +class Delegate {} + +fun box() : String { + class Test { + var p: String by Delegate() + } + + val test = Test() + assert(!isGetCalled && !isSetCalled) + test.p = "NEW" + if (isSetCalled && !isGetCalled) { + isSetCalled = false + val x = test.p + if (!isSetCalled && isGetCalled) + return "OK" + } + return "NOK" +} diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt new file mode 100644 index 00000000000..7abcfa66c22 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt @@ -0,0 +1,75 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 2 + * DESCRIPTION: Local extension callables for for-loop operator iterator call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var flag = false + +class MyIterator(shouldBeCalled: Boolean = false) : CharIterator() { + init { + flag = shouldBeCalled + } + private var index = 0 + override fun nextChar(): Char { index++; return 'd'} + override fun hasNext(): Boolean = index < 5 +} + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.iterator +import libPackage1.invoke +import libPackage2.* + + +class Iterable(iterator: Inv) { + /*operator fun iterator(): CharIterator = MyIterator()*/ +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = MyIterator() +} + +operator fun Iterable.iterator(): CharIterator = MyIterator() + +fun box(): String { + operator fun Iterable.iterator(): CharIterator = MyIterator(true) + + for (i in Iterable(Inv('c'))) { + println(i) + } + return if (flag) + "OK" + else "NOK" +} + diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt new file mode 100644 index 00000000000..3b245aa259e --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt @@ -0,0 +1,75 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 3 + * DESCRIPTION: Explicitly imported extension callables for for-loop operator iterator call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var flag = false + +class MyIterator(shouldBeCalled: Boolean = false) : CharIterator() { + init { + flag = shouldBeCalled + } + private var index = 0 + override fun nextChar(): Char { index++; return 'd'} + override fun hasNext(): Boolean = index < 5 +} + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator(true) +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.iterator +import libPackage1.invoke +import libPackage2.* + + +class Iterable(iterator: Inv) { + /*operator fun iterator(): CharIterator = MyIterator()*/ +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = MyIterator() +} + +operator fun Iterable.iterator(): CharIterator = MyIterator() + +fun box(): String { + /*operator fun Iterable.iterator(): CharIterator = MyIterator()*/ + + for (i in Iterable(Inv('c'))) { + println(i) + } + return if (flag) + "OK" + else "NOK" +} + diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt new file mode 100644 index 00000000000..e3a2f2185a8 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt @@ -0,0 +1,75 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 4 + * DESCRIPTION: Extension callables, declared in the package scope, for for-loop operator iterator call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var flag = false + +class MyIterator(shouldBeCalled: Boolean = false) : CharIterator() { + init { + flag = shouldBeCalled + } + private var index = 0 + override fun nextChar(): Char { index++; return 'd'} + override fun hasNext(): Boolean = index < 5 +} + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator(true) +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator() +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +/*import libPackage1.iterator +import libPackage1.invoke*/ +import libPackage2.* + + +class Iterable(iterator: Inv) { + /*operator fun iterator(): CharIterator = MyIterator()*/ +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = MyIterator() +} + +operator fun Iterable.iterator(): CharIterator = MyIterator(true) + +fun box(): String { + /*operator fun Iterable.iterator(): CharIterator = MyIterator()*/ + + for (i in Iterable(Inv('c'))) { + println(i) + } + return if (flag) + "OK" + else "NOK" +} + diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt new file mode 100644 index 00000000000..5f13bc14915 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt @@ -0,0 +1,77 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 5 + * DESCRIPTION: Star-imported extension callables for for-loop operator iterator call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var flag = false + +class MyIterator(shouldBeCalled: Boolean = false) : CharIterator() { + init { + flag = shouldBeCalled + } + private var index = 0 + override fun nextChar(): Char { index++; return 'd'} + override fun hasNext(): Boolean = index < 5 +} + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator(true) +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Iterable +import testPack.Inv + +operator fun Iterable.iterator() : CharIterator = MyIterator(true) +operator fun Inv.invoke() : CharIterator = MyIterator() + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +/*import libPackage1.iterator +import libPackage1.invoke*/ +import libPackage2.* + + +class Iterable(iterator: Inv) { + /*operator fun iterator(): CharIterator = MyIterator()*/ +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = MyIterator() +} + +/* +operator fun Iterable.iterator(): CharIterator = MyIterator(true) +*/ + +fun box(): String { + /*operator fun Iterable.iterator(): CharIterator = MyIterator()*/ + + for (i in Iterable(Inv('c'))) { + println(i) + } + return if (flag) + "OK" + else "NOK" +} + diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt new file mode 100644 index 00000000000..d0b5d94bd4a --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt @@ -0,0 +1,84 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 6 + * DESCRIPTION: Non-extension member callables for delegated properties call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var isGetCalled = false +var isSetCalled = false + + + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.getValue +import libPackage1.setValue +import libPackage2.* +import kotlin.reflect.KProperty + +class Delegate { + operator fun getValue(thisRef: Any?, property: KProperty<*>): String { + isGetCalled = true + return "" + } + + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { + isSetCalled = true + } +} + +class Test { + var p: String by Delegate() +} + +fun box() : String { + operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" + } + operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + + val test = Test() + assert(!isGetCalled && !isSetCalled) + test.p = "NEW" + if (isSetCalled && !isGetCalled) { + isSetCalled = false + val x = test.p + if (!isSetCalled && isGetCalled) + return "OK" + } + return "NOK" +} diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.7.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.7.kt new file mode 100644 index 00000000000..22160bbc9bb --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.7.kt @@ -0,0 +1,81 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 7 + * DESCRIPTION: local extension callables for delegated properties call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var isGetCalled = false +var isSetCalled = false + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.getValue +import libPackage1.setValue +import libPackage2.* +import kotlin.reflect.KProperty + +class Delegate {} + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +fun box() : String { + class Test { + var p: String by Delegate() + + operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + isGetCalled = true + return "" + } + operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { + isSetCalled = true + } + } + + val test = Test() + assert(!isGetCalled && !isSetCalled) + test.p = "NEW" + if (isSetCalled && !isGetCalled) { + isSetCalled = false + val x = test.p + if (!isSetCalled && isGetCalled) + return "OK" + } + return "NOK" +} diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.8.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.8.kt new file mode 100644 index 00000000000..6502fa87b0b --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.8.kt @@ -0,0 +1,77 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 8 + * DESCRIPTION: Explicitly imported extension callables for delegated properties call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var isGetCalled = false +var isSetCalled = false + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + isGetCalled = true + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { + isSetCalled = true +} + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +import libPackage1.getValue +import libPackage1.setValue +import libPackage2.* +import kotlin.reflect.KProperty + +class Delegate {} + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { +} + +fun box() : String { + class Test { + var p: String by Delegate() + } + + val test = Test() + assert(!isGetCalled && !isSetCalled) + test.p = "NEW" + if (isSetCalled && !isGetCalled) { + isSetCalled = false + val x = test.p + if (!isSetCalled && isGetCalled) + return "OK" + } + return "NOK" +} diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.9.kt b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.9.kt new file mode 100644 index 00000000000..2bfd64046fa --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.9.kt @@ -0,0 +1,76 @@ +// WITH_RUNTIME + +/* + * KOTLIN CODEGEN BOX SPEC TEST (POSITIVE) + * + * SPEC VERSION: 0.1-268 + * PLACE: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 3 -> sentence 1 + * NUMBER: 9 + * DESCRIPTION: Extension callables, declared in the package scope, for delegated properties call + */ + +// FILE: LibMyIterator.kt +package libMyIteratorPackage + +var isGetCalled = false +var isSetCalled = false + +// FILE: Lib1.kt +package libPackage1 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Lib2.kt +package libPackage2 +import libMyIteratorPackage.* +import testPack.Delegate +import kotlin.reflect.KProperty + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +// FILE: Test.kt +package testPack +import libMyIteratorPackage.* +//import libPackage1.getValue +//import libPackage1.setValue +import libPackage2.* +import kotlin.reflect.KProperty + +class Delegate {} + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + isGetCalled = true + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { + isSetCalled = true +} + +fun box() : String { + class Test { + var p: String by Delegate() + } + + val test = Test() + assert(!isGetCalled && !isSetCalled) + test.p = "NEW" + if (isSetCalled && !isGetCalled) { + isSetCalled = false + val x = test.p + if (!isSetCalled && isGetCalled) + return "OK" + } + return "NOK" +} diff --git a/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json new file mode 100644 index 00000000000..db91530f22c --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json @@ -0,0 +1,68 @@ +{ + "2": { + "pos": { + "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Extension callables, declared in the package scope, for for-loop operator iterator call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Star-imported extension callables for for-loop operator iterator call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Non-extension member callables for for-loop operator iterator call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Star-imported extension callables for delegated properties call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Explicitly imported extension callables for delegated properties call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Extension callables, declared in the package scope, for delegated properties call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Non-extension member callables for delegated properties call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Local extension callables for for-loop operator iterator call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "Explicitly imported extension callables for for-loop operator iterator call", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 0, + "description": "local extension callables for delegated properties call", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json index 4a657d4e777..86c6014ba53 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/testsMap.json @@ -1,7 +1,123 @@ { + "1": { + "pos": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "smart cast for the property available through the operator invoke", + "path": "compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos/1.1.kt", + "unexpectedBehaviour": true + } + ] + } + }, "6": { "pos": { + "4": [ + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Extension callables declared in the package scope", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "sets of explicitly imported, declared in the package scope and star-imported extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/3.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 6, + "description": "sets of extension callables declared in the package scope", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "sets of declared in the package scope and star-imported extension callables", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-268", + "casesNumber": 3, + "description": "Star-imported extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "set of star-imported extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "sets of declared in the package scope and star-imported extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/4.2.kt", + "unexpectedBehaviour": false + } + ], + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 10, + "description": "Non-extension member callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "set of non-extension member callables only", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 3, + "description": "The sets of non-extension member callables named f of type T;", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 3, + "description": "sets of non-extension member callables, local, explicitly imported, declared in the package scope and star-imported extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 5, + "description": "sets of non-extension member callables, local, explicitly imported, declared in the package scope and star-imported extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "sets of non-extension member callables only", + "unexpectedBehaviour": false + } + ], "2": [ + { + "specVersion": "0.1-268", + "casesNumber": 5, + "description": "Non-extension member callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt", + "unexpectedBehaviour": true + }, { "specVersion": "0.1-268", "casesNumber": 2, @@ -48,39 +164,14 @@ "unexpectedBehaviour": true } ], - "1": [ - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "set of non-extension member callables only", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 3, - "description": "The sets of non-extension member callables named f of type T;", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 3, - "description": "sets of non-extension member callables, local, explicitly imported, declared in the package scope and star-imported extension callables", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 5, - "description": "sets of non-extension member callables, local, explicitly imported, declared in the package scope and star-imported extension callables", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "sets of non-extension member callables only", - "unexpectedBehaviour": false - } - ], "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Explicitly imported extension callables", + "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt", + "unexpectedBehaviour": false + }, { "specVersion": "0.1-268", "casesNumber": 3, @@ -95,42 +186,6 @@ "unexpectedBehaviour": false } ], - "4": [ - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "sets of explicitly imported, declared in the package scope and star-imported extension callables", - "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/3.1.kt", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 6, - "description": "sets of extension callables declared in the package scope", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "sets of declared in the package scope and star-imported extension callables", - "unexpectedBehaviour": false - } - ], - "5": [ - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "set of star-imported extension callables", - "unexpectedBehaviour": false - }, - { - "specVersion": "0.1-268", - "casesNumber": 1, - "description": "sets of declared in the package scope and star-imported extension callables", - "path": "compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/p-6/pos/4.2.kt", - "unexpectedBehaviour": false - } - ], "6": [ { "specVersion": "0.1-268", diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt new file mode 100644 index 00000000000..5903990352e --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt @@ -0,0 +1,240 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: Non-extension member callables + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1, 2 +package libPackage + +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E +import kotlin.reflect.KProperty + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1, 2 +package testPackCase1 +import libPackage.plus +import libPackage.* +import libPackage.invoke + +class Case() { + + class E(val plus: Inv? = null) { + operator fun plus(value: Int) = Case() + } + + class Inv() { + operator fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + operator fun E.plus(value: Int) = Case() + + run { + e+1 + } + e+1 + e.plus(1) + e.plus?.invoke(1) //ok + } +} + +// FILE: LibCase3.kt +// TESTCASE NUMBER: 3, 4 +package libPackage +import testPackCase3.Case +import testPackCase3.Case.Inv +import testPackCase3.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3, 4 +package testPackCase3 +import libPackage.plus +import libPackage.* +import libPackage.invoke + +class Case() { + + class E(val plus: Inv? = null) { + operator fun plus(value: Int) = Case() + } + + class Inv() { + operator fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + operator fun E.plus(value: Int) = Case() + + run { + operator fun E.plus(value: Int) = Case() + + e+1 + } + e+1 + } + fun boo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + /*operator*/ fun E.plus(value: Int) = Case() + + e+1 + } + e+1 + } +} + +// FILE: LibCase5.kt +// TESTCASE NUMBER: 5, 6 +package libPackage + +import testPackCase5.Case +import testPackCase5.Case.Inv +import testPackCase5.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase6.kt +// TESTCASE NUMBER: 5, 6 +package testPackCase5 +import libPackage.plusAssign +import libPackage.* +import libPackage.invoke + +class Case() { + + class E(val plusAssign: Inv? = null) { + operator fun plusAssign(value: Int) {} + } + + class Inv() { + operator fun invoke(value: Int) {} + } + + fun foo(e: E) { + operator fun Case.E.plusAssign(value: Int) {} + + run { + e+=1 + } + e+=1 + e.plusAssign(1) + e.plusAssign?.invoke(1) //ok + } +} + + +// FILE: LibCase7.kt +// TESTCASE NUMBER: 7, 8 +package libPackage +import testPackCase8.Case +import testPackCase8.Case.Inv +import testPackCase8.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + +// FILE: TestCase8.kt +// TESTCASE NUMBER: 7, 8 +package testPackCase8 +import libPackage.plusAssign +import libPackage.* +import libPackage.invoke + +class Case() { + + class E(val plusAssign: Inv? = null) { + operator fun plusAssign(value: Int) {} + } + + class Inv() { + operator fun invoke(value: Int) {} + } + + fun foo(e: E) { + operator fun E.plusAssign(value: Int) {} + + run { + operator fun E.plusAssign(value: Int) {} + + e+=1 + } + e+=1 + } + fun boo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + /*operator*/ fun E.plusAssign(value: Int) {} + + e+=1 + } + e+=1 + } +} + + +// FILE: LibCase9.kt +// TESTCASE NUMBER: 9, 10 +package libPackage +import testPackCase10.Iterable +import testPackCase10.Inv + +operator fun Iterable.iterator() : CharIterator = TODO() +operator fun Inv.invoke() {} + +// FILE: TestCase10.kt +// TESTCASE NUMBER: 9, 10 +package testPackCase10 +import libPackage.iterator +import libPackage.invoke + +class Iterable(iterator: Inv) { + operator fun iterator() : CharIterator = TODO() +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = TODO() +} + +operator fun Iterable.iterator() : CharIterator = TODO() + +fun case(){ + operator fun Iterable.iterator() : CharIterator = TODO() + val iterable: Iterable = Iterable(Inv('c')) + + fun foo(){ + iterable.iterator() + for (i in iterable) { + println(i) + } + } + iterable.iterator() + for (i in iterable) { + println(i) + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt new file mode 100644 index 00000000000..6df6bf648ce --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt @@ -0,0 +1,217 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 2 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 2 + * DESCRIPTION: Non-extension member callables + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E +import kotlin.reflect.KProperty + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testPackCase1 +import libPackage.plus +import libPackage.* +import libPackage.invoke +class Case() { + + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + operator fun E.plus(value: Int) = Case() + + run { + e + 1 + } + e + 1 + + } +} + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 2 +package libPackage +import testPackCase2.Case +import testPackCase2.Case.Inv +import testPackCase2.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 2 +package testPackCase2 +import libPackage.plus +import libPackage.* +import libPackage.invoke + +operator fun Case.E.plus(value: Int) = Case() + +class Case() { + + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + operator fun E.plus(value: Int) = Case() + + run { + operator fun E.plus(value: Int) = Case() + + .plus; typeCall: operator extension function")!>e + 1 + } + e + 1 + } +} + +// FILE: LibCase3.kt +// TESTCASE NUMBER: 3 +package libPackage +import testPackCase3.Case +import testPackCase3.Case.Inv +import testPackCase3.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPackCase3 +import libPackage.plusAssign +import libPackage.invoke +import libPackage.* +class Case() { + + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + operator fun E.plusAssign(value: Int) {} + + run { + e += 1 + } + e += 1 + + } +} + + +// FILE: LibCase4.kt +// TESTCASE NUMBER: 4 +package libPackage +import testPackCase4.Case +import testPackCase4.Case.Inv +import testPackCase4.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackCase4 +import libPackage.plusAssign +import libPackage.* +import libPackage.invoke + +operator fun Case.E.plusAssign(value: Int) {} + +class Case() { + + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + operator fun E.plusAssign(value: Int) {} + + run { + operator fun E.plusAssign(value: Int) {} + + .plusAssign; typeCall: operator extension function")!>e += 1 + } + e += 1 + } +} + + +// FILE: TestCase5.kt +/* + * TESTCASE NUMBER: 5 + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36996 + */ +package testPackCase5 +import kotlin.reflect.KProperty + +class Delegate { + /*operator*/ fun getValue(thisRef: Any?, property: KProperty<*>): String { + return "" + } + + /*operator*/ fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { + } +} + +operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" +} +operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) {} + +fun case() { + class Test { + var p: String by Delegate() + + operator fun Delegate.getValue(thisRef: Any?, property: KProperty<*>): String { + return "" + } + operator fun Delegate.setValue(thisRef: Any?, property: KProperty<*>, value: String) { + } + } + val test = Test() + test.p = "NEW" + val x = test.p + +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt new file mode 100644 index 00000000000..d61e134de2c --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt @@ -0,0 +1,193 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * 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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 3 + * DESCRIPTION: Explicitly imported extension callables + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage1 +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage2 +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testPackCase1 +import libPackage1.plus +import libPackage1.invoke +import libPackage2.* +class Case() { + + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + e + 1 + } + e + 1 + + } +} + +// FILE: LibCase2.kt +// TESTCASE NUMBER: 2 +package libPackage1 +import testPackCase2.Case +import testPackCase2.Case.Inv +import testPackCase2.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + +// FILE: LibCase2.kt +// TESTCASE NUMBER: 2 +package libPackage2 +import testPackCase2.Case +import testPackCase2.Case.Inv +import testPackCase2.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase2.kt +// TESTCASE NUMBER: 2 +package testPackCase2 +import libPackage1.plus +import libPackage1.invoke +import libPackage2.* +class Case() { + + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + /*operator*/ fun E.plus(value: Int) = Case() + + e + 1 + } + e + 1 + } +} + +// FILE: LibCase3.kt +// TESTCASE NUMBER: 3 +package libPackage +import testPackCase3.Case +import testPackCase3.Case.Inv +import testPackCase3.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPackCase3 +import libPackage.plusAssign +import libPackage.invoke +import libPackage.* +class Case() { + + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + e += 1 + } + e += 1 + + } +} + + +// FILE: LibCase4.kt +// TESTCASE NUMBER: 4 +package libPackage +import testPackCase4.Case +import testPackCase4.Case.Inv +import testPackCase4.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackCase4 +import libPackage.plusAssign +import libPackage.* +import libPackage.invoke + +operator fun Case.E.plusAssign(value: Int) {} + +class Case() { + + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + /*operator*/ fun E.plusAssign(value: Int) {} + + e += 1 + } + e += 1 + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt new file mode 100644 index 00000000000..18a0d1d6a9c --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt @@ -0,0 +1,194 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 4 + * DESCRIPTION: Extension callables declared in the package scope + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E + +operator fun Case.E.plus(value: Int) = Case().Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testPackCase1 +import libPackage.* + +operator fun Case.E.plus(value: Int) = Case().Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + +class Case() { + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + inner class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + e + 1 + } + e + 1 + + } +} + +// FILE: Lib1.kt +// TESTCASE NUMBER: 2 +package libPackage1 +import testPackCase2.Case +import testPackCase2.Case.Inv +import testPackCase2.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: Lib2.kt +// TESTCASE NUMBER: 2 +package testPackCase2 +import testPackCase2.Case +import testPackCase2.Case.Inv +import testPackCase2.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 2 +package testPackCase2 +import libPackage1.* +class Case() { + + operator fun plus(value: Int) = Case() + + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + /*operator*/ fun E.plus(value: Int) = Case() + + e + 1 + } + e + 1 + } +} + + +// FILE: LibCase3.kt +// TESTCASE NUMBER: 3 +package libPackage +import testPackCase3.Case +import testPackCase3.Case.Inv +import testPackCase3.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 3 +package testPackCase3 +import libPackage.* + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + +class Case() { + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + inner class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + e += 1 + } + e += 1 + + } +} + +// FILE: Lib1.kt +// TESTCASE NUMBER: 4 +package libPackage1 +import testPackCase4.Case +import testPackCase4.Case.Inv +import testPackCase4.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: Lib2.kt +// TESTCASE NUMBER: 4 +package testPackCase4 +import testPackCase4.Case +import testPackCase4.Case.Inv +import testPackCase4.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase4.kt +// TESTCASE NUMBER: 4 +package testPackCase4 +import libPackage1.* +class Case() { + + operator fun plusAssign(value: Int) {} + + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + /*operator*/ fun E.plusAssign(value: Int) {} + + e += 1 + } + e += 1 + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt new file mode 100644 index 00000000000..4c3036db83c --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt @@ -0,0 +1,103 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 5 + * DESCRIPTION: Star-imported extension callables + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage +import testPackCase1.Case +import testPackCase1.Case.Inv +import testPackCase1.Case.E + +operator fun Case.E.plus(value: Int) = Inv() +operator fun Case.Inv.invoke(i: Int) = 1 + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testPackCase1 +import libPackage.* + +class Case() { + class E(val plus: Inv? = null) { + /*operator*/ fun plus(value: Int) = Case() + } + + class Inv() { + /*operator*/ fun invoke(value: Int) = Case() + } + + fun foo(e: E) { + /*operator*/ fun E.plus(value: Int) = Case() + + run { + e + 1 + } + e + 1 + + } +} + +// FILE: Lib1.kt +// TESTCASE NUMBER: 2 +package libPackage1 + +public inline operator fun CharSequence.contains(regex: Regex): Boolean = regex.containsMatchIn(this) + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 2 +package testPackCase2 +import libPackage1.* +class Case() { + + fun foo() { + "".contains(Regex("")) + } +} + +// FILE: LibCase3.kt +// TESTCASE NUMBER: 3 +package libPackage +import testPackCase3.Case +import testPackCase3.Case.Inv +import testPackCase3.Case.E + +operator fun Case.E.plusAssign(value: Int) {} +operator fun Case.Inv.invoke(i: Int) {} + + +// FILE: TestCase3.kt +// TESTCASE NUMBER: 1 +package testPackCase3 +import libPackage.* + +class Case() { + class E(val plusAssign: Inv? = null) { + /*operator*/ fun plusAssign(value: Int) {} + } + + class Inv() { + /*operator*/ fun invoke(value: Int) {} + } + + fun foo(e: E) { + /*operator*/ fun E.plusAssign(value: Int) {} + + run { + e += 1 + } + e += 1 + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt new file mode 100644 index 00000000000..5dbd1aa9479 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt @@ -0,0 +1,34 @@ +// !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, operator-call -> paragraph 2 -> sentence 3 + * RELEVANT PLACES: 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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 6 + * DESCRIPTION: Star-imported extension callables + */ + + +// FILE: LibCase1.kt +// TESTCASE NUMBER: 1 +package libPackage + +/*public*/ private inline operator fun CharSequence.contains(regex: Regex): Boolean = regex.containsMatchIn(this) + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testPackCase1 +import libPackage.* + +class Case() { + + fun foo() { + "".contains(Regex("")) + } +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.kt new file mode 100644 index 00000000000..6f6d35d2707 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.kt @@ -0,0 +1,227 @@ +// !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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: properties available through the invoke convention are non-eligible for operator calls + */ + +// FILE: TestCase1.kt +/* + * TESTCASE NUMBER: 1 + * NOTE:Delegated properties + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36844 + */ +package testPackCase1 + +fun case1() { + var b = B() + val a: String = b.p +} + +class B() { + val p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected +} + +class Delegate { + val getValue = G() +} + +class G { + operator fun invoke(i: Int): String = "" +} + + +// FILE: TestCase2.kt +/* + * TESTCASE NUMBER: 2 + * NOTE:Delegated properties + */ +package testPackCase2 +fun case2() { + var b = B() + val a: String = b.p + b.p = "" +} + +class B() { + var p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected +} + +class Delegate { + val getValue = G() + val setValue = S() +} + +class G { + operator fun invoke(i: Int): String = "" +} + +class S { + operator fun invoke(i: String) {} +} + +// FILE: TestCase3.kt +/* + * TESTCASE NUMBER: 3 + * NOTE: Arithmetic and comparison operators + */ +package testPackCase3 + +class Comp() { + operator fun invoke(i: Int): Int = 1 +} + +class Arifm() { + operator fun invoke(i: Int) {} +} + +class B() { + val plus = Arifm() + val minus = Arifm() + val compareTo = Comp() +} + +fun case3() { + var b = B() + b + 5 + b - 5 + b < 5 + b >= 5 +} +// FILE: TestCase4.kt +/* + * TESTCASE NUMBER: 4 + * NOTE: Operator-form assignments + */ +package testPackCase4 +class Assign() { + operator fun invoke(i: Int) {} +} + +class B(val minusAssign: Assign = Assign()) { + val plusAssign = Assign() +} + +fun case3() { + var b = B() + b += 2 + b -= 3 +} + +// FILE: TestCase5.kt +/* + * TESTCASE NUMBER: 5 + * NOTE: Arithmetic and comparison operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36852 + */ +package testPackCase5 + +class Case5() { + + fun f(c: Case5){ + this + 1 //OPERATOR_MODIFIER_REQUIRED for class plus, resolved to (1) + c + 1 //OPERATOR_MODIFIER_REQUIRED for class plus, resolved to (1) + } + + inner class plus constructor(val i:Int){ + operator fun invoke(i:Int) {} //(1) + } +} + +// FILE: TestCase6.kt +/* + * TESTCASE NUMBER: 6 + * NOTE: Arithmetic and comparison operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36852 + */ +package testPackCase6 + +class B(var a: Int = 0) { + + inner class E(){ + val plus :E =TODO() + + fun foo(b: B){ + this + 1 + } + + operator fun invoke(value: Int) = B() + } +} + +// FILE: TestCase7.kt +/* + * TESTCASE NUMBER: 7 + * NOTE: for-loop operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36898 + */ +package testPackCase7 + +fun case7 () { + val iterable: Iterable = Iterable(Inv('s')) + for (i in iterable) { + println(i) + } +} + +class Iterable(val iterator: Inv) { + // operator fun iterator() : CharIterator = TODO() +} + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = object : CharIterator() { + private var index = 0 + + override fun nextChar(): Char { + index++; return c + } + + override fun hasNext(): Boolean = index < 5 + } +} + + +// FILE: TestCase8.kt +/* + * TESTCASE NUMBER: 8 + * NOTE: for-loop operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36898 + */ +package testPackCase8 + +fun case8 () { + val iterable: Iterable = Iterable() + for (i in iterable) { + println(i) + } +} + +class Iterable() { + // operator fun iterator() : CharIterator = TODO() +} +val Iterable.iterator: Inv + get() = Inv('c') + +class Inv(val c: Char) { + operator fun invoke(): CharIterator = object : CharIterator() { + private var index = 0 + + override fun nextChar(): Char { + index++; return c + } + + override fun hasNext(): Boolean = index < 5 + } +} + diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/pos/1.1.kt new file mode 100644 index 00000000000..0ab60ee8555 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/pos/1.1.kt @@ -0,0 +1,73 @@ +// !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, operator-call -> paragraph 4 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: properties available through the invoke convention are non-eligible for operator calls + */ + +// FILE: TestCase1.kt +/* + * TESTCASE NUMBER: 1 + * NOTE: Arithmetic and comparison operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36855 + */ +package testPackCase1 + +class Arithmetic() { + operator fun invoke(i: Int) = B() +} +class B() { + operator fun plus(i: Int) : B =B() + val plusAssign = Arithmetic() + + fun case7(){ + var b =B() + b+=1 //ASSIGN_OPERATOR_AMBIGUITY + this += 1 //ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT, PROPERTY_AS_OPERATOR + } +} + +fun case1() { + var b = B() + b += 1 //ASSIGN_OPERATOR_AMBIGUITY +} + +// FILE: TestCase2.kt +/* + * TESTCASE NUMBER: 1 + * NOTE: Arithmetic and comparison operators + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36855 + */ +package testPackCase2 + +class Arithmetic() { + operator fun invoke(i: Int) = B() +} + +class B() { + operator fun plusAssign(i: Int) {} + val plus = Arithmetic() + + + fun case2(b: B) { + b += 1 //ok + + var b1 = B() + b1 += 1 //ASSIGN_OPERATOR_AMBIGUITY + + this += 1 //ok + } +} + +fun case2() { + var b = B() + b += 1 //ASSIGN_OPERATOR_AMBIGUITY +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json new file mode 100644 index 00000000000..4b2d20ebf12 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/testsMap.json @@ -0,0 +1,73 @@ +{ + "4": { + "neg": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "smart case for property `plus` available through the operator invoke", + "path": "compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg/1.1.kt", + "unexpectedBehaviour": true + }, + { + "specVersion": "0.1-268", + "casesNumber": 8, + "description": "properties available through the invoke convention are non-eligible for operator calls", + "unexpectedBehaviour": true + } + ] + }, + "pos": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "properties available through the invoke convention are non-eligible for operator calls", + "unexpectedBehaviour": true + } + ] + } + }, + "2": { + "pos": { + "3": [ + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Extension callables declared in the package scope", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 3, + "description": "Star-imported extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 10, + "description": "Non-extension member callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "Star-imported extension callables", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-268", + "casesNumber": 5, + "description": "Non-extension member callables", + "unexpectedBehaviour": true + }, + { + "specVersion": "0.1-268", + "casesNumber": 4, + "description": "Explicitly imported extension callables", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg/1.1.kt new file mode 100644 index 00000000000..632a9e4d203 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg/1.1.kt @@ -0,0 +1,43 @@ +// !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: type-inference, smart-casts, smart-cast-sink-stability -> paragraph 5 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 4 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, operator-call -> paragraph 2 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: smart case for property `plus` available through the operator invoke + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36876 + */ +// TESTCASE NUMBER: 1 +class Case1() { + + class E(val plus: Inv? = null, val value: Inv? = null) + + class Inv() { + operator fun invoke(value: Int) = Case1() + } + + fun foo(e: E) { + + if (e.plus != null) { + run { e + 1 } + + /* + [PROPERTY_AS_OPERATOR] (ok) + Properties cannot be used in operator conventions: 'invoke' in 'operatorCall.Case1.Inv' + [UNSAFE_OPERATOR_CALL] (nok) + Operator call corresponds to a dot-qualified call 'e.plus(1)' which is not allowed on a nullable receiver 'e'. + */ + e + 1 + + e.plus.invoke(1) //ok + } + + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos/1.1.kt b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos/1.1.kt new file mode 100644 index 00000000000..c0bda02ddbd --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos/1.1.kt @@ -0,0 +1,38 @@ +// !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: type-inference, smart-casts, smart-cast-sink-stability -> paragraph 5 -> sentence 1 + * RELEVANT PLACES: overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 1 -> sentence 1 + * overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 3 -> sentence 1 + * NUMBER: 1 + * DESCRIPTION: smart cast for the property available through the operator invoke + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-36876 + */ +// TESTCASE NUMBER: 1 +class Case1() { + + class E(val plus: Inv? = null, val value: Inv? = null) + + class Inv() { + operator fun invoke(value: Int) = Case1() + } + + fun foo(e: E) { + + if (e.value != null) { + run { e.value(1) } + /* + [UNSAFE_CALL] (nok) + Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Case1.Inv? + */ + e.value(1) + + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/testsMap.json new file mode 100644 index 00000000000..127db809764 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/testsMap.json @@ -0,0 +1,24 @@ +{ + "5": { + "neg": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "smart case for property `plus` available through the operator invoke", + "unexpectedBehaviour": true + } + ] + }, + "pos": { + "1": [ + { + "specVersion": "0.1-268", + "casesNumber": 1, + "description": "smart cast for the property available through the operator invoke", + "unexpectedBehaviour": true + } + ] + } + } +} \ 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 09feb008165..a11091d1153 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 @@ -25,7 +25,7 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } public void testAllFilesPresentInDiagnostics() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "linked/type-inference", "linked/type-system/type-kinds/type-parameters", "linked/type-system/subtyping", "linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "linked/declarations/classifier-declaration/classifier-initialization", "linked/declarations/function-declaration", "linked/declarations/property-declaration/property-initialization", "linked/annotations", "linked/statements/assignments/simple-assignments", "linked/inheritance", "linked/expressions/function-literals", "linked/expressions/call-and-property-access-expressions", "linked/overloadable-operators", "linked/overload-resolution/c-level-partition", "linked/overload-resolution/determining-function-applicability-for-a-specific-call", "linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "linked/type-inference/smart-casts/smart-cast-types", "linked/type-inference/local-type-inference", "linked/type-system/type-kinds/type-parameters", "linked/type-system/subtyping", "linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "linked/declarations/classifier-declaration/classifier-initialization", "linked/declarations/function-declaration", "linked/declarations/property-declaration/property-initialization", "linked/annotations", "linked/statements/assignments/simple-assignments", "linked/inheritance", "linked/expressions/function-literals", "linked/expressions/call-and-property-access-expressions", "linked/overloadable-operators", "linked/overload-resolution/c-level-partition", "linked/overload-resolution/determining-function-applicability-for-a-specific-call", "linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph"); } @TestMetadata("compiler/tests-spec/testData/diagnostics/linked") @@ -37,7 +37,7 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } public void testAllFilesPresentInLinked() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "type-inference", "type-system/type-kinds/type-parameters", "type-system/subtyping", "control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "declarations/classifier-declaration/classifier-initialization", "declarations/function-declaration", "declarations/property-declaration/property-initialization", "annotations", "statements/assignments/simple-assignments", "inheritance", "expressions/function-literals", "expressions/call-and-property-access-expressions", "overloadable-operators", "overload-resolution/c-level-partition", "overload-resolution/determining-function-applicability-for-a-specific-call", "control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "type-inference/smart-casts/smart-cast-types", "type-inference/local-type-inference", "type-system/type-kinds/type-parameters", "type-system/subtyping", "control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "declarations/classifier-declaration/classifier-initialization", "declarations/function-declaration", "declarations/property-declaration/property-initialization", "annotations", "statements/assignments/simple-assignments", "inheritance", "expressions/function-literals", "expressions/call-and-property-access-expressions", "overloadable-operators", "overload-resolution/c-level-partition", "overload-resolution/determining-function-applicability-for-a-specific-call", "control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph"); } @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis") @@ -3605,6 +3605,124 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } } } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Operator_call extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInOperator_call() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-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/operator-call/p-2"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-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/operator-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/operator-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/operator-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/operator-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/operator-call/p-2/pos/3.5.kt"); + } + + @TestMetadata("3.6.kt") + public void test3_6() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.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/operator-call/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class P_4 extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInP_4() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/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/operator-call/p-4/neg/1.1.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/operator-call/p-4/neg"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/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("1.1.kt") + public void test1_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/pos/1.1.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/operator-call/p-4/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + } } @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention") @@ -3980,6 +4098,94 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } } + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Type_inference extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInType_inference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference"), Pattern.compile("^(.+)\\.kt$"), null, true, "smart-casts/smart-cast-types", "local-type-inference"); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Smart_casts extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSmart_casts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts"), Pattern.compile("^(.+)\\.kt$"), null, true, "smart-cast-types"); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Smart_cast_sink_stability extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInSmart_cast_sink_stability() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class P_5 extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInP_5() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/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/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg/1.1.kt"); + } + + public void testAllFilesPresentInNeg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/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("1.1.kt") + public void test1_1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos/1.1.kt"); + } + + public void testAllFilesPresentInPos() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-sink-stability/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + } + } + } + @TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-system") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/BlackBoxCodegenTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/BlackBoxCodegenTestSpecGenerated.java index 72c0b5a6a59..ef8957b2a2a 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/BlackBoxCodegenTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/BlackBoxCodegenTestSpecGenerated.java @@ -25,7 +25,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes } public void testAllFilesPresentInBox() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates"); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates", "linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver"); } @TestMetadata("compiler/tests-spec/testData/codegen/box/linked") @@ -37,7 +37,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes } public void testAllFilesPresentInLinked() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), null, true); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver"); } @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions") @@ -3302,7 +3302,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes } public void testAllFilesPresentInOverload_resolution() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution"), Pattern.compile("^(.+)\\.kt$"), null, true); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution"), Pattern.compile("^(.+)\\.kt$"), null, true, "building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver"); } @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs") @@ -3314,7 +3314,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes } public void testAllFilesPresentInBuilding_the_overload_candidate_set_ocs() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs"), Pattern.compile("^(.+)\\.kt$"), null, true); + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs"), Pattern.compile("^(.+)\\.kt$"), null, true, "call-with-an-explicit-receiver"); } @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/infix-function-call") @@ -3360,6 +3360,95 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes } } } + + @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Operator_call extends AbstractBlackBoxCodegenTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInOperator_call() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class P_2 extends AbstractBlackBoxCodegenTestSpec { + 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/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Pos extends AbstractBlackBoxCodegenTestSpec { + 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/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.1.kt"); + } + + @TestMetadata("3.10.kt") + public void test3_10() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.10.kt"); + } + + @TestMetadata("3.2.kt") + public void test3_2() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.2.kt"); + } + + @TestMetadata("3.3.kt") + public void test3_3() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.3.kt"); + } + + @TestMetadata("3.4.kt") + public void test3_4() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.4.kt"); + } + + @TestMetadata("3.5.kt") + public void test3_5() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.5.kt"); + } + + @TestMetadata("3.6.kt") + public void test3_6() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.6.kt"); + } + + @TestMetadata("3.7.kt") + public void test3_7() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.7.kt"); + } + + @TestMetadata("3.8.kt") + public void test3_8() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.8.kt"); + } + + @TestMetadata("3.9.kt") + public void test3_9() throws Exception { + runTest("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos/3.9.kt"); + } + + public void testAllFilesPresentInPos() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + } + } + } } @TestMetadata("compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention")