aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-14 12:49:09 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:05:15 +0200
commit0bdee32e8b35b6c994248def87cb8f6f874572dd (patch)
tree659e087d649d299ec4deff363a6da0836b5d6158
parentb10b93e6f8bdee650ccbe588db476bd0c8c8819c (diff)
downloaddotty-0bdee32e8b35b6c994248def87cb8f6f874572dd.tar.gz
dotty-0bdee32e8b35b6c994248def87cb8f6f874572dd.tar.bz2
dotty-0bdee32e8b35b6c994248def87cb8f6f874572dd.zip
Black hole detection for LazyRefs
Now catches attempts to recursively force a LazyRef type that's in train of being evaluated.
-rw-r--r--src/dotty/tools/dotc/core/Types.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 358720836..6797836cf 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1815,7 +1815,16 @@ object Types {
}
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
- lazy val ref = refFn()
+ private var myRef: Type = null
+ private var computed = false
+ lazy val ref = {
+ if (computed) assert(myRef != null)
+ else {
+ computed = true
+ myRef = refFn()
+ }
+ myRef
+ }
override def underlying(implicit ctx: Context) = ref
override def toString = s"LazyRef($ref)"
override def equals(other: Any) = other match {