Skip to content

Commit 8c798e2

Browse files
committed
Fix #7060: Make single-parameter constrained more versatile
1 parent c9d2f34 commit 8c798e2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ object ProtoTypes {
483483
val state = ctx.typerState
484484
val addTypeVars = alwaysAddTypeVars || !owningTree.isEmpty
485485
if (tl.isInstanceOf[PolyType])
486-
assert(!(ctx.typerState.isCommittable && !addTypeVars),
486+
assert(!ctx.typerState.isCommittable || addTypeVars,
487487
s"inconsistent: no typevars were added to committable constraint ${state.constraint}")
488488
// hk type lambdas can be added to constraints without typevars during match reduction
489489

@@ -502,8 +502,8 @@ object ProtoTypes {
502502
(added, tvars)
503503
}
504504

505-
/** 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
505+
def constrained(tl: TypeLambda)(implicit ctx: Context): TypeLambda =
506+
constrained(tl, EmptyTree, alwaysAddTypeVars = ctx.typerState.isCommittable)._1
507507

508508
def newTypeVar(bounds: TypeBounds)(implicit ctx: Context): TypeVar = {
509509
val poly = PolyType(DepParamName.fresh().toTypeName :: Nil)(

0 commit comments

Comments
 (0)