Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/generic/specialCalls.kt
T
Mikhail Zarechenskiy 2cac6a9e7d Improve inference on generics for callable references
#KT-10711 Fixed
 #KT-12802 Fixed
 #KT-12964 Fixed
 #KT-15439 Fixed

Analyze callable references in `dependent` mode, then complete them with
respect to expected types
2017-01-24 02:15:26 +03:00

23 lines
692 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
fun baz(i: Int) = i
fun <T> bar(x: T): T = TODO()
fun nullableFun(): ((Int) -> Int)? = null
fun test() {
val x1: (Int) -> Int = bar(if (true) ::baz else ::baz)
val x2: (Int) -> Int = bar(nullableFun() ?: ::baz)
val x3: (Int) -> Int = bar(::baz <!USELESS_ELVIS!>?: ::baz<!>)
val i = 0
val x4: (Int) -> Int = bar(when (i) {
10 -> ::baz
20 -> ::baz
else -> ::baz
})
val x5: (Int) -> Int = bar(::baz<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
(if (true) ::baz else ::baz)(1)
}