You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
P.scala:9:error: method y overrides nothing
overridedefy=1^
one error found
This is either a misleading error message, since A.y is definitely visible in B or as I think a plain error. Section 5.1.4 of the spec doesn't disallow this.
The same applies for qualified private members as in:
@paulp said:
This is mostly a duplicate of #1352. The issue is not that you can't override them, but that you can't widen the visibility to public. This works:
classA {
classB {
private[A] defx=0
}
classCextendsB {
overrideprivate[A] defx=1// or even this works// override protected[A] def x = 1
}
}
My "mostly" qualifier above is because it doesn't look like you can override def y in your first example, because A is not an enclosing class inside B:
// override protected[A] def y = 1
a.scala:9:error: A is not an enclosing classoverrideprotected[A] defy=1^// override protected def y = 1
a.scala:9:error: method y overrides nothing
overrideprotecteddefy=1^// override protected[B] def y = 1
a.scala:9:error: method B$$$$y overrides nothing
overrideprotected[B] defy=1^
gives the following compile error:
This is either a misleading error message, since A.y is definitely visible in B or as I think a plain error. Section 5.1.4 of the spec doesn't disallow this.
The same applies for qualified private members as in:
The text was updated successfully, but these errors were encountered: