@@ -390,7 +390,9 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
390
390
def thisType : Type = toDenot(sym).thisType
391
391
392
392
// tests
393
- def isClass : Boolean = sym.isClass
393
+ def isClass : Boolean = {
394
+ sym.isClass && (sym.isPackageObject || ! (sym is Flags .Package ))
395
+ }
394
396
def isType : Boolean = sym.isType
395
397
def isAnonymousClass : Boolean = toDenot(sym).isAnonymousClass
396
398
def isConstructor : Boolean = toDenot(sym).isConstructor
@@ -414,7 +416,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
414
416
def isDeferred : Boolean = sym is Flags .Deferred
415
417
def isPrivate : Boolean = sym is Flags .Private
416
418
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 )
418
420
419
421
def getsJavaPrivateFlag : Boolean =
420
422
isPrivate // || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass)
@@ -438,7 +440,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
438
440
(sym is Flags .Module ) && ! (sym is Flags .ImplClass ) // / !sym.isNestedClass
439
441
def isJavaEntryPoint : Boolean = CollectEntryPoints .isJavaEntyPoint(sym)
440
442
441
- def isClassConstructor : Boolean = sym.name == nme. CONSTRUCTOR
443
+ def isClassConstructor : Boolean = toDenot( sym).isClassConstructor
442
444
443
445
/**
444
446
* 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{
454
456
def rawowner : Symbol = owner
455
457
def originalOwner : Symbol = {
456
458
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
461
467
} catch {
462
468
case e : NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
463
469
}
0 commit comments