Skip to content

[bport] Revert to fix false positive reachability warnings #14104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
if prev == Empty && covered == Empty then // defer until a case is reachable
deferred ::= pat
else {
for (pat <- deferred.reverseIterator)
report.warning(MatchCaseUnreachable(), pat.srcPos)
// FIXME: These should be emitted, but reverted for i13931
//for (pat <- deferred.reverseIterator)
// report.warning(MatchCaseUnreachable(), pat.srcPos)
if pat != EmptyTree // rethrow case of catch uses EmptyTree
&& isSubspace(covered, prev)
then {
Expand Down
12 changes: 6 additions & 6 deletions tests/neg-custom-args/fatal-warnings/i8711.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 ---------------------------
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 ---------------------------------------------------------
7 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B
| ^^^^
| Unreachable case
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 --------------------------
| ^
| this case is unreachable since type A and class B are unrelated
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 --------------------------------------------------------
12 | case x: C => x // error
| ^^^^
| Unreachable case
| ^
| this case is unreachable since type A | B and class C are unrelated
1 change: 0 additions & 1 deletion tests/patmat/i13485.check
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
11: Match case Unreachable
16: Match case Unreachable
2 changes: 1 addition & 1 deletion tests/patmat/i13485.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sealed trait Foo
class Bar

def test1(bar: Bar) = bar match
case _: Foo => 1
case _: Foo => 1 // FIXME: this is unreachable, but reverted for i13931
case _: Bar => 2

def test2(bar: Bar) = bar match
Expand Down
4 changes: 4 additions & 0 deletions tests/patmat/i13931.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Test:
def test = Vector() match
case Seq() => println("empty")
case _ => println("non-empty")