Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/referenceAdaptationCompatibility.kt
T
2020-06-01 10:19:33 +03:00

57 lines
1.2 KiB
Kotlin
Vendored

// !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<!>
}
}
}