Skip to content

Commit 071a8a9

Browse files
Turn 6697 into a neg test
This subtyping check use to work because of the bug in question. Note that 6697 tries to use GADT knowledge that is currently unavailable on expression patterns (as demonstrated in 6697-2.scala), so I don't think we are in a urge to support this with match types.
1 parent 46832a1 commit 071a8a9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

tests/pos/6697.scala renamed to tests/neg/6697-1.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ object Test {
33
case class Of[sup, sub <: sup]() extends Off
44
type Sup[O <: Off] = O match { case Of[sup, sub] => sup }
55
type Sub[O <: Off] = O match { case Of[sup, sub] => sub }
6-
type Copy[O <: Off] = Of[Sup[O], Sub[O]]
6+
type Copy[O <: Off] = Of[Sup[O], Sub[O]] // error
7+
// Type argument Test.Sub[O] does not conform to upper bound Test.Sup[O]
78
}

tests/neg/6697-2.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object Test {
2+
sealed trait Off
3+
case class Of[sup, sub <: sup]() extends Off
4+
5+
def sup[O <: Off](o: O) = o match {
6+
case _: Of[sup, sub] =>
7+
val a: sub = null.asInstanceOf
8+
// Even though we know that sub <: sup from Of's bounds, that knowledge
9+
// is lost in the body of pattern matching expressions...
10+
11+
val b: sup = a // error
12+
// Found: (a : sub)
13+
// Required: sup
14+
// where: sub is a type in method sup with bounds <: Test.Of[?, ?]#sup
15+
16+
()
17+
}
18+
}

0 commit comments

Comments
 (0)