StackOverflow 文档 Scala Language 教程 范围 受保护的范围 受保护的范围 Created: November-22, 2018 受保护的作用域允许从当前类的任何子类访问该值。 class FooClass { protected val x = "foo" } class BarClass extends FooClass { val y = x // It is a subclass instance, will compile } class ClassB { val f = new FooClass f.x // <- This will not compile } 包装保护范围对象私有范围