@@ -59,14 +59,11 @@ sealed abstract class GadtConstraint extends Showable {
5959 /** Further constrain a path-dependent type already present in the constraint. */
6060 def addBound (p : PathType , sym : Symbol , bound : Type , isUpper : Boolean )(using Context ): Boolean
6161
62- /** Record the equality between two singleton types. */
63- def addEquality (p : PathType , q : PathType )(using Context ): Unit
62+ /** Record the aliasing relationship between two singleton types. */
63+ def recordPathAliasing (p : PathType , q : PathType )(using Context ): Unit
6464
65- /** Check whether two singleton types are equivalent. */
66- def isEquivalent (p : PathType , q : PathType ): Boolean
67-
68- /** Query the representative member of a singleton type. */
69- def reprOf (p : PathType ): PathType | Null
65+ /** Check whether two paths are equivalent via path aliasing. */
66+ def isAliasingPath (p : PathType , q : PathType ): Boolean
7067
7168 /** Scrutinee path of the current pattern matching. */
7269 def scrutineePath : TermRef | Null
@@ -124,7 +121,7 @@ final class ProperGadtConstraint private(
124121 private var pathDepReverseMapping : SimpleIdentityMap [TypeParamRef , TypeRef ],
125122 private var wasConstrained : Boolean ,
126123 private var myScrutineePath : TermRef | Null ,
127- private var myUnionFind : SimpleIdentityMap [PathType , PathType ],
124+ private var pathAliasingMap : SimpleIdentityMap [PathType , PathType ],
128125 private var myPatternSkolem : SkolemType | Null ,
129126) extends GadtConstraint with ConstraintHandling {
130127 import dotty .tools .dotc .config .Printers .{gadts , gadtsConstr }
@@ -137,7 +134,7 @@ final class ProperGadtConstraint private(
137134 pathDepReverseMapping = SimpleIdentityMap .empty,
138135 wasConstrained = false ,
139136 myScrutineePath = null ,
140- myUnionFind = SimpleIdentityMap .empty,
137+ pathAliasingMap = SimpleIdentityMap .empty,
141138 myPatternSkolem = null ,
142139 )
143140
@@ -392,9 +389,6 @@ final class ProperGadtConstraint private(
392389 buf ++= " }"
393390 buf.result
394391
395- /** Get the representative member of the path in the union find. */
396- override def reprOf (p : PathType ): PathType | Null = lookupPath(p)
397-
398392 override def addToConstraint (params : List [Symbol ])(using Context ): Boolean = {
399393 import NameKinds .DepParamName
400394
@@ -512,15 +506,15 @@ final class ProperGadtConstraint private(
512506 }
513507
514508 private def lookupPath (p : PathType ): PathType | Null =
515- def recur (p : PathType ): PathType | Null = myUnionFind (p) match
509+ def recur (p : PathType ): PathType | Null = pathAliasingMap (p) match
516510 case null => null
517511 case q : PathType if q eq p => q
518512 case q : PathType =>
519513 recur(q)
520514
521515 recur(p)
522516
523- override def addEquality (p : PathType , q : PathType )(using Context ): Unit =
517+ override def recordPathAliasing (p : PathType , q : PathType )(using Context ): Unit =
524518 val pRep : PathType | Null = lookupPath(p)
525519 val qRep : PathType | Null = lookupPath(q)
526520
@@ -529,13 +523,13 @@ final class ProperGadtConstraint private(
529523 case (null , r : PathType ) => r
530524 case (r : PathType , null ) => r
531525 case (r1 : PathType , r2 : PathType ) =>
532- myUnionFind = myUnionFind .updated(r2, r1)
526+ pathAliasingMap = pathAliasingMap .updated(r2, r1)
533527 r1
534528
535- myUnionFind = myUnionFind .updated(p, newRep)
536- myUnionFind = myUnionFind .updated(q, newRep)
529+ pathAliasingMap = pathAliasingMap .updated(p, newRep)
530+ pathAliasingMap = pathAliasingMap .updated(q, newRep)
537531
538- override def isEquivalent (p : PathType , q : PathType ): Boolean =
532+ override def isAliasingPath (p : PathType , q : PathType ): Boolean =
539533 lookupPath(p) match
540534 case null => false
541535 case p0 : PathType => lookupPath(q) match
@@ -637,7 +631,7 @@ final class ProperGadtConstraint private(
637631 pathDepReverseMapping,
638632 wasConstrained,
639633 myScrutineePath,
640- myUnionFind ,
634+ pathAliasingMap ,
641635 myPatternSkolem,
642636 )
643637
@@ -650,7 +644,7 @@ final class ProperGadtConstraint private(
650644 this .pathDepReverseMapping = other.pathDepReverseMapping
651645 this .wasConstrained = other.wasConstrained
652646 this .myScrutineePath = other.myScrutineePath
653- this .myUnionFind = other.myUnionFind
647+ this .pathAliasingMap = other.pathAliasingMap
654648 this .myPatternSkolem = other.myPatternSkolem
655649 case _ => ;
656650 }
@@ -675,10 +669,10 @@ final class ProperGadtConstraint private(
675669 }
676670
677671 def updateUnionFind () =
678- myUnionFind (myPatternSkolem.nn) match {
672+ pathAliasingMap (myPatternSkolem.nn) match {
679673 case null =>
680674 case repr : PathType =>
681- myUnionFind = myUnionFind .updated(path, repr)
675+ pathAliasingMap = pathAliasingMap .updated(path, repr)
682676 }
683677
684678 updateMappings()
@@ -784,7 +778,7 @@ final class ProperGadtConstraint private(
784778 }
785779 }
786780 sb ++= " \n Singleton equalities:\n "
787- myUnionFind foreachBinding { case (path, _) =>
781+ pathAliasingMap foreachBinding { case (path, _) =>
788782 val repr = lookupPath(path)
789783 repr match
790784 case repr : PathType if repr ne path =>
@@ -805,8 +799,6 @@ final class ProperGadtConstraint private(
805799 override def bounds (tp : TypeRef )(using Context ): TypeBounds | Null = null
806800 override def fullBounds (tp : TypeRef )(using Context ): TypeBounds | Null = null
807801
808- override def reprOf (p : PathType ): PathType | Null = null
809-
810802 override def isLess (sym1 : Symbol , sym2 : Symbol )(using Context ): Boolean = unsupported(" EmptyGadtConstraint.isLess" )
811803 override def isLess (tp1 : NamedType , tp2 : NamedType )(using Context ): Boolean = unsupported(" EmptyGadtConstraint.isLess" )
812804
@@ -827,9 +819,9 @@ final class ProperGadtConstraint private(
827819 override def addBound (sym : Symbol , bound : Type , isUpper : Boolean )(using Context ): Boolean = unsupported(" EmptyGadtConstraint.addBound" )
828820 override def addBound (path : PathType , sym : Symbol , bound : Type , isUpper : Boolean )(using Context ): Boolean = unsupported(" EmptyGadtConstraint.addBound" )
829821
830- override def addEquality (p : PathType , q : PathType )(using Context ) = ()
822+ override def recordPathAliasing (p : PathType , q : PathType )(using Context ) = ()
831823
832- override def isEquivalent (p : PathType , q : PathType ) = false
824+ override def isAliasingPath (p : PathType , q : PathType ) = false
833825
834826 override def approximation (sym : Symbol , fromBelow : Boolean , maxLevel : Int )(using Context ): Type = unsupported(" EmptyGadtConstraint.approximation" )
835827
0 commit comments