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
classA:protectedclassB// This fails to compile, as expected// val x = A().B()objectC:protectedvalp="protected"protecteddefgetString() ="Hello!"protectedclassD// This fails to compile// val y = C.p// And this also fails to compile// val z = C.getString()// However, this compiles just fine.valalpha=C.D()
Output
The code compiles, even though a protected inner class is being accessed outside of the declaring object.
Expectation
I know that there isn't any point in declaring members of objects protected, since an object can't be extended. However, the way that protected inner classes are handled (which, as far as I can tell, is to ignore the protected keyword) is inconsistent with the way that protected vars/vals/defs are treated inside objects.
The text was updated successfully, but these errors were encountered:
21 |val beta = new C.D()
| ^^^
|class D cannot be accessed as a member of C.type from the top-level definitions in package <empty>.
| protected class D can only be accessed from object C.
1 error found
Compiler version
3.6.3
Minimized code
Output
The code compiles, even though a protected inner class is being accessed outside of the declaring object.
Expectation
I know that there isn't any point in declaring members of objects
protected
, since an object can't be extended. However, the way that protected inner classes are handled (which, as far as I can tell, is to ignore theprotected
keyword) is inconsistent with the way that protected vars/vals/defs are treated inside objects.The text was updated successfully, but these errors were encountered: