Fix tests: "infix modifier required" and "operator modifier required" errors

This commit is contained in:
Yan Zhulanow
2015-11-26 15:56:56 +03:00
parent a3ff3ffc45
commit 9d1af5a17e
635 changed files with 1283 additions and 1617 deletions
@@ -1,22 +0,0 @@
// KT-3998 Infix call doesn't work for function literals and another classes which implements invoke convention (in JS backend)
package foo
fun test(): String {
val a: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "a" }
val b: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = {
val aa = this as @Extension Function2<Any?, Any?, Any?>;
val cc = it as @Extension Function2<Any?, Any?, Any?>;
"${null.aa(null)} b ${null.cc(null)}"
}
val c: (@Extension Function2<*, *, *>).(@Extension Function2<*, *, *>)->String = { "c" }
val f = a.b(c) // works
val s = a b c //compiler crashes
return "$f | $s"
}
fun box(): String {
assertEquals("a b c | a b c", test())
return "OK"
}
@@ -10,19 +10,19 @@
package foo
class Bar/* : Function0<String>*/ {
fun invoke() = "Bar.invoke()"
operator fun invoke() = "Bar.invoke()"
}
class Baz/* : Function2<Int, Boolean, String>*/ {
fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)"
operator fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)"
}
class Mixed/* :
Function1<Int, String>,
Function2<Int, Boolean, String>*/
{
fun invoke(i: Int) = "Mixed.invoke($i)"
fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)"
operator fun invoke(i: Int) = "Mixed.invoke($i)"
operator fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)"
}
fun box(): String {
@@ -1,7 +1,7 @@
package foo
class Foo(val postfix: String) {
public fun invoke(text: String): String {
operator fun invoke(text: String): String {
return text + postfix
}
}
@@ -1,8 +1,8 @@
package foo
class A {
fun invoke() = "##"
fun invoke(i: Int) = "#${i}"
operator fun invoke() = "##"
operator fun invoke(i: Int) = "#${i}"
}
fun foo() = A()
@@ -1,7 +1,7 @@
package foo
class A {
fun invoke(i: Int) = i
operator fun invoke(i: Int) = i
}
fun box(): Boolean {
@@ -1,6 +1,6 @@
package foo
fun Int.invoke(x: Int) = this + x
operator fun Int.invoke(x: Int) = this + x
fun box(): Boolean {
return 1(2) == 3
}