Skip to content

Fix #5333: Invalid entries in the baseType cache #5343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,10 @@ object SymDenotations {
Stats.record("basetype cache entries")
if (!baseTp.exists) Stats.record("basetype cache NoTypes")
}
btrCache.put(tp, baseTp)
if (!tp.isProvisional)
btrCache.put(tp, baseTp)
else
btrCache.remove(tp) // Remove any potential sentinel value
}

def ensureAcyclic(baseTp: Type) = {
Expand Down Expand Up @@ -1682,8 +1685,8 @@ object SymDenotations {
case _ =>
val superTp = tp.superType
val baseTp = recur(superTp)
if (inCache(superTp) && tp.symbol.maybeOwner.isType)
record(tp, baseTp) // typeref cannot be a GADT, so cache is stable
if (inCache(superTp))
record(tp, baseTp)
else
btrCache.remove(tp)
baseTp
Expand Down Expand Up @@ -1717,8 +1720,6 @@ object SymDenotations {
val baseTp = recur(superTp)
tp match {
case tp: CachedType if baseTp.exists && inCache(superTp) =>
// Note: This also works for TypeVars: If they are not instantiated, their supertype
// is a TypeParamRef, which is never cached. So uninstantiated TypeVars are not cached either.
record(tp, baseTp)
case _ =>
}
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/seqtype-cycle/Test2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package object scala {
// needed for some reasons
type Throwable = java.lang.Throwable
type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
type List[+A] = scala.collection.immutable.List[A]
type Iterable[+A] = scala.collection.Iterable[A]

type Seq[A] = scala.collection.Seq[A]
val Seq = scala.collection.Seq
Expand Down