Skip to content

Commit d1024dd

Browse files
committed
Refactor before fixing #4272
1 parent b1d9162 commit d1024dd

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -519,23 +519,15 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
519519
def mergeParams(ps1: List[TypeParamRef], ps2: List[TypeParamRef]) =
520520
(ps1 /: ps2)((ps1, p2) => if (ps1.contains(p2)) ps1 else p2 :: ps1)
521521

522-
def mergeEntries(e1: Type, e2: Type): Type = e1 match {
523-
case e1: TypeBounds =>
524-
e2 match {
525-
case e2: TypeBounds => e1 & e2
526-
case _ if e1 contains e2 => e2
527-
case _ => mergeError
528-
}
529-
case tv1: TypeVar =>
530-
e2 match {
531-
case tv2: TypeVar if tv1.instanceOpt eq tv2.instanceOpt => e1
532-
case _ => mergeError
533-
}
522+
def mergeEntries(e1: Type, e2: Type): Type =
523+
(e1, e2) match {
524+
case (e1: TypeBounds, e2: TypeBounds) => e1 & e2
525+
case (e1: TypeBounds, _) if e1 contains e2 => e2
526+
case (tv1: TypeVar, tv2: TypeVar) if tv1.instanceOpt eq tv2.instanceOpt => e1
534527
case _ if e1 eq e2 => e1
535-
case _ => mergeError
536-
}
537-
538-
def mergeError = throw new AssertionError(i"cannot merge $this with $other")
528+
case _ =>
529+
throw new AssertionError(i"cannot merge $this with $other")
530+
}
539531

540532
val that = other.asInstanceOf[OrderingConstraint]
541533
new OrderingConstraint(

0 commit comments

Comments
 (0)