I think I’ve found a slightly more elegant example than making it public. However, this seems very hacky and unintended by design.
open class A(protected val number: Int) {
companion object {
@JvmStatic
protected val A._number
get() = number
}
}
class B private constructor(number: Int) : A(number) {
companion object {
@JvmStatic
fun createFromA(a: A) = B(a._number)
}
}
Could someone please shed some light on what the difference between Java-protected and Kotlin-protected visbility is?