Skip to content

Commit 926a843

Browse files
committed
Refactorings in preparation of opaques change
1 parent 863167d commit 926a843

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
@@ -4293,13 +4293,16 @@ object Types {
42934293
parentsCache
42944294
}
42954295

4296+
protected def newLikeThis(prefix: Type, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol)(given Context): ClassInfo =
4297+
ClassInfo(prefix, cls, classParents, decls, selfInfo)
4298+
42964299
def derivedClassInfo(prefix: Type)(implicit ctx: Context): ClassInfo =
42974300
if (prefix eq this.prefix) this
4298-
else ClassInfo(prefix, cls, classParents, decls, selfInfo)
4301+
else newLikeThis(prefix, classParents, decls, selfInfo)
42994302

43004303
def derivedClassInfo(prefix: Type = this.prefix, classParents: List[Type] = this.classParents, decls: Scope = this.decls, selfInfo: TypeOrSymbol = this.selfInfo)(implicit ctx: Context): ClassInfo =
43014304
if ((prefix eq this.prefix) && (classParents eq this.classParents) && (decls eq this.decls) && (selfInfo eq this.selfInfo)) this
4302-
else ClassInfo(prefix, cls, classParents, decls, selfInfo)
4305+
else newLikeThis(prefix, classParents, decls, selfInfo)
43034306

43044307
override def computeHash(bs: Binders): Int = doHash(bs, cls, prefix)
43054308
override def hashIsStable: Boolean = prefix.hashIsStable && classParents.hashIsStable
@@ -4340,9 +4343,8 @@ object Types {
43404343
def finalized(parents: List[Type])(implicit ctx: Context): ClassInfo =
43414344
ClassInfo(prefix, cls, parents, decls, selfInfo)
43424345

4343-
override def derivedClassInfo(prefix: Type)(implicit ctx: Context): ClassInfo =
4344-
if (prefix eq this.prefix) this
4345-
else new TempClassInfo(prefix, cls, decls, selfInfo)
4346+
override def newLikeThis(prefix: Type, classParents: List[Type], decls: Scope, selfInfo: TypeOrSymbol)(given Context): ClassInfo =
4347+
TempClassInfo(prefix, cls, decls, selfInfo)
43464348

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

0 commit comments

Comments
 (0)