aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/Run.scala6
-rw-r--r--src/dotty/tools/dotc/core/Constraint.scala42
-rw-r--r--src/dotty/tools/dotc/util/SimpleMap.scala4
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