Add compatibility warning for reference adaptation

This commit is contained in:
Mikhail Zarechenskiy
2020-05-31 23:50:19 +03:00
parent 684dfb959c
commit 47e6805186
10 changed files with 240 additions and 3 deletions
@@ -0,0 +1,57 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
object Test1 {
fun <T> foo(f: () -> T): T = f()
fun bar(): Int = 0
object Scope {
fun bar(x: Int = 0): String = ""
fun test() {
val result = foo(<!COMPATIBILITY_WARNING!>::bar<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
}
object Test2 {
fun foo(f: () -> Unit) {}
fun bar() {}
object Scope {
fun bar(): String = ""
fun test() {
foo(<!COMPATIBILITY_WARNING!>::bar<!>)
}
}
}
object Test3 {
fun <T> foo(f: (Int, Int) -> T): T = TODO()
fun bar(x: Int, y: Int): Int = 0
object Scope {
fun bar(vararg ints: Int): String = ""
fun test() {
val result = foo(<!COMPATIBILITY_WARNING!>::bar<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
}
object Test4 {
fun <T> foo(f: (Array<String>) -> T): T = TODO()
fun bar(g: Array<String>): Int = 0
object Scope {
// Works before 1.4
fun bar(vararg g: String): String = ""
fun test() {
val result = foo(::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
}