@@ -33,27 +33,11 @@ object Checking {
33
33
/** A general checkBounds method that can be used for TypeApply nodes as
34
34
* well as for AppliedTypeTree nodes.
35
35
*/
36
- def checkBounds (args : List [tpd.Tree ], boundss : List [TypeBounds ], instantiate : (Type , List [Type ]) => Type )(implicit ctx : Context ) = {
37
- val argTypes = args.tpes
38
- for ((arg, bounds) <- args zip boundss) {
39
- def notConforms (which : String , bound : Type ) = {
40
- ctx.error(
36
+ def checkBounds (args : List [tpd.Tree ], boundss : List [TypeBounds ], instantiate : (Type , List [Type ]) => Type )(implicit ctx : Context ) =
37
+ for ((arg, which, bound) <- ctx.boundsViolations(args, boundss, instantiate))
38
+ ctx.error(
41
39
d " Type argument ${arg.tpe} does not conform to $which bound $bound ${err.whyNoMatchStr(arg.tpe, bound)}" ,
42
40
arg.pos)
43
- }
44
- def checkOverlapsBounds (lo : Type , hi : Type ): Unit = {
45
- // println(i"instantiating ${bounds.hi} with $argTypes")
46
- // println(i" = ${instantiate(bounds.hi, argTypes)}")
47
- val hiBound = instantiate(bounds.hi, argTypes)
48
- if (! (lo <:< hiBound)) notConforms(" upper" , hiBound)
49
- if (! (bounds.lo <:< hi)) notConforms(" lower" , bounds.lo)
50
- }
51
- arg.tpe match {
52
- case TypeBounds (lo, hi) => checkOverlapsBounds(lo, hi)
53
- case tp => checkOverlapsBounds(tp, tp)
54
- }
55
- }
56
- }
57
41
58
42
/** A type map which checks that the only cycles in a type are F-bounds
59
43
* and that protects all F-bounded references by LazyRefs.
@@ -190,10 +174,9 @@ trait Checking {
190
174
/** Check that type arguments `args` conform to corresponding bounds in `poly`
191
175
* Note: This does not check the bounds of AppliedTypeTrees. These
192
176
* are handled by method checkBounds in FirstTransform
193
- * TODO: remove pos parameter
194
177
*/
195
- def checkBounds (args : List [tpd.Tree ], poly : PolyType , pos : Position )(implicit ctx : Context ): Unit = Checking .checkBounds(
196
- args, poly.paramBounds, (tp, argTypes) => tp .substParams(poly, argTypes ))
178
+ def checkBounds (args : List [tpd.Tree ], poly : PolyType )(implicit ctx : Context ): Unit =
179
+ Checking .checkBounds( args, poly.paramBounds, _ .substParams(poly, _ ))
197
180
198
181
/** Check that type `tp` is stable. */
199
182
def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit =
@@ -290,7 +273,7 @@ trait NoChecking extends Checking {
290
273
import tpd ._
291
274
override def checkNonCyclic (sym : Symbol , info : TypeBounds , reportErrors : Boolean )(implicit ctx : Context ): Type = info
292
275
override def checkValue (tree : Tree , proto : Type )(implicit ctx : Context ): tree.type = tree
293
- override def checkBounds (args : List [tpd.Tree ], poly : PolyType , pos : Position )(implicit ctx : Context ): Unit = ()
276
+ override def checkBounds (args : List [tpd.Tree ], poly : PolyType )(implicit ctx : Context ): Unit = ()
294
277
override def checkStable (tp : Type , pos : Position )(implicit ctx : Context ): Unit = ()
295
278
override def checkLegalPrefix (tp : Type , selector : Name , pos : Position )(implicit ctx : Context ): Unit = ()
296
279
override def checkClassTypeWithStablePrefix (tp : Type , pos : Position , traitReq : Boolean )(implicit ctx : Context ): Type = tp
0 commit comments