aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-01-30 17:53:54 +1100
committerMartin Odersky <odersky@gmail.com>2017-01-31 16:14:18 +1100
commitfc2bbfeaaf50c073ff1f22bfd0f3231a0b8d08a1 (patch)
treee25072cbd4122aad81968b046e06e86f0b84e56d /compiler/src
parentdd0a8032f70cf7c15a928d5756ce8f27791c9a7d (diff)
downloaddotty-fc2bbfeaaf50c073ff1f22bfd0f3231a0b8d08a1.tar.gz
dotty-fc2bbfeaaf50c073ff1f22bfd0f3231a0b8d08a1.tar.bz2
dotty-fc2bbfeaaf50c073ff1f22bfd0f3231a0b8d08a1.zip
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.
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala10
-rw-r--r--compiler/src/dotty/tools/dotc/core/TyperState.scala6
2 files changed, 11 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
index 42df53fed..3aa20f15b 100644
--- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
+++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
@@ -79,12 +79,12 @@ trait ConstraintHandling {
if (Config.failOnInstantiationToNothing) assert(false, msg)
else ctx.log(msg)
}
- constr.println(i"adding $description")
+ constr.println(i"adding $description in ${ctx.typerState.hashesStr}")
val lower = constraint.lower(param)
val res =
addOneBound(param, bound, isUpper = true) &&
lower.forall(addOneBound(_, bound, isUpper = true))
- constr.println(i"added $description = $res")
+ constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
res
}
@@ -95,7 +95,7 @@ trait ConstraintHandling {
val res =
addOneBound(param, bound, isUpper = false) &&
upper.forall(addOneBound(_, bound, isUpper = false))
- constr.println(i"added $description = $res")
+ constr.println(i"added $description = $res in ${ctx.typerState.hashesStr}")
res
}
@@ -108,12 +108,12 @@ trait ConstraintHandling {
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
val lo1 = constraint.nonParamBounds(p1).lo
val hi2 = constraint.nonParamBounds(p2).hi
- constr.println(i"adding $description down1 = $down1, up2 = $up2")
+ constr.println(i"adding $description down1 = $down1, up2 = $up2 ${ctx.typerState.hashesStr}")
constraint = constraint.addLess(p1, p2)
down1.forall(addOneBound(_, hi2, isUpper = true)) &&
up2.forall(addOneBound(_, lo1, isUpper = false))
}
- constr.println(i"added $description = $res")
+ constr.println(i"added $description = $res ${ctx.typerState.hashesStr}")
res
}
diff --git a/compiler/src/dotty/tools/dotc/core/TyperState.scala b/compiler/src/dotty/tools/dotc/core/TyperState.scala
index 5c476c1cb..206438d86 100644
--- a/compiler/src/dotty/tools/dotc/core/TyperState.scala
+++ b/compiler/src/dotty/tools/dotc/core/TyperState.scala
@@ -79,6 +79,9 @@ class TyperState(r: Reporter) extends DotClass with Showable {
def tryWithFallback[T](op: => T)(fallback: => T)(implicit ctx: Context): T = unsupported("tryWithFallBack")
override def toText(printer: Printer): Text = "ImmutableTyperState"
+
+ /** A string showing the hashes of all nested mutable typerstates */
+ def hashesStr: String = ""
}
class MutableTyperState(previous: TyperState, r: Reporter, override val isCommittable: Boolean)
@@ -207,4 +210,7 @@ extends TyperState(r) {
}
override def toText(printer: Printer): Text = constraint.toText(printer)
+
+ override def hashesStr: String = hashCode.toString + " -> " + previous.hashesStr
+
}