diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-29 11:18:59 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-29 11:18:59 +0200 |
commit | 8b9bdfe5f0c8c084b2db90ddcc0b5bbc25347034 (patch) | |
tree | 6454ba46dd8c88a340509459a67ff35272b2ac72 /src/dotty/tools/dotc/core | |
parent | 3ea2fe9ab1abccc550f21ed07209c5b55cf1a867 (diff) | |
download | dotty-8b9bdfe5f0c8c084b2db90ddcc0b5bbc25347034.tar.gz dotty-8b9bdfe5f0c8c084b2db90ddcc0b5bbc25347034.tar.bz2 dotty-8b9bdfe5f0c8c084b2db90ddcc0b5bbc25347034.zip |
Avoid cyclic reference errors in ShowScala
This is done by predicating some shortcuts on tp.symbol.isStatic
where tp is a NamedType with the condition tp.denotationIsCurrent,
i.e. we avoid forcing the denotation. This safe because the branches
taken on isStatic are optimizations.
This commit contains the minimum set of changes to make showScala pass.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Substituters.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index fdcc077b3..c67d352a4 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -12,7 +12,7 @@ trait Substituters { this: Context => case tp: BoundType => if (tp.binder eq from) tp.copyBoundType(to.asInstanceOf[tp.BT]) else tp case tp: NamedType => - if (tp.symbol.isStatic) tp + if (tp.denotationIsCurrent && tp.symbol.isStatic) tp else tp.derivedSelect(subst(tp.prefix, from, to, theMap)) case _: ThisType | NoPrefix => tp @@ -184,7 +184,7 @@ trait Substituters { this: Context => case tp @ RefinedThis(rt) => if (rt eq from) to else tp case tp: NamedType => - if (tp.symbol.isStatic) tp + if (tp.denotationIsCurrent && tp.symbol.isStatic) tp else tp.derivedSelect(substThis(tp.prefix, from, to, theMap)) case _: ThisType | _: BoundType | NoPrefix => tp diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 63a26e21a..c2d465f7f 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1102,7 +1102,8 @@ object Types { // (1) checkedPeriod != Nowhere => lastDenotation != null // (2) lastDenotation != null => lastSymbol != null - def knownDenotation: Boolean = lastDenotation != null + def denotationIsCurrent(implicit ctx: Context) = + lastDenotation != null && lastDenotation.validFor.runId == ctx.runId /** The denotation currently denoted by this type */ final def denot(implicit ctx: Context): Denotation = { @@ -2658,7 +2659,7 @@ object Types { this(x, if (tp1.exists) tp1 else tp.prefix) } case tp: TermRef => - if (stopAtStatic && tp.symbol.isStatic) x + if (stopAtStatic && tp.denotationIsCurrent && tp.symbol.isStatic) x else this(x, tp.prefix) case _: ThisType |