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
43604360 val pt1 = pt.deepenProtoTrans
43614361 val approxPt = withMode(Mode .TypevarsMissContext ):
43624362 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)
43634374 if (pt1 `ne` pt)
43644375 && (pt1 ne sharpenedPt)
43654376 && (AvoidWildcardsMap ()(approxPt) `eq` approxPt)
4366- && ! isFullyDefined(formal, ForceDegree .none) then
4377+ && ! isFullyDefined(formal, ForceDegree .none)
4378+ && ! formalConstrained then
43674379 constrainResult(tree.symbol, wtp, pt1)
43684380 val arg = inferImplicitArg(formal, tree.span.endPos)
43694381
You can’t perform that action at this time.
0 commit comments