aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index a867253b7..ebe52d522 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -269,6 +269,9 @@ object SymDenotations {
/** Is this denotation a class? */
final def isClass: Boolean = isInstanceOf[ClassDenotation]
+ /** Is this denotation a non-trait class? */
+ final def isRealClass(implicit ctx: Context) = isClass && !is(Trait)
+
/** Cast to class denotation */
final def asClass: ClassDenotation = asInstanceOf[ClassDenotation]
@@ -446,7 +449,7 @@ object SymDenotations {
| ${owner.showLocated} where target is defined""".stripMargin)
else if (
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
- || pre.baseType(cls).exists
+ || pre.baseTypeRef(cls).exists // ??? why not use derivesFrom ???
|| isConstructor
|| (owner is ModuleClass) // don't perform this check for static members
))
@@ -847,12 +850,12 @@ object SymDenotations {
private[this] var myBaseClasses: List[ClassSymbol] = null
private[this] var mySuperClassBits: BitSet = null
- /** Invalidate baseTypeCache and superClassBits on new run */
+ /** Invalidate baseTypeRefCache and superClassBits on new run */
private def checkBasesUpToDate()(implicit ctx: Context) =
- if (baseTypeValid != ctx.runId) {
- baseTypeCache = new java.util.HashMap[CachedType, Type]
+ if (baseTypeRefValid != ctx.runId) {
+ baseTypeRefCache = new java.util.HashMap[CachedType, Type]
mySuperClassBits = null
- baseTypeValid = ctx.runId
+ baseTypeRefValid = ctx.runId
}
private def computeBases(implicit ctx: Context): Unit = {
@@ -1062,18 +1065,18 @@ object SymDenotations {
raw.filterExcluded(excluded).asSeenFrom(pre).toDenot(pre)
}
- private[this] var baseTypeCache: java.util.HashMap[CachedType, Type] = null
- private[this] var baseTypeValid: RunId = NoRunId
+ private[this] var baseTypeRefCache: java.util.HashMap[CachedType, Type] = null
+ private[this] var baseTypeRefValid: RunId = NoRunId
- /** Compute tp.baseType(this) */
- final def baseTypeOf(tp: Type)(implicit ctx: Context): Type = {
+ /** Compute tp.baseTypeRef(this) */
+ final def baseTypeRefOf(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 p :: ps1 => foldGlb(bt & baseTypeRefOf(p), ps1)
case _ => bt
}
- def computeBaseTypeOf(tp: Type): Type = {
+ def computeBaseTypeRefOf(tp: Type): Type = {
Stats.record("computeBaseTypeOf")
if (symbol.isStatic && tp.derivesFrom(symbol))
symbol.typeRef
@@ -1087,34 +1090,34 @@ object SymDenotations {
if (cdenot.superClassBits contains symbol.superId) foldGlb(NoType, tp.parents)
else NoType
case _ =>
- baseTypeOf(tp.underlying)
+ baseTypeRefOf(tp.underlying)
}
case tp: TypeProxy =>
- baseTypeOf(tp.underlying)
+ baseTypeRefOf(tp.underlying)
case AndType(tp1, tp2) =>
- baseTypeOf(tp1) & baseTypeOf(tp2)
+ baseTypeRefOf(tp1) & baseTypeRefOf(tp2)
case OrType(tp1, tp2) =>
- baseTypeOf(tp1) | baseTypeOf(tp2)
+ baseTypeRefOf(tp1) | baseTypeRefOf(tp2)
case _ =>
NoType
}
}
- /*>|>*/ ctx.debugTraceIndented(s"$tp.baseType($this)") /*<|<*/ {
+ /*>|>*/ ctx.debugTraceIndented(s"$tp.baseTypeRef($this)") /*<|<*/ {
tp match {
case tp: CachedType =>
checkBasesUpToDate()
- var basetp = baseTypeCache get tp
+ var basetp = baseTypeRefCache get tp
if (basetp == null) {
- baseTypeCache.put(tp, NoPrefix)
- basetp = computeBaseTypeOf(tp)
- baseTypeCache.put(tp, basetp)
+ baseTypeRefCache.put(tp, NoPrefix)
+ basetp = computeBaseTypeRefOf(tp)
+ baseTypeRefCache.put(tp, basetp)
} else if (basetp == NoPrefix) {
throw new CyclicReference(this)
}
basetp
case _ =>
- computeBaseTypeOf(tp)
+ computeBaseTypeRefOf(tp)
}
}
}