@@ -1575,7 +1575,7 @@ object SymDenotations {
1575
1575
private var myMemberCachePeriod : Period = Nowhere
1576
1576
1577
1577
/** A cache from types T to baseType(T, C) */
1578
- type BaseTypeMap = java.util. IdentityHashMap [CachedType , Type ]
1578
+ type BaseTypeMap = EqHashMap [CachedType , Type ]
1579
1579
private var myBaseTypeCache : BaseTypeMap = null
1580
1580
private var myBaseTypeCachePeriod : Period = Nowhere
1581
1581
@@ -1592,7 +1592,7 @@ object SymDenotations {
1592
1592
1593
1593
private def baseTypeCache (using Context ): BaseTypeMap = {
1594
1594
if ! currentHasSameBaseTypesAs(myBaseTypeCachePeriod) then
1595
- myBaseTypeCache = new BaseTypeMap
1595
+ myBaseTypeCache = BaseTypeMap ()
1596
1596
myBaseTypeCachePeriod = ctx.period
1597
1597
myBaseTypeCache
1598
1598
}
@@ -1906,14 +1906,16 @@ object SymDenotations {
1906
1906
/** Compute tp.baseType(this) */
1907
1907
final def baseTypeOf (tp : Type )(using Context ): Type = {
1908
1908
val btrCache = baseTypeCache
1909
- def inCache (tp : Type ) = btrCache.get(tp) != null
1909
+ def inCache (tp : Type ) = tp match
1910
+ case tp : CachedType => btrCache.contains(tp)
1911
+ case _ => false
1910
1912
def record (tp : CachedType , baseTp : Type ) = {
1911
1913
if (Stats .monitored) {
1912
1914
Stats .record(" basetype cache entries" )
1913
1915
if (! baseTp.exists) Stats .record(" basetype cache NoTypes" )
1914
1916
}
1915
1917
if (! tp.isProvisional)
1916
- btrCache.put (tp, baseTp)
1918
+ btrCache(tp) = baseTp
1917
1919
else
1918
1920
btrCache.remove(tp) // Remove any potential sentinel value
1919
1921
}
@@ -1926,7 +1928,7 @@ object SymDenotations {
1926
1928
def recur (tp : Type ): Type = try {
1927
1929
tp match {
1928
1930
case tp : CachedType =>
1929
- val baseTp = btrCache.get (tp)
1931
+ val baseTp = btrCache.lookup (tp)
1930
1932
if (baseTp != null ) return ensureAcyclic(baseTp)
1931
1933
case _ =>
1932
1934
}
@@ -1945,7 +1947,7 @@ object SymDenotations {
1945
1947
}
1946
1948
1947
1949
def computeTypeRef = {
1948
- btrCache.put (tp, NoPrefix )
1950
+ btrCache(tp) = NoPrefix
1949
1951
val tpSym = tp.symbol
1950
1952
tpSym.denot match {
1951
1953
case clsd : ClassDenotation =>
@@ -1980,7 +1982,7 @@ object SymDenotations {
1980
1982
1981
1983
case tp @ AppliedType (tycon, args) =>
1982
1984
def computeApplied = {
1983
- btrCache.put (tp, NoPrefix )
1985
+ btrCache(tp) = NoPrefix
1984
1986
val baseTp =
1985
1987
if (tycon.typeSymbol eq symbol) tp
1986
1988
else (tycon.typeParams: @ unchecked) match {
@@ -2041,7 +2043,9 @@ object SymDenotations {
2041
2043
}
2042
2044
catch {
2043
2045
case ex : Throwable =>
2044
- btrCache.remove(tp)
2046
+ tp match
2047
+ case tp : CachedType => btrCache.remove(tp)
2048
+ case _ =>
2045
2049
throw ex
2046
2050
}
2047
2051
0 commit comments