aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Constraint.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-04-29 16:14:42 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-05-08 21:51:46 +0200
commitef8f24203f4a3ef75d0b8e45a9dd9470bd474e7d (patch)
treee568b66eb7d8c33bc0770c0fb3b043d007a93078 /src/dotty/tools/dotc/core/Constraint.scala
parentf84a49d4502c9a1ad328c1f5a3a558afade63848 (diff)
downloaddotty-ef8f24203f4a3ef75d0b8e45a9dd9470bd474e7d.tar.gz
dotty-ef8f24203f4a3ef75d0b8e45a9dd9470bd474e7d.tar.bz2
dotty-ef8f24203f4a3ef75d0b8e45a9dd9470bd474e7d.zip
Tightened satisfiablity checks.
Satisfiability was too loose before. It is noww tightened. We check that the lower bounds of all constrained parameters represent a solution to the constraint. To make the check pass we have to first propagate the constraint by re-verifying all bounds.
Diffstat (limited to 'src/dotty/tools/dotc/core/Constraint.scala')
-rw-r--r--src/dotty/tools/dotc/core/Constraint.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Constraint.scala b/src/dotty/tools/dotc/core/Constraint.scala
index d3d19ec30..a16c85316 100644
--- a/src/dotty/tools/dotc/core/Constraint.scala
+++ b/src/dotty/tools/dotc/core/Constraint.scala
@@ -77,6 +77,8 @@ class Constraint(val myMap: SimpleMap[PolyType, Array[Type]]) extends Showable {
*/
private def updateEntries(pt: PolyType, entries: Array[Type])(implicit ctx: Context) : Constraint = {
val res = new Constraint(myMap.updated(pt, entries))
+ //assert(res.domainPolys.filter(pt =>
+ // pt.resultType.resultType.widen.classSymbol.name.toString == "Ensuring").length < 2) //DEBUG
if (Config.checkConstraintsNonCyclic) checkNonCyclic(pt, entries)
ctx.runInfo.recordConstraintSize(res)
res
@@ -246,6 +248,16 @@ class Constraint(val myMap: SimpleMap[PolyType, Array[Type]]) extends Showable {
if isBounds(entries(n))
} yield PolyParam(poly, n)
+ /** Check whether predicate holds for all parameters in constraint
+ */
+ def forallParams(p: PolyParam => Boolean): Boolean = {
+ myMap.foreachBinding { (poly, entries) =>
+ for (i <- 0 until paramCount(entries))
+ if (isBounds(entries(i)) && !p(PolyParam(poly, i))) return false
+ }
+ true
+ }
+
/** Perform operation `op` on all typevars, or only on uninstantiated
* typevars, depending on whether `uninstOnly` is set or not.
*/