Skip to content

Commit a800a10

Browse files
committed
Get rid of TypeState.hashesStr
Hashes ruin diffability; replace them with the serial `id` numbers.
1 parent 59bb75b commit a800a10

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,21 @@ trait ConstraintHandling {
8686
finally homogenizeArgs = saved
8787
}
8888

89+
private def location(implicit ctx: Context) = "" // i"in ${ctx.typerState.stateChainStr}" // use for debugging
90+
8991
protected def addUpperBound(param: TypeParamRef, bound: Type): Boolean = {
9092
def description = i"constraint $param <: $bound to\n$constraint"
9193
if (bound.isRef(defn.NothingClass) && ctx.typerState.isGlobalCommittable) {
9294
def msg = s"!!! instantiated to Nothing: $param, constraint = ${constraint.show}"
9395
if (Config.failOnInstantiationToNothing) assert(false, msg)
9496
else ctx.log(msg)
9597
}
96-
constr.println(i"adding $description in ${ctx.typerState.hashesStr}")
98+
constr.println(i"adding $description$location")
9799
val lower = constraint.lower(param)
98100
val res =
99101
addOneBound(param, bound, isUpper = true) &&
100102
lower.forall(addOneBound(_, bound, isUpper = true))
101-
constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
103+
constr.println(i"added $description = $res$location")
102104
res
103105
}
104106

@@ -109,7 +111,7 @@ trait ConstraintHandling {
109111
val res =
110112
addOneBound(param, bound, isUpper = false) &&
111113
upper.forall(addOneBound(_, bound, isUpper = false))
112-
constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
114+
constr.println(i"added $description = $res$location")
113115
res
114116
}
115117

@@ -122,12 +124,12 @@ trait ConstraintHandling {
122124
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
123125
val lo1 = constraint.nonParamBounds(p1).lo
124126
val hi2 = constraint.nonParamBounds(p2).hi
125-
constr.println(i"adding $description down1 = $down1, up2 = $up2 ${ctx.typerState.hashesStr}")
127+
constr.println(i"adding $description down1 = $down1, up2 = $up2$location")
126128
constraint = constraint.addLess(p1, p2)
127129
down1.forall(addOneBound(_, hi2, isUpper = true)) &&
128130
up2.forall(addOneBound(_, lo1, isUpper = false))
129131
}
130-
constr.println(i"added $description = $res ${ctx.typerState.hashesStr}")
132+
constr.println(i"added $description = $res$location")
131133
res
132134
}
133135

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ object TyperState {
1818
@sharable private var nextId: Int = 0
1919
}
2020

21-
class TyperState(previous: TyperState /* | Null */) extends DotClass with Showable {
21+
class TyperState(previous: TyperState /* | Null */) {
2222

2323
val id = TyperState.nextId
2424
TyperState.nextId += 1
2525

26-
//assert(id != 146)
27-
2826
private[this] var myReporter =
2927
if (previous == null) new ConsoleReporter() else previous.reporter
3028

@@ -181,8 +179,7 @@ class TyperState(previous: TyperState /* | Null */) extends DotClass with Showab
181179
constraint = constraint.remove(poly)
182180
}
183181

184-
override def toText(printer: Printer): Text = s"TS[$id]"
182+
override def toString: String = s"TS[$id]"
185183

186-
def hashesStr: String =
187-
if (previous == null) "" else hashCode.toString + " -> " + previous.hashesStr
184+
def stateChainStr: String = s"$this${if (previous == null) "" else previous.stateChainStr}"
188185
}

0 commit comments

Comments
 (0)