Skip to content

Commit 9d01fea

Browse files
committed
Drop ClassDenotation.appliedRef and ClassInfo.typeRef
- keep typeRef in ClassDenotaton, since we need it before info is completed - keep appliedRef in ClassInfo, since it depends on prefix.
1 parent 68ea8a4 commit 9d01fea

File tree

3 files changed

+13
-43
lines changed

3 files changed

+13
-43
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,20 +1412,15 @@ object SymDenotations {
14121412
else ThisType.raw(TypeRef(pre, symbol.asType))
14131413
}
14141414
*/
1415-
private[this] var myAppliedRef: Type = null // @!!!: Use classInfo.appliedRef instead?
1416-
private[this] var myTypeRef: TypeRef = null // @!!!: Use classInfo.appliedRef instead?
1417-
1418-
override def appliedRef(implicit ctx: Context): Type = {
1419-
if (myAppliedRef == null) myAppliedRef = super.appliedRef
1420-
if (ctx.erasedTypes) myAppliedRef.typeConstructor
1421-
else myAppliedRef
1422-
}
1415+
private[this] var myTypeRef: TypeRef = null
14231416

14241417
override def typeRef(implicit ctx: Context): TypeRef = {
14251418
if (myTypeRef == null) myTypeRef = super.typeRef
14261419
myTypeRef
14271420
}
14281421

1422+
override def appliedRef(implicit ctx: Context): Type = classInfo.appliedRef
1423+
14291424
private def baseData(implicit onBehalf: BaseData, ctx: Context): (List[ClassSymbol], BaseClassSet) = {
14301425
if (!baseDataCache.isValid) baseDataCache = BaseData.newCache()
14311426
baseDataCache(this)

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,8 @@ object Types {
470470
final def memberExcluding(name: Name, excluding: FlagSet)(implicit ctx: Context): Denotation = {
471471
// We need a valid prefix for `asSeenFrom`
472472
val pre = this match {
473-
case tp: ClassInfo =>
474-
tp.typeRef // @!!! appliedRef
475-
case _ =>
476-
widenIfUnstable
473+
case tp: ClassInfo => tp.appliedRef
474+
case _ => widenIfUnstable
477475
}
478476
findMember(name, pre, excluding)
479477
}
@@ -3432,48 +3430,25 @@ object Types {
34323430
decls: Scope,
34333431
selfInfo: DotClass /* should be: Type | Symbol */) extends CachedGroundType with TypeType {
34343432

3433+
private var selfTypeCache: Type = null
3434+
private var appliedRefCache: Type = null
3435+
34353436
/** The self type of a class is the conjunction of
34363437
* - the explicit self type if given (or the info of a given self symbol), and
34373438
* - the fully applied reference to the class itself.
34383439
*/
34393440
def selfType(implicit ctx: Context): Type = {
34403441
if (selfTypeCache == null)
34413442
selfTypeCache = {
3442-
def fullRef = fullyAppliedRef
34433443
val given = cls.givenSelfType
3444-
val raw =
3445-
if (!given.exists) fullRef
3446-
else if (cls is Module) given
3447-
else if (ctx.erasedTypes) fullRef
3448-
else AndType(given, fullRef)
3449-
raw//.asSeenFrom(prefix, cls.owner)
3444+
if (!given.exists) appliedRef
3445+
else if (cls is Module) given
3446+
else if (ctx.erasedTypes) appliedRef
3447+
else AndType(given, appliedRef)
34503448
}
34513449
selfTypeCache
34523450
}
34533451

3454-
private var selfTypeCache: Type = null
3455-
3456-
//private def fullyAppliedRef(base: Type, tparams: List[TypeSymbol])(implicit ctx: Context): Type =
3457-
// base.appliedTo(tparams.map(_.typeRef))
3458-
3459-
/** The class type with all type parameters */
3460-
def fullyAppliedRef(implicit ctx: Context): Type = // @!!! eliminate
3461-
//if (true)
3462-
cls.appliedRef
3463-
//else fullyAppliedRef(cls.typeRef, cls.typeParams)
3464-
3465-
private var appliedRefCache: Type = null
3466-
private var typeRefCache: TypeRef = null
3467-
3468-
def typeRef(implicit ctx: Context): TypeRef = {
3469-
def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this)
3470-
if (typeRefCache == null)
3471-
typeRefCache =
3472-
if ((cls is PackageClass) || cls.owner.isTerm) symbolicTypeRef
3473-
else TypeRef(prefix, cls.name, clsDenot)
3474-
typeRefCache
3475-
}
3476-
34773452
def appliedRef(implicit ctx: Context): Type = {
34783453
def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this)
34793454
if (appliedRefCache == null) {

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
234234
}
235235

236236
def linearizedAncestorTypes(info: ClassInfo): List[Type] = {
237-
val ref = info.fullyAppliedRef
237+
val ref = info.appliedRef
238238
// Note that the ordering of classes in `baseClasses` is important.
239239
info.baseClasses.tail.map(ref.baseType)
240240
}

0 commit comments

Comments
 (0)