diff options
author | Martin Odersky <odersky@gmail.com> | 2013-11-10 22:40:14 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-11-10 22:40:14 +0100 |
commit | 2be8e8e6c1b48597d221f6cfc11c5f3b6fc113b3 (patch) | |
tree | cd087b2c3d520703ddc4a4f89dadb06f98f95180 | |
parent | a7b60116c30677eeff310b81af2fa714bf1950d6 (diff) | |
download | dotty-2be8e8e6c1b48597d221f6cfc11c5f3b6fc113b3.tar.gz dotty-2be8e8e6c1b48597d221f6cfc11c5f3b6fc113b3.tar.bz2 dotty-2be8e8e6c1b48597d221f6cfc11c5f3b6fc113b3.zip |
Reporting max constraint
Instead of throwing an exception if SImpleMap size goes over some threshold, we now report the largest constraint encountered in a run.
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Constraint.scala | 42 | ||||
-rw-r--r-- | src/dotty/tools/dotc/util/SimpleMap.scala | 4 |
3 files changed, 28 insertions, 24 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index a00fda36b..b12511478 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -4,7 +4,7 @@ package dotc import core._ import Contexts._, Periods._, Symbols._ import io.PlainFile -import util.{SourceFile, NoSource, Stats} +import util.{SourceFile, NoSource, Stats, SimpleMap} class Run(comp: Compiler)(implicit ctx: Context) { @@ -28,6 +28,8 @@ class Run(comp: Compiler)(implicit ctx: Context) { } } - def printSummary(): Unit = + def printSummary(): Unit = { ctx.typerState.reporter.printSummary + Constraint.printMax() + } }
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/Constraint.scala b/src/dotty/tools/dotc/core/Constraint.scala index af797c09b..29e1e01fe 100644 --- a/src/dotty/tools/dotc/core/Constraint.scala +++ b/src/dotty/tools/dotc/core/Constraint.scala @@ -36,8 +36,13 @@ class Constraint(val map: SimpleMap[PolyType, Array[Type]]) extends AnyVal with * the entries corresponding to `pt` with `entries`. */ def updated(pt: PolyType, entries: Array[Type]) = { - assert(map(pt) != null) - new Constraint(map.updated(pt, entries)) + import Constraint._ + val res = new Constraint(map.updated(pt, entries)) + if (res.map.size > maxSize) { + maxSize = res.map.size + maxConstraint = res + } + res } /** A new constraint which is derived from this constraint by removing @@ -53,25 +58,17 @@ class Constraint(val map: SimpleMap[PolyType, Array[Type]]) extends AnyVal with noneLeft = (entries(i) eq NoType) || i == pnum i += 1 } - new Constraint( - if (noneLeft) map remove pt - else { - val newEntries = entries.clone - newEntries(pnum) = NoType - map.updated(pt, newEntries) - }) - } - - def +(pt: PolyType) = { -/* - pt.resultType match { - case MethodType(pname :: rest, _) => - assert(pname.toString != "__thingToAdd") - case _ => + if (noneLeft) new Constraint(map remove pt) + else { + val newEntries = entries.clone + newEntries(pnum) = NoType + updated(pt, newEntries) } -*/ - new Constraint(map.updated(pt, pt.paramBounds.toArray)) } + + def +(pt: PolyType) = + updated(pt, pt.paramBounds.toArray) + /** A new constraint which is derived from this constraint by removing * the type parameter `param` from the domain and replacing all occurrences * of the parameter elsewhere in the constraint by type `tp`. @@ -120,3 +117,10 @@ class Constraint(val map: SimpleMap[PolyType, Array[Type]]) extends AnyVal with override def toText(printer: Printer): Text = "Constraint(" ~ constrainedTypesText(printer) ~ ") {" ~ constraintText(2, printer) ~ "}" } + +object Constraint { + var maxSize = 0 + var maxConstraint: Constraint = _ + def printMax()(implicit ctx: Context) = + if (maxSize > 0) println(s"max constraint = ${maxConstraint.show}") +} diff --git a/src/dotty/tools/dotc/util/SimpleMap.scala b/src/dotty/tools/dotc/util/SimpleMap.scala index 60b9e77ed..0d6f0a2b4 100644 --- a/src/dotty/tools/dotc/util/SimpleMap.scala +++ b/src/dotty/tools/dotc/util/SimpleMap.scala @@ -177,10 +177,8 @@ object SimpleMap { new Map5(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5) } } - def updated[V1 >: V <: AnyRef](k: K, v: V1) = { - assert(m.size < 12) // !!!DEBUG - want to see when maps blow up + def updated[V1 >: V <: AnyRef](k: K, v: V1) = new MapMore(m.updated(k, v)) - } override def contains(k: K) = m contains k def mapValues[V1 >: V <: AnyRef](f: V1 => V1) = { val assocs = m.toList |