@@ -3192,12 +3192,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
31923192 case _ => false
31933193 }
31943194
3195+ var assumeApplyExists = false
3196+ // if true, issue any errors about the apply instead of `fallBack`,
3197+ // since they are more likely to be informative.
3198+
31953199 def tryApply (using Context ) = {
31963200 val pt1 = pt.withContext(ctx)
31973201 val sel = typedSelect(untpd.Select (untpd.TypedSplice (tree), nme.apply), pt1)
31983202 .withAttachment(InsertedApply , ())
3199- if (sel.tpe.isError) sel
3200- else try adapt(simplify(sel, pt1, locked), pt1, locked) finally sel.removeAttachment(InsertedApply )
3203+ if sel.tpe.isError then
3204+ // assume the apply exists if qualifier has a hidden search failure of type
3205+ // FailedExtension or NestedFailure
3206+ sel match
3207+ case Select (qual, _) =>
3208+ assumeApplyExists = qual.getAttachment(Typer .HiddenSearchFailure ).exists(
3209+ _.exists(_.reason.isInstanceOf [FailedExtension | NestedFailure ]))
3210+ case _ =>
3211+ sel
3212+ else
3213+ assumeApplyExists = true
3214+ try adapt(simplify(sel, pt1, locked), pt1, locked) finally sel.removeAttachment(InsertedApply )
32013215 }
32023216
32033217 def tryImplicit (fallBack : => Tree ) =
@@ -3217,11 +3231,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
32173231 if (isApplyProto(pt) || isMethod(tree) || isSyntheticApply(tree)) tryImplicit(fallBack)
32183232 else tryEither(tryApply) { (app, appState) =>
32193233 tryImplicit {
3220- if (tree.tpe.member(nme.apply).exists) {
3221- // issue the error about the apply, since it is likely more informative than the fallback
3234+ if assumeApplyExists then
32223235 appState.commit()
32233236 app
3224- }
32253237 else fallBack
32263238 }
32273239 }
0 commit comments