@@ -1623,6 +1623,13 @@ object SymDenotations {
1623
1623
final def baseTypeOf (tp : Type )(implicit ctx : Context ): Type = {
1624
1624
val btrCache = baseTypeCache
1625
1625
def inCache (tp : Type ) = btrCache.get(tp) != null
1626
+ def record (tp : CachedType , baseTp : Type ) = {
1627
+ if (Stats .monitored) {
1628
+ Stats .record(" basetype cache entries" )
1629
+ if (! baseTp.exists) Stats .record(" basetype cache NoTypes" )
1630
+ }
1631
+ btrCache.put(tp, baseTp)
1632
+ }
1626
1633
1627
1634
def ensureAcyclic (baseTp : Type ) = {
1628
1635
if (baseTp `eq` NoPrefix ) throw CyclicReference (this )
@@ -1667,13 +1674,13 @@ object SymDenotations {
1667
1674
else NoType
1668
1675
else
1669
1676
recur(clsd.typeRef).asSeenFrom(prefix, clsd.owner)
1670
- if (baseTp.exists) btrCache.put (tp, baseTp) else btrCache.remove(tp)
1677
+ if (baseTp.exists) record (tp, baseTp) else btrCache.remove(tp)
1671
1678
baseTp
1672
1679
case _ =>
1673
1680
val superTp = tp.superType
1674
1681
val baseTp = recur(superTp)
1675
1682
if (baseTp.exists && inCache(superTp) && tp.symbol.maybeOwner.isType)
1676
- btrCache.put (tp, baseTp) // typeref cannot be a GADT, so cache is stable
1683
+ record (tp, baseTp) // typeref cannot be a GADT, so cache is stable
1677
1684
else
1678
1685
btrCache.remove(tp)
1679
1686
baseTp
@@ -1693,7 +1700,7 @@ object SymDenotations {
1693
1700
case tparams : List [Symbol @ unchecked] =>
1694
1701
recur(tycon).subst(tparams, args)
1695
1702
}
1696
- if (baseTp.exists) btrCache.put (tp, baseTp) else btrCache.remove(tp)
1703
+ if (baseTp.exists) record (tp, baseTp) else btrCache.remove(tp)
1697
1704
baseTp
1698
1705
}
1699
1706
computeApplied
@@ -1709,7 +1716,7 @@ object SymDenotations {
1709
1716
case tp : CachedType if baseTp.exists && inCache(superTp) =>
1710
1717
// Note: This also works for TypeVars: If they are not instantiated, their supertype
1711
1718
// is a TypeParamRef, which is never cached. So uninstantiated TypeVars are not cached either.
1712
- btrCache.put (tp, baseTp)
1719
+ record (tp, baseTp)
1713
1720
case _ =>
1714
1721
}
1715
1722
baseTp
@@ -1734,7 +1741,7 @@ object SymDenotations {
1734
1741
case _ => combined
1735
1742
}
1736
1743
}
1737
- if (baseTp.exists && inCache(tp1) && inCache(tp2)) btrCache.put (tp, baseTp)
1744
+ if (baseTp.exists && inCache(tp1) && inCache(tp2)) record (tp, baseTp)
1738
1745
baseTp
1739
1746
}
1740
1747
computeAndOrType
0 commit comments