@@ -625,6 +625,10 @@ object SymDenotations {
625625 def isPackageObject (implicit ctx : Context ): Boolean =
626626 name.isPackageObjectName && owner.is(Package ) && this .is(Module )
627627
628+ /** Is this symbol a toplevel definition in a package object? */
629+ def isWrappedToplevelDef (given Context ): Boolean =
630+ ! isConstructor && owner.isPackageObject
631+
628632 /** Is this symbol an abstract type? */
629633 final def isAbstractType (implicit ctx : Context ): Boolean = this .is(DeferredType )
630634
@@ -1527,6 +1531,14 @@ object SymDenotations {
15271531 myBaseTypeCachePeriod = Nowhere
15281532 }
15291533
1534+ def invalidateMemberCaches (sym : Symbol )(given Context ): Unit =
1535+ if myMemberCache != null then myMemberCache.invalidate(sym.name)
1536+ if ! sym.flagsUNSAFE.is(Private ) then
1537+ invalidateMemberNamesCache()
1538+ if sym.isWrappedToplevelDef then
1539+ val outerCache = sym.owner.owner.asClass.classDenot.myMemberCache
1540+ if outerCache != null then outerCache.invalidate(sym.name)
1541+
15301542 override def copyCaches (from : SymDenotation , phase : Phase )(implicit ctx : Context ): this .type = {
15311543 from match {
15321544 case from : ClassDenotation =>
@@ -1726,11 +1738,9 @@ object SymDenotations {
17261738 }
17271739
17281740 /** Enter a symbol in given `scope` without potentially replacing the old copy. */
1729- def enterNoReplace (sym : Symbol , scope : MutableScope )(implicit ctx : Context ): Unit = {
1741+ def enterNoReplace (sym : Symbol , scope : MutableScope )(given Context ): Unit =
17301742 scope.enter(sym)
1731- if (myMemberCache != null ) myMemberCache.invalidate(sym.name)
1732- if (! sym.flagsUNSAFE.is(Private )) invalidateMemberNamesCache()
1733- }
1743+ invalidateMemberCaches(sym)
17341744
17351745 /** Replace symbol `prev` (if defined in current class) by symbol `replacement`.
17361746 * If `prev` is not defined in current class, do nothing.
@@ -2123,6 +2133,7 @@ object SymDenotations {
21232133 if (pcls.isCompleting) recur(pobjs1, acc)
21242134 else {
21252135 val pmembers = pcls.computeNPMembersNamed(name).filterWithPredicate { d =>
2136+ // Drop members of `Any` and `Object`
21262137 val owner = d.symbol.maybeOwner
21272138 (owner ne defn.AnyClass ) && (owner ne defn.ObjectClass )
21282139 }
@@ -2140,7 +2151,7 @@ object SymDenotations {
21402151 val compiledNow = d.filterWithPredicate(d =>
21412152 d.symbol.isDefinedInCurrentRun || d.symbol.associatedFile == null
21422153 // if a symbol does not have an associated file, assume it is defined
2143- // in the current run anyway. This typically happens for pickling and
2154+ // in the current run anyway. This is true for packages, and also can happen for pickling and
21442155 // from-tasty tests that generate a fresh symbol and then re-use it in the next run.
21452156 )
21462157 if compiledNow.exists then compiledNow
0 commit comments