@@ -1636,15 +1636,16 @@ object SymDenotations {
16361636 * cache ErasedValueType at all.
16371637 */
16381638 def isCachable (tp : Type , btrCache : BaseTypeMap ): Boolean = {
1639- def inCache (tp : Type ) = btrCache.containsKey(tp)
1639+ def inCache (tp : Type ) = btrCache.containsKey(tp) && isCachable(tp, btrCache)
16401640 tp match {
1641- case _ : TypeErasure .ErasedValueType => false
16421641 case tp : TypeRef if tp.symbol.isClass => true
16431642 case tp : TypeVar => tp.inst.exists && inCache(tp.inst)
1643+ case tp : TypeParamRef if ctx.typerState.constraint.contains(tp) => false
16441644 // case tp: TypeProxy => inCache(tp.underlying) // disabled, can re-enable insyead of last two lines for performance testing
16451645 case tp : TypeProxy => isCachable(tp.underlying, btrCache)
16461646 case tp : AndType => isCachable(tp.tp1, btrCache) && isCachable(tp.tp2, btrCache)
16471647 case tp : OrType => isCachable(tp.tp1, btrCache) && isCachable(tp.tp2, btrCache)
1648+ case _ : TypeErasure .ErasedValueType => false
16481649 case _ => true
16491650 }
16501651 }
@@ -1685,6 +1686,8 @@ object SymDenotations {
16851686 case tparams : List [Symbol @ unchecked] =>
16861687 baseTypeOf(tycon).subst(tparams, args)
16871688 }
1689+ case tp : TypeParamRef =>
1690+ baseTypeOf(ctx.typeComparer.bounds(tp).hi)
16881691 case tp : TypeProxy =>
16891692 baseTypeOf(tp.superType)
16901693 case AndType (tp1, tp2) =>
@@ -1709,19 +1712,24 @@ object SymDenotations {
17091712 tp.stripTypeVar match {
17101713 case tp : CachedType =>
17111714 val btrCache = baseTypeCache
1715+ if (! isCachable(tp, btrCache))
1716+ computeBaseTypeOf(tp)
1717+ else
17121718 try {
1713- var basetp = btrCache get tp
1719+ var basetp = btrCache. get(tp)
17141720 if (basetp == null ) {
17151721 btrCache.put(tp, NoPrefix )
17161722 basetp = computeBaseTypeOf(tp)
1717- if (! basetp.exists) Stats .record(" base type miss" )
1718- if (isCachable(tp, btrCache)) {
1719- if (basetp.exists) Stats .record(" cached base type hit" )
1720- else Stats .record(" cached base type miss" )
1723+ if (basetp.exists) {
1724+ Stats .record(" cached base type exists" )
17211725 btrCache.put(tp, basetp)
17221726 }
1723- else btrCache.remove(tp)
1724- } else if (basetp `eq` NoPrefix )
1727+ else {
1728+ Stats .record(" cached base type missing" )
1729+ btrCache.remove(tp)
1730+ }
1731+ }
1732+ else if (basetp `eq` NoPrefix )
17251733 throw CyclicReference (this )
17261734 basetp
17271735 }
0 commit comments