aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-18 11:26:59 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-06 13:15:28 +0200
commitdb4f7a19c9329d59da09a4de6b8476b4b6988cdf (patch)
treee70a1cf2d4af3a9e3e4b3999d5000b4466627143 /compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
parent26497bb3c654e294a48db2098978bc77b11f2889 (diff)
downloaddotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.tar.gz
dotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.tar.bz2
dotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.zip
Further refactorings
- Use TypeLambda instead of PolyType. - Further harmonize factory operations
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala22
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
index ab176b632..64621ec94 100644
--- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
+++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
@@ -42,10 +42,10 @@ trait ConstraintHandling {
*/
protected var homogenizeArgs = false
- /** We are currently comparing polytypes. Used as a flag for
+ /** We are currently comparing type lambdas. Used as a flag for
* optimization: when `false`, no need to do an expensive `pruneLambdaParams`
*/
- protected var comparedPolyTypes: Set[PolyType] = Set.empty
+ protected var comparedTypeLambdas: Set[TypeLambda] = Set.empty
private def addOneBound(param: TypeParamRef, bound: Type, isUpper: Boolean): Boolean =
!constraint.contains(param) || {
@@ -306,21 +306,21 @@ trait ConstraintHandling {
if (e.exists) e.bounds else param.binder.paramInfos(param.paramNum)
}
- /** Add polytype `pt`, possibly with type variables `tvars`, to current constraint
+ /** Add type lambda `tl`, possibly with type variables `tvars`, to current constraint
* and propagate all bounds.
* @param tvars See Constraint#add
*/
- def addToConstraint(pt: PolyType, tvars: List[TypeVar]): Unit =
+ def addToConstraint(tl: TypeLambda, tvars: List[TypeVar]): Unit =
assert {
- checkPropagated(i"initialized $pt") {
- constraint = constraint.add(pt, tvars)
- pt.paramNames.indices.forall { i =>
- val param = TypeParamRef(pt, i)
+ checkPropagated(i"initialized $tl") {
+ constraint = constraint.add(tl, tvars)
+ tl.paramNames.indices.forall { i =>
+ val param = TypeParamRef(tl, i)
val bounds = constraint.nonParamBounds(param)
val lower = constraint.lower(param)
val upper = constraint.upper(param)
if (lower.nonEmpty && !bounds.lo.isRef(defn.NothingClass) ||
- upper.nonEmpty && !bounds.hi.isRef(defn.AnyClass)) constr.println(i"INIT*** $pt")
+ upper.nonEmpty && !bounds.hi.isRef(defn.AnyClass)) constr.println(i"INIT*** $tl")
lower.forall(addOneBound(_, bounds.hi, isUpper = true)) &&
upper.forall(addOneBound(_, bounds.lo, isUpper = false))
}
@@ -357,10 +357,10 @@ trait ConstraintHandling {
* missing.
*/
def pruneLambdaParams(tp: Type) =
- if (comparedPolyTypes.nonEmpty) {
+ if (comparedTypeLambdas.nonEmpty) {
val approx = new ApproximatingTypeMap {
def apply(t: Type): Type = t match {
- case t @ TypeParamRef(pt: PolyType, n) if comparedPolyTypes contains pt =>
+ case t @ TypeParamRef(pt: TypeLambda, n) if comparedTypeLambdas contains pt =>
val effectiveVariance = if (fromBelow) -variance else variance
val bounds = pt.paramInfos(n)
if (effectiveVariance > 0) bounds.lo