我有以下类结构:
abstract class Abstr{
protected abstract fun m()
}
class Child : Abstr(){
private val subChild: Abstr = Child()
override fun m() = subChild.m()// Error:(12, 18) Kotlin: Cannot access 'm': it is protected in 'Abstr'
}
Run Code Online (Sandbox Code Playgroud)
我有一个例外 Kotlin: Cannot access 'm': it is protected in 'Abstr'
这有点令人困惑,因为相同的结构对于java来说是合法的.
- protected - 仅在此类中可见+在子类中也可见;
是bug还是预期的行为?
kotlin ×1