Skip to content

Commit 8d0c927

Browse files
committed
Refactorings in preparation of opaques change
1 parent 877a6c7 commit 8d0c927

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,10 @@ object SymDenotations {
12031203
def opaqueAlias(implicit ctx: Context): Type = {
12041204
def recur(tp: Type): Type = tp match {
12051205
case RefinedType(parent, rname, TypeAlias(alias)) =>
1206-
if (rname == name) alias else recur(parent)
1206+
def alias1 = alias match
1207+
case alias: LazyRef => alias.ref
1208+
case _ => alias
1209+
if (rname == name) alias1 else recur(parent)
12071210
case _ =>
12081211
NoType
12091212
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,13 +4300,16 @@ object Types {
43004300
parentsCache
43014301
}
43024302

4303+
protected def newLikeThis(prefix: Type, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol)(given Context): ClassInfo =
4304+
ClassInfo(prefix, cls, classParents, decls, selfInfo)
4305+
43034306
def derivedClassInfo(prefix: Type)(implicit ctx: Context): ClassInfo =
43044307
if (prefix eq this.prefix) this
4305-
else ClassInfo(prefix, cls, classParents, decls, selfInfo)
4308+
else newLikeThis(prefix, classParents, decls, selfInfo)
43064309

43074310
def derivedClassInfo(prefix: Type = this.prefix, classParents: List[Type] = this.classParents, decls: Scope = this.decls, selfInfo: TypeOrSymbol = this.selfInfo)(implicit ctx: Context): ClassInfo =
43084311
if ((prefix eq this.prefix) && (classParents eq this.classParents) && (decls eq this.decls) && (selfInfo eq this.selfInfo)) this
4309-
else ClassInfo(prefix, cls, classParents, decls, selfInfo)
4312+
else newLikeThis(prefix, classParents, decls, selfInfo)
43104313

43114314
override def computeHash(bs: Binders): Int = doHash(bs, cls, prefix)
43124315
override def hashIsStable: Boolean = prefix.hashIsStable && classParents.hashIsStable
@@ -4347,9 +4350,8 @@ object Types {
43474350
def finalized(parents: List[Type])(implicit ctx: Context): ClassInfo =
43484351
ClassInfo(prefix, cls, parents, decls, selfInfo)
43494352

4350-
override def derivedClassInfo(prefix: Type)(implicit ctx: Context): ClassInfo =
4351-
if (prefix eq this.prefix) this
4352-
else new TempClassInfo(prefix, cls, decls, selfInfo)
4353+
override def newLikeThis(prefix: Type, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol)(given Context): ClassInfo =
4354+
TempClassInfo(prefix, cls, decls, selfInfo)
43534355

43544356
override def toString: String = s"TempClassInfo($prefix, $cls)"
43554357
}

0 commit comments

Comments
 (0)