Skip to content

Commit 70eae28

Browse files
committed
Get rid of TypeState.hashesStr
Hashes ruin diffability; replace them with the serial `id` numbers.
1 parent 6251b8e commit 70eae28

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
@@ -85,19 +85,21 @@ trait ConstraintHandling {
8585
finally homogenizeArgs = saved
8686
}
8787

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

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

@@ -121,12 +123,12 @@ trait ConstraintHandling {
121123
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
122124
val lo1 = constraint.nonParamBounds(p1).lo
123125
val hi2 = constraint.nonParamBounds(p2).hi
124-
constr.println(i"adding $description down1 = $down1, up2 = $up2 ${ctx.typerState.hashesStr}")
126+
constr.println(i"adding $description down1 = $down1, up2 = $up2$location")
125127
constraint = constraint.addLess(p1, p2)
126128
down1.forall(addOneBound(_, hi2, isUpper = true)) &&
127129
up2.forall(addOneBound(_, lo1, isUpper = false))
128130
}
129-
constr.println(i"added $description = $res ${ctx.typerState.hashesStr}")
131+
constr.println(i"added $description = $res$location")
130132
res
131133
}
132134

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)