Skip to content

Commit a6f4b55

Browse files
committed
Emit inner classes table.
1 parent 8cf176a commit a6f4b55

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import dotty.tools.dotc.util.{Positions, DotClass}
2828
import Decorators._
2929
import tpd._
3030
import StdNames.nme
31+
import NameOps._
3132

3233
class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
3334
trait NonExistentTree extends tpd.Tree
@@ -382,7 +383,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
382383
def toTypeName: Name = n.toTypeName
383384
def isTypeName: Boolean = n.isTypeName
384385
def toTermName: Name = n.toTermName
385-
def dropModule: Name = ???
386+
def dropModule: Name = n.stripModuleClassSuffix
386387

387388
def len: Int = n.length
388389
def offset: Int = n.start
@@ -409,7 +410,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
409410

410411
// tests
411412
def isClass: Boolean = {
412-
sym.isClass && (sym.isPackageObject || !(sym is Flags.Package))
413+
sym.isPackageObject || (sym.isClass)
413414
}
414415
def isType: Boolean = sym.isType
415416
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
@@ -474,16 +475,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
474475

475476
// navigation
476477
def owner: Symbol = toDenot(sym).owner
477-
def rawowner: Symbol = owner
478+
def rawowner: Symbol = {
479+
originalOwner
480+
}
478481
def originalOwner: Symbol = {
479482
try {
480483
if (sym.exists) {
481484
val original = toDenot(sym).initial
482485
val validity = original.validFor
483486
val shiftedContext = ctx.withPhase(validity.phaseId)
484487
val r = toDenot(sym)(shiftedContext).maybeOwner
485-
if(r is Flags.Package) NoSymbol
486-
else r
488+
r
487489
} else NoSymbol
488490
} catch {
489491
case e: NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
@@ -510,14 +512,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
510512
def companionModule: Symbol = toDenot(sym).companionModule
511513
def companionSymbol: Symbol = if (sym is Flags.Module) companionClass else companionModule
512514
def moduleClass: Symbol = toDenot(sym).moduleClass
513-
def enclosingClassSym: Symbol = enclClass //todo is handled specially for JavaDefined symbols in scalac
515+
def enclosingClassSym: Symbol = {
516+
if(this.isClass) {
517+
val ct = ctx.withPhase(ctx.flattenPhase.prev)
518+
toDenot(sym)(ct).owner.enclosingClass(ct)
519+
}
520+
else sym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev))
521+
} //todo is handled specially for JavaDefined symbols in scalac
514522

515523

516524

517525
// members
518526
def primaryConstructor: Symbol = toDenot(sym).primaryConstructor
519527
def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
520-
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList
528+
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses(ctx.withPhase(ctx.flattenPhase.prev)).map(_.symbol).toList
521529
def annotations: List[Annotation] = Nil
522530
def companionModuleMembers: List[Symbol] = {
523531
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,

0 commit comments

Comments
 (0)