File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -590,7 +590,10 @@ object Denotations {
590
590
} while (d ne denot)
591
591
this
592
592
case _ =>
593
- if (coveredInterval.containsPhaseId(ctx.phaseId)) staleSymbolError
593
+ if (coveredInterval.containsPhaseId(ctx.phaseId)) {
594
+ if (ctx.settings.debug.value) ctx.traceInvalid(this )
595
+ staleSymbolError
596
+ }
594
597
else NoDenotation
595
598
}
596
599
Original file line number Diff line number Diff line change @@ -57,7 +57,37 @@ trait SymDenotations { this: Context =>
57
57
} catch {
58
58
case ex : StaleSymbol => false
59
59
}
60
+
61
+ /** Explain why symbol is invalid; used for debugging only */
62
+ def traceInvalid (denot : Denotation ): Boolean = {
63
+ def show (d : Denotation ) = s " $d# ${d.symbol.id}"
64
+ def explain (msg : String ) = {
65
+ println(s " ${show(denot)} is invalid at ${this .period} because $msg" )
66
+ false
67
+ }
68
+ denot match {
69
+ case denot : SymDenotation =>
70
+ def explainSym (msg : String ) = explain(s " $msg\n defined = ${denot.definedPeriodsString}" )
71
+ if (denot.is(ValidForever ) || denot.isRefinementClass) true
72
+ else {
73
+ implicit val ctx : Context = this
74
+ val initial = denot.initial
75
+ if ((initial ne denot) || ctx.phaseId != initial.validFor.firstPhaseId) {
76
+ ctx.withPhase(initial.validFor.firstPhaseId).traceInvalid(initial.asSymDenotation)
77
+ } else try {
78
+ val owner = denot.owner.denot
79
+ if (! traceInvalid(owner)) explainSym(" owner is invalid" )
80
+ else if (! owner.isClass || owner.isRefinementClass || denot.isSelfSym) true
81
+ else if (owner.unforcedDecls.lookupAll(denot.name) contains denot.symbol) true
82
+ else explainSym(s " decls of ${show(owner)} are ${owner.unforcedDecls.lookupAll(denot.name).toList}, do not contain ${denot.symbol}" )
83
+ } catch {
84
+ case ex : StaleSymbol => explainSym(s " $ex was thrown " )
85
+ }
86
+ }
87
+ case _ =>
88
+ explain(" denotation is not a SymDenotation" )
60
89
}
90
+ }
61
91
}
62
92
63
93
object SymDenotations {
You can’t perform that action at this time.
0 commit comments