Skip to content
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

non public type members allowed in public signatures #4400

Open
scabug opened this issue Mar 27, 2011 · 3 comments
Open

non public type members allowed in public signatures #4400

scabug opened this issue Mar 27, 2011 · 3 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 27, 2011

=== What steps will reproduce the problem? ===

Given this trait, with a private type member:

 scala> trait X { private[this] type A = Int; def a: A = 1 }
 defined trait X

The access restrictions correctly prevent me from accessing the type
member from outside of x.

 scala> type xA = x.A
 <console>:10: error: type A is not a member of java.lang.Object with X
        type xA = x.A
                  ^
 scala> val x = new X {}
 x: java.lang.Object with X = $$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> trait X { private[this] trait A; def a: A = null }
 <console>:8: error: private trait A escapes its defining scope as
part of type X.this.A
        trait X { private[this] trait A; def a: 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 do you see instead? ===

=== Additional information ===

https://groups.google.com/d/topic/scala-language/_txHz6q3Rw4/discussion

=== What versions of the following are you using? ===

  • Scala: 2.8.1 / 2.9.0.RC1
@scabug
Copy link
Author

scabug commented Mar 27, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4400?orig=1
Reporter: @retronym

@scabug
Copy link
Author

scabug commented Dec 11, 2015

@SethTisue said:
this is changing in Dotty: scala/scala3#997

@som-snytt
Copy link

The example from 2011 is i1130.scala. I'll see how close I can get i997.scala.

@scala scala deleted a comment from scabug Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants