@@ -479,11 +479,11 @@ object ProtoTypes {
479
479
* for each parameter.
480
480
* @return The added type lambda, and the list of created type variables.
481
481
*/
482
- def constrained (tl : TypeLambda , owningTree : untpd.Tree , alwaysAddTypeVars : Boolean = false )(implicit ctx : Context ): (TypeLambda , List [TypeTree ]) = {
482
+ def constrained (tl : TypeLambda , owningTree : untpd.Tree , alwaysAddTypeVars : Boolean )(implicit ctx : Context ): (TypeLambda , List [TypeTree ]) = {
483
483
val state = ctx.typerState
484
484
val addTypeVars = alwaysAddTypeVars || ! owningTree.isEmpty
485
485
if (tl.isInstanceOf [PolyType ])
486
- assert(! ( ctx.typerState.isCommittable && ! addTypeVars) ,
486
+ assert(! ctx.typerState.isCommittable || addTypeVars,
487
487
s " inconsistent: no typevars were added to committable constraint ${state.constraint}" )
488
488
// hk type lambdas can be added to constraints without typevars during match reduction
489
489
@@ -502,8 +502,13 @@ object ProtoTypes {
502
502
(added, tvars)
503
503
}
504
504
505
+ def constrained (tl : TypeLambda , owningTree : untpd.Tree )(implicit ctx : Context ): (TypeLambda , List [TypeTree ]) =
506
+ constrained(tl, owningTree,
507
+ alwaysAddTypeVars = tl.isInstanceOf [PolyType ] && ctx.typerState.isCommittable)
508
+
505
509
/** Same as `constrained(tl, EmptyTree)`, but returns just the created type lambda */
506
- def constrained (tl : TypeLambda )(implicit ctx : Context ): TypeLambda = constrained(tl, EmptyTree )._1
510
+ def constrained (tl : TypeLambda )(implicit ctx : Context ): TypeLambda =
511
+ constrained(tl, EmptyTree )._1
507
512
508
513
def newTypeVar (bounds : TypeBounds )(implicit ctx : Context ): TypeVar = {
509
514
val poly = PolyType (DepParamName .fresh().toTypeName :: Nil )(
0 commit comments