Reputation: 2521
I have a function in Kotlin that I want to inline despite not being high-order.
I find that through out the project I have numerous occurrences of such scenario.
Therefore, to ignore compiler warnings about using inline functions, I have to use lots of Suppress("NOTHING_TO_INLINE")
annotations through out my project and it's starting to bother me.
Is there any way to block this warning for the whole project by, for instance, a compiler option? I'd like to know how to do this in IntelliJ IDEA.
Upvotes: 7
Views: 2085
Reputation: 122
With the release of Kotlin 2.1.0 earlier this week, you can now suppress warnings globally by adding a compiler flag:
// build.gradle.kts
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xsuppress-warning=NOTHING_TO_INLINE")
}
}
This will suppress the compiler warning project-wide.
However, IntelliJ IDEs do not seem to support this compiler flag yet (as of version 2023.3), as the inline warning still visually appears. I suspect this will be fixed in the next release.
Upvotes: 1
Reputation: 28228
It doesn't look like it's possible to disable the inspection globally. I can't find a setting in IntelliJ at least. You can, however, disable the inspection for an entire file:
@file:Suppress("NOTHING_TO_INLINE")
If you press ALT+Enter on the warning, you'll get an option to suppress it which just contains suppressing for the function, class (if it's in one), or for the entire file. Any inspections you can disable usually has a "Disable inspection" option on this list (which NOTHING_TO_INLINE
does not have).
You can, however, disable the warnings when compiling (but it does not affect the inspection; you'll still see warnings while editing) by adding suppressWarnings
to the compileKotlin task. Note that this disables ALL warnings, not just specific ones.
compileKotlin {
kotlinOptions.suppressWarnings = true
}
Upvotes: 12