@@ -1239,8 +1239,8 @@ object SymDenotations {
1239
1239
private [this ] var baseTypeRefCache : java.util.HashMap [CachedType , Type ] = null
1240
1240
private [this ] var baseTypeRefValid : RunId = NoRunId
1241
1241
1242
- private var baseDataCache : BaseData = null
1243
- private var memberNamesCache : MemberNames = null
1242
+ private var baseDataCache : BaseData = BaseData . None
1243
+ private var memberNamesCache : MemberNames = MemberNames . None
1244
1244
1245
1245
private def memberCache (implicit ctx : Context ): LRUCache [Name , PreDenotation ] = {
1246
1246
if (myMemberCachePeriod != ctx.period) {
@@ -1250,31 +1250,21 @@ object SymDenotations {
1250
1250
myMemberCache
1251
1251
}
1252
1252
1253
- private def baseDataCacheValid (implicit ctx : Context ) =
1254
- baseDataCache != null && baseDataCache.isValid
1255
-
1256
- private def invalidateBaseDataCache () =
1257
- if (baseDataCache != null ) {
1258
- baseDataCache.invalidate()
1259
- baseDataCache = null
1260
- }
1261
-
1262
- private def memberNamesCacheValid (implicit ctx : Context ) =
1263
- memberNamesCache != null && memberNamesCache.isValid
1253
+ private def invalidateBaseDataCache () = {
1254
+ baseDataCache.invalidate()
1255
+ baseDataCache = BaseData .None
1256
+ }
1264
1257
1265
- private def invalidateMemberNamesCache () =
1266
- if (memberNamesCache != null ) {
1267
- memberNamesCache.invalidate()
1268
- memberNamesCache = null
1269
- }
1258
+ private def invalidateMemberNamesCache () = {
1259
+ memberNamesCache.invalidate()
1260
+ memberNamesCache = MemberNames .None
1261
+ }
1270
1262
1271
1263
override def copyCaches (from : SymDenotation , phase : Phase )(implicit ctx : Context ): this .type = {
1272
1264
from match {
1273
1265
case from : ClassDenotation =>
1274
- if (from.memberNamesCache != null && from.memberNamesCache.isValidAt(phase))
1275
- memberNamesCache = from.memberNamesCache
1276
- if (from.baseDataCache != null && from.baseDataCache.isValidAt(phase))
1277
- baseDataCache = from.baseDataCache
1266
+ if (from.memberNamesCache.isValidAt(phase)) memberNamesCache = from.memberNamesCache
1267
+ if (from.baseDataCache.isValidAt(phase)) baseDataCache = from.baseDataCache
1278
1268
case _ =>
1279
1269
}
1280
1270
this
@@ -1429,7 +1419,7 @@ object SymDenotations {
1429
1419
}
1430
1420
1431
1421
private def baseData (implicit onBehalf : BaseData , ctx : Context ): (List [ClassSymbol ], BaseClassSet ) = {
1432
- if (! baseDataCacheValid ) baseDataCache = BaseData ()
1422
+ if (! baseDataCache.isValid ) baseDataCache = BaseData .newCache ()
1433
1423
baseDataCache(this )
1434
1424
}
1435
1425
@@ -1771,7 +1761,7 @@ object SymDenotations {
1771
1761
if ((this is PackageClass ) || ! Config .cacheMemberNames)
1772
1762
computeMemberNames(keepOnly) // don't cache package member names; they might change
1773
1763
else {
1774
- if (! memberNamesCacheValid ) memberNamesCache = MemberNames ()
1764
+ if (! memberNamesCache.isValid ) memberNamesCache = MemberNames .newCache ()
1775
1765
memberNamesCache(keepOnly, this )
1776
1766
}
1777
1767
@@ -2071,7 +2061,7 @@ object SymDenotations {
2071
2061
implicit val None : MemberNames = new InvalidCache with MemberNames {
2072
2062
def apply (keepOnly : NameFilter , clsd : ClassDenotation )(implicit onBehalf : MemberNames , ctx : Context ) = ???
2073
2063
}
2074
- def apply ()(implicit ctx : Context ): MemberNames = new MemberNamesImpl (ctx.period)
2064
+ def newCache ()(implicit ctx : Context ): MemberNames = new MemberNamesImpl (ctx.period)
2075
2065
}
2076
2066
2077
2067
trait BaseData extends InheritedCache {
@@ -2085,7 +2075,7 @@ object SymDenotations {
2085
2075
def apply (clsd : ClassDenotation )(implicit onBehalf : BaseData , ctx : Context ) = ???
2086
2076
def signalProvisional () = ()
2087
2077
}
2088
- def apply ()(implicit ctx : Context ): BaseData = new BaseDataImpl (ctx.period)
2078
+ def newCache ()(implicit ctx : Context ): BaseData = new BaseDataImpl (ctx.period)
2089
2079
}
2090
2080
2091
2081
private abstract class InheritedCacheImpl (val createdAt : Period ) extends InheritedCache {
0 commit comments