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
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
fun baz(i: Int) = i
|
||||
fun <T> bar(x: T): T = x
|
||||
|
||||
fun nullableFun(): ((Int) -> Int)? = null
|
||||
|
||||
fun box(): String {
|
||||
val x1: (Int) -> Int = bar(if (true) ::baz else ::baz)
|
||||
val x2: (Int) -> Int = bar(nullableFun() ?: ::baz)
|
||||
val x3: (Int) -> Int = bar(::baz ?: ::baz)
|
||||
|
||||
val i = 0
|
||||
val x4: (Int) -> Int = bar(when (i) {
|
||||
10 -> ::baz
|
||||
20 -> ::baz
|
||||
else -> ::baz
|
||||
})
|
||||
|
||||
val x5: (Int) -> Int = bar(::baz!!)
|
||||
|
||||
if (x1(1) != 1) return "fail 1"
|
||||
if (x2(1) != 1) return "fail 2"
|
||||
if (x3(1) != 1) return "fail 3"
|
||||
if (x4(1) != 1) return "fail 4"
|
||||
if (x5(1) != 1) return "fail 5"
|
||||
|
||||
if ((if (true) ::baz else ::baz)(1) != 1) return "fail 6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user