@@ -4250,33 +4250,38 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4250
4250
else formals1
4251
4251
implicitArgs(formals2, argIndex + 1 , pt)
4252
4252
4253
- val ownedVars = ctx.typerState.ownedVars
4254
- val pt1 = pt.deepenProtoTrans
4255
- if ((! formal.isGround) && (formal.simplified `ne` formal) && (pt1 `ne` pt) && (pt1 ne sharpenedPt) && (ownedVars ne locked) && ! ownedVars.isEmpty) {
4253
+ def tryConstrainType (pt1 : Type ): Boolean = {
4254
+ val ownedVars = ctx.typerState.ownedVars
4256
4255
val qualifying = (ownedVars -- locked).toList
4257
- if (qualifying.nonEmpty) {
4256
+ if ((pt1 `ne` pt) && (pt1 ne sharpenedPt) && (ownedVars ne locked) && ! ownedVars.isEmpty && qualifying.nonEmpty) {
4258
4257
val approxRes = wildApprox(pt1.resultType)
4259
4258
val tm = new TypeMap :
4260
4259
def apply (t : Type ) = t match
4261
4260
case fp@ FunProto (args, resType) =>
4262
4261
fp.derivedFunProto(
4263
4262
args.map(arg =>
4264
- if (arg.isInstanceOf [untpd.TypedSplice ]) arg
4263
+ if (arg.isInstanceOf [untpd.TypedSplice ]) arg
4265
4264
else dummyArg(arg.typeOpt).withSpan(arg.span)
4266
4265
),
4267
4266
mapOver(resType)
4268
4267
)
4269
4268
case _ =>
4270
4269
mapOver(t)
4271
4270
val stripedApproxRes = tm(approxRes)
4272
- val resultAlreadyConstrained = pt1.isInstanceOf [MethodOrPoly ]
4273
- if (! resultAlreadyConstrained && ! stripedApproxRes.containsWildcardTypes) {
4271
+ if (! stripedApproxRes.containsWildcardTypes) {
4274
4272
if ctx.typerState.isCommittable then
4275
4273
NoViewsAllowed .constrainResult(tree.symbol, wtp.resultType, stripedApproxRes)
4276
4274
else constrainResult(tree.symbol, wtp.resultType, stripedApproxRes)
4275
+ } else {
4276
+ false
4277
4277
}
4278
+ } else {
4279
+ false
4278
4280
}
4279
4281
}
4282
+
4283
+ val pt1 = pt.deepenProtoTrans
4284
+ tryConstrainType(pt1)
4280
4285
val arg = inferImplicitArg(formal, tree.span.endPos)
4281
4286
arg.tpe match
4282
4287
case failed : AmbiguousImplicits =>
0 commit comments