Skip to content

Commit

Permalink
Space: Replace showType & make Space Showable (#19370)
Browse files Browse the repository at this point in the history
Replace showType with a small tweak to RefinedPrinter, so the rest of
the logic is followed.  For instance, show infix types and tuples
correctly.

Also, make Space Showable, reusing the existing logic for Space, but
additionally specifying the Space class name, which is important for
following Space traces.
  • Loading branch information
nicolasstucki authored Jan 5, 2024
2 parents 2746ee8 + edc74b7 commit d2cc3ae
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 174 deletions.
234 changes: 87 additions & 147 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class SpaceEngineTest:
val a = Prod(tp, unappTp, params)
val b = Empty

val res1 = isSubspace(a, b)
val res1 = a.isSubspace(b)

val a2 = simplify(a)
val b2 = simplify(b)
val a2 = a.simplify
val b2 = b.simplify
val rem1 = minus(a2, b2)
val rem2 = simplify(rem1)
val rem2 = rem1.simplify
val res2 = rem2 == Empty

assertEquals(
Expand All @@ -46,19 +46,12 @@ class SpaceEngineTest:
|simplify(rem1) == Empty
|rem2 == Empty
|
|a = ${show(a)}
|b = ${show(b)}
|a2 = ${show(a2)}
|b2 = ${show(b2)}
|rem1 = ${show(rem1)}
|rem2 = ${show(rem2)}
|
|a = ${a.toString}
|b = ${b.toString}
|a2 = ${a2.toString}
|b2 = ${b2.toString}
|rem1 = ${rem1.toString}
|rem2 = ${rem2.toString}
|a = $a
|b = $b
|a2 = $a2
|b2 = $b2
|rem1 = $rem1
|rem2 = $rem2
|
|""".stripMargin, res1, res2)
}
6 changes: 3 additions & 3 deletions tests/patmat/aliasing.check
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
14: Pattern Match Exhaustivity: _: Trait & Test.Alias1, _: Clazz & Test.Alias1
19: Pattern Match Exhaustivity: _: Trait & Test.Alias2
23: Pattern Match Exhaustivity: _: Trait & (Test.Alias2 & OpenTrait2){val x: Int}
14: Pattern Match Exhaustivity: _: Trait & Alias1, _: Clazz & Alias1
19: Pattern Match Exhaustivity: _: Trait & Alias2
23: Pattern Match Exhaustivity: _: Trait & (Alias2 & OpenTrait2){val x: Int}
2 changes: 1 addition & 1 deletion tests/patmat/i12020.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19: Pattern Match Exhaustivity: _: TypeDef
19: Pattern Match Exhaustivity: _: x$1.reflect.TypeDef
2 changes: 1 addition & 1 deletion tests/patmat/i2502.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5: Pattern Match Exhaustivity: _: BTypes.ClassBType
5: Pattern Match Exhaustivity: _: BTypes.this.ClassBType
2 changes: 1 addition & 1 deletion tests/patmat/i2502b.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5: Pattern Match Exhaustivity: _: BTypes.ClassBType
5: Pattern Match Exhaustivity: _: BTypes.this.ClassBType
2 changes: 1 addition & 1 deletion tests/patmat/i3938.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34: Pattern Match Exhaustivity: bar.C()
34: Pattern Match Exhaustivity: foo.bar.C()
2 changes: 1 addition & 1 deletion tests/patmat/i6255b.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3: Pattern Match Exhaustivity: _: Expr[Int]
3: Pattern Match Exhaustivity: _: scala.quoted.Expr[Int]
2 changes: 1 addition & 1 deletion tests/patmat/t10100.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12: Pattern Match Exhaustivity: (_, FancyFoo(_))
12: Pattern Match Exhaustivity: (_, NonExhaustive#FancyFoo(_))
2 changes: 1 addition & 1 deletion tests/patmat/t9779.check
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10: Pattern Match Exhaustivity: _: a.Elem[_]
10: Pattern Match Exhaustivity: _: a.Elem[?]

0 comments on commit d2cc3ae

Please sign in to comment.