Skip to content

Commit 04432cb

Browse files
committed
Fix spacing, i21577.check, and warn comment changes
1 parent 442146a commit 04432cb

File tree

5 files changed

+41
-42
lines changed

5 files changed

+41
-42
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,6 @@ object SpaceEngine {
969969

970970
def checkMatch(m: Match)(using Context): Unit =
971971
if exhaustivityCheckable(m.selector) then checkExhaustivity(m)
972-
973972
if reachabilityCheckable(m.selector) then
974973
// With explicit nulls, even if the selector type is non-nullable,
975974
// we still need to consider the possibility of null value,

tests/explicit-nulls/neg/pattern-matching.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ class Foo:
5151
case Cat => 200
5252
case null => 300 // ok
5353

54-
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
54+
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/explicit-nulls/run/pattern-matching.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ object Test:
3434
val r6 = s2 match
3535
case null => 200
3636
case s2: String => 100
37-
assert(r6 == 200)
37+
assert(r6 == 200)
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:5:9 --------------------------------------------
2-
5 | case _ => // warn
3-
| ^
4-
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
5-
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:12:9 -------------------------------------------
6-
12 | case _ => // warn
7-
| ^
8-
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
9-
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:16:7 -------------------------------------------
10-
16 | case _ => // warn
11-
| ^
12-
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
13-
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:20:7 -------------------------------------------
14-
20 | case _ => // warn
15-
| ^
16-
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
17-
-- [E029] Pattern Match Exhaustivity Warning: tests\explicit-nulls\warn\i21577.scala:29:27 -----------------------------
18-
29 |def f7(s: String | Null) = s match // warn
19-
| ^
20-
| match may not be exhaustive.
21-
|
22-
| It would fail on pattern case: _: Null
23-
|
24-
| longer explanation available when compiling with `-explain`
25-
-- [E029] Pattern Match Exhaustivity Warning: tests\explicit-nulls\warn\i21577.scala:36:33 -----------------------------
26-
36 |def f9(s: String | Int | Null) = s match // warn
27-
| ^
28-
| match may not be exhaustive.
29-
|
30-
| It would fail on pattern case: _: Int
31-
|
32-
| longer explanation available when compiling with `-explain`
1+
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:5:9 --------------------------------------------
2+
5 | case _ => // warn: null only
3+
| ^
4+
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
5+
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:12:9 -------------------------------------------
6+
12 | case _ => // warn: null only
7+
| ^
8+
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
9+
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:16:7 -------------------------------------------
10+
16 | case _ => // warn: null only
11+
| ^
12+
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
13+
-- [E121] Pattern Match Warning: tests\explicit-nulls\warn\i21577.scala:20:7 -------------------------------------------
14+
20 | case _ => // warn: unreachable
15+
| ^
16+
| Unreachable case except for null (if this is intentional, consider writing case null => instead).
17+
-- [E029] Pattern Match Exhaustivity Warning: tests\explicit-nulls\warn\i21577.scala:29:27 -----------------------------
18+
29 |def f7(s: String | Null) = s match // warn: not exhaustive
19+
| ^
20+
| match may not be exhaustive.
21+
|
22+
| It would fail on pattern case: _: Null
23+
|
24+
| longer explanation available when compiling with `-explain`
25+
-- [E029] Pattern Match Exhaustivity Warning: tests\explicit-nulls\warn\i21577.scala:36:33 -----------------------------
26+
36 |def f9(s: String | Int | Null) = s match // warn: not exhaustive
27+
| ^
28+
| match may not be exhaustive.
29+
|
30+
| It would fail on pattern case: _: Int
31+
|
32+
| longer explanation available when compiling with `-explain`

tests/explicit-nulls/warn/i21577.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ def f(s: String) =
22
val s2 = s.trim()
33
s2 match
44
case s3: String =>
5-
case _ => // warn
5+
case _ => // warn: null only
66

77

88
def f2(s: String | Null) =
99
val s2 = s.nn.trim()
1010
s2 match
1111
case s3: String =>
12-
case _ => // warn
12+
case _ => // warn: null only
1313

1414
def f3(s: String | Null) = s match
1515
case s2: String =>
16-
case _ => // warn
16+
case _ => // warn: null only
1717

1818
def f5(s: String) = s match
1919
case _: String =>
20-
case _ => // warn
20+
case _ => // warn: unreachable
2121

2222
def f6(s: String) = s.trim() match
2323
case _: String =>
@@ -26,13 +26,13 @@ def f6(s: String) = s.trim() match
2626
def f61(s: String) = s.trim() match
2727
case _: String =>
2828

29-
def f7(s: String | Null) = s match // warn
29+
def f7(s: String | Null) = s match // warn: not exhaustive
3030
case _: String =>
3131

3232
def f8(s: String | Null) = s match
3333
case _: String =>
3434
case null =>
3535

36-
def f9(s: String | Int | Null) = s match // warn
36+
def f9(s: String | Int | Null) = s match // warn: not exhaustive
3737
case _: String =>
38-
case null =>
38+
case null =>

0 commit comments

Comments
 (0)