aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-21 14:45:01 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-24 14:57:49 +0100
commit7427c671f9a5321dd13a74b5175bba512699b385 (patch)
tree037dbd3394a259592edc6a9bc264b09ddb31b01c /tests/neg
parenta89f48d1c3bef21ecf14048985334de6e0a8e505 (diff)
downloaddotty-7427c671f9a5321dd13a74b5175bba512699b385.tar.gz
dotty-7427c671f9a5321dd13a74b5175bba512699b385.tar.bz2
dotty-7427c671f9a5321dd13a74b5175bba512699b385.zip
Fixes in TypeComparer for RefinedTypes.
The previous scheme did not propagate bounds correctly. More generally, given a comparison T { X <: A } <: U { X <: B } it would errenously decompose this to T <: U, A <: B But we really need to check whether the total constraint for X in T { X <: A } subsumes the total constraint for X in T { X <: B } The new scheme propagates only if the binding in the lower type is an alias. E.g. T { X = A } <: Y { X <: B } decomposes to T { A = A } <: U, A <: B The change uncovered another bug, where in the slow path we too a member relative to a refined type; We need to "narrow" the type to a RefinedThis instead. (See use of "narrow" in TypeComparer). That change uncovered a third bug concerning the underlying type of a RefinedThis. The last bug was fixed in a previous commit (84f32cd814f2e07725b6ad1f6bff23d4ee38c397). Two tests (1048, 1843) which were pos tests for scalac but failed compling in dotc have changed their status and location. They typecheck now, but fail later. They have been moved to pending. There's a lot of diagnostic code in TypeComparer to figure out the various problems. I left it in to be able to come back to the commit in case there are more problems. The checks and diagnostics will be removed in a subsequent commit.
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/boundspropagation.scala14
-rw-r--r--tests/neg/t1048.scala21
-rw-r--r--tests/neg/t1843.scala25
3 files changed, 14 insertions, 46 deletions
diff --git a/tests/neg/boundspropagation.scala b/tests/neg/boundspropagation.scala
index 560d5416c..bc39e042e 100644
--- a/tests/neg/boundspropagation.scala
+++ b/tests/neg/boundspropagation.scala
@@ -24,3 +24,17 @@ object test3 {
case y: Tree[_] => y
}
}
+
+// Example contributed by Jason. I believe this should not typecheck,
+// even though scalac does typecheck it.
+object test4 {
+ class Base {
+ type N
+
+ class Tree[-S, -T >: Option[S]]
+
+ def g(x: Any): Tree[_, _ <: Option[N]] = x match {
+ case y: Tree[_, _] => y
+ }
+ }
+}
diff --git a/tests/neg/t1048.scala b/tests/neg/t1048.scala
deleted file mode 100644
index 4b8e78b4c..000000000
--- a/tests/neg/t1048.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-trait T[U] {
- def x: T[_ <: U]
-}
-
-object T {
- def unapply[U](t: T[U]): Option[T[_ <: U]] = Some(t.x)
-}
-
-object Test {
- def f[W](t: T[W]) = t match {
- case T(T(_)) => ()
-// Gives:
-// t1048.scala:11: error: There is no best instantiation of pattern type T[Any']
-// that makes it a subtype of selector type T[_ <: W].
-// Non-variant type variable U cannot be uniquely instantiated.
-// case T(T(_)) => ()
-// ^
-// one error found
- }
-}
-
diff --git a/tests/neg/t1843.scala b/tests/neg/t1843.scala
deleted file mode 100644
index 8504bf342..000000000
--- a/tests/neg/t1843.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
-* Scala Compiler Will Crash On this File
-* ... Or Will It?
-*
-*/
-
-object Crash {
- trait UpdateType[A]
- case class StateUpdate[A](updateType : UpdateType[A], value : A)
- case object IntegerUpdateType extends UpdateType[Integer]
-
- //However this method will cause a crash
- def crash(updates: List[StateUpdate[_]]): Unit = {
- updates match {
- case Nil =>
- case u::us =>
- u match {
- //Line below seems to be the crashing line
- case StateUpdate(key, newValue) if (key == IntegerUpdateType) =>
- println("Requires a statement to induce the crash")
- case _ =>
- }
- }
- }
-}