@@ -1310,6 +1310,18 @@ object SymDenotations {
1310
1310
case _ => bt
1311
1311
}
1312
1312
1313
+ def inCache (tp : Type ) = baseTypeRefCache.containsKey(tp)
1314
+
1315
+ /** Can't cache types containing type variables which are uninstantiated
1316
+ * or whose instances can change, depending on typerstate.
1317
+ */
1318
+ def isCachable (tp : Type ): Boolean = tp match {
1319
+ case tp : TypeProxy => inCache(tp.underlying)
1320
+ case tp : AndOrType => inCache(tp.tp1) && inCache(tp.tp2)
1321
+ case tp : TypeVar => tp.inst.exists && inCache(tp.inst)
1322
+ case _ => true
1323
+ }
1324
+
1313
1325
def computeBaseTypeRefOf (tp : Type ): Type = {
1314
1326
Stats .record(" computeBaseTypeOf" )
1315
1327
if (symbol.isStatic && tp.derivesFrom(symbol))
@@ -1326,9 +1338,6 @@ object SymDenotations {
1326
1338
case _ =>
1327
1339
baseTypeRefOf(tp.underlying)
1328
1340
}
1329
- case tp : TypeVar =>
1330
- if (tp.inst.exists) computeBaseTypeRefOf(tp.inst)
1331
- else Uncachable (computeBaseTypeRefOf(tp.underlying))
1332
1341
case tp : TypeProxy =>
1333
1342
baseTypeRefOf(tp.underlying)
1334
1343
case AndType (tp1, tp2) =>
@@ -1349,14 +1358,9 @@ object SymDenotations {
1349
1358
var basetp = baseTypeRefCache get tp
1350
1359
if (basetp == null ) {
1351
1360
baseTypeRefCache.put(tp, NoPrefix )
1352
- basetp = computeBaseTypeRefOf(tp) match {
1353
- case Uncachable (basetp) =>
1354
- baseTypeRefCache.remove(tp)
1355
- basetp
1356
- case basetp =>
1357
- baseTypeRefCache.put(tp, basetp)
1358
- basetp
1359
- }
1361
+ basetp = computeBaseTypeRefOf(tp)
1362
+ if (isCachable(tp)) baseTypeRefCache.put(tp, basetp)
1363
+ else baseTypeRefCache.remove(tp)
1360
1364
} else if (basetp == NoPrefix ) {
1361
1365
throw CyclicReference (this )
1362
1366
}
@@ -1438,8 +1442,6 @@ object SymDenotations {
1438
1442
}
1439
1443
}
1440
1444
1441
- private case class Uncachable (tp : Type ) extends UncachedGroundType
1442
-
1443
1445
/** The denotation of a package class.
1444
1446
* It overrides ClassDenotation to take account of package objects when looking for members
1445
1447
*/
0 commit comments