mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Merge pull request #10962 from tamasvajk/kotlin-unreachable-catch
Kotlin: Exclude .kt files from `java/unreachable-catch-clause`
This commit is contained in:
@@ -86,6 +86,7 @@ predicate overlappingExceptions(RefType e1, RefType e2) {
|
||||
|
||||
from TryStmt try, int first, int second, RefType masking, RefType masked, string multiCatchMsg
|
||||
where
|
||||
try.getFile().isJavaSourceFile() and
|
||||
masking = caughtType(try, first) and
|
||||
masking.getAStrictAncestor() = masked and
|
||||
masked = caughtType(try, second) and
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Statements/PartiallyMaskedCatch.ql
|
||||
@@ -0,0 +1,31 @@
|
||||
fun fn0() { throw java.io.IOException() }
|
||||
|
||||
fun fn1() {
|
||||
try {
|
||||
throw java.io.IOException()
|
||||
} catch (e: java.io.FileNotFoundException) {
|
||||
println(e)
|
||||
} catch (e: java.io.IOException) {
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun fn2() {
|
||||
try {
|
||||
fn0()
|
||||
} catch (e: java.io.FileNotFoundException) {
|
||||
println(e)
|
||||
} catch (e: java.io.IOException) {
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun fn3() {
|
||||
try {
|
||||
throw java.io.FileNotFoundException()
|
||||
} catch (e: java.io.FileNotFoundException) {
|
||||
println(e)
|
||||
} catch (e: java.io.IOException) { // TODO: False negative
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user