aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-03 19:02:42 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-03 19:02:42 +0200
commit609aeee025eec0bfc6680bf7fe717d0083cfb15b (patch)
tree285e0ed9fe11ddacac7277cf928b62ff48ce677f /src/dotty/tools/dotc/core/SymDenotations.scala
parentdf79c5efc7190e7a61ce7ac526aca0aac520ea9f (diff)
downloaddotty-609aeee025eec0bfc6680bf7fe717d0083cfb15b.tar.gz
dotty-609aeee025eec0bfc6680bf7fe717d0083cfb15b.tar.bz2
dotty-609aeee025eec0bfc6680bf7fe717d0083cfb15b.zip
Improvements in tracing and some Type fixes.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala64
1 files changed, 42 insertions, 22 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 106bb1ca6..ed83878a1 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -98,11 +98,10 @@ object SymDenotations {
private def completeFrom(completer: LazyType): Unit = {
if (_flags is Touched) throw new CyclicReference(this)
_flags |= Touched
-// Context.theBase.initialCtx.traceIndented( // !!! DEBUG
-// ">>>> completing "+this.debugString+"/"+owner.id,
-// "<<<< completed: "+this.debugString) {
+
+ /* !!! DEBUG Context.theBase.initialCtx.traceIndented(s"completing ${this.debugString}") */ {
completer.complete(this)
-// }
+ }
}
protected[core] final def info_=(tp: Type) = {
@@ -855,13 +854,31 @@ object SymDenotations {
final def baseTypeOf(tp: Type)(implicit ctx: Context): Type = {
+ def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
+ case p :: ps1 => foldGlb(bt & baseTypeOf(p), ps1)
+ case _ => bt
+ }
+
def computeBaseTypeOf(tp: Type): Type = tp match {
+ case tp: TypeRef =>
+ val subcls = tp.symbol
+ if (subcls eq symbol)
+ tp
+ else (subcls.denot) match {
+ case cdenot: ClassDenotation =>
+ if (cdenot.superClassBits contains symbol.superId) foldGlb(NoType, tp.parents)
+ else NoType
+ case _ =>
+ baseTypeOf(tp.underlying)
+ }
case tp: TypeProxy =>
baseTypeOf(tp.underlying)
case AndType(tp1, tp2) =>
baseTypeOf(tp1) & baseTypeOf(tp2)
case OrType(tp1, tp2) =>
baseTypeOf(tp1) | baseTypeOf(tp2)
+/*
+ *
case tp: ClassInfo =>
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
case p :: ps1 => foldGlb(bt & baseTypeOf(p), ps1)
@@ -873,28 +890,31 @@ object SymDenotations {
tp.rebase(foldGlb(NoType, tp.classParents))
else
NoType
+*/
case _ =>
NoType
}
- if (symbol.isStatic) symbol.typeConstructor
- else tp match {
- case tp: CachedType =>
- if (baseTypeValid != ctx.runId) {
- baseTypeCache = new java.util.HashMap[CachedType, Type]
- baseTypeValid = ctx.runId
- }
- var basetp = baseTypeCache get tp
- if (basetp == null) {
- baseTypeCache.put(tp, NoType)
- basetp = computeBaseTypeOf(tp)
- baseTypeCache.put(tp, basetp)
- } else if (basetp == NoType) {
- throw new CyclicReference(symbol)
- }
- basetp
- case _ =>
- computeBaseTypeOf(tp)
+ /* !!! DEBUG ctx.traceIndented(s"$tp.baseType($this)") */ {
+ if (symbol.isStatic) symbol.typeConstructor
+ else tp match {
+ case tp: CachedType =>
+ if (baseTypeValid != ctx.runId) {
+ baseTypeCache = new java.util.HashMap[CachedType, Type]
+ baseTypeValid = ctx.runId
+ }
+ var basetp = baseTypeCache get tp
+ if (basetp == null) {
+ baseTypeCache.put(tp, NoType)
+ basetp = computeBaseTypeOf(tp)
+ baseTypeCache.put(tp, basetp)
+ } else if (basetp == NoType) {
+ throw new CyclicReference(symbol)
+ }
+ basetp
+ case _ =>
+ computeBaseTypeOf(tp)
+ }
}
}