admin管理员组文章数量:1405636
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.
本文标签: Are there potential issues with Kotlin39s PublishedApi annotationStack Overflow
版权声明:本文标题:Are there potential issues with Kotlin's PublishedApi annotation? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744236420a2596575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论