aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/boundspropagation.scala
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/boundspropagation.scala
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/boundspropagation.scala')
-rw-r--r--tests/neg/boundspropagation.scala14
1 files changed, 14 insertions, 0 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
+ }
+ }
+}