Files
kotlin-fork/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/7.fir.kt
T
pyos 67a6785f63 FIR DFA: move eq/notEq null-to-type translation to LogicSystem
This makes the `returns() implies` checker slightly cleaner, and also
fixes the case that I've missed where in RHS of `x ?:` type of `x` was
not set to `Nothing?`.
2022-11-22 15:44:37 +00:00

51 lines
1.5 KiB
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_EXPRESSION
// SKIP_TXT
// TESTCASE NUMBER: 1
fun case_1(x: Int?) {
if ((x is Int) <!USELESS_ELVIS!>?: (x is Int)<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
}
}
// TESTCASE NUMBER: 2
fun case_2(x: Int?) {
if (x?.equals(1) ?: x is Int) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
}
}
// TESTCASE NUMBER: 3
fun case_3(x: Boolean?) {
if (x ?: (<!SENSELESS_COMPARISON!>x != null<!>)) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!><!UNSAFE_CALL!>.<!>not()
}
}
// TESTCASE NUMBER: 4
fun case_4(x: Boolean?) {
if (if (x != null) x else <!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!><!UNSAFE_CALL!>.<!>not()
}
}
// TESTCASE NUMBER: 5
fun case_5(x: Any?) {
if (if (x is String) true else false) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>length<!>
}
}
// TESTCASE NUMBER: 6
fun case_6(x: Any?) {
if ((if (x != null) true else null) != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>length<!>
}
}