@@ -1214,6 +1214,10 @@ trait Types
1214
1214
1215
1215
private [reflect] var underlyingCache : Type = NoType
1216
1216
private [reflect] var underlyingPeriod = NoPeriod
1217
+ private [Types ] def invalidateSingleTypeCaches (): Unit = {
1218
+ underlyingCache = NoType
1219
+ underlyingPeriod = NoPeriod
1220
+ }
1217
1221
override def underlying : Type = {
1218
1222
val cache = underlyingCache
1219
1223
if (underlyingPeriod == currentPeriod && cache != null ) cache
@@ -1354,6 +1358,12 @@ trait Types
1354
1358
private [reflect] var baseTypeSeqPeriod = NoPeriod
1355
1359
private [reflect] var baseClassesCache : List [Symbol ] = _
1356
1360
private [reflect] var baseClassesPeriod = NoPeriod
1361
+ private [Types ] def invalidatedCompoundTypeCaches () {
1362
+ baseTypeSeqCache = null
1363
+ baseTypeSeqPeriod = NoPeriod
1364
+ baseClassesCache = null
1365
+ baseClassesPeriod = NoPeriod
1366
+ }
1357
1367
1358
1368
override def baseTypeSeq : BaseTypeSeq = {
1359
1369
val cached = baseTypeSeqCache
@@ -1912,6 +1922,9 @@ trait Types
1912
1922
1913
1923
narrowedCache
1914
1924
}
1925
+ private [Types ] def invalidateModuleTypeRefCaches (): Unit = {
1926
+ narrowedCache = null
1927
+ }
1915
1928
override protected def finishPrefix (rest : String ) = objectPrefix + rest
1916
1929
override def directObjectString = super .safeToString
1917
1930
override def toLongString = toString
@@ -1989,8 +2002,12 @@ trait Types
1989
2002
* several times. Hence, no need to protected with synchronized in a multi-threaded
1990
2003
* usage scenario.
1991
2004
*/
1992
- private [Types ] var relativeInfoCache : Type = _
1993
- private [Types ] var relativeInfoPeriod : Period = NoPeriod
2005
+ private var relativeInfoCache : Type = _
2006
+ private var relativeInfoPeriod : Period = NoPeriod
2007
+ private [Types ] def invalidateNonClassTypeRefCaches (): Unit = {
2008
+ relativeInfoCache = NoType
2009
+ relativeInfoPeriod = NoPeriod
2010
+ }
1994
2011
1995
2012
private [Types ] def relativeInfo = /* trace(s"relativeInfo(${safeToString}})")*/ {
1996
2013
if (relativeInfoPeriod != currentPeriod) {
@@ -2123,6 +2140,10 @@ trait Types
2123
2140
}
2124
2141
thisInfoCache
2125
2142
}
2143
+ private [Types ] def invalidateAbstractTypeRefCaches (): Unit = {
2144
+ symInfoCache = null
2145
+ thisInfoCache = null
2146
+ }
2126
2147
override def bounds = thisInfo.bounds
2127
2148
override protected [Types ] def baseTypeSeqImpl : BaseTypeSeq = transform(bounds.hi).baseTypeSeq prepend this
2128
2149
override def kind = " AbstractTypeRef"
@@ -2142,9 +2163,12 @@ trait Types
2142
2163
trivial = fromBoolean(! sym.isTypeParameter && pre.isTrivial && areTrivialTypes(args))
2143
2164
toBoolean(trivial)
2144
2165
}
2145
- private [scala] def invalidateCaches (): Unit = {
2166
+ private [Types ] def invalidateTypeRefCaches (): Unit = {
2167
+ parentsCache = null
2146
2168
parentsPeriod = NoPeriod
2169
+ baseTypeSeqCache = null
2147
2170
baseTypeSeqPeriod = NoPeriod
2171
+ normalized = null
2148
2172
}
2149
2173
private [reflect] var parentsCache : List [Type ] = _
2150
2174
private [reflect] var parentsPeriod = NoPeriod
@@ -4575,14 +4599,31 @@ trait Types
4575
4599
invalidateCaches(tp, updatedSyms)
4576
4600
}
4577
4601
4578
- def invalidateCaches (t : Type , updatedSyms : List [Symbol ]) = t match {
4579
- case st : SingleType if updatedSyms.contains(st.sym) =>
4580
- st.underlyingCache = NoType
4581
- st.underlyingPeriod = NoPeriod
4582
- case tr : NonClassTypeRef if updatedSyms.contains(tr.sym) =>
4583
- tr.relativeInfoCache = NoType
4584
- tr.relativeInfoPeriod = NoPeriod
4585
- case _ =>
4602
+ def invalidateCaches (t : Type , updatedSyms : List [Symbol ]) = {
4603
+ t match {
4604
+ case st : SingleType if updatedSyms.contains(st.sym) => st.invalidateSingleTypeCaches()
4605
+ case _ =>
4606
+ }
4607
+ t match {
4608
+ case tr : NonClassTypeRef if updatedSyms.contains(tr.sym) => tr.invalidateNonClassTypeRefCaches()
4609
+ case _ =>
4610
+ }
4611
+ t match {
4612
+ case tr : AbstractTypeRef if updatedSyms.contains(tr.sym) => tr.invalidateAbstractTypeRefCaches()
4613
+ case _ =>
4614
+ }
4615
+ t match {
4616
+ case tr : TypeRef if updatedSyms.contains(tr.sym) => tr.invalidateTypeRefCaches()
4617
+ case _ =>
4618
+ }
4619
+ t match {
4620
+ case tr : ModuleTypeRef if updatedSyms.contains(tr.sym) => tr.invalidateModuleTypeRefCaches()
4621
+ case _ =>
4622
+ }
4623
+ t match {
4624
+ case ct : CompoundType if ct.baseClasses.exists(updatedSyms.contains) => ct.invalidatedCompoundTypeCaches()
4625
+ case _ =>
4626
+ }
4586
4627
}
4587
4628
4588
4629
val shorthands = Set (
0 commit comments