Skip to content

Commit 681f3bc

Browse files
committed
Reorganize maybeOwner
1 parent c07bd13 commit 681f3bc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object SymDenotations {
7373
class SymDenotation private[SymDenotations] (
7474
symbolHint: Symbol | Null,
7575
final val common: SymCommon,
76-
final val maybeOwner: Symbol,
76+
ownerOrNull: Symbol | Null,
7777
final val name: Name,
7878
initFlags: FlagSet,
7979
initInfo: Type,
@@ -91,6 +91,9 @@ object SymDenotations {
9191
*/
9292
if (Config.checkNoSkolemsInInfo) assertNoSkolems(initInfo)
9393

94+
final def maybeOwner: Symbol =
95+
if ownerOrNull == null then NoSymbol else ownerOrNull
96+
9497
// ------ Getting and setting fields -----------------------------
9598

9699
private var myFlags: FlagSet = adaptFlags(initFlags)
@@ -99,7 +102,9 @@ object SymDenotations {
99102
private var myParamss: List[List[Symbol]] = Nil
100103

101104
/** The owner of the symbol; overridden in NoDenotation */
102-
def owner: Symbol = maybeOwner
105+
final def owner: Symbol =
106+
assert(ownerOrNull != null, "NoDenotation.owner")
107+
ownerOrNull
103108

104109
/** The flag set */
105110
final def flags(using Context): FlagSet = { ensureCompleted(); myFlags }
@@ -2057,8 +2062,8 @@ object SymDenotations {
20572062
val builder = new BaseDataBuilder
20582063
def traverse(parents: List[Type]): Unit = parents match {
20592064
case p :: parents1 =>
2060-
p.classSymbol match {
2061-
case pcls: ClassSymbol => builder.addAll(pcls.baseClasses)
2065+
p.classSymbol.denot match {
2066+
case pcls: ClassDenotation => builder.addAll(pcls.baseClasses)
20622067
case _ => assert(isRefinementClass || p.isError || ctx.mode.is(Mode.Interactive), s"$this has non-class parent: $p")
20632068
}
20642069
traverse(parents1)
@@ -2414,8 +2419,8 @@ object SymDenotations {
24142419
def maybeAdd(name: Name) = if (keepOnly(thisType, name)) names += name
24152420
try {
24162421
for ptype <- parentTypes do
2417-
ptype.classSymbol match
2418-
case pcls: ClassSymbol =>
2422+
ptype.classSymbol.denot match
2423+
case pcls: ClassDenotation =>
24192424
for name <- pcls.memberNames(keepOnly) do
24202425
maybeAdd(name)
24212426
val ownSyms =
@@ -2678,10 +2683,9 @@ object SymDenotations {
26782683
}
26792684

26802685
@sharable object NoDenotation
2681-
extends SymDenotation(NoSymbol, SymCommon(NoCoord, 0, 0), NoSymbol, "<none>".toTermName, Permanent, NoType) {
2686+
extends SymDenotation(NoSymbol, SymCommon(NoCoord, 0, 0), null, "<none>".toTermName, Permanent, NoType) {
26822687
override def isTerm: Boolean = false
26832688
override def exists: Boolean = false
2684-
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
26852689
override def computeAsSeenFrom(pre: Type)(using Context): SingleDenotation = this
26862690
override def mapInfo(f: Type => Type)(using Context): SingleDenotation = this
26872691
override def asSeenFrom(pre: Type)(using Context): AsSeenFromResult = this

0 commit comments

Comments
 (0)