Avoid trivially true branch for the last arm of an exhaustive match - #27070
SolalPirelli wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
File moved since this was not a deep-subtype test, and it was using -Werror to pretend to be a pos test, but it's a warn test.
| i match { | ||
| case Bar => println("i is a Bar") | ||
| case i: Foo => println("i is a Foo") | ||
| case Bar => println("i is a Long") |
There was a problem hiding this comment.
This file checks that the CanEqual import for Bar and Foo is used (i.e., doesn't warn as unused), so changing the order of the comparison is necessary to make sure it's actually used here.
| @@ -1,10 +1,8 @@ | |||
| //> using options -Werror -explain | |||
There was a problem hiding this comment.
These tests already produced errors, having nopos-errors with -Werror in addition to that is just odd.
There was a problem hiding this comment.
The ticket was something about there being two diagnostics, so this documents the warning.
It looks odd because the test rig doesn't have a way to do both warns and errors.
|
|
||
| def f2(o: Option[O.X]) = o match | ||
| case None => 0 | ||
| case Some(x: O.X) => 1 // ditto in reverse order |
There was a problem hiding this comment.
regression test for a bug introduced while developing this (found in benchmarks)
| def main(args: Array[String]): Unit = | ||
| f(E.Left(42)) | ||
| f(E.Right(42)) | ||
| f(E.Both(42, 0)) |
There was a problem hiding this comment.
regression test for a bug introduced while developing this (found in cats)
752252d to
218b497
Compare
| toRemove += prod | ||
| handleInputs(prod, prod.asInstanceOf[MultiANewArrayInsnNode].dims) | ||
|
|
||
| // Remove "is instance of j.l.Object", a leftover after some optimizations |
There was a problem hiding this comment.
See LocalOptimizationBytecodeTests changes below to understand what this PR achieves; this change here is needed so that some temporary type tests get eliminated properly in our motivating examples.
| case B(_) => "OK" | ||
| case C(_) => "NOT OK" // error | ||
| } | ||
| // nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) |
There was a problem hiding this comment.
Same comment about the comment.
|
Benchmarks started. Workflow run. |
Inspired by a commit in Haoyi's #26365
We can already prove a match is exhaustive thanks to the space engine, so let's use that fact.
Have you relied on LLM-based tools in this contribution?
No
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)