aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-23 14:05:14 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-23 14:14:40 +0200
commite2a130a32e8ec67bfc834f93ed44490bc9a83399 (patch)
tree8979e25c74990cc74847874706948c6a9e508e7e /src
parent58ae0d03a13fbe159120c9356884f96dda37d575 (diff)
downloaddotty-e2a130a32e8ec67bfc834f93ed44490bc9a83399.tar.gz
dotty-e2a130a32e8ec67bfc834f93ed44490bc9a83399.tar.bz2
dotty-e2a130a32e8ec67bfc834f93ed44490bc9a83399.zip
Made TypeVars uncahable keys
TypeVars can appear as keys in baseType caches. The problem is that their base types depend on their instantiation, which is not always know yet when the test is performed. So results of baseType on type variables should never be cached. Todo: check whether there are any other caching problems involving typevars. Conflicts: src/dotty/tools/dotc/core/SymDenotations.scala
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 88f75fbfd..a2637f8f8 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -1323,6 +1323,9 @@ object SymDenotations {
case _ =>
baseTypeRefOf(tp.underlying)
}
+ case tp: TypeVar =>
+ if (tp.inst.exists) computeBaseTypeRefOf(tp.inst)
+ else Uncachable(computeBaseTypeRefOf(tp.underlying))
case tp: TypeProxy =>
baseTypeRefOf(tp.underlying)
case AndType(tp1, tp2) =>
@@ -1343,8 +1346,14 @@ object SymDenotations {
var basetp = baseTypeRefCache get tp
if (basetp == null) {
baseTypeRefCache.put(tp, NoPrefix)
- basetp = computeBaseTypeRefOf(tp)
+ basetp = computeBaseTypeRefOf(tp) match {
+ case Uncachable(basetp) =>
+ baseTypeRefCache.remove(tp)
+ basetp
+ case basetp =>
baseTypeRefCache.put(tp, basetp)
+ basetp
+ }
} else if (basetp == NoPrefix) {
throw CyclicReference(this)
}
@@ -1422,6 +1431,8 @@ object SymDenotations {
}
}
+ private case class Uncachable(tp: Type) extends UncachedGroundType
+
/** The denotation of a package class.
* It overrides ClassDenotation to take account of package objects when looking for members
*/