From 1dea9916e686adc96df9d7886346af2ed1abe45f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 31 Oct 2016 17:33:00 +0100 Subject: Fix #1637: Future defs are always OK Drop special mode that handles future defs without which we get DenotationNotDefinedHere errors. In more than a year, this has only turned up false negatives. So I think it's better to drop the check, and the contortions needed to deal with it. --- src/dotty/tools/dotc/core/Denotations.scala | 36 +++++------------------------ 1 file changed, 6 insertions(+), 30 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 7866d6697..6a39c5787 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -2,7 +2,7 @@ package dotty.tools package dotc package core -import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation, NotDefinedHereDenotation } +import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation } import Contexts.{Context, ContextBase} import Names.{Name, PreName} import Names.TypeName @@ -131,16 +131,9 @@ object Denotations { */ def atSignature(sig: Signature, site: Type = NoPrefix, relaxed: Boolean = false)(implicit ctx: Context): Denotation - /** The variant of this denotation that's current in the given context, or - * `NotDefinedHereDenotation` if this denotation does not exist at current phase, but - * is defined elsewhere in this run. - */ - def currentIfExists(implicit ctx: Context): Denotation - /** The variant of this denotation that's current in the given context. - * If no such denotation exists: If Mode.FutureDefs is set, the - * denotation with each alternative at its first point of definition, - * otherwise a `NotDefinedHere` exception is thrown. + * If no such denotation exists, returns the denotation with each alternative + * at its first point of definition. */ def current(implicit ctx: Context): Denotation @@ -569,8 +562,6 @@ object Denotations { final def signature(implicit ctx: Context) = Signature.OverloadedSignature def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): Denotation = derivedMultiDenotation(denot1.atSignature(sig, site, relaxed), denot2.atSignature(sig, site, relaxed)) - def currentIfExists(implicit ctx: Context): Denotation = - derivedMultiDenotation(denot1.currentIfExists, denot2.currentIfExists) def current(implicit ctx: Context): Denotation = derivedMultiDenotation(denot1.current, denot2.current) def altsWith(p: Symbol => Boolean): List[SingleDenotation] = @@ -765,7 +756,7 @@ object Denotations { * is brought forward to be valid in the new runId. Otherwise * the symbol is stale, which constitutes an internal error. */ - def currentIfExists(implicit ctx: Context): SingleDenotation = { + def current(implicit ctx: Context): SingleDenotation = { val currentPeriod = ctx.period val valid = myValidFor if (valid.code <= 0) { @@ -839,24 +830,14 @@ object Denotations { // performance: Test setup: Compile everything in dotc and immediate subdirectories // 10 times. Best out of 10: 18154ms with `prev` field, 17777ms without. cnt += 1 - if (cnt > MaxPossiblePhaseId) return NotDefinedHereDenotation + if (cnt > MaxPossiblePhaseId) + return current(ctx.withPhase(coveredInterval.firstPhaseId)) } cur } } } - def current(implicit ctx: Context): SingleDenotation = { - val d = currentIfExists - if (d ne NotDefinedHereDenotation) d else currentNoDefinedHere - } - - private def currentNoDefinedHere(implicit ctx: Context): SingleDenotation = - if (ctx.mode is Mode.FutureDefsOK) - current(ctx.withPhase(coveredInterval.firstPhaseId)) - else - throw new NotDefinedHere(demandOutsideDefinedMsg) - private def demandOutsideDefinedMsg(implicit ctx: Context): String = s"demanding denotation of $this at phase ${ctx.phase}(${ctx.phaseId}) outside defined interval: defined periods are${definedPeriodsString}" @@ -1233,9 +1214,4 @@ object Denotations { util.Stats.record("stale symbol") override def getMessage() = msg } - - class NotDefinedHere(msg: => String) extends Exception { - util.Stats.record("not defined here") - override def getMessage() = msg - } } \ No newline at end of file -- cgit v1.2.3