@@ -20,6 +20,9 @@ import config.Printers.{constr, typr}
20
20
*/
21
21
trait ConstraintHandling {
22
22
23
+ def constr_println (msg : => String ): Unit = constr.println(msg)
24
+ def typr_println (msg : => String ): Unit = typr.println(msg)
25
+
23
26
implicit def ctx : Context
24
27
25
28
protected def isSubType (tp1 : Type , tp2 : Type ): Boolean
@@ -107,23 +110,23 @@ trait ConstraintHandling {
107
110
if (Config .failOnInstantiationToNothing) assert(false , msg)
108
111
else ctx.log(msg)
109
112
}
110
- constr.println (i " adding $description$location" )
113
+ constr_println (i " adding $description$location" )
111
114
val lower = constraint.lower(param)
112
115
val res =
113
116
addOneBound(param, bound, isUpper = true ) &&
114
117
lower.forall(addOneBound(_, bound, isUpper = true ))
115
- constr.println (i " added $description = $res$location" )
118
+ constr_println (i " added $description = $res$location" )
116
119
res
117
120
}
118
121
119
122
protected def addLowerBound (param : TypeParamRef , bound : Type ): Boolean = {
120
123
def description = i " constraint $param >: $bound to \n $constraint"
121
- constr.println (i " adding $description" )
124
+ constr_println (i " adding $description" )
122
125
val upper = constraint.upper(param)
123
126
val res =
124
127
addOneBound(param, bound, isUpper = false ) &&
125
128
upper.forall(addOneBound(_, bound, isUpper = false ))
126
- constr.println (i " added $description = $res$location" )
129
+ constr_println (i " added $description = $res$location" )
127
130
res
128
131
}
129
132
@@ -136,20 +139,20 @@ trait ConstraintHandling {
136
139
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
137
140
val lo1 = constraint.nonParamBounds(p1).lo
138
141
val hi2 = constraint.nonParamBounds(p2).hi
139
- constr.println (i " adding $description down1 = $down1, up2 = $up2$location" )
142
+ constr_println (i " adding $description down1 = $down1, up2 = $up2$location" )
140
143
constraint = constraint.addLess(p1, p2)
141
144
down1.forall(addOneBound(_, hi2, isUpper = true )) &&
142
145
up2.forall(addOneBound(_, lo1, isUpper = false ))
143
146
}
144
- constr.println (i " added $description = $res$location" )
147
+ constr_println (i " added $description = $res$location" )
145
148
res
146
149
}
147
150
148
151
/** Make p2 = p1, transfer all bounds of p2 to p1
149
152
* @pre less(p1)(p2)
150
153
*/
151
154
private def unify (p1 : TypeParamRef , p2 : TypeParamRef ): Boolean = {
152
- constr.println (s " unifying $p1 $p2" )
155
+ constr_println (s " unifying $p1 $p2" )
153
156
assert(constraint.isLess(p1, p2))
154
157
val down = constraint.exclusiveLower(p2, p1)
155
158
val up = constraint.exclusiveUpper(p1, p2)
@@ -247,7 +250,7 @@ trait ConstraintHandling {
247
250
case _ : TypeBounds =>
248
251
val bound = if (fromBelow) constraint.fullLowerBound(param) else constraint.fullUpperBound(param)
249
252
val inst = avoidParam(bound)
250
- typr.println (s " approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}" )
253
+ typr_println (s " approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}" )
251
254
inst
252
255
case inst =>
253
256
assert(inst.exists, i " param = $param\n constraint = $constraint" )
@@ -346,7 +349,7 @@ trait ConstraintHandling {
346
349
val lower = constraint.lower(param)
347
350
val upper = constraint.upper(param)
348
351
if (lower.nonEmpty && ! bounds.lo.isRef(defn.NothingClass ) ||
349
- upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr.println (i " INIT*** $tl" )
352
+ upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr_println (i " INIT*** $tl" )
350
353
lower.forall(addOneBound(_, bounds.hi, isUpper = true )) &&
351
354
upper.forall(addOneBound(_, bounds.lo, isUpper = false ))
352
355
case _ =>
0 commit comments