aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-08 16:12:01 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-08 18:32:33 +0200
commit058729ceac3354a2cc34490b528e76afb09ee0ce (patch)
tree2b98e78b607c7f0438ebd2eac8b68f5a72b46a04 /src/dotty/tools/dotc/core/Types.scala
parentf87153bc5d74f66e2fcf22dc7282da31813430da (diff)
downloaddotty-058729ceac3354a2cc34490b528e76afb09ee0ce.tar.gz
dotty-058729ceac3354a2cc34490b528e76afb09ee0ce.tar.bz2
dotty-058729ceac3354a2cc34490b528e76afb09ee0ce.zip
LazyRefs break cycles for unpickled types
Insert LazyRefs to break cycles for F-bounded types that are unpickled or read from Java signatures.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index a81d200d3..8ec5c7295 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1236,7 +1236,7 @@ object Types {
if (ctx.underlyingRecursions < LogPendingUnderlyingThreshold)
op
else if (ctx.pendingUnderlying contains this)
- throw new CyclicReference(symbol)
+ throw CyclicReference(symbol)
else
try {
ctx.pendingUnderlying += this
@@ -1487,7 +1487,7 @@ object Types {
unique(new CachedConstantType(value))
}
- case class LazyRef(refFn: () => Type) extends UncachedProxyType with TermType {
+ case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
lazy val ref = refFn()
override def underlying(implicit ctx: Context) = ref
override def toString = s"LazyRef($ref)"
@@ -2689,10 +2689,17 @@ object Types {
extends FatalTypeError(
s"""malformed type: $pre is not a legal prefix for $denot because it contains abstract type member${if (absMembers.size == 1) "" else "s"} ${absMembers.mkString(", ")}""")
- class CyclicReference(val denot: SymDenotation)
+ class CyclicReference private (val denot: SymDenotation)
extends FatalTypeError(s"cyclic reference involving $denot") {
def show(implicit ctx: Context) = s"cyclic reference involving ${denot.show}"
- printStackTrace()
+ }
+
+ object CyclicReference {
+ def apply(denot: SymDenotation)(implicit ctx: Context): CyclicReference = {
+ val ex = new CyclicReference(denot)
+ if (!(ctx.mode is typer.Mode.CheckCyclic)) ex.printStackTrace()
+ ex
+ }
}
class MergeError(msg: String) extends FatalTypeError(msg)