@PrivateApi
class KtPrivateApi {
fun foo() = Unit
}
class KtPublicApi : KtPrivateApi() {
}
fun usage() {
KtPublicApi().foo() // ok, if @PrivateApi applies only for the class declaration but not its members
}
Example 2
This is not applicable for Kotlin, but should be supported in a library, which has compiled classes as input.
class JavaPackagePrivateClass {
public void foo() {}
}
public class JavaPublicClass extends JavaPackagePrivateClass {
}
void usage() {
new JavaPublicClass().foo(); // accessible
}
Example 1
Example 2
This is not applicable for Kotlin, but should be supported in a library, which has compiled classes as input.
For IJ, I've implemented this here: https://github.com/JetBrains/intellij-community/blob/f8819a2580a0cc6c2f6a456a6a5fa83bf2e3cf7e/tools/apiDump/src/impl.kt#L134
Also please take a look at supertype expansion: https://github.com/JetBrains/intellij-community/blob/f8819a2580a0cc6c2f6a456a6a5fa83bf2e3cf7e/tools/apiDump/src/impl.kt#L340 It solves this problem: https://github.com/Kotlin/binary-compatibility-validator/blob/3a7003363502236e64bbf044540e569b3eb808a4/src/main/kotlin/api/KotlinSignaturesLoading.kt#L276