diff options
author | Paul Phillips <paulp@improving.org> | 2012-08-10 16:19:19 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-11 08:29:22 -0700 |
commit | db46c71e8830639bc79e6363332a06642fd3d8cc (patch) | |
tree | 52b5457a53bac5119522611cbbc4d40da1a1f76b /test/files/run/t2251b.scala | |
parent | 48d9fb7307fb6519fe786a7d9be97996c5812fb7 (diff) | |
download | scala-db46c71e8830639bc79e6363332a06642fd3d8cc.tar.gz scala-db46c71e8830639bc79e6363332a06642fd3d8cc.tar.bz2 scala-db46c71e8830639bc79e6363332a06642fd3d8cc.zip |
Improvement for SI-2251, failure to lub f-bounds.
After a great struggle, I realized that the major reason that
code like this still doesn't compile:
List(Stream(), List())
is that we were poisoning the computed lub in mergePrefixAndArgs by
throwing in Any when the max recursion depth was reached. I modified
it to return NoType instead, which allowed me to teach lublist to
recognize what has happened and fall back to a weaker type, one
which does not contain recursive bounds. This enables the lubbing
process to complete. The most elusive lub, defeated. Notice also
that the refinement members are correctly parameterized on Nothing,
rather than on Any as has often been the case.
scala> List(Stream(), List())
res0: List[scala.collection.immutable.LinearSeq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[Nothing] with scala.collection.AbstractSeq[Nothing]{def reverse: scala.collection.immutable.LinearSeq[Nothing] with scala.collection.AbstractSeq[Nothing]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[Nothing] with scala.collection.AbstractSeq[Nothing]; def takeRight(n: ...
Diffstat (limited to 'test/files/run/t2251b.scala')
-rw-r--r-- | test/files/run/t2251b.scala | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/files/run/t2251b.scala b/test/files/run/t2251b.scala new file mode 100644 index 0000000000..b67b3aec1e --- /dev/null +++ b/test/files/run/t2251b.scala @@ -0,0 +1,48 @@ +class A +trait B[T <: B[T]] extends A +class B1[T <: B1[T]] extends B[T] +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } +class E extends B[E] { override def toString = "E" } +class F extends B[F] { override def toString = "F" } +class G extends B1[G] { override def toString = "G" } + +object Test { + import scala.collection.{ mutable, immutable } + import scala.collection.immutable.{ Vector } + import scala.reflect.runtime.universe._ + def what[T: TypeTag](x: T) = println(typeTag[T]) + + def main(args: Array[String]): Unit = { + what(List(List(new C), Stream(new D))) + what(List(List(new C), Stream(new D), Vector(new E), Set(new F))) + what(List(immutable.Vector(new C), Stream(new D))) + what(List(collection.Set(new F), mutable.Set(new G))) + what(List(collection.Set(new F), immutable.Set(new G))) + what(List(mutable.Set(new F), immutable.Set(new G))) + what(List(mutable.Seq(new F), immutable.Seq(new G))) + what(List(mutable.Map(new C -> new D), immutable.Map(new F -> new G))) + what(List(mutable.MutableList(new F), immutable.List(new G))) + what(List(mutable.Seq(new F), collection.Seq(new G))) + what(List(mutable.LinearSeq(new F), collection.IndexedSeq(new G))) + } +} + + +// class D extends B[D] { override def toString = "D" } + + +// class E { +// val ys = List(List(new C), Stream(new D)) +// } + +// object Test { +// def trav = List(List(), Stream()) + +// def main(args: Array[String]): Unit = { +// val f = (new E).ys _ +// var xs: Set[List[_ <: Seq[B[_]]]] = Set() +// xs += f() +// println(xs) +// } +// } |