Add compatibility warning for SAM conversions on Kotlin functions

This commit is contained in:
Mikhail Zarechenskiy
2020-05-29 14:15:35 +03:00
parent 080d8fa127
commit 01de789c76
15 changed files with 467 additions and 2 deletions
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun interface KRunnable {
fun invoke()
}
object Test1 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test1.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun foo(f: () -> String) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test3 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
object Test4 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun bar() {}
fun test() {
val result = foo(1, ::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
object Test5 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test() {
<!DEBUG_INFO_CALL("fqName: Test5.Scope.foo; typeCall: function")!>foo { }<!>
}
}
}