aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-29 11:18:59 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-29 11:18:59 +0200
commit8b9bdfe5f0c8c084b2db90ddcc0b5bbc25347034 (patch)
tree6454ba46dd8c88a340509459a67ff35272b2ac72 /src
parent3ea2fe9ab1abccc550f21ed07209c5b55cf1a867 (diff)
downloaddotty-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')
-rw-r--r--src/dotty/tools/dotc/core/Substituters.scala4
-rw-r--r--src/dotty/tools/dotc/core/Types.scala5
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala4
3 files changed, 7 insertions, 6 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
diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala
index f4eb8606c..7a2b93178 100644
--- a/src/dotty/tools/dotc/printing/PlainPrinter.scala
+++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala
@@ -94,7 +94,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
tp match {
case tp: TypeType =>
toTextRHS(tp)
- case tp: TermRef if !tp.knownDenotation =>
+ case tp: TermRef if !tp.denotationIsCurrent =>
toTextRef(tp) ~ ".type"
case tp: TermRef if tp.denot.isOverloaded =>
"<overloaded " ~ toTextRef(tp) ~ ">"
@@ -182,7 +182,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
text.stripPrefix(objectPrefix).stripPrefix(packagePrefix)
protected def selectionString(tp: NamedType) =
- if (tp.knownDenotation && tp.symbol.exists) nameString(tp.symbol)
+ if (tp.denotationIsCurrent && tp.symbol.exists) nameString(tp.symbol)
else nameString(tp.name)
/** The string representation of this type used as a prefix */