如何使字段对子类可见,但对其内部类不可见?
class Foo
class Parent {
protected val x = 5
}
class Sub extends Parent {
println(x) // 5
new Foo {
println(x) // it's 5, but I want it to be a compiler error...
}
}
如何使字段对子类可见,但对其内部类不可见?
class Foo
class Parent {
protected val x = 5
}
class Sub extends Parent {
println(x) // 5
new Foo {
println(x) // it's 5, but I want it to be a compiler error...
}
}