File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4360,10 +4360,22 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4360
4360
val pt1 = pt.deepenProtoTrans
4361
4361
val approxPt = withMode(Mode .TypevarsMissContext ):
4362
4362
wildApprox(pt1)
4363
+ var formalConstrained = false
4364
+ val tm = new TypeMap :
4365
+ def apply (t : Type ): Type = t match
4366
+ case tvar : TypeVar =>
4367
+ formalConstrained |= ctx.typerState.constraint.contains(tvar)
4368
+ val inst = tvar.instanceOpt
4369
+ if (inst.exists && ! formalConstrained) mapOver(inst) else tvar
4370
+ case _ =>
4371
+ if formalConstrained then t
4372
+ else mapOver(t)
4373
+ tm(formal)
4363
4374
if (pt1 `ne` pt)
4364
4375
&& (pt1 ne sharpenedPt)
4365
4376
&& (AvoidWildcardsMap ()(approxPt) `eq` approxPt)
4366
- && ! isFullyDefined(formal, ForceDegree .none) then
4377
+ && ! isFullyDefined(formal, ForceDegree .none)
4378
+ && ! formalConstrained then
4367
4379
constrainResult(tree.symbol, wtp, pt1)
4368
4380
val arg = inferImplicitArg(formal, tree.span.endPos)
4369
4381
You can’t perform that action at this time.
0 commit comments