Fix diagnostic inferred type calculation for null in some cases

#KT-36222 fixed
This commit is contained in:
Ilya Chernikov
2020-02-19 17:15:37 +01:00
parent 997debdd42
commit 2727507d18
7 changed files with 45 additions and 1 deletions
@@ -0,0 +1,9 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(f: () -> String) {}
fun <K> select(x: K, y: K): K = x
fun test() {
foo { select("non-null", null) } // inferred String? but String is expected
}
@@ -0,0 +1,10 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(f: () -> String) {}
fun <K> select(x: K, y: K): K = x
fun test() {
foo { <!TYPE_MISMATCH!>select("non-null", null)<!> } // inferred String? but String is expected
}
@@ -0,0 +1,5 @@
package
public fun foo(/*0*/ f: () -> kotlin.String): kotlin.Unit
public fun </*0*/ K> select(/*0*/ x: K, /*1*/ y: K): K
public fun test(): kotlin.Unit