From 8b1e58ffb847706cada8fc5834c5ac6bcfcd8421 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 8 Jul 2014 14:21:45 +0200 Subject: Add definedPeriodsString method for disgnostics. --- src/dotty/tools/dotc/core/Denotations.scala | 35 +++++++++++++---------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/dotty/tools/dotc/core/Denotations.scala') diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 82ee6560d..a2c8af886 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -570,31 +570,14 @@ object Denotations { //println(s"searching: $cur at $currentPeriod, valid for ${cur.validFor}") cur = cur.nextInRun cnt += 1 - if (cnt > MaxPossiblePhaseId) { - println(s"seems to be a loop in Denotations for $this, currentPeriod = $currentPeriod") - printPeriods(this) - assert(false) - } + assert(cnt <= MaxPossiblePhaseId, + s"demanding denotation of $this outside defined interval: defined periods are${definedPeriodsString}") } cur } - } } - private def printPeriods(current: SingleDenotation): Unit = { - print(s"periods for $this:") - var cur = current - var cnt = 0 - do { - print(" " + cur.validFor) - cur = cur.nextInRun - cnt += 1 - if (cnt > MaxPossiblePhaseId) { println(" ..."); return } - } while (cur ne current) - println() - } - /** Install this denotation to be the result of the given denotation transformer. * This is the implementation of the same-named method in SymDenotations. * It's placed here because it needs access to private fields of SingleDenotation. @@ -643,6 +626,20 @@ object Denotations { if (symbol == NoSymbol) symbol.toString else s"" + + def definedPeriodsString: String = { + var sb = new StringBuilder() + var cur = this + var cnt = 0 + do { + sb.append(" " + cur.validFor) + cur = cur.nextInRun + cnt += 1 + if (cnt > MaxPossiblePhaseId) { sb.append(" ..."); cur = this } + } while (cur ne this) + sb.toString + } + // ------ PreDenotation ops ---------------------------------------------- final def first = this -- cgit v1.2.3