Skip to content

Commit 8b3eee8

Browse files
committed
Fix tests
1 parent 6f370fd commit 8b3eee8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object TypeTestsCasts {
151151
ps.forall(p => isCheckDefinitelyFalse(x, p))
152152
else if xSpace.canDecompose then
153153
val xs = xSpace.decompose.map(_.tp)
154-
xs.exists(x => isCheckDefinitelyFalse(x, p))
154+
xs.forall(x => isCheckDefinitelyFalse(x, p))
155155
else
156156
val xClass = effectiveClass(x.widen)
157157
val pClass = effectiveClass(p.widen)
@@ -181,9 +181,14 @@ object TypeTestsCasts {
181181
val res2 = recur(tp2, P)
182182

183183
if res1.isEmpty && res2.isEmpty then res1
184-
else if isCheckDefinitelyFalse(tp1, P) && res2.isEmpty then res2
185-
else if res1.isEmpty && isCheckDefinitelyFalse(tp2, P) then res1
186-
else res1
184+
else if res2.isEmpty then
185+
if isCheckDefinitelyFalse(tp1, P) then res2
186+
else i"it cannot be checked against the type $tp1"
187+
else if res1.isEmpty then
188+
if isCheckDefinitelyFalse(tp2, P) then res1
189+
else i"it cannot be checked against the type $tp2"
190+
else
191+
i"it cannot be checked against the type $tp2"
187192

188193
case _ =>
189194
// always false test warnings are emitted elsewhere

tests/neg-custom-args/isInstanceOf/i5826.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Foo {
22
def test[A]: List[Int] | A => Int = {
3-
case ls: List[Int] => ls.head // error
3+
case ls: List[Int] => ls.head // ok, List decomposes to Some and None
44
case _ => 0
55
}
66

0 commit comments

Comments
 (0)