```if (e is Error && e !is AssertionEr...
# compiler
p
Copy code
if (e is Error
    && e !is AssertionError
    && e !is NotImplementedError // why compiler complains about "Check for instance is always 'true'." ?
) {
    throw e
}
d
It's an IDE inspection, not a compiler warning
p
Hello, Dmitriy! It is also compiler warning.
d
To distinguish them you can do the following: enable every FIR checker that we have (and output kotlin.git-searchable internal IDs of reported diagnostics) by chanting the
-Wextra -Xuse-fir-experimental-checkers -Xrender-internal-diagnostic-names
incantation in compiler arguments. If a warning does not appear in compilation logs after that — it's an IDE inspection. You can also enable IJ's internal mode; then the aforementioned IDs should be displayed right in IDE (pic related). If a warning does not have an ID after that — it's an IDE inspection.
What is the full code then? I failed to reproduce it for the compiler
p
Copy code
fun ensureNonCritical(e: Exception) {
    if (e is Error
        && e !is NotImplementedError
    ) {
        throw e
    }
}
executing using Gradle cmd
Copy code
kotlin=2.1.20
d
Ah, that's simple.
Error
is not a subtype of
Exception
. They both inherit from
Throwable
, but there is no subtyping relation between them
I got a little confused, since you mentioned
true
in the original message, not
false
p
😂 Sorry! My bad!
👌 1
But it is strange that 'e is Error' is not marked as 'Always false'
Copy code
fun ensureNonCritical(e: Exception) {
    if (e is Error) {
        throw e
    }
}
d
Indeed, looks like a little bug. Could you please report it to YouTrack? Also cc @Nick Lunyak
👌 1
thank you color 1