@@ -14,7 +14,7 @@ import annotation.tailrec
14
14
15
15
object OrderingConstraint {
16
16
17
- type ArrayValuedMap [T ] = SimpleMap [GenericType , Array [T ]]
17
+ type ArrayValuedMap [T ] = SimpleMap [PolyType , Array [T ]]
18
18
19
19
/** The type of `OrderingConstraint#boundsMap` */
20
20
type ParamBounds = ArrayValuedMap [Type ]
@@ -32,11 +32,11 @@ object OrderingConstraint {
32
32
33
33
/** A lens for updating a single entry array in one of the three constraint maps */
34
34
abstract class ConstraintLens [T <: AnyRef : ClassTag ] {
35
- def entries (c : OrderingConstraint , poly : GenericType ): Array [T ]
36
- def updateEntries (c : OrderingConstraint , poly : GenericType , entries : Array [T ])(implicit ctx : Context ): OrderingConstraint
35
+ def entries (c : OrderingConstraint , poly : PolyType ): Array [T ]
36
+ def updateEntries (c : OrderingConstraint , poly : PolyType , entries : Array [T ])(implicit ctx : Context ): OrderingConstraint
37
37
def initial : T
38
38
39
- def apply (c : OrderingConstraint , poly : GenericType , idx : Int ) = {
39
+ def apply (c : OrderingConstraint , poly : PolyType , idx : Int ) = {
40
40
val es = entries(c, poly)
41
41
if (es == null ) initial else es(idx)
42
42
}
@@ -47,7 +47,7 @@ object OrderingConstraint {
47
47
* parts of `current` which are not shared by `prev`.
48
48
*/
49
49
def update (prev : OrderingConstraint , current : OrderingConstraint ,
50
- poly : GenericType , idx : Int , entry : T )(implicit ctx : Context ): OrderingConstraint = {
50
+ poly : PolyType , idx : Int , entry : T )(implicit ctx : Context ): OrderingConstraint = {
51
51
var es = entries(current, poly)
52
52
if (es != null && (es(idx) eq entry)) current
53
53
else {
@@ -72,7 +72,7 @@ object OrderingConstraint {
72
72
update(prev, current, param.binder, param.paramNum, entry)
73
73
74
74
def map (prev : OrderingConstraint , current : OrderingConstraint ,
75
- poly : GenericType , idx : Int , f : T => T )(implicit ctx : Context ): OrderingConstraint =
75
+ poly : PolyType , idx : Int , f : T => T )(implicit ctx : Context ): OrderingConstraint =
76
76
update(prev, current, poly, idx, f(apply(current, poly, idx)))
77
77
78
78
def map (prev : OrderingConstraint , current : OrderingConstraint ,
@@ -81,25 +81,25 @@ object OrderingConstraint {
81
81
}
82
82
83
83
val boundsLens = new ConstraintLens [Type ] {
84
- def entries (c : OrderingConstraint , poly : GenericType ): Array [Type ] =
84
+ def entries (c : OrderingConstraint , poly : PolyType ): Array [Type ] =
85
85
c.boundsMap(poly)
86
- def updateEntries (c : OrderingConstraint , poly : GenericType , entries : Array [Type ])(implicit ctx : Context ): OrderingConstraint =
86
+ def updateEntries (c : OrderingConstraint , poly : PolyType , entries : Array [Type ])(implicit ctx : Context ): OrderingConstraint =
87
87
newConstraint(c.boundsMap.updated(poly, entries), c.lowerMap, c.upperMap)
88
88
def initial = NoType
89
89
}
90
90
91
91
val lowerLens = new ConstraintLens [List [PolyParam ]] {
92
- def entries (c : OrderingConstraint , poly : GenericType ): Array [List [PolyParam ]] =
92
+ def entries (c : OrderingConstraint , poly : PolyType ): Array [List [PolyParam ]] =
93
93
c.lowerMap(poly)
94
- def updateEntries (c : OrderingConstraint , poly : GenericType , entries : Array [List [PolyParam ]])(implicit ctx : Context ): OrderingConstraint =
94
+ def updateEntries (c : OrderingConstraint , poly : PolyType , entries : Array [List [PolyParam ]])(implicit ctx : Context ): OrderingConstraint =
95
95
newConstraint(c.boundsMap, c.lowerMap.updated(poly, entries), c.upperMap)
96
96
def initial = Nil
97
97
}
98
98
99
99
val upperLens = new ConstraintLens [List [PolyParam ]] {
100
- def entries (c : OrderingConstraint , poly : GenericType ): Array [List [PolyParam ]] =
100
+ def entries (c : OrderingConstraint , poly : PolyType ): Array [List [PolyParam ]] =
101
101
c.upperMap(poly)
102
- def updateEntries (c : OrderingConstraint , poly : GenericType , entries : Array [List [PolyParam ]])(implicit ctx : Context ): OrderingConstraint =
102
+ def updateEntries (c : OrderingConstraint , poly : PolyType , entries : Array [List [PolyParam ]])(implicit ctx : Context ): OrderingConstraint =
103
103
newConstraint(c.boundsMap, c.lowerMap, c.upperMap.updated(poly, entries))
104
104
def initial = Nil
105
105
}
@@ -149,7 +149,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
149
149
150
150
// ----------- Contains tests --------------------------------------------------
151
151
152
- def contains (pt : GenericType ): Boolean = boundsMap(pt) != null
152
+ def contains (pt : PolyType ): Boolean = boundsMap(pt) != null
153
153
154
154
def contains (param : PolyParam ): Boolean = {
155
155
val entries = boundsMap(param.binder)
@@ -280,7 +280,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
280
280
stripParams(tp, paramBuf, isUpper)
281
281
.orElse(if (isUpper) defn.AnyType else defn.NothingType )
282
282
283
- def add (poly : GenericType , tvars : List [TypeVar ])(implicit ctx : Context ): This = {
283
+ def add (poly : PolyType , tvars : List [TypeVar ])(implicit ctx : Context ): This = {
284
284
assert(! contains(poly))
285
285
val nparams = poly.paramNames.length
286
286
val entries1 = new Array [Type ](nparams * 2 )
@@ -293,7 +293,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
293
293
* Update all bounds to be normalized and update ordering to account for
294
294
* dependent parameters.
295
295
*/
296
- private def init (poly : GenericType )(implicit ctx : Context ): This = {
296
+ private def init (poly : PolyType )(implicit ctx : Context ): This = {
297
297
var current = this
298
298
val loBuf, hiBuf = new mutable.ListBuffer [PolyParam ]
299
299
var i = 0
@@ -400,7 +400,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
400
400
def removeParam (ps : List [PolyParam ]) =
401
401
ps.filterNot(p => p.binder.eq(poly) && p.paramNum == idx)
402
402
403
- def replaceParam (tp : Type , atPoly : GenericType , atIdx : Int ): Type = tp match {
403
+ def replaceParam (tp : Type , atPoly : PolyType , atIdx : Int ): Type = tp match {
404
404
case bounds @ TypeBounds (lo, hi) =>
405
405
406
406
def recombine (andor : AndOrType , op : (Type , Boolean ) => Type , isUpper : Boolean ): Type = {
@@ -440,9 +440,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
440
440
}
441
441
}
442
442
443
- def remove (pt : GenericType )(implicit ctx : Context ): This = {
443
+ def remove (pt : PolyType )(implicit ctx : Context ): This = {
444
444
def removeFromOrdering (po : ParamOrdering ) = {
445
- def removeFromBoundss (key : GenericType , bndss : Array [List [PolyParam ]]): Array [List [PolyParam ]] = {
445
+ def removeFromBoundss (key : PolyType , bndss : Array [List [PolyParam ]]): Array [List [PolyParam ]] = {
446
446
val bndss1 = bndss.map(_.filterConserve(_.binder ne pt))
447
447
if (bndss.corresponds(bndss1)(_ eq _)) bndss else bndss1
448
448
}
@@ -451,7 +451,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
451
451
newConstraint(boundsMap.remove(pt), removeFromOrdering(lowerMap), removeFromOrdering(upperMap))
452
452
}
453
453
454
- def isRemovable (pt : GenericType ): Boolean = {
454
+ def isRemovable (pt : PolyType ): Boolean = {
455
455
val entries = boundsMap(pt)
456
456
@ tailrec def allRemovable (last : Int ): Boolean =
457
457
if (last < 0 ) true
@@ -464,7 +464,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
464
464
465
465
// ---------- Exploration --------------------------------------------------------
466
466
467
- def domainPolys : List [GenericType ] = boundsMap.keys
467
+ def domainPolys : List [PolyType ] = boundsMap.keys
468
468
469
469
def domainParams : List [PolyParam ] =
470
470
for {
@@ -481,7 +481,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
481
481
true
482
482
}
483
483
484
- def foreachParam (p : (GenericType , Int ) => Unit ): Unit =
484
+ def foreachParam (p : (PolyType , Int ) => Unit ): Unit =
485
485
boundsMap.foreachBinding { (poly, entries) =>
486
486
0 .until(poly.paramNames.length).foreach(p(poly, _))
487
487
}
@@ -536,7 +536,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
536
536
537
537
override def checkClosed ()(implicit ctx : Context ): Unit = {
538
538
def isFreePolyParam (tp : Type ) = tp match {
539
- case PolyParam (binder : GenericType , _) => ! contains(binder)
539
+ case PolyParam (binder : PolyType , _) => ! contains(binder)
540
540
case _ => false
541
541
}
542
542
def checkClosedType (tp : Type , where : String ) =
0 commit comments