KTI-1665 [kotlin] Adjust testdata for KtDataFlowInspectionTest

Some missing `USELESS_IS_CHECK` diagnostics are now reported in K2

Corresponding issue: KT-58203
Corresponding commit from kotlin: 88ff93df

GitOrigin-RevId: 6dd50eaebdb1929ad260963a63fc20f3e77792d6
This commit is contained in:
Roman Golyshev
2024-03-25 13:44:47 +00:00
committed by intellij-monorepo-bot
parent 3f890f8310
commit 55bd83c0d1
3 changed files with 5 additions and 8 deletions
@@ -13,8 +13,7 @@ inline fun <reified T: Number> number(t: T) {
// Cannot say anything
if (x is T) {}
x = "hello"
// TODO: support 'always false' here
if (x is T) {}
if (<warning descr="[USELESS_IS_CHECK] Check for instance is always 'false'.">x is T</warning>) {}
}
// Non-reified
@@ -1,14 +1,13 @@
// WITH_STDLIB
fun unrelatedTypes(obj : Any) {
if (obj is X) {
// Difference with K1: no 'USELESS_IS_CHECK' warning, hence we report it, as it's useful
if (<warning descr="Condition 'obj is Y' is always false">obj is Y</warning>) { }
if (<warning descr="Condition 'obj !is Y' is always true">obj !is Y</warning>) { }
if (<warning descr="[USELESS_IS_CHECK] Check for instance is always 'false'.">obj is Y</warning>) { }
if (<warning descr="[USELESS_IS_CHECK] Check for instance is always 'true'.">obj !is Y</warning>) { }
}
}
fun nullableTypes(obj : Any?) {
if (obj is X?) {
if (obj is Y?) {
if (<warning descr="[USELESS_IS_CHECK] Check for instance is always 'true'.">obj is Y?</warning>) {
if (<warning descr="Condition 'obj == null' is always true">obj == null</warning>) { }
}
}
@@ -47,8 +47,7 @@ fun whenIs(obj : Any?) {
}
if (obj is X) {
when(obj) {
// Difference with K1: no 'USELESS_IS_CHECK' warning, hence we report DFA warning, as it's useful
<warning descr="'when' branch is never reachable">is Y</warning> -> {}
<warning descr="[USELESS_IS_CHECK] Check for instance is always 'false'.">is Y</warning> -> {}
}
}
}