ribesg
10/04/2023, 9:16 AM@file:OptIn(ExperimentalForeignApi::class)
to hundreds of files because of https://kotlinlang.org/docs/whatsnew19.html#explicit-c-interoperability-stability-guarantees ?
Fun timesFlorian Levis
10/04/2023, 9:20 AMFlorian Levis
10/04/2023, 9:22 AMkotlin {
sourceSets {
all {
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}
}
ribesg
10/04/2023, 9:28 AMCLOVIS
10/04/2023, 9:50 AMFlorian Levis
10/04/2023, 10:02 AMribesg
10/04/2023, 10:05 AMmbonnin
10/04/2023, 5:17 PMCLOVIS
10/04/2023, 5:18 PMmbonnin
10/04/2023, 5:19 PMmbonnin
10/04/2023, 5:21 PMmbonnin
10/04/2023, 5:23 PMmbonnin
10/04/2023, 5:25 PMCLOVIS
10/04/2023, 5:31 PMCLOVIS
10/04/2023, 5:31 PMmbonnin
10/04/2023, 5:31 PMmbonnin
10/04/2023, 5:32 PMCLOVIS
10/04/2023, 5:33 PMmbonnin
10/04/2023, 5:39 PMIn any case, my advice is still sound, even if there are no promises madeI guess so. But it's a pain for the lib author. Is it possible to propagate at the module level instead of each and every symbol?
CLOVIS
10/04/2023, 5:46 PMmbonnin
10/04/2023, 5:47 PMmbonnin
10/04/2023, 5:47 PMCLOVIS
10/04/2023, 5:48 PMmbonnin
10/04/2023, 6:06 PMmbonnin
10/04/2023, 6:15 PMcommonMain
? ExperimentalForeignApi
is only available in native (kdoc)mbonnin
10/04/2023, 6:15 PMmbonnin
10/04/2023, 6:21 PMmbonnin
10/04/2023, 6:24 PM@ExperimentalForeignApi
symbols in expect
declarations, which is called out as something not to dombonnin
10/04/2023, 6:38 PMFlorian Levis
10/12/2023, 4:52 PMMmmm how do you opt-in/propagate from?commonMain
is only available in native (kdoc)ExperimentalForeignApi
but if you're making library, do not opt-in at the module-level, in fact, do not opt-in at all. Instead, propagate the warning to your users, otherwise their projects will break whenever this gets changedHow to you propagate an opt-in at all? Not specifically in native mode. I've generated a http client based on an openapidoc with https://openapi-generator.tech/docs/generators/kotlin, option serializationLibrary=kotlinx_serialization, and updated configfile to kotlin kts. I didn't OptIn "module wide" as said. Compilation now emit warning like this:
This declaration needs opt-in. Its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'When I use the library in a project, there is no warning about it 🤔 So what I understand is the optin is not propagated... The documentation talk about "custom" annotation https://kotlinlang.org/docs/opt-in-requirements.html#propagating-opt-in I'm lost :x
CLOVIS
10/12/2023, 5:41 PM@ExperimentalSerializationApi
annotation.
If you want to propagate the experimental warning to your caller, just annotate your function with @ExperimentalSerializationApi
as well, this way they get the same warning :)Florian Levis
10/12/2023, 5:47 PMCLOVIS
10/12/2023, 5:47 PMFlorian Levis
10/12/2023, 5:48 PMCLOVIS
10/12/2023, 5:48 PMCLOVIS
10/12/2023, 5:49 PM