File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
compiler/src/dotty/tools/dotc/transform
tests/neg-custom-args/isInstanceOf Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11class 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
You can’t perform that action at this time.
0 commit comments