@@ -3850,22 +3850,29 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3850
3850
3851
3851
val args = implicitArgs(wtp.paramInfos, 0 , pt)
3852
3852
3853
- def issueErrors (failingArgs : List [Tree ]): Tree = {
3854
- val firstNonAmbiguous = failingArgs.tpes.find(tp => tp.isError && ! tp.isInstanceOf [AmbiguousImplicits ])
3855
- def firstError = failingArgs.tpes.find(_.isError)
3856
- val propFail = firstNonAmbiguous.orElse(firstError).getOrElse(NoType )
3857
-
3858
- def paramSymWithMethodTree (paramName : TermName ) =
3853
+ def issueErrors (): Tree = {
3854
+ val paramSyms =
3859
3855
if tree.symbol.exists then
3860
3856
tree.symbol.paramSymss.flatten
3861
3857
.map(sym => sym.name -> sym)
3862
3858
.toMap
3863
- .get(paramName)
3864
- .map((_, tree))
3865
3859
else
3866
- None
3860
+ Map .empty
3861
+
3862
+ def paramSymWithMethodTree (paramName : TermName ) = paramSyms.get(paramName).map((_, tree))
3863
+ def paramHasDefault (paramName : TermName ) = paramSyms.get(paramName).map(_.is(HasDefault )).getOrElse(false )
3864
+
3865
+ val nonDefaultArgs : List [Tree ] =
3866
+ wtp.paramNames
3867
+ .lazyZip(args)
3868
+ .filter((paramName, arg) => ! paramHasDefault(paramName))
3869
+ .map(((paramName, arg) => arg))
3870
+
3871
+ var firstNonAmbiguous = nonDefaultArgs.tpes.find(tp => tp.isError && ! tp.isInstanceOf [AmbiguousImplicits ])
3872
+ def firstError = nonDefaultArgs.tpes.find(_.isError)
3873
+ val propFail : Type = firstNonAmbiguous.orElse(firstError).getOrElse(NoType )
3867
3874
3868
- wtp.paramNames.lazyZip(wtp.paramInfos).lazyZip(failingArgs ).foreach { (paramName, formal, arg) =>
3875
+ wtp.paramNames.lazyZip(wtp.paramInfos).lazyZip(nonDefaultArgs ).foreach { (paramName, formal, arg) =>
3869
3876
arg.tpe match {
3870
3877
case failure : SearchFailureType =>
3871
3878
report.error(
@@ -3875,7 +3882,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3875
3882
case _ =>
3876
3883
}
3877
3884
}
3878
- untpd.Apply (tree, failingArgs ).withType(propFail)
3885
+ untpd.Apply (tree, args ).withType(propFail)
3879
3886
}
3880
3887
3881
3888
if (args.tpes.exists(_.isError)) {
@@ -3890,19 +3897,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3890
3897
// implicits are passed as named args.
3891
3898
if hasDefaultParams then
3892
3899
val namedArgs = wtp.paramNames.lazyZip(args).flatMap { (pname, arg) =>
3893
- if arg.tpe.isInstanceOf [NoMatchingImplicits ] then Nil
3894
- else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
3900
+ if arg.tpe.isError then Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
3895
3901
}
3896
3902
val app = cpy.Apply (tree)(untpd.TypedSplice (tree), namedArgs)
3897
3903
val needsUsing = wtp.isContextualMethod || wtp.match
3898
3904
case MethodType (ContextBoundParamName (_) :: _) => sourceVersion.isAtLeast(`3.4`)
3899
3905
case _ => false
3900
3906
if needsUsing then app.setApplyKind(ApplyKind .Using )
3901
3907
typr.println(i " try with default implicit args $app" )
3902
- val tpdApply @ Apply (_, args1) = typed(app, pt, locked): @ unchecked
3903
- println(" tpdApply.tpe " + tpdApply.tpe)
3904
- if tpdApply.tpe.isError then issueErrors(args1) else tpdApply
3905
- else issueErrors(args)
3908
+ val tpdApply = typed(app, pt, locked)
3909
+ if tpdApply.tpe.isError then issueErrors() else tpdApply
3910
+ else issueErrors()
3906
3911
}
3907
3912
else tree match {
3908
3913
case tree : Block =>
0 commit comments