@@ -28,6 +28,7 @@ import dotty.tools.dotc.util.{Positions, DotClass}
2828import Decorators ._
2929import tpd ._
3030import StdNames .nme
31+ import NameOps ._
3132
3233class 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
@@ -475,16 +476,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
475476
476477 // navigation
477478 def owner : Symbol = toDenot(sym).owner
478- def rawowner : Symbol = owner
479+ def rawowner : Symbol = {
480+ originalOwner
481+ }
479482 def originalOwner : Symbol = {
480483 try {
481484 if (sym.exists) {
482485 val original = toDenot(sym).initial
483486 val validity = original.validFor
484487 val shiftedContext = ctx.withPhase(validity.phaseId)
485- val r = toDenot(sym)(shiftedContext).maybeOwner
486- if (r is Flags .Package ) NoSymbol
487- else r
488+ val r = toDenot(sym)(shiftedContext).maybeOwner.enclosingClass(shiftedContext)
489+ r
488490 } else NoSymbol
489491 } catch {
490492 case e : NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
@@ -511,14 +513,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
511513 def companionModule : Symbol = toDenot(sym).companionModule
512514 def companionSymbol : Symbol = if (sym is Flags .Module ) companionClass else companionModule
513515 def moduleClass : Symbol = toDenot(sym).moduleClass
514- def enclosingClassSym : Symbol = enclClass // todo is handled specially for JavaDefined symbols in scalac
516+ def enclosingClassSym : Symbol = {
517+ if (this .isClass) {
518+ val ct = ctx.withPhase(ctx.flattenPhase.prev)
519+ toDenot(sym)(ct).owner.enclosingClass(ct)
520+ }
521+ else sym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev))
522+ } // todo is handled specially for JavaDefined symbols in scalac
515523
516524
517525
518526 // members
519527 def primaryConstructor : Symbol = toDenot(sym).primaryConstructor
520528 def nestedClasses : List [Symbol ] = memberClasses // exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
521- def memberClasses : List [Symbol ] = toDenot(sym).info.memberClasses.map(_.symbol).toList
529+ def memberClasses : List [Symbol ] = toDenot(sym).info.memberClasses(ctx.withPhase(ctx.flattenPhase.prev)) .map(_.symbol).toList
522530 def annotations : List [Annotation ] = Nil
523531 def companionModuleMembers : List [Symbol ] = {
524532 // phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
0 commit comments