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
private types displayed in error messages #8812
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8812?orig=1 |
@retronym said (edited on Feb 20, 2015 12:05:40 AM UTC): It seems a poor design to use the private type alias in the signature of a public method. We don't prevent that outright. Why not? Using a smaller example: trait Test {
private type T = Int
val t: T
}
case TypeRef(_, sym, args) =>
checkNoEscape(sym)
if (!hiddenSymbols.isEmpty && hiddenSymbols.head == sym &&
sym.isAliasType && sameLength(sym.typeParams, args)) {
hiddenSymbols = hiddenSymbols.tail
t.dealias
} else t The trait Test {
private type T[_] = Int
val t: M[T] // error: private type T escapes its defining scope as part of type M[Test.this.T]
}
trait M[N[_]] But after we admit This dealiasing-rather-than-forbidding dates back to the dawn of existential types: scala/scala@8414eba Next steps to improve on this would be:
|
@paulp said:
Well, it has always been like that, so it is most likely unchangeable. And it's useful, or would be if it worked sensibly. If a private type alias to a public type is expanded when it appears in a public type, and one is stuck repeating a type like "Dingo with Foo with Bar" fifty times in the method signatures of the interface, one is glad to be able to call it This. But I'd be crazy to start talking about access. I'll just refer you to my fifty open access-related tickets, anything I might say about this has to be in four of them. |
@retronym said: |
@paulp said: I'm not saying this is a compelling use case, even though it's all inflicted on me by scala, but it's the principle of the thing. I shouldn't have to introduce a type alias into the API just because I want one for the hygiene of a single source file. |
@paulp said: trait IndexedSeqView[A, +Coll] ... {
private[this] type This = IndexedSeqView[A, Coll]
override def filter(p: A => Boolean): This
override def init: This
override def drop(n: Int): This
override def take(n: Int): This
override def slice(from: Int, until: Int): This
override def dropWhile(p: A => Boolean): This
override def takeWhile(p: A => Boolean): This
override def span(p: A => Boolean): (This, This)
override def splitAt(n: Int): (This, This)
override def reverse: This
} I don't think a self-respecting language can make someone type IndexedSeqView[A, Coll] twelve times in ten lines. |
@retronym said: @inline private[this] type This = IndexedSeqView[A, Coll] I'm still not sure if |
Oh good, another bug involving access. Just throw it on the dead letter pile.
The text was updated successfully, but these errors were encountered: