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 {
151
151
ps.forall(p => isCheckDefinitelyFalse(x, p))
152
152
else if xSpace.canDecompose then
153
153
val xs = xSpace.decompose.map(_.tp)
154
- xs.exists (x => isCheckDefinitelyFalse(x, p))
154
+ xs.forall (x => isCheckDefinitelyFalse(x, p))
155
155
else
156
156
val xClass = effectiveClass(x.widen)
157
157
val pClass = effectiveClass(p.widen)
@@ -181,9 +181,14 @@ object TypeTestsCasts {
181
181
val res2 = recur(tp2, P )
182
182
183
183
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"
187
192
188
193
case _ =>
189
194
// always false test warnings are emitted elsewhere
Original file line number Diff line number Diff line change 1
1
class Foo {
2
2
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
4
4
case _ => 0
5
5
}
6
6
You can’t perform that action at this time.
0 commit comments