diff options
author | Martin Odersky <odersky@gmail.com> | 2013-01-21 14:24:32 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-01-21 14:24:32 +0100 |
commit | 4822da28b769484f9dac3ec83d437149e0559a48 (patch) | |
tree | c3cb89f91f786a375a8ee2c4308a541d8b05be81 /src/dotty/tools/dotc/core/Types.scala | |
parent | e59b8822f53fa6fad057ac9642d31e4026800bf5 (diff) | |
download | dotty-4822da28b769484f9dac3ec83d437149e0559a48.tar.gz dotty-4822da28b769484f9dac3ec83d437149e0559a48.tar.bz2 dotty-4822da28b769484f9dac3ec83d437149e0559a48.zip |
Changed NamedType dereferencing so that we need not keep track of name validity periods. Instead, we simply retry on missing member lookup in an earlier phase. This scheme is less complicated and works as long as names that are renamed in phase A are not re-used in a phase B >= A.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 61e7fa26c..460265e3d 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -300,11 +300,11 @@ object Types { case tp: ClassInfo => val classd = tp.classd val candidates = classd.membersNamed(name) - val resultSyms = candidates + val results = candidates .filterAccessibleFrom(pre) .filterExcluded(excluded) .asSeenFrom(pre, classd.symbol) - if (resultSyms.exists) resultSyms.toDenot + if (results.exists) results.toDenot else new ErrorDenotation // todo: refine case tp: AndType => tp.tp1.findMember(name, pre, excluded) & tp.tp2.findMember(name, pre, excluded) @@ -573,18 +573,24 @@ object Types { if (!(validPeriods contains ctx.period)) { val thisPeriod = ctx.period lastDenotation = - if (validPeriods.runId == thisPeriod.runId) + if (validPeriods.runId == thisPeriod.runId) { lastDenotation.current - else if (thisPeriod.phaseId > name.lastIntroPhaseId) - ctx.atPhase(name.lastIntroPhaseId)(prefix.member(name)(_)).current - else - prefix.member(name) - if (checkPrefix(lastDenotation.symbol) && !prefix.isLegalPrefix) - throw new MalformedType(prefix, lastDenotation.symbol) + } else { + val d = loadDenot + if (d.exists || ctx.phaseId == FirstPhaseId) { + if (checkPrefix(d.symbol) && !prefix.isLegalPrefix) + throw new MalformedType(prefix, d.symbol) + d + } else {// name has changed; try load in earlier phase and make current + denot(ctx.withPhase(ctx.phaseId - 1)).current + } + } } lastDenotation } + protected def loadDenot(implicit ctx: Context) = prefix.member(name) + def isType = name.isTypeName def isTerm = name.isTermName @@ -619,8 +625,8 @@ object Types { final class TermRefWithSignature(prefix: Type, name: TermName, override val signature: Signature) extends TermRef(prefix, name) { override def computeHash = doHash((name, signature), prefix) - override def denot(implicit ctx: Context): Denotation = - super.denot.atSignature(signature) + override def loadDenot(implicit ctx: Context): Denotation = + super.loadDenot.atSignature(signature) } final class TypeRefNoPrefix(val fixedSym: TypeSymbol)(implicit ctx: Context) |