[FIR] Add nullability to ILT. #KT-37639 Fixed

This commit is contained in:
Dmitriy Novozhilov
2020-03-20 15:32:33 +03:00
parent 006e1f6528
commit 6ce8d661ad
11 changed files with 89 additions and 23 deletions
@@ -0,0 +1,13 @@
// ISSUE: KT-37639
fun takeInt(x: Int) {}
fun test_1(b: Boolean) {
val x = if (b) 1 else null
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
}
fun test_2(b: Boolean, y: Int) {
val x = if (b) y else null
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x)
}
@@ -0,0 +1,27 @@
FILE: nullableIntegerLiteralType.kt
public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun test_1(b: R|kotlin/Boolean|): R|kotlin/Unit| {
lval x: R|kotlin/Int?| = when () {
R|<local>/b| -> {
Int(1)
}
else -> {
Null(null)
}
}
<Inapplicable(INAPPLICABLE): [/takeInt]>#(R|<local>/x|)
}
public final fun test_2(b: R|kotlin/Boolean|, y: R|kotlin/Int|): R|kotlin/Unit| {
lval x: R|kotlin/Int?| = when () {
R|<local>/b| -> {
R|<local>/y|
}
else -> {
Null(null)
}
}
<Inapplicable(INAPPLICABLE): [/takeInt]>#(R|<local>/x|)
}
@@ -12,11 +12,11 @@ FILE: main.kt
^ R|<local>/x|.R|kotlin/Any.toString|()
}
)
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
Q|JavaUsage|.R|/JavaUsage.foo3|<R|ft<kotlin/Int, kotlin/Int?>!|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
}
, Int(1))
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|kotlin/Number|): R|kotlin/String| {
Q|JavaUsage|.R|/JavaUsage.foo3|<R|ft<kotlin/Int, kotlin/Int?>!|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|kotlin/Number|): R|kotlin/String| {
^ R|<local>/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|()
}
, Int(2))
@@ -17,7 +17,7 @@ FILE: main.kt
}
Q|JavaClass|.R|/JavaClass.foo2|(R|<local>/y|)
Q|JavaClass|.R|/JavaClass.foo3|<R|kotlin/Int|>(foo3@fun <anonymous>(it: R|ft<kotlin/Int, kotlin/Int?>!|): R|ft<kotlin/String, kotlin/String?>!| {
Q|JavaClass|.R|/JavaClass.foo3|<R|ft<kotlin/Int, kotlin/Int?>!|>(foo3@fun <anonymous>(it: R|ft<kotlin/Int, kotlin/Int?>!|): R|ft<kotlin/String, kotlin/String?>!| {
^ R|<local>/it|.R|kotlin/Int.plus|(Int(4)).R|kotlin/Any.toString|()
}
, Int(5))