Skip to content

Commit 6ccdec3

Browse files
authored
Merge pull request #5343 from dotty-staging/fix-caches
Fix #5333: Invalid entries in the baseType cache
2 parents 6fd349a + ed76b73 commit 6ccdec3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,10 @@ object SymDenotations {
16311631
Stats.record("basetype cache entries")
16321632
if (!baseTp.exists) Stats.record("basetype cache NoTypes")
16331633
}
1634-
btrCache.put(tp, baseTp)
1634+
if (!tp.isProvisional)
1635+
btrCache.put(tp, baseTp)
1636+
else
1637+
btrCache.remove(tp) // Remove any potential sentinel value
16351638
}
16361639

16371640
def ensureAcyclic(baseTp: Type) = {
@@ -1682,8 +1685,8 @@ object SymDenotations {
16821685
case _ =>
16831686
val superTp = tp.superType
16841687
val baseTp = recur(superTp)
1685-
if (inCache(superTp) && tp.symbol.maybeOwner.isType)
1686-
record(tp, baseTp) // typeref cannot be a GADT, so cache is stable
1688+
if (inCache(superTp))
1689+
record(tp, baseTp)
16871690
else
16881691
btrCache.remove(tp)
16891692
baseTp
@@ -1717,8 +1720,6 @@ object SymDenotations {
17171720
val baseTp = recur(superTp)
17181721
tp match {
17191722
case tp: CachedType if baseTp.exists && inCache(superTp) =>
1720-
// Note: This also works for TypeVars: If they are not instantiated, their supertype
1721-
// is a TypeParamRef, which is never cached. So uninstantiated TypeVars are not cached either.
17221723
record(tp, baseTp)
17231724
case _ =>
17241725
}

tests/pos/seqtype-cycle/Test2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package object scala {
22
// needed for some reasons
33
type Throwable = java.lang.Throwable
44
type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
5+
type List[+A] = scala.collection.immutable.List[A]
6+
type Iterable[+A] = scala.collection.Iterable[A]
57

68
type Seq[A] = scala.collection.Seq[A]
79
val Seq = scala.collection.Seq

0 commit comments

Comments
 (0)