@@ -625,6 +625,10 @@ object SymDenotations {
625
625
def isPackageObject (implicit ctx : Context ): Boolean =
626
626
name.isPackageObjectName && owner.is(Package ) && this .is(Module )
627
627
628
+ /** Is this symbol a toplevel definition in a package object? */
629
+ def isWrappedToplevelDef (given Context ): Boolean =
630
+ ! isConstructor && owner.isPackageObject
631
+
628
632
/** Is this symbol an abstract type? */
629
633
final def isAbstractType (implicit ctx : Context ): Boolean = this .is(DeferredType )
630
634
@@ -1527,6 +1531,14 @@ object SymDenotations {
1527
1531
myBaseTypeCachePeriod = Nowhere
1528
1532
}
1529
1533
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
+
1530
1542
override def copyCaches (from : SymDenotation , phase : Phase )(implicit ctx : Context ): this .type = {
1531
1543
from match {
1532
1544
case from : ClassDenotation =>
@@ -1726,11 +1738,9 @@ object SymDenotations {
1726
1738
}
1727
1739
1728
1740
/** 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 =
1730
1742
scope.enter(sym)
1731
- if (myMemberCache != null ) myMemberCache.invalidate(sym.name)
1732
- if (! sym.flagsUNSAFE.is(Private )) invalidateMemberNamesCache()
1733
- }
1743
+ invalidateMemberCaches(sym)
1734
1744
1735
1745
/** Replace symbol `prev` (if defined in current class) by symbol `replacement`.
1736
1746
* If `prev` is not defined in current class, do nothing.
@@ -2123,6 +2133,7 @@ object SymDenotations {
2123
2133
if (pcls.isCompleting) recur(pobjs1, acc)
2124
2134
else {
2125
2135
val pmembers = pcls.computeNPMembersNamed(name).filterWithPredicate { d =>
2136
+ // Drop members of `Any` and `Object`
2126
2137
val owner = d.symbol.maybeOwner
2127
2138
(owner ne defn.AnyClass ) && (owner ne defn.ObjectClass )
2128
2139
}
@@ -2140,7 +2151,7 @@ object SymDenotations {
2140
2151
val compiledNow = d.filterWithPredicate(d =>
2141
2152
d.symbol.isDefinedInCurrentRun || d.symbol.associatedFile == null
2142
2153
// 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
2144
2155
// from-tasty tests that generate a fresh symbol and then re-use it in the next run.
2145
2156
)
2146
2157
if compiledNow.exists then compiledNow
0 commit comments