@@ -54,6 +54,7 @@ import transform.CheckUnused.OriginalName
54
54
import scala .annotation .{unchecked as _ , * }
55
55
import dotty .tools .dotc .util .chaining .*
56
56
import dotty .tools .dotc .ast .untpd .Mod
57
+ import dotty .tools .dotc .reporting .Reporter .NoReporter
57
58
58
59
object Typer {
59
60
@@ -4357,24 +4358,22 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4357
4358
else formals1
4358
4359
implicitArgs(formals2, argIndex + 1 , pt)
4359
4360
4361
+
4362
+ def doesntContainsWildcards = {
4363
+ val newCtx = ctx.fresh.setNewScope.setReporter(new reporting.ThrowingReporter (NoReporter ))
4364
+ val pt1 = pt.deepenProtoTrans(using newCtx)
4365
+ try {
4366
+ ! pt1.containsWildcardTypes(using newCtx)
4367
+ } catch {
4368
+ case _ : UnhandledError => false
4369
+ }
4370
+ }
4360
4371
val pt1 = pt.deepenProtoTrans
4361
- val approxPt = withMode(Mode .TypevarsMissContext ):
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) || tvar.instanceOpt.isInstanceOf [TypeVar ]
4368
- tvar
4369
- case _ =>
4370
- if formalConstrained then t
4371
- else mapOver(t)
4372
- tm(formal)
4373
4372
if (pt1 `ne` pt)
4374
4373
&& (pt1 ne sharpenedPt)
4375
- && ( AvoidWildcardsMap ()(approxPt) `eq` approxPt)
4374
+ && formal.typeSymbol != defn. ClassTagClass
4376
4375
&& ! isFullyDefined(formal, ForceDegree .none)
4377
- && ! formalConstrained then
4376
+ && doesntContainsWildcards then
4378
4377
constrainResult(tree.symbol, wtp, pt1)
4379
4378
val arg = inferImplicitArg(formal, tree.span.endPos)
4380
4379
0 commit comments