Skip to content

Commit fc2bbfe

Browse files
committed
Print typerstate nesting info as part of constr printing
When printing info about adding to constraints, show the hashes of the typerstate stack, so that we know where constraints are added.
1 parent dd0a803 commit fc2bbfe

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ trait ConstraintHandling {
7979
if (Config.failOnInstantiationToNothing) assert(false, msg)
8080
else ctx.log(msg)
8181
}
82-
constr.println(i"adding $description")
82+
constr.println(i"adding $description in ${ctx.typerState.hashesStr}")
8383
val lower = constraint.lower(param)
8484
val res =
8585
addOneBound(param, bound, isUpper = true) &&
8686
lower.forall(addOneBound(_, bound, isUpper = true))
87-
constr.println(i"added $description = $res")
87+
constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
8888
res
8989
}
9090

@@ -95,7 +95,7 @@ trait ConstraintHandling {
9595
val res =
9696
addOneBound(param, bound, isUpper = false) &&
9797
upper.forall(addOneBound(_, bound, isUpper = false))
98-
constr.println(i"added $description = $res")
98+
constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
9999
res
100100
}
101101

@@ -108,12 +108,12 @@ trait ConstraintHandling {
108108
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
109109
val lo1 = constraint.nonParamBounds(p1).lo
110110
val hi2 = constraint.nonParamBounds(p2).hi
111-
constr.println(i"adding $description down1 = $down1, up2 = $up2")
111+
constr.println(i"adding $description down1 = $down1, up2 = $up2 ${ctx.typerState.hashesStr}")
112112
constraint = constraint.addLess(p1, p2)
113113
down1.forall(addOneBound(_, hi2, isUpper = true)) &&
114114
up2.forall(addOneBound(_, lo1, isUpper = false))
115115
}
116-
constr.println(i"added $description = $res")
116+
constr.println(i"added $description = $res ${ctx.typerState.hashesStr}")
117117
res
118118
}
119119

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class TyperState(r: Reporter) extends DotClass with Showable {
7979
def tryWithFallback[T](op: => T)(fallback: => T)(implicit ctx: Context): T = unsupported("tryWithFallBack")
8080

8181
override def toText(printer: Printer): Text = "ImmutableTyperState"
82+
83+
/** A string showing the hashes of all nested mutable typerstates */
84+
def hashesStr: String = ""
8285
}
8386

8487
class MutableTyperState(previous: TyperState, r: Reporter, override val isCommittable: Boolean)
@@ -207,4 +210,7 @@ extends TyperState(r) {
207210
}
208211

209212
override def toText(printer: Printer): Text = constraint.toText(printer)
213+
214+
override def hashesStr: String = hashCode.toString + " -> " + previous.hashesStr
215+
210216
}

0 commit comments

Comments
 (0)