Is there any reason why things like an unused loca...
# compiler
k
Is there any reason why things like an unused local variable and an unused function are warnings in the IDE but not in the compiler?
For context, I spent a bit trying to enable
allWarningsAsErrors = true
and it kept successfully building when I had intentionally added an unused variable. I found this surprising.
e
my WAG is that not all warnings are created equally. an unused function might be called via reflection or, in the case of
$dayJob
, generated bytecode added during class instrumentation. as such, it can be difficult to definitively flag something as truly unused.
but it's probably a bug. 😄
k
In both of those cases it seems like those warnings should be manually suppressed with a comment explaining that, then?
e
agreed 100%
k
I did just recently update my project to Kotlin 2.0.0 compiler, I wonder if it’s a bug there.
e
it's fine if the IDE inspections are slow or occasionally flaky, but the compiler should work the same way every time it is invoked. so I believe warnings that are more expensive to compute will not be in the compiler
unused local and private are probably easy, but "unused" in general requires seeing the whole project at once. so I guess they maybe don't introduce it in the compiler since it's covered more comprehensively in the IDE anyway?