I have learned how to use Kotlin's PublishedApi decorator so that I can call an internal
function from a public inline
function like so:
inline fun <reified T: Any> publicFun(){
internalHelper(T::class)
}
@PublishedApi
internal fun <T : Any> internalHelper(clazz: KClass<T>){
// do stuff
}
As the PublishedApi
documentation states:
the declaration becomes effectively public, and this should be considered with respect to binary compatibility maintaining.
I have been told that, since the internal
function becomes "effectively public" that changes to the internalHelper
function could result in ABI changes that could be breaking to consumers of this library. Which could present issues.
But at the same time, my understanding is that the PublishedApi
does not allow a consuming to library to actually access internalHelper
. So I don't see how this could cause issues.
I'm trying to understand if it is "safe" to use PublishedApi
in a library, or if it could lead to any subtle, nasty issues in the future. What's the deal here?
I have learned how to use Kotlin's PublishedApi decorator so that I can call an internal
function from a public inline
function like so:
inline fun <reified T: Any> publicFun(){
internalHelper(T::class)
}
@PublishedApi
internal fun <T : Any> internalHelper(clazz: KClass<T>){
// do stuff
}
As the PublishedApi
documentation states:
the declaration becomes effectively public, and this should be considered with respect to binary compatibility maintaining.
I have been told that, since the internal
function becomes "effectively public" that changes to the internalHelper
function could result in ABI changes that could be breaking to consumers of this library. Which could present issues.
But at the same time, my understanding is that the PublishedApi
does not allow a consuming to library to actually access internalHelper
. So I don't see how this could cause issues.
I'm trying to understand if it is "safe" to use PublishedApi
in a library, or if it could lead to any subtle, nasty issues in the future. What's the deal here?
1 Answer
Reset to default 1But at the same time, my understanding is that the
PublishedApi
does not allow a consuming to library to actually accessinternalHelper
.
Not directly, of course, but if a consuming library includes a call to publicFun
, then the compiled version of their code will call internalHelper
-- because publicFun
, of course, got inlined.
If internalHelper
gets changed, then the compiled version of that library may stop working.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744236420a4564491.html
评论列表(0条)