[NI] Discriminate resulting type Nothing(?) at fixation stage
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun <K> select2(x: K, y: K): K = TODO()
|
||||
fun <K> select3(x: K, y: K, z: K): K = TODO()
|
||||
|
||||
fun test2(f: ((String) -> Int)?) {
|
||||
val a0: ((Int) -> Int)? = select2({ it -> it }, null)
|
||||
val b0: ((Nothing) -> Unit)? = select2({ it -> <!UNUSED_EXPRESSION!>it<!> }, null)
|
||||
|
||||
select3({ it.length }, f, null)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> select2(/*0*/ x: K, /*1*/ y: K): K
|
||||
public fun </*0*/ K> select3(/*0*/ x: K, /*1*/ y: K, /*2*/ z: K): K
|
||||
public fun test2(/*0*/ f: ((kotlin.String) -> kotlin.Int)?): kotlin.Unit
|
||||
+1
-2
@@ -22,8 +22,7 @@ fun test(f1: (Int) -> Unit, f2: kotlin.Function1<Int, Unit>) {
|
||||
dependantSelect2(null, ::foo)
|
||||
dependantSelect3(null, ::foo, ::cloneFoo)
|
||||
dependantSelect3(null, f1, ::bar)
|
||||
// Here we have LOWER(Nothing?), UPPER(Function1) and therefore type variable is fixed to the former
|
||||
dependantSelect3(null, <!TYPE_MISMATCH!>::bar<!>, f1)
|
||||
dependantSelect3(null, ::bar, f1)
|
||||
|
||||
// These errors are actually can be fixed (and, probably, should) if we force resolution of callable reference
|
||||
dependantSelect3(null, ::foo, <!TYPE_MISMATCH!>::bar<!>)
|
||||
|
||||
Reference in New Issue
Block a user