Skip to content

Commit 799de6c

Browse files
committed
Space: Fix isSubspace invariant by using simplify
1 parent 20026ec commit 799de6c

File tree

1 file changed

+6
-2
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ sealed trait Space:
6161
private val isSubspaceCache = mutable.HashMap.empty[Space, Boolean]
6262

6363
def isSubspace(b: Space)(using Context): Boolean =
64-
if this == Empty then true
64+
val a = this
65+
val a2 = a.simplify
66+
val b2 = b.simplify
67+
if (a ne a2) || (b ne b2) then a2.isSubspace(b2)
68+
else if a == Empty then true
6569
else if b == Empty then false
6670
else trace(s"isSubspace(${show(this)}, ${show(b)})", debug) {
67-
isSubspaceCache.getOrElseUpdate(b, computeIsSubspace(this, b))
71+
isSubspaceCache.getOrElseUpdate(b, computeIsSubspace(a, b))
6872
}
6973

7074
private var mySimplify: Space | Null = _

0 commit comments

Comments
 (0)