aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/ConstraintHandling.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-12 18:37:47 +0100
committerMartin Odersky <odersky@gmail.com>2015-01-12 18:37:47 +0100
commitf76e81ed5cc5f57fcbdde6ea98503bd031c903a2 (patch)
tree11ba5d4175d9ce3134117a48e8a81999cc9ae2fc /src/dotty/tools/dotc/core/ConstraintHandling.scala
parent7df0423e49e81904ba703d44b0389d3a544aa946 (diff)
downloaddotty-f76e81ed5cc5f57fcbdde6ea98503bd031c903a2.tar.gz
dotty-f76e81ed5cc5f57fcbdde6ea98503bd031c903a2.tar.bz2
dotty-f76e81ed5cc5f57fcbdde6ea98503bd031c903a2.zip
Streamline unification
Instead of recording a `TypeAlias(p)` for the entry of an eliminated parameter we record directly the solution `p`.
Diffstat (limited to 'src/dotty/tools/dotc/core/ConstraintHandling.scala')
-rw-r--r--src/dotty/tools/dotc/core/ConstraintHandling.scala67
1 files changed, 32 insertions, 35 deletions
diff --git a/src/dotty/tools/dotc/core/ConstraintHandling.scala b/src/dotty/tools/dotc/core/ConstraintHandling.scala
index d8078e26b..264cff012 100644
--- a/src/dotty/tools/dotc/core/ConstraintHandling.scala
+++ b/src/dotty/tools/dotc/core/ConstraintHandling.scala
@@ -107,44 +107,41 @@ trait ConstraintHandling {
* make sure 'B >: A' gets added and vice versa. Furthermore, if the constraint
* implies 'A <: B <: A', A and B get unified.
*/
- def addc(param: PolyParam, bound: Type, fromBelow: Boolean): Boolean =
- constraint.bounds(param) match {
- case TypeBounds(plo: PolyParam, phi) if (plo eq phi) && constraint.contains(plo) =>
- addc(plo, bound, fromBelow)
- case pbounds0 =>
- bound match {
- case bound: PolyParam if constraint contains bound =>
- val bbounds0 @ TypeBounds(lo, hi) = constraint.bounds(bound)
- if (lo eq hi)
- addc(param, lo, fromBelow)
- else if (param == bound)
- true
- else if (fromBelow && param.occursIn(lo, fromBelow = true))
- unify(param, bound)
- else if (!fromBelow && param.occursIn(hi, fromBelow = false))
- unify(bound, param)
- else {
- val pbounds = prepare(param, bound, fromBelow)
- val bbounds = prepare(bound, param, !fromBelow)
- pbounds.exists && bbounds.exists && {
- install(param, pbounds.bounds, pbounds0)
- install(bound, bbounds.bounds, bbounds0)
- true
- }
- }
- case bound: AndOrType if fromBelow != bound.isAnd =>
- addc(param, bound.tp1, fromBelow) &&
- addc(param, bound.tp2, fromBelow)
- case bound: WildcardType =>
+ def addc(param: PolyParam, bound: Type, fromBelow: Boolean): Boolean = {
+ val pbounds0 = constraint.bounds(param)
+ bound match {
+ case bound: PolyParam if constraint contains bound =>
+ val bbounds0 @ TypeBounds(lo, hi) = constraint.bounds(bound)
+ if (lo eq hi)
+ addc(param, lo, fromBelow)
+ else if (param == bound)
+ true
+ else if (fromBelow && param.occursIn(lo, fromBelow = true))
+ unify(param, bound)
+ else if (!fromBelow && param.occursIn(hi, fromBelow = false))
+ unify(bound, param)
+ else {
+ val pbounds = prepare(param, bound, fromBelow)
+ val bbounds = prepare(bound, param, !fromBelow)
+ pbounds.exists && bbounds.exists && {
+ install(param, pbounds.bounds, pbounds0)
+ install(bound, bbounds.bounds, bbounds0)
true
- case bound => // !!! remove to keep the originals
- val pbounds = prepare(param, bound, fromBelow)
- pbounds.exists && {
- install(param, pbounds.bounds, pbounds0)
- true
- }
+ }
+ }
+ case bound: AndOrType if fromBelow != bound.isAnd =>
+ addc(param, bound.tp1, fromBelow) &&
+ addc(param, bound.tp2, fromBelow)
+ case bound: WildcardType =>
+ true
+ case bound => // !!! remove to keep the originals
+ val pbounds = prepare(param, bound, fromBelow)
+ pbounds.exists && {
+ install(param, pbounds.bounds, pbounds0)
+ true
}
}
+ }
/** Install bounds for param */
def install(param: PolyParam, newBounds: TypeBounds, oldBounds: TypeBounds): Unit = {