Skip to content

Commit

Permalink
Invalidate package's member cache when entering a toplevel definition
Browse files Browse the repository at this point in the history
Invalidate enclosing package's member cache when entering a toplevel definition in
a wrapper package object.
  • Loading branch information
odersky committed Dec 5, 2019
1 parent 7fc54b9 commit 99e116c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1726,11 +1726,16 @@ object SymDenotations {
}

/** Enter a symbol in given `scope` without potentially replacing the old copy. */
def enterNoReplace(sym: Symbol, scope: MutableScope)(implicit ctx: Context): Unit = {
def enterNoReplace(sym: Symbol, scope: MutableScope)(given Context): Unit =
scope.enter(sym)
if (myMemberCache != null) myMemberCache.invalidate(sym.name)
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
}
invalidateMemberCaches(sym)

def invalidateMemberCaches(sym: Symbol)(given Context): Unit =
if myMemberCache != null then myMemberCache.invalidate(sym.name)
else if !sym.flagsUNSAFE.is(Private) then
invalidateMemberNamesCache()
if sym.owner.isPackageObject then
sym.owner.owner.asClass.invalidateMemberCaches(sym)

/** Replace symbol `prev` (if defined in current class) by symbol `replacement`.
* If `prev` is not defined in current class, do nothing.
Expand Down Expand Up @@ -2123,6 +2128,7 @@ object SymDenotations {
if (pcls.isCompleting) recur(pobjs1, acc)
else {
val pmembers = pcls.computeNPMembersNamed(name).filterWithPredicate { d =>
// Drop members of `Any` and `Object`
val owner = d.symbol.maybeOwner
(owner ne defn.AnyClass) && (owner ne defn.ObjectClass)
}
Expand Down

0 comments on commit 99e116c

Please sign in to comment.