@@ -427,7 +427,7 @@ object ProtoTypes {
427
427
* - t2 is a ascription (t22: T) and t1 is at the outside of t22
428
428
* - t2 is a closure (...) => t22 and t1 is at the outside of t22
429
429
*/
430
- def hasInnerErrors (t : Tree , argType : Option [ Type ] )(using Context ): Boolean = t match
430
+ def hasInnerErrors (t : Tree , argType : Type )(using Context ): Boolean = t match
431
431
case Typed (expr, tpe) => hasInnerErrors(expr, argType)
432
432
case closureDef(mdef) => hasInnerErrors(mdef.rhs, argType)
433
433
case _ =>
@@ -438,14 +438,17 @@ object ProtoTypes {
438
438
typr.println(i " error subtree $t1 of $t with ${t1.typeOpt}, spans = ${t1.span}, ${t.span}" )
439
439
t1.typeOpt match
440
440
case errorType : ErrorType if errorType.msg.isInstanceOf [TypeMismatchMsg ] =>
441
+ // if error is caused by an argument type mismatch,
442
+ // then return false to try to find an extension.
443
+ // see i20335.scala for test case.
441
444
val typeMismtachMsg = errorType.msg.asInstanceOf [TypeMismatchMsg ]
442
- ! argType.contains( typeMismtachMsg.expected)
445
+ argType != typeMismtachMsg.expected
443
446
case _ => true
444
447
else
445
448
false
446
449
}
447
450
448
- private def cacheTypedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree , force : Boolean , argType : Option [ Type ] )(using Context ): Tree = {
451
+ private def cacheTypedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree , force : Boolean , argType : Type )(using Context ): Tree = {
449
452
var targ = state.typedArg(arg)
450
453
if (targ == null )
451
454
untpd.functionWithUnknownParamType(arg) match {
@@ -491,7 +494,7 @@ object ProtoTypes {
491
494
val protoTyperState = ctx.typerState
492
495
val oldConstraint = protoTyperState.constraint
493
496
val args1 = args.mapWithIndexConserve((arg, idx) =>
494
- cacheTypedArg(arg, arg => typer.typed(norm(arg, idx)), force = false , None ))
497
+ cacheTypedArg(arg, arg => typer.typed(norm(arg, idx)), force = false , NoType ))
495
498
val newConstraint = protoTyperState.constraint
496
499
497
500
if ! args1.exists(arg => isUndefined(arg.tpe)) then state.typedArgs = args1
@@ -539,7 +542,7 @@ object ProtoTypes {
539
542
val targ = cacheTypedArg(arg,
540
543
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
541
544
force = true ,
542
- Some ( wideFormal) )
545
+ wideFormal)
543
546
val targ1 = typer.adapt(targ, wideFormal, locked)
544
547
if wideFormal eq formal then targ1
545
548
else checkNoWildcardCaptureForCBN(targ1)
0 commit comments