@@ -7,6 +7,7 @@ import scala.annotation.threadUnsafe
7
7
8
8
import dotty .tools .dotc .core .Flags
9
9
import dotty .tools .dotc .core .Symbols ._
10
+ import dotty .tools .dotc .core .Phases .Phase
10
11
import dotty .tools .dotc .transform .SymUtils ._
11
12
12
13
/**
@@ -125,7 +126,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
125
126
// The lambdalift phase lifts all nested classes to the enclosing class, so if we collect
126
127
// member classes right after lambdalift, we obtain all nested classes, including local and
127
128
// anonymous ones.
128
- val nestedClasses = symHelper (classSym).nestedClasses
129
+ val nestedClasses = getNestedClasses (classSym)
129
130
130
131
// If this is a top-level class, and it has a companion object, the member classes of the
131
132
// companion are added as members of the class. For example:
@@ -143,7 +144,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
143
144
val companionModuleMembers = {
144
145
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
145
146
// not local classes of the companion module (E in the example) that were lifted by lambdalift.
146
- if (classSym.linkedClass.isTopLevelModuleClass) /* exitingPickler*/ symHelper (classSym.linkedClass).memberClasses
147
+ if (classSym.linkedClass.isTopLevelModuleClass) /* exitingPickler*/ getMemberClasses (classSym.linkedClass)
147
148
else Nil
148
149
}
149
150
@@ -175,6 +176,22 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
175
176
classBType
176
177
}
177
178
179
+ /** For currently compiled classes: All locally defined classes including local classes.
180
+ * The empty list for classes that are not currently compiled.
181
+ */
182
+ private def getNestedClasses (sym : Symbol ): List [Symbol ] = definedClasses(sym, ctx.flattenPhase)
183
+
184
+ /** For currently compiled classes: All classes that are declared as members of this class
185
+ * (but not inherited ones). The empty list for classes that are not currently compiled.
186
+ */
187
+ private def getMemberClasses (sym : Symbol ): List [Symbol ] = definedClasses(sym, ctx.lambdaLiftPhase)
188
+
189
+ private def definedClasses (sym : Symbol , phase : Phase ) =
190
+ if (sym.isDefinedInCurrentRun)
191
+ ctx.atPhase(phase) {
192
+ toDenot(sym).info.decls.filter(_.isClass)
193
+ }
194
+ else Nil
178
195
179
196
private def buildNestedInfo (innerClassSym : Symbol ): Option [NestedInfo ] = {
180
197
assert(innerClassSym.isClass, s " Cannot build NestedInfo for non-class symbol $innerClassSym" )
0 commit comments