https://kotlinlang.org logo
Title
v

Vitali Plagov

02/02/2022, 10:35 AM
I’m injecting a class that is annotated with
@ExperimentalStdlibApi
The compiler asks me to handle this and the Kotlin plugin offers me 5 options to do that. I’m confused which one to choose?
m

Michael de Kaste

02/02/2022, 10:44 AM
its exactly how you want to handle it. The use of an experimental library can be a big problem, as the class or function CAN simply disappear in later versions. Do you simply not care at all? I believe you can even opt-in on a compiler level throughout your whole application with
-Xopt-in=kotlin.ExperimentalStdlibApi
.
v

Vampire

02/02/2022, 10:45 AM
Maybe tell us which of the options you don't understand
v

Vitali Plagov

02/02/2022, 10:49 AM
I ended up with adding
@ExperimentalStdlibApi
on the second class. I more or less understand all options, thanks their description is self-explanatory. Wasn’t sure which one is correct to use, without going deep in details of each
v

Vampire

02/02/2022, 10:52 AM
Correct depends on your use-case. Do you want to opt-in only for the constructor, or for the whole class or for all code in the file or do you want to delay this opt-in to the user of that constructor or class.
v

Vitali Plagov

02/02/2022, 11:01 AM
Looks like the best way to handle is to opt out from an experimental stdlib feature 🙂