Skip to content

Fix/#536 nested classes #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,24 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{

// members
def primaryConstructor: Symbol = toDenot(sym).primaryConstructor
def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList

/** For currently compiled classes: All locally defined classes including local classes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between a "locally defined class" and a "local class"? Also what about using the description "classes defined in the current symbol scope" or something like that?

* The empty list for classes that are not currently compiled.
*/
def nestedClasses: List[Symbol] = definedClasses(ctx.flattenPhase)

/** For currently compiled classes: All classes that are declared as members of this class
* (but not inherited ones). The empty list for classes that are not currently compiled.
*/
def memberClasses: List[Symbol] = definedClasses(ctx.lambdaLiftPhase)

private def definedClasses(phase: Phase) =
if (sym.isDefinedInCurrentRun)
ctx.atPhase(phase) { implicit ctx =>
toDenot(sym).info.decls.filter(_.isClass).toList
}
else Nil

def annotations: List[Annotation] = Nil
def companionModuleMembers: List[Symbol] = {
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
Expand Down
2 changes: 2 additions & 0 deletions src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ object Phases {
private val extensionMethodsCache = new PhaseCache(classOf[ExtensionMethods])
private val erasureCache = new PhaseCache(classOf[Erasure])
private val patmatCache = new PhaseCache(classOf[PatternMatcher])
private val lambdaLiftCache = new PhaseCache(classOf[LambdaLift])
private val flattenCache = new PhaseCache(classOf[Flatten])
private val explicitOuterCache = new PhaseCache(classOf[ExplicitOuter])
private val gettersCache = new PhaseCache(classOf[Getters])
Expand All @@ -245,6 +246,7 @@ object Phases {
def extensionMethodsPhase = extensionMethodsCache.phase
def erasurePhase = erasureCache.phase
def patmatPhase = patmatCache.phase
def lambdaLiftPhase = lambdaLiftCache.phase
def flattenPhase = flattenCache.phase
def explicitOuterPhase = explicitOuterCache.phase
def gettersPhase = gettersCache.phase
Expand Down
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ object Symbols {
}

/** Subclass tests and casts */
final def isTerm(implicit ctx: Context): Boolean = denot.isTerm
final def isType(implicit ctx: Context): Boolean = denot.isType
final def isTerm(implicit ctx: Context): Boolean = lastDenot.isTerm
final def isType(implicit ctx: Context): Boolean = lastDenot.isType
final def isClass: Boolean = isInstanceOf[ClassSymbol]

final def asTerm(implicit ctx: Context): TermSymbol = { assert(isTerm, s"asTerm called on not-a-Term $this" ); asInstanceOf[TermSymbol] }
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i536.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Max {
java.util.Collections.max(null)
}