-
Notifications
You must be signed in to change notification settings - Fork 21
non public type members allowed in public signatures #4400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4400?orig=1 |
@SethTisue said: |
The example from 2011 is i1130.scala. I'll see how close I can get i997.scala. |
in both Scala 2 and 3, it matters whether scala 2.13.15> trait Foo { private[Foo] trait A; def a: A = null }
trait Foo
scala 2.13.15> trait Foo { private trait A; def a: A = null }
^
error: private trait A escapes its defining scope as part of type Foo.this.A Welcome to Scala 3.6.2 (17.0.13, Java OpenJDK 64-Bit Server VM).
scala> trait Foo { private[Foo] trait A; def a: A = null }
// defined trait Foo
scala> trait Foo { private trait A; def a: A = null }
-- Error: ----------------------------------------------------------------------
1 |trait Foo { private trait A; def a: A = null }
| ^
| non-private method a in trait Foo refers to private trait A
| in its type signature => Foo.this.A
1 error found I don't know why that would be. |
https://scala-lang.org/files/archive/spec/2.13/05-classes-and-objects.html#private is relevant:
so in spec-ese, "qualified private" is in fact a separate concept, it seems. But I'm not currently finding spec language that gives further insight into the difference https://www.scala-lang.org/old/node/10488 gives some insight and pointers — but it concludes with Heiko asking my exact question:
and Martin never answered |
@SethTisue private means doesn't participate in overriding 5.1.4. I don't know about leakability. |
=== 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: