Skip to content

Commit 0f499df

Browse files
authored
Merge pull request github#10877 from tamasvajk/kotlin-safe-call-null-check
Kotlin: Add test for useless null check on safe calls
2 parents 086362d + d65c52b commit 0f499df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

java/ql/test/kotlin/query-tests/UselessNullCheck/Test.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ fun fn(x:Any?, y: Any?) {
99
println("y not null")
1010
}
1111
}
12+
13+
fun fn0(o: Any?) {
14+
if (o != null) {
15+
o?.toString()
16+
o.toString()
17+
}
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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) ... |

0 commit comments

Comments
 (0)