@@ -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
@@ -474,16 +475,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
474
475
475
476
// navigation
476
477
def owner : Symbol = toDenot(sym).owner
477
- def rawowner : Symbol = owner
478
+ def rawowner : Symbol = {
479
+ originalOwner
480
+ }
478
481
def originalOwner : Symbol = {
479
482
try {
480
483
if (sym.exists) {
481
484
val original = toDenot(sym).initial
482
485
val validity = original.validFor
483
486
val shiftedContext = ctx.withPhase(validity.phaseId)
484
487
val r = toDenot(sym)(shiftedContext).maybeOwner
485
- if (r is Flags .Package ) NoSymbol
486
- else r
488
+ r
487
489
} else NoSymbol
488
490
} catch {
489
491
case e : NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
@@ -510,14 +512,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
510
512
def companionModule : Symbol = toDenot(sym).companionModule
511
513
def companionSymbol : Symbol = if (sym is Flags .Module ) companionClass else companionModule
512
514
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
514
522
515
523
516
524
517
525
// members
518
526
def primaryConstructor : Symbol = toDenot(sym).primaryConstructor
519
527
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
521
529
def annotations : List [Annotation ] = Nil
522
530
def companionModuleMembers : List [Symbol ] = {
523
531
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
0 commit comments