-
Notifications
You must be signed in to change notification settings - Fork 21
unification should consider all parents #6948
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6948?orig=1 |
@retronym said (edited on Jan 9, 2013 2:46:22 PM UTC): import collection.generic._
object Test {
def shuffle[T, CC[X] <: TraversableOnce[X]]
(xs: CC[T])
(implicit bf: CanBuildFrom[CC[T], T, CC[T]]): CC[T] = null.asInstanceOf[CC[T]]
def foo1(r: R1) = shuffle(r) // fail
def foo2(r: R1) = shuffle(r: IndexedSeq[Int]) // okay
def foo3(r: R2) = shuffle(r) // okay
abstract class AbstractSeq[+A] extends collection.Seq[A]
abstract class R1
extends AbstractSeq[Int]
with IndexedSeq[Int]
abstract class R2 extends IndexedSeq[Int]
} The intermediate class, |
@retronym said: AFAICT, the only fix we could deliver in 2.10.1 would be an improved type inference, which of course is also not without risk (one man's treasure is another man's trash.) While I'm happy to live with |
@retronym said: https://github.com/retronym/scala/compare/ticket/6948
|
@paulp said: import scala.collection.immutable.BitSet
import scala.collection.generic.CanBuildFrom
object Test {
def builder[A, CC[X] <: TraversableOnce[X], Coll](xs: Coll with CC[A] with AnyRef)(implicit cbf: CanBuildFrom[_, A, CC[A]]) = cbf()
def main(args: Array[String]) {
println(builder(null: BitSet) += 1 result)
}
} |
@gkossakowski said: |
@paulp said: This is completely nuts! Do you really want to ship another major version which a) cannot figure out not to infer types which you can't access and b) does so reliably in common situations? scala> def f[A, CC[X]](xs: CC[A]) = xs
warning: there were 1 feature warning(s); re-run with -feature for details
f: [A, CC[X]](xs: CC[A])CC[A]
scala> f(BitSet(1))
res0: scala.collection.AbstractSet[Int] = BitSet(1)
scala> var x: scala.collection.AbstractSet[Int] = res0
<console>:21: error: class AbstractSet in package collection cannot be accessed in package collection
var x: scala.collection.AbstractSet[Int] = res0
^ And again it's a regression from 2.9. |
@adriaanm said: |
@paulp said: I will gladly send you a PR to make the Abstract* classes public. That is the only thing I can do. I know how to fix the type computation and it requires a fundamental rework of the typer far beyond what I was able to accomplish when I had better access than I do now and was better paid than I am now. |
@adriaanm said: |
@paulp said: |
@adriaanm said: |
@retronym said: |
@paulp said: I don't know, I'm not the guy to weigh those tradeoffs. I think removing them entirely is probably unwise, but I doubt there are any hail marys coming to fix any of the issues before 2.11. I'll send a PR removing the access limitations. In case anyone is thinking they don't want to make those classes public because it increases the binary compatibility surface area, I have some bad news: thanks to the leaking of those supposed-to-be-internal types, they're already in the footprint. object Test {
def f[A, CC[X]](xs: CC[A]) = xs
def g = f(scala.collection.immutable.BitSet(1))
}
// public <A extends java/lang/Object, CC extends java/lang/Object> CC f(CC);
// Signature: (Ljava/lang/Object;)Ljava/lang/Object;
// public scala.collection.AbstractSet<java.lang.Object> g();
// Signature: ()Lscala/collection/AbstractSet; In other words there is no such thing as a private type. |
@paulp said (edited by @adriaanm on Feb 10, 2014 12:47:12 AM UTC): |
Removing the "collections" label because this bug in more general and we avoid it for the collections by making the Abstract* classes public. |
Has anyone considered solving this by simply disallowing private superclasses to public classes (or more generally, disallowing having a superclass with a more restricted access than the current class) ? |
The current message refers to some
|
This works fine
But this gives an error:
The text was updated successfully, but these errors were encountered: