aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-04 09:57:15 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-04 09:57:15 +0200
commit9cd15421432871b920d377af86e1cd1b3edb270e (patch)
tree89906915175582a84d44dc56a8df2b2b65539ed9
parent609aeee025eec0bfc6680bf7fe717d0083cfb15b (diff)
downloaddotty-9cd15421432871b920d377af86e1cd1b3edb270e.tar.gz
dotty-9cd15421432871b920d377af86e1cd1b3edb270e.tar.bz2
dotty-9cd15421432871b920d377af86e1cd1b3edb270e.zip
Trying to get at the root of cyclic reference problems.
Part 1: Enabling tracing and avoiding subtype computations in margeDenot.
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala13
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala4
-rw-r--r--src/dotty/tools/dotc/core/TypeComparers.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala42
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
5 files changed, 35 insertions, 28 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 08f4c9c57..c0fa46e31 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -227,9 +227,10 @@ object Denotations {
val sym2Eligible = sym2.isAsConcrete(sym1)
val bounds1 = normalize(info1)
val bounds2 = normalize(info2)
- if (sym2Eligible && bounds2 <:< bounds1) denot2
- else if (sym1Eligible && bounds1 <:< bounds2) denot1
- else new JointRefDenotation(
+// if (sym2Eligible && bounds2 <:< bounds1) denot2
+// else if (sym1Eligible && bounds1 <:< bounds2) denot1
+// else
+ new LazyJointRefDenotation(
if (sym2Eligible) sym2 else sym1,
bounds1 & bounds2,
denot1.validFor & denot2.validFor)
@@ -505,6 +506,12 @@ object Denotations {
override protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor)
}
+ class LazyJointRefDenotation(val symbol: Symbol, infoFn: => Type, initValidFor: Period) extends SingleDenotation {
+ validFor = initValidFor
+ lazy val info = infoFn
+ override protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor)
+ }
+
class ErrorDenotation(implicit ctx: Context) extends SingleDenotation {
override def exists = false
val symbol = NoSymbol
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index ed83878a1..3f0ad171a 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -99,7 +99,7 @@ object SymDenotations {
if (_flags is Touched) throw new CyclicReference(this)
_flags |= Touched
- /* !!! DEBUG Context.theBase.initialCtx.traceIndented(s"completing ${this.debugString}") */ {
+ Context.theBase.initialCtx.traceIndented(s"completing ${this.debugString}") {
completer.complete(this)
}
}
@@ -895,7 +895,7 @@ object SymDenotations {
NoType
}
- /* !!! DEBUG ctx.traceIndented(s"$tp.baseType($this)") */ {
+ ctx.traceIndented(s"$tp.baseType($this)") {
if (symbol.isStatic) symbol.typeConstructor
else tp match {
case tp: CachedType =>
diff --git a/src/dotty/tools/dotc/core/TypeComparers.scala b/src/dotty/tools/dotc/core/TypeComparers.scala
index 7320438ed..464cec37c 100644
--- a/src/dotty/tools/dotc/core/TypeComparers.scala
+++ b/src/dotty/tools/dotc/core/TypeComparers.scala
@@ -55,7 +55,7 @@ object TypeComparers {
}
}
- def firstTry(tp1: Type, tp2: Type): Boolean = /* !!! DEBUG ctx.traceIndented(s"$tp1 <:< $tp2") */ {
+ def firstTry(tp1: Type, tp2: Type): Boolean = ctx.traceIndented(s"$tp1 <:< $tp2") {
tp2 match {
case tp2: NamedType =>
tp1 match {
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index f86cc5296..7b09df769 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -19,32 +19,32 @@ trait TypeOps { this: Context =>
else
toPrefix(pre.baseType(cls).normalizedPrefix, cls.owner, thiscls)
- /* !!! DEBUG ctx.traceIndented(s"$tp.asSeenFrom($pre, $cls)") */ {
- tp match {
- case tp: NamedType =>
- val sym = tp.symbol
- if (sym.isStatic) tp
- else {
- val tp1 = tp.derivedNamedType(asSeenFrom(tp.prefix, pre, cls, theMap))
- // short-circuit instantiated type parameters
- if ((tp1 ne tp) && (sym is (TypeParam, butNot = Deferred))) tp1.dealias
- else tp1
- }
- case ThisType(thiscls) =>
- toPrefix(pre, cls, thiscls)
- case _: BoundType | NoPrefix =>
- tp
- case tp: RefinedType =>
- tp.derivedRefinedType(
+ ctx.traceIndented(s"$tp.asSeenFrom($pre, $cls)") {
+ tp match {
+ case tp: NamedType =>
+ val sym = tp.symbol
+ if (sym.isStatic) tp
+ else {
+ val tp1 = tp.derivedNamedType(asSeenFrom(tp.prefix, pre, cls, theMap))
+ // short-circuit instantiated type parameters
+ if ((tp1 ne tp) && (sym is (TypeParam, butNot = Deferred))) tp1.dealias
+ else tp1
+ }
+ case ThisType(thiscls) =>
+ toPrefix(pre, cls, thiscls)
+ case _: BoundType | NoPrefix =>
+ tp
+ case tp: RefinedType =>
+ tp.derivedRefinedType(
asSeenFrom(tp.parent, pre, cls, theMap),
tp.refinedName,
asSeenFrom(tp.refinedInfo, pre, cls, theMap))
- case _ =>
- (if (theMap != null) theMap else new AsSeenFromMap(pre, cls))
- .mapOver(tp)
+ case _ =>
+ (if (theMap != null) theMap else new AsSeenFromMap(pre, cls))
+ .mapOver(tp)
+ }
}
}
- }
class AsSeenFromMap(pre: Type, cls: Symbol) extends TypeMap {
def apply(tp: Type) = asSeenFrom(tp, pre, cls, this)
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 98dcc43a1..a397426c7 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -984,7 +984,7 @@ object Types {
final class TermRefWithSignature(prefix: Type, name: TermName, val sig: Signature) extends TermRef(prefix, name) {
override def signature(implicit ctx: Context) = sig
- override def loadDenot(implicit ctx: Context): Denotation =
+ override def loadDenot(implicit ctx: Context): Denotation =
super.loadDenot.atSignature(sig)
override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRefWithSignature =
TermRef(prefix, name, sig)