Subclass exposes its internal supertype

Inheritance chain like this is not allowed:
Public class > Internal implementation > Public interface.

And gives compile time error: Subclass exposes its internal supertype.

I just wonder how exactly it exposes? Internal implementation doesn’t have any new public methods, just those which are already exposed, so what exactly is exposed?

class Public : InternalImpl<Int>() {
    override fun publicFun() {
        super.publicFun()
    }
}

internal open class InternalImpl<T> : PublicInterface<T> {
    
    private fun privateFun() {

    }

    override fun publicFun() {

    }
}

interface PublicInterface<T> {
    fun publicFun()
}
class Public : PublicInterface<T> by InternalImpl<Int>()

I believe the answer to the problem itself is given here:

1 Like