Skip to content

Commit ac059ab

Browse files
committed
address review feedback
1 parent 62d73ea commit ac059ab

21 files changed

+51
-38
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ object messages {
791791

792792
val explanation =
793793
hl"""|There are several ways to make the match exhaustive:
794-
| - add missing cases as shown in the warning
795-
| - change the return type of irrefutable extractors as `Some[T]` if exist
796-
| - add a wildcard `_` case at the end
794+
| - Add missing cases as shown in the warning
795+
| - If an extractor always return Some(...), write Some[X] for its return type
796+
| - Add a case _ => ... at the end to match all remaining cases
797797
|"""
798798
}
799799

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
654654
if (mergeList) "_*" else "_: List"
655655
else if (scalaConsType.isRef(sym))
656656
if (mergeList) "_" else "List(_)"
657-
else if (tp.classSymbol.is(CaseClass))
658-
// use constructor syntax for case class
659-
showType(tp) + signature(tp).map(_ => "_").mkString("(", ", ", ")")
660-
else if (sym.is(Flags.Case) && signature(tp).nonEmpty)
661-
tp.classSymbol.name + signature(tp).map(_ => "_").mkString("(", ", ", ")")
662657
else if (decomposed) "_: " + showType(tp)
663658
else "_"
664659
case Kon(tp, params) =>

tests/patmat/gadt.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
13: Pattern Match Exhaustivity: IntLit(_)
2-
22: Pattern Match Exhaustivity: Or(_, _)
3-
45: Pattern Match Exhaustivity: BooleanLit(_), IntLit(_)
4-
55: Pattern Match Exhaustivity: Sum(_, _)
1+
13: Pattern Match Exhaustivity: _: IntLit
2+
22: Pattern Match Exhaustivity: _: Or
3+
45: Pattern Match Exhaustivity: _: BooleanLit, _: IntLit
4+
55: Pattern Match Exhaustivity: _: Sum

tests/patmat/i2502b.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5: Pattern Match Exhaustivity: _: BTypes.ClassBType

tests/patmat/i2502b.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
abstract class BTypes {
2+
trait BType
3+
4+
sealed trait RefBType extends BType {
5+
def classOrArrayType: String = this match {
6+
case ClassBType(internalName) => internalName
7+
case a: ArrayBType => ""
8+
}
9+
}
10+
11+
final case class ClassBType(val internalName: String) extends RefBType
12+
class ArrayBType extends RefBType
13+
14+
object ClassBType {
15+
def unapply(x: RefBType): Option[String] = None
16+
}
17+
}

tests/patmat/nontrivial-andtype.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16: Pattern Match Exhaustivity: D, _: C, B(), _: A
1+
16: Pattern Match Exhaustivity: D, _: C, _: B, _: A

tests/patmat/patmat-adt.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
7: Pattern Match Exhaustivity: Bad(Good(_)), Good(Bad(_))
1+
7: Pattern Match Exhaustivity: Bad(_: Good), Good(_: Bad)
22
19: Pattern Match Exhaustivity: Some(_)
3-
24: Pattern Match Exhaustivity: (_, Some(_))
4-
29: Pattern Match Exhaustivity: (None, None), (Some(_), Some(_))
3+
24: Pattern Match Exhaustivity: (_, _: Some)
4+
29: Pattern Match Exhaustivity: (None, None), (_: Some, _: Some)
55
50: Pattern Match Exhaustivity: LetL(BooleanLit), LetL(IntLit)

tests/patmat/patmatexhaust.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
7: Pattern Match Exhaustivity: Baz
2-
11: Pattern Match Exhaustivity: Bar(_)
3-
23: Pattern Match Exhaustivity: (Qult(), Qult()), (Kult(_), Kult(_))
2+
11: Pattern Match Exhaustivity: _: Bar
3+
23: Pattern Match Exhaustivity: (_: Qult, _: Qult), (_: Kult, _: Kult)
44
49: Pattern Match Exhaustivity: _: Gp
55
59: Pattern Match Exhaustivity: Nil
66
75: Pattern Match Exhaustivity: _: B
77
100: Pattern Match Exhaustivity: _: C1
8-
114: Pattern Match Exhaustivity: D2(), D1
8+
114: Pattern Match Exhaustivity: _: D2, D1
99
126: Pattern Match Exhaustivity: _: C1

tests/patmat/t3683a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14: Pattern Match Exhaustivity: XX()
1+
14: Pattern Match Exhaustivity: _: XX

tests/patmat/t6582_exhaust_big.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
27: Pattern Match Exhaustivity: Z.Z11()
1+
27: Pattern Match Exhaustivity: _: Z.Z11

tests/patmat/t7631.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8: Pattern Match Exhaustivity: TestB()
1+
8: Pattern Match Exhaustivity: _: TestB

tests/patmat/t7669.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10: Pattern Match Exhaustivity: NotHandled(_)
1+
10: Pattern Match Exhaustivity: _: NotHandled

tests/patmat/t8178.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
6: Pattern Match Exhaustivity: FailsChild2(_)
2-
14: Pattern Match Exhaustivity: VarArgs1(_)
3-
27: Pattern Match Exhaustivity: SeqArgs2(_)
1+
6: Pattern Match Exhaustivity: _: FailsChild2
2+
14: Pattern Match Exhaustivity: _: VarArgs1
3+
27: Pattern Match Exhaustivity: _: SeqArgs2

tests/patmat/t8412.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7: Pattern Match Exhaustivity: Lit(_)
1+
7: Pattern Match Exhaustivity: _: Lit

tests/patmat/t8511.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18: Pattern Match Exhaustivity: Baz(), Bar(_)
1+
18: Pattern Match Exhaustivity: _: Baz, _: Bar

tests/patmat/t9232.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13: Pattern Match Exhaustivity: Node2(), Node1(Foo(_))
1+
13: Pattern Match Exhaustivity: _: Node2, Node1(Foo(_))

tests/patmat/t9289.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
9: Pattern Match Exhaustivity: module.LetR()
2-
20: Pattern Match Exhaustivity: module.LetR()
1+
9: Pattern Match Exhaustivity: _: module.LetR
2+
20: Pattern Match Exhaustivity: _: module.LetR

tests/patmat/t9351.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
8: Pattern Match Exhaustivity: _: A
2-
17: Pattern Match Exhaustivity: (_, None), (_, Some(_))
2+
17: Pattern Match Exhaustivity: (_, None), (_, _: Some)
33
28: Pattern Match Exhaustivity: (_, _)

tests/patmat/t9573.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9: Pattern Match Exhaustivity: Horse(_)
1+
9: Pattern Match Exhaustivity: _: Horse

tests/patmat/t9657.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
29: Pattern Match Exhaustivity: Bus(_)
2-
38: Pattern Match Exhaustivity: Bus(_)
3-
49: Pattern Match Exhaustivity: Bus(_)
4-
58: Pattern Match Exhaustivity: Bus(_)
1+
29: Pattern Match Exhaustivity: _: Bus
2+
38: Pattern Match Exhaustivity: _: Bus
3+
49: Pattern Match Exhaustivity: _: Bus
4+
58: Pattern Match Exhaustivity: _: Bus

tests/patmat/t9672.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22: Pattern Match Exhaustivity: SimpleExpr.IntExpr(_)
1+
22: Pattern Match Exhaustivity: _: SimpleExpr.IntExpr

0 commit comments

Comments
 (0)