Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun A.invoke() = "##"
|
||||
fun A.invoke(i: Int) = "#${i}"
|
||||
operator fun A.invoke() = "##"
|
||||
operator fun A.invoke(i: Int) = "#${i}"
|
||||
}
|
||||
|
||||
fun foo() = A()
|
||||
|
||||
@@ -5,7 +5,7 @@ fun test1(predicate: (Int) -> Int, i: Int) = predicate(i)
|
||||
fun test2(predicate: (Int) -> Int, i: Int) = predicate.invoke(i)
|
||||
|
||||
class Method {
|
||||
fun invoke(i: Int) = i
|
||||
operator fun invoke(i: Int) = i
|
||||
}
|
||||
|
||||
fun test3(method: Method, i: Int) = method.invoke(i)
|
||||
@@ -14,7 +14,7 @@ fun test4(method: Method, i: Int) = method(i)
|
||||
|
||||
class Method2 {}
|
||||
|
||||
fun Method2.invoke(s: String) = s
|
||||
operator fun Method2.invoke(s: String) = s
|
||||
|
||||
fun test5(method2: Method2, s: String) = method2(s)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
//KT-2728 Can't compile A()()
|
||||
|
||||
class A {
|
||||
fun invoke() = "##"
|
||||
fun invoke(i: Int) = "#${i}"
|
||||
operator fun invoke() = "##"
|
||||
operator fun invoke(i: Int) = "#${i}"
|
||||
}
|
||||
|
||||
fun foo() = A()
|
||||
|
||||
@@ -11,5 +11,5 @@ class Bad(val a: () -> Int) {
|
||||
|
||||
fun test(): Int = a()
|
||||
|
||||
fun invoke(): Int = 2
|
||||
operator fun invoke(): Int = 2
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//KT-3297 Calling the wrong function inside an extension method to the Function0 class
|
||||
|
||||
fun <R> Function0<R>.or(alt: () -> R): R {
|
||||
infix fun <R> Function0<R>.or(alt: () -> R): R {
|
||||
try {
|
||||
return this()
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
public class A(val s: String) {
|
||||
|
||||
public fun get(i: Int) : A = A("$s + $i")
|
||||
operator fun get(i: Int) : A = A("$s + $i")
|
||||
|
||||
public fun invoke(builder : A.() -> String): String = builder()
|
||||
operator fun invoke(builder : A.() -> String): String = builder()
|
||||
}
|
||||
fun x(y : String) : A = A(y)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//KT-3631 String.invoke doesn't work with literals
|
||||
|
||||
fun String.invoke(i: Int) = "$this$i"
|
||||
operator fun String.invoke(i: Int) = "$this$i"
|
||||
|
||||
fun box() = if ("a"(12) == "a12") "OK" else "fail"
|
||||
@@ -5,7 +5,7 @@ open class A {
|
||||
}
|
||||
|
||||
class B {
|
||||
fun invoke(f: B.() -> Unit) = 2
|
||||
operator fun invoke(f: B.() -> Unit) = 2
|
||||
}
|
||||
|
||||
open class C
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//KT-3821 Invoke convention doesn't work for `this`
|
||||
|
||||
class A() {
|
||||
fun invoke() = 42
|
||||
operator fun invoke() = 42
|
||||
fun foo() = this() // Expecting a function type, but found A
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user