https://kotlinlang.org logo
#compiler
Title
# compiler
d

Daniel Svensson

10/14/2020, 7:25 AM
Is it possible to turn some Kotlin compiler warnings into errors via a compiler plugin, or compiler plugins don't have access to that? Goal being for example turning unused variables into errors etc.
see flag allWarningsAsErrors
d

Daniel Svensson

10/14/2020, 8:17 AM
Yes I know right, it's insane. All C-compilers have for ages been able to flip specific compiler warnings into error.
I'm currently wrapping compilation in bash that greps for specific warnings and fail the build based on that. While it works, every line of bash smells bad.
Thus I was hoping to find more integrated deterministic ways of dealing with this.
g

gildor

10/14/2020, 8:36 AM
I see now your point, no there is no way to do this for specific warning
I would create a feature request
not sure that compiler plugins has access to this information
d

Daniel Svensson

10/14/2020, 8:45 AM
Yeah, think there's an issue about this already iirc. Was hoping a plugin would be an alternative, thanks.
d

dmitriy.novozhilov

10/14/2020, 9:15 AM
@Daniel Svensson We are working on refactoring CLI for new kotlin compiler, and in it we want support such functionality. But it won't be released soon, and there is no workarounds for your case right now
d

Daniel Svensson

10/14/2020, 9:22 AM
Excellent!
s

shikasd

10/14/2020, 1:56 PM
Theoretically, you could hack compiler to suppress particular diagnostics and introduce your own with the same text instead, but with Error level. I remember at least folks from arrow-meta doing something with diagnostics, but maybe it is available even without it. My suspicion is that it is limited to JVM only, but maybe it covers your case
3 Views