Kotlin: Add test for useless null check on safe calls

This commit is contained in:
Tamas Vajk
2022-10-19 08:49:56 +02:00
parent 643cfced6a
commit d65c52bfc5
2 changed files with 8 additions and 0 deletions

View File

@@ -9,3 +9,10 @@ fun fn(x:Any?, y: Any?) {
println("y not null")
}
}
fun fn0(o: Any?) {
if (o != null) {
o?.toString()
o.toString()
}
}

View File

@@ -0,0 +1 @@
| Test.kt:15:12:15:21 | ... (value equals) ... | This check is useless. $@ cannot be null at this check, since it is guarded by $@. | Test.kt:15:9:15:9 | tmp0_safe_receiver | tmp0_safe_receiver | Test.kt:14:9:14:17 | ... (value not-equals) ... | ... (value not-equals) ... |