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
scala>traitX { private[this] typeA=Int; defa:A=1 }
defined traitX
The access restrictions correctly prevent me from accessing the type
member from outside of x.
scala>typexA= x.A
<console>:10:error: typeA is not a member of java.lang.ObjectwithXtypexA= x.A
^
scala>valx=newX {}
x: java.lang.ObjectwithX= $$anon$$1@58bf7b3e
scala> x.a
res6: Int=1
But I can see the type in the eta-expanded signature here:
scala> x.a _
res7: () => x.A= <function0>
Not sure if this is a problem, it just strikes me as a bit odd to
allow private type members to appear in public signatures, by contrast
with the way private template definitions are handled.
scala>traitX { private[this] traitA; defa:A=null }
<console>:8:error: privatetraitA escapes its defining scope as
part of typeX.this.AtraitX { private[this] traitA; defa:A=null }
Similar problems exists with other access modifiers.
=== What is the expected behavior? ===
Whatever Adriaan deems sound upon his return from the Antipodes.
=== What steps will reproduce the problem? ===
Given this trait, with a private type member:
The access restrictions correctly prevent me from accessing the type
member from outside of
x
.But I can see the type in the eta-expanded signature here:
Not sure if this is a problem, it just strikes me as a bit odd to
allow private type members to appear in public signatures, by contrast
with the way private template definitions are handled.
Similar problems exists with other access modifiers.
=== What is the expected behavior? ===
Whatever Adriaan deems sound upon his return from the Antipodes.
=== What do you see instead? ===
=== Additional information ===
https://groups.google.com/d/topic/scala-language/_txHz6q3Rw4/discussion
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: