I’m using OptIn features quite liberally in my code base. Because of this, I get a lot of warnings of the following form while compiling:
w: /path/to/file.kt: (73, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
Is there a way to disable these warnings when compiling with Gradle? They tend to obscure relevant warnings when looking at the compile output.
The same goes for the code analysis warnings when I do a git commit. I like this feature when doing a commit, but since I have the @OptIn clause sin plenty of my files, it keeps telling me that there a warnings, which requires me to look at them individually and then reissue the commit.
I’d like to have a way to tell the compiler and code analyser to never warn me about the fact that I’m using the OptIn features.
After doing this, I seem to get less warnings, but I still get a set of them from the following target:
> Task :array:compileKotlinMetadata
w: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+InlineClasses
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
w: /home/elias/prog/array_kotlin/array/src/commonMain/kotlin/array/common.kt: (49, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /home/elias/prog/array_kotlin/array/src/commonMain/kotlin/array/common.kt: (128, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /home/elias/prog/array_kotlin/array/src/commonMain/kotlin/array/io.kt: (41, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /home/elias/prog/array_kotlin/array/src/commonMain/kotlin/array/parser.kt: (43, 6): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
Do I need to add the flag to some other section too?
In addition to this, I also have a set of these warnings that I would like to disable:
> Task :array:compileKotlinJvm
w: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+InlineClasses
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
Seems like you missed adding it for the common code.
w: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+InlineClasses
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
Sadly I don’t know any way of removing this warning. I’m not sure it’s possible, but I can live with it since it is only displayed once per build/module and not for every inline class.
Thank you again for your help. I didn’t understand what you meant by compiler options for common code, as I would have expected the ones for each target to be applied.
Your suggestion did lead me to search for other targets for which I can add compiler options, and while “common” was not one that worked I did find another one that stops the warnings: