Skip to content

non public type members allowed in public signatures #4400

Open
@scabug

Description

@scabug

=== 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions