Convert KFunction to Function in type mismatch fixes #KT-16770 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-05-03 21:03:37 +03:00
parent 25609f1159
commit 8c3e787584
12 changed files with 154 additions and 11 deletions
@@ -0,0 +1,8 @@
// "Change return type of enclosing function 'myFunction' to '(Int) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
fun myFunction(s: String): (String, Int) -> Boolean = <caret>s::verifyData
}
fun String.verifyData(a: Int) = this.length > a
@@ -0,0 +1,8 @@
// "Change return type of enclosing function 'myFunction' to '(Int) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
fun myFunction(s: String): (Int) -> Boolean = s::verifyData
}
fun String.verifyData(a: Int) = this.length > a
@@ -0,0 +1,8 @@
// "Change type of 'myFunction' to '(Int, (Int) -> Boolean) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, Int) -> Int = <caret>::verifyData
}
fun verifyData(a: Int, b: (Int) -> Boolean) = b(a)
@@ -0,0 +1,8 @@
// "Change type of 'myFunction' to '(Int, (Int) -> Boolean) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, (Int) -> Boolean) -> Boolean = ::verifyData
}
fun verifyData(a: Int, b: (Int) -> Boolean) = b(a)
@@ -0,0 +1,10 @@
// "Change type of 'myFunction' to '(Int) -> KFunction0<Boolean>'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, Int) -> Int = <caret>::verifyData
}
fun Int.internalVerifyData() = this > 0
fun verifyData(a: Int) = a::internalVerifyData
@@ -0,0 +1,12 @@
import kotlin.reflect.KFunction0
// "Change type of 'myFunction' to '(Int) -> KFunction0<Boolean>'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int) -> KFunction0<Boolean> = ::verifyData
}
fun Int.internalVerifyData() = this > 0
fun verifyData(a: Int) = a::internalVerifyData
@@ -0,0 +1,8 @@
// "Change type of 'myFunction' to 'KFunction2<Int, Int, Boolean>'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, Int) -> Int = <caret>::verifyData
}
fun verifyData(a: Int, b: Int) = (a > 10 && b > 10)
@@ -0,0 +1,10 @@
import kotlin.reflect.KFunction2
// "Change type of 'myFunction' to 'KFunction2<Int, Int, Boolean>'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: KFunction2<Int, Int, Boolean> = ::verifyData
}
fun verifyData(a: Int, b: Int) = (a > 10 && b > 10)
+8
View File
@@ -0,0 +1,8 @@
// "Change type of 'myFunction' to '(Int, Int) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, Int) -> Int = <caret>::verifyData
}
fun verifyData(a: Int, b: Int) = (a > 10 && b > 10)
@@ -0,0 +1,8 @@
// "Change type of 'myFunction' to '(Int, Int) -> Boolean'" "true"
// WITH_RUNTIME
fun foo() {
var myFunction: (Int, Int) -> Boolean = ::verifyData
}
fun verifyData(a: Int, b: Int) = (a > 10 && b > 10)