@@ -28,6 +28,7 @@ import dotty.tools.dotc.util.{Positions, DotClass}
28
28
import Decorators ._
29
29
import tpd ._
30
30
import StdNames .nme
31
+ import NameOps ._
31
32
32
33
class DottyBackendInterface ()(implicit ctx : Context ) extends BackendInterface {
33
34
trait NonExistentTree extends tpd.Tree
@@ -382,7 +383,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
382
383
def toTypeName : Name = n.toTypeName
383
384
def isTypeName : Boolean = n.isTypeName
384
385
def toTermName : Name = n.toTermName
385
- def dropModule : Name = ???
386
+ def dropModule : Name = n.stripModuleClassSuffix
386
387
387
388
def len : Int = n.length
388
389
def offset : Int = n.start
@@ -409,7 +410,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
409
410
410
411
// tests
411
412
def isClass : Boolean = {
412
- sym.isClass && (sym. isPackageObject || ! (sym is Flags . Package ) )
413
+ sym.isPackageObject || (sym.isClass )
413
414
}
414
415
def isType : Boolean = sym.isType
415
416
def isAnonymousClass : Boolean = toDenot(sym).isAnonymousClass
@@ -475,16 +476,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
475
476
476
477
// navigation
477
478
def owner : Symbol = toDenot(sym).owner
478
- def rawowner : Symbol = owner
479
+ def rawowner : Symbol = {
480
+ originalOwner
481
+ }
479
482
def originalOwner : Symbol = {
480
483
try {
481
484
if (sym.exists) {
482
485
val original = toDenot(sym).initial
483
486
val validity = original.validFor
484
487
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
488
490
} else NoSymbol
489
491
} catch {
490
492
case e : NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
@@ -511,14 +513,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
511
513
def companionModule : Symbol = toDenot(sym).companionModule
512
514
def companionSymbol : Symbol = if (sym is Flags .Module ) companionClass else companionModule
513
515
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
515
523
516
524
517
525
518
526
// members
519
527
def primaryConstructor : Symbol = toDenot(sym).primaryConstructor
520
528
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
522
530
def annotations : List [Annotation ] = Nil
523
531
def companionModuleMembers : List [Symbol ] = {
524
532
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
0 commit comments