Skip to content

Commit 480cb8d

Browse files
committed
subtype check instead constrainResult
1 parent b91ad9b commit 480cb8d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,32 +4265,25 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
42654265
)
42664266
case _ =>
42674267
mapOver(t)
4268-
val ownedVars = ctx.typerState.ownedVars
4269-
def qualifying = (ownedVars -- locked).toList
42704268
val resultAlreadyConstrained = pt1.isInstanceOf[MethodOrPoly]
42714269
if !formal.isGround
42724270
&& (formal.simplified `ne` formal)
42734271
&& (pt1 `ne` pt)
42744272
&& (pt1 ne sharpenedPt)
4275-
&& (ownedVars ne locked)
4276-
&& !ownedVars.isEmpty
4277-
&& qualifying.nonEmpty
42784273
&& !resultAlreadyConstrained then
42794274
val approxRes = wildApprox(pt1.resultType)
42804275
val stripedApproxRes = tm(approxRes)
42814276
if !stripedApproxRes.containsWildcardTypes then
4282-
if ctx.typerState.isCommittable then
4283-
return NoViewsAllowed.constrainResult(tree.symbol, wtp.resultType, stripedApproxRes)
4284-
else return constrainResult(tree.symbol, wtp.resultType, stripedApproxRes)
4277+
return wtp.resultType <:< stripedApproxRes
42854278
false
42864279
}
42874280

42884281
val pt1 = pt.deepenProtoTrans
4289-
val isConstrained = tryConstrainType(pt1)
4282+
tryConstrainType(pt1)
42904283
val arg = inferImplicitArg(formal, tree.span.endPos)
42914284
arg.tpe match
42924285
case failed: AmbiguousImplicits =>
4293-
if !isConstrained && (pt1 `ne` pt) && (pt1 ne sharpenedPt) && constrainResult(tree.symbol, wtp, pt1)
4286+
if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && constrainResult(tree.symbol, wtp, pt1)
42944287
then implicitArgs(formals, argIndex, pt)
42954288
else arg :: implicitArgs(formals1, argIndex + 1, pt)
42964289
case failed: SearchFailureType =>

0 commit comments

Comments
 (0)