aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-10 11:50:01 +0200
committerMartin Odersky <odersky@gmail.com>2014-07-17 11:02:01 +0200
commit7b13a861787eb1e7823957b156dbb989f7b415d3 (patch)
treefa4846e18c0ce0180c05e498eb7462e83ad869d7 /src/dotty/tools/dotc/core/SymDenotations.scala
parent8d41e9dcee916e2fa4c7f096eb491d38e1185c1c (diff)
downloaddotty-7b13a861787eb1e7823957b156dbb989f7b415d3.tar.gz
dotty-7b13a861787eb1e7823957b156dbb989f7b415d3.tar.bz2
dotty-7b13a861787eb1e7823957b156dbb989f7b415d3.zip
Invalidate member caches in different periods
A membercache is not valid in a period different from the one it was created in. Reason: The denotations stored in the cache might have different infos in different periods. Also: add maybeOwner convenience method for printing, which handles NoDenotation/NoSymbol gracefully.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 7d1948784..b0a09baf0 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -83,6 +83,9 @@ object SymDenotations {
/** The owner of the symbol; overridden in NoDenotation */
def owner: Symbol = ownerIfExists
+ /** Same as owner, except returns NoSymbol for NoSymbol */
+ def maybeOwner: Symbol = if (exists) owner else NoSymbol
+
/** The flag set */
final def flags(implicit ctx: Context): FlagSet = { ensureCompleted(); myFlags }
@@ -987,6 +990,7 @@ object SymDenotations {
mySuperClassBits = null
myMemberFingerPrint = FingerPrint.unknown
myMemberCache = null
+ myMemberCachePeriod = Nowhere
memberNamesCache = SimpleMap.Empty
}
@@ -1121,9 +1125,13 @@ object SymDenotations {
}
private[this] var myMemberCache: LRUCache[Name, PreDenotation] = null
+ private[this] var myMemberCachePeriod: Period = Nowhere
- private def memberCache: LRUCache[Name, PreDenotation] = {
- if (myMemberCache == null) myMemberCache = new LRUCache
+ private def memberCache(implicit ctx: Context): LRUCache[Name, PreDenotation] = {
+ if (myMemberCachePeriod != ctx.period) {
+ myMemberCache = new LRUCache
+ myMemberCachePeriod = ctx.period
+ }
myMemberCache
}