Skip to content

qualified private allowed to escape via aliases #5008

Closed as not planned
Closed as not planned
@scabug

Description

@scabug

There are so many access related tickets open I can't tell in a reasonable amount of time if this already exists. Not so great.

package foo {
  class A {
    private[foo] trait Foo
    // Public type alias is disallowed if Foo is private or private[this].
    // But allowed if private[foo] or private[A].
    type Bar = Foo
  
    def f(x: Foo) = 5
  }
}

package bar {
  class B extends foo.A {
    // Disallowed as expected.
    //
    // val x1 = new Foo { }
    // ./a.scala:12: error: trait Foo in class A cannot be accessed in bar.B
    //     val x1 = new Foo { }
    //                  ^
    // one error found
    
    // allowed
    val x2 = new Bar { }
    // allowed
    override def f(x: Bar) = 10
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions