Skip to content

Commit e1f7af3

Browse files
committed
Better printing of TyperStates
Identify them by number. Helps in the same way other fixed numbering schemes help understand debug output.
1 parent 0ea1710 commit e1f7af3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@ import printing.Texts._
1212
import config.Config
1313
import collection.mutable
1414
import java.lang.ref.WeakReference
15+
import Decorators._
16+
17+
object TyperState {
18+
@sharable private var nextId: Int = 0
19+
}
1520

1621
class TyperState(previous: TyperState /* | Null */) extends DotClass with Showable {
1722

23+
val id = TyperState.nextId
24+
TyperState.nextId += 1
25+
26+
//assert(id != 146)
27+
1828
private[this] var myReporter =
1929
if (previous == null) new ConsoleReporter() else previous.reporter
2030

@@ -171,7 +181,7 @@ class TyperState(previous: TyperState /* | Null */) extends DotClass with Showab
171181
constraint = constraint.remove(poly)
172182
}
173183

174-
override def toText(printer: Printer): Text = constraint.toText(printer)
184+
override def toText(printer: Printer): Text = s"TS[$id]"
175185

176186
def hashesStr: String =
177187
if (previous == null) "" else hashCode.toString + " -> " + previous.hashesStr

0 commit comments

Comments
 (0)