Skip to content

Inconsistency between inferred and declared typing for types with restricted visibility #3870

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

Closed
olafurpg opened this issue Jan 19, 2018 · 4 comments

Comments

@olafurpg
Copy link
Contributor

I was able to reproduce a Scala 2.12.4 bug with dotty 0.5.0-RC1, see original ticket scala/bug#1800

I encountered this bug today running scalafix ExplicitResultTypes on the akka codebase, here is a minimized reproduction

package a {
  private[a] object b {
    class B
  }
  object c { def getB: b.B = new b.B() }
}
package d {
  object e {
    val f = a.c.getB
    // val g: a.b.B = a.c.getB // Error

// scala 2.x
// foo.scala:10: error: object b in package a cannot be accessed in package a
//     val g: a.b.B = a.c.getB
//              ^

// dotty
// -- Error: foo.scala:10:13 ------------------------------------------------------
// 10 |    val g: a.b.B = a.c.getB // Error: does not compile
//    |           ^^^
//    |object b in package a cannot be accessed as a member of a.type from module class e$.
// one error found
  }
}
@smarter
Copy link
Member

smarter commented Jan 19, 2018

I think we just shouldn't allow private-qualified types to leak, just like we already disallow private types from leaking: https://github.com/lampepfl/dotty/blob/52bddff77b39b1169d030094825b2a0d5e1b7d5b/compiler/src/dotty/tools/dotc/typer/Checking.scala#L382-L402

@odersky
Copy link
Contributor

odersky commented Jan 22, 2018

It's a long-standing very thorny issue. The best way forward might be to eliminate qualified private altogether.

@odersky
Copy link
Contributor

odersky commented Jan 22, 2018

I would argue we should not try to solve this before we have decided on the fate of qualified private.

@odersky odersky closed this as completed Jan 22, 2018
@sjrd
Copy link
Member

sjrd commented Jan 22, 2018

By qualified private do you mean private[enclosing]? If yes, you can't possibly eliminate that altogether. That's the only thing that allows to maintain a semblance of distinction between a public API and a private API. Without that, evolving libraries in backward source/binary compatible ways will become completely impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants