Skip to content

Commit 7a6fcc1

Browse files
committed
Mimic scalac originalOwner.
1 parent 33a39ef commit 7a6fcc1

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
390390
def thisType: Type = toDenot(sym).thisType
391391

392392
// tests
393-
def isClass: Boolean = sym.isClass
393+
def isClass: Boolean = {
394+
sym.isClass && (sym.isPackageObject || !(sym is Flags.Package))
395+
}
394396
def isType: Boolean = sym.isType
395397
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
396398
def isConstructor: Boolean = toDenot(sym).isConstructor
@@ -414,7 +416,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
414416
def isDeferred: Boolean = sym is Flags.Deferred
415417
def isPrivate: Boolean = sym is Flags.Private
416418
def getsJavaFinalFlag: Boolean =
417-
isFinal && !sym.isClassConstructor && !(sym is Flags.Mutable) && !(sym.enclosingClass is Flags.JavaInterface)
419+
isFinal && !toDenot(sym).isClassConstructor && !(sym is Flags.Mutable) && !(sym.enclosingClass is Flags.JavaInterface)
418420

419421
def getsJavaPrivateFlag: Boolean =
420422
isPrivate //|| (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass)
@@ -438,7 +440,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
438440
(sym is Flags.Module) && !(sym is Flags.ImplClass) /// !sym.isNestedClass
439441
def isJavaEntryPoint: Boolean = CollectEntryPoints.isJavaEntyPoint(sym)
440442

441-
def isClassConstructor: Boolean = sym.name == nme.CONSTRUCTOR
443+
def isClassConstructor: Boolean = toDenot(sym).isClassConstructor
442444

443445
/**
444446
* True for module classes of modules that are top-level or owned only by objects. Module classes
@@ -454,10 +456,14 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
454456
def rawowner: Symbol = owner
455457
def originalOwner: Symbol = {
456458
try {
457-
val original = toDenot(sym).initial
458-
val validity = original.validFor
459-
val shiftedContext = ctx.withPhase(validity.phaseId)
460-
toDenot(sym)(shiftedContext).maybeOwner
459+
if (sym.exists) {
460+
val original = toDenot(sym).initial
461+
val validity = original.validFor
462+
val shiftedContext = ctx.withPhase(validity.phaseId)
463+
val r = toDenot(sym)(shiftedContext).maybeOwner
464+
if(r is Flags.Package) NoSymbol
465+
else r
466+
} else NoSymbol
461467
} catch {
462468
case e: NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
463469
}

0 commit comments

Comments
 (0)