@@ -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 val ctx : Context
24
27
25
28
protected def isSubType (tp1 : Type , tp2 : Type ): Boolean
@@ -120,23 +123,23 @@ trait ConstraintHandling {
120
123
if (Config .failOnInstantiationToNothing) assert(false , msg)
121
124
else ctx.log(msg)
122
125
}
123
- constr.println (i " adding $description$location" )
126
+ constr_println (i " adding $description$location" )
124
127
val lower = constraint.lower(param)
125
128
val res =
126
129
addOneBound(param, bound, isUpper = true ) &&
127
130
lower.forall(addOneBound(_, bound, isUpper = true ))
128
- constr.println (i " added $description = $res$location" )
131
+ constr_println (i " added $description = $res$location" )
129
132
res
130
133
}
131
134
132
135
protected def addLowerBound (param : TypeParamRef , bound : Type ): Boolean = {
133
136
def description = i " constraint $param >: $bound to \n $constraint"
134
- constr.println (i " adding $description" )
137
+ constr_println (i " adding $description" )
135
138
val upper = constraint.upper(param)
136
139
val res =
137
140
addOneBound(param, bound, isUpper = false ) &&
138
141
upper.forall(addOneBound(_, bound, isUpper = false ))
139
- constr.println (i " added $description = $res$location" )
142
+ constr_println (i " added $description = $res$location" )
140
143
res
141
144
}
142
145
@@ -149,20 +152,20 @@ trait ConstraintHandling {
149
152
val up2 = p2 :: constraint.exclusiveUpper(p2, p1)
150
153
val lo1 = constraint.nonParamBounds(p1).lo
151
154
val hi2 = constraint.nonParamBounds(p2).hi
152
- constr.println (i " adding $description down1 = $down1, up2 = $up2$location" )
155
+ constr_println (i " adding $description down1 = $down1, up2 = $up2$location" )
153
156
constraint = constraint.addLess(p1, p2)
154
157
down1.forall(addOneBound(_, hi2, isUpper = true )) &&
155
158
up2.forall(addOneBound(_, lo1, isUpper = false ))
156
159
}
157
- constr.println (i " added $description = $res$location" )
160
+ constr_println (i " added $description = $res$location" )
158
161
res
159
162
}
160
163
161
164
/** Make p2 = p1, transfer all bounds of p2 to p1
162
165
* @pre less(p1)(p2)
163
166
*/
164
167
private def unify (p1 : TypeParamRef , p2 : TypeParamRef ): Boolean = {
165
- constr.println (s " unifying $p1 $p2" )
168
+ constr_println (s " unifying $p1 $p2" )
166
169
assert(constraint.isLess(p1, p2))
167
170
val down = constraint.exclusiveLower(p2, p1)
168
171
val up = constraint.exclusiveUpper(p1, p2)
@@ -260,7 +263,7 @@ trait ConstraintHandling {
260
263
case _ : TypeBounds =>
261
264
val bound = if (fromBelow) constraint.fullLowerBound(param) else constraint.fullUpperBound(param)
262
265
val inst = avoidParam(bound)
263
- typr.println (s " approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}" )
266
+ typr_println (s " approx ${param.show}, from below = $fromBelow, bound = ${bound.show}, inst = ${inst.show}" )
264
267
inst
265
268
case inst =>
266
269
assert(inst.exists, i " param = $param\n constraint = $constraint" )
@@ -359,7 +362,7 @@ trait ConstraintHandling {
359
362
val lower = constraint.lower(param)
360
363
val upper = constraint.upper(param)
361
364
if (lower.nonEmpty && ! bounds.lo.isRef(defn.NothingClass ) ||
362
- upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr.println (i " INIT*** $tl" )
365
+ upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr_println (i " INIT*** $tl" )
363
366
lower.forall(addOneBound(_, bounds.hi, isUpper = true )) &&
364
367
upper.forall(addOneBound(_, bounds.lo, isUpper = false ))
365
368
case _ =>
0 commit comments