Skip to content

Commit 7722fa9

Browse files
committed
Fix type test warning involving applied types
Previously, the check relied used `maximizeType`, which means that depending on which bound got picked by type inference, the check might fail. Instead, we only need to check if there is a possible constraint solution by making sure both subtype tests return true. I'm not sure if this is always a safe type test, but it at least avoids spurious warnings. This is necessary to bootstrap dotty after the previous commit which added a `dealias` to `recur`, this probably means that there are other situations where `recur` is missing checks.
1 parent aeeb14b commit 7722fa9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,7 @@ object TypeTestsCasts {
105105
debug.println("P1 : " + P1.show)
106106
debug.println("X : " + X.show)
107107

108-
P1 <:< X // constraint P1
109-
110-
// use fromScala2x to avoid generating pattern bound symbols
111-
maximizeType(P1, span, fromScala2x = true)
112-
113-
val res = P1 <:< P
108+
val res = (P1 <:< X) && (P1 <:< P)
114109
debug.println("P1 : " + P1.show)
115110
debug.println("P1 <:< P = " + res)
116111

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A[-T]
2+
class B[T] extends A[T]
3+
4+
object Test {
5+
def foo(x: A[Null]) = x match {
6+
case x: B[Null] =>
7+
case _ =>
8+
}
9+
}

0 commit comments

Comments
 (0)