Skip to content

Commit d9d64f1

Browse files
committed
Implement toString for OrderingConstraint
We had problems printing constraints which are ill-formed, because the basic operations & , | cause exceptions themselves. toString serves as a fallback if show does not work.
1 parent f0fb487 commit d9d64f1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
129129

130130
type This = OrderingConstraint
131131

132-
133132
// ----------- Basic indices --------------------------------------------------
134133

135134
/** The number of type parameters in the given entry array */
@@ -576,4 +575,22 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
576575
}
577576
Text.lines(List(header, uninstVarsText, constrainedText, boundsText, orderingText, ")"))
578577
}
578+
579+
override def toString: String = {
580+
def entryText(tp: Type): String = tp match {
581+
case tp: TypeBounds => tp.toString
582+
case _ =>" := " + tp
583+
}
584+
val constrainedText =
585+
" constrained types = " + domainPolys.mkString("\n")
586+
val boundsText =
587+
" bounds = " + {
588+
val assocs =
589+
for (param <- domainParams)
590+
yield
591+
param.binder.paramNames(param.paramNum) + ": " + entryText(entry(param))
592+
assocs.mkString("\n")
593+
}
594+
constrainedText + "\n" + boundsText
595+
}
579596
}

0 commit comments

Comments
 (0)