Skip to content

Commit 9ab6aba

Browse files
committed
Improve toString for TypeState
Now includes stack of ids of all nested typer states.
1 parent f97852c commit 9ab6aba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object TyperState {
1717
@sharable private var nextId: Int = 0
1818
}
1919

20-
class TyperState(previous: TyperState /* | Null */) {
20+
class TyperState(private val previous: TyperState /* | Null */) {
2121

2222
Stats.record("typerState")
2323

@@ -178,7 +178,12 @@ class TyperState(previous: TyperState /* | Null */) {
178178
constraint = constraint.remove(poly)
179179
}
180180

181-
override def toString: String = s"TS[$id]"
181+
override def toString: String = {
182+
def ids(state: TyperState): List[String] =
183+
s"${state.id}${if (state.isCommittable) "" else "X"}" ::
184+
(if (state.previous == null) Nil else ids(state.previous))
185+
s"TS[${ids(this).mkString(", ")}]"
186+
}
182187

183188
def stateChainStr: String = s"$this${if (previous == null) "" else previous.stateChainStr}"
184189
}

0 commit comments

Comments
 (0)