Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
@@ -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"
|
||||
}
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
-1
@@ -1,7 +1,7 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
fun invoke(i: Int) = i
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user