Files
kotlin-fork/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.fir.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

39 lines
746 B
Kotlin
Vendored

//KT-2164 !! does not propagate nullability information
package kt2164
fun foo(x: Int): Int = x + 1
fun main() {
val x: Int? = null
foo(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
if (x != null) {
foo(x)
foo(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
foo(x)
}
foo(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
if (x != null) {
foo(x)
foo(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
foo(x)
} else {
foo(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
foo(x!!)
foo(x)
}
foo(x)
foo(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
foo(x)
val y: Int? = null
y!!
y<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
foo(y)
foo(y<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
}