Soren Roth
11/01/2024, 6:52 PMJoffrey
11/01/2024, 6:54 PM@Deprecated
with level HIDDEN
. But it won't allow new code to be compiled with the hidden declaration, so that might not work for you.
If you want new code to compile, but still provide some friction, I think the best you can do is a RequiresOptIn
with ERROR level.Joffrey
11/01/2024, 6:56 PMinline
functions. Your inline function calls some other functions/properties, and those need to be public in the bytecode because they will be inlined in the consumer's code, but you don't want consumers to use these declarations directly. In this case, you can use internal
+ @PublishedApi
to declare the functions that are used by inline functions and that you don't really want to expose.Joffrey
11/01/2024, 7:23 PMSoren Roth
11/01/2024, 8:10 PMJoffrey
11/01/2024, 8:19 PMbod
11/01/2024, 8:25 PMinterface PublicApi {
fun doSomethingPublic()
}
interface PrivateApi {
fun doSomethingPrivate()
}
fun PublicApi(): PublicApi {
return object: PublicApi, PrivateApi {
override fun doSomethingPublic() {
println("public")
}
override fun doSomethingPrivate() {
println("private")
}
}
}
fun main() {
val publicApi = PublicApi()
publicApi.doSomethingPublic()
publicApi as PrivateApi // Only special people know you can actually do this ;)
publicApi.doSomethingPrivate()
}
bod
11/01/2024, 8:27 PMJoffrey
11/01/2024, 10:43 PMPrivateApi
a real subtype of PublicApi
, but yeah otherwise that would be the ideaSoren Roth
11/01/2024, 11:13 PM