@@ -84,6 +84,14 @@ object Typer {
8484 */
8585 private [typer] val HiddenSearchFailure = new Property .Key [List [SearchFailure ]]
8686
87+ /** Is tree a compiler-generated `.apply` node that refers to the
88+ * apply of a function class?
89+ */
90+ private [typer] def isSyntheticApply (tree : tpd.Tree ): Boolean = tree match {
91+ case tree : tpd.Select => tree.hasAttachment(InsertedApply )
92+ case _ => false
93+ }
94+
8795 /** Add `fail` to the list of search failures attached to `tree` */
8896 def rememberSearchFailure (tree : tpd.Tree , fail : SearchFailure ) =
8997 tree.putAttachment(HiddenSearchFailure ,
@@ -2843,11 +2851,6 @@ class Typer extends Namer
28432851 case _ => false
28442852 }
28452853
2846- def isSyntheticApply (tree : Tree ): Boolean = tree match {
2847- case tree : Select => tree.hasAttachment(InsertedApply )
2848- case _ => false
2849- }
2850-
28512854 def tryApply (using Context ) = {
28522855 val pt1 = pt.withContext(ctx)
28532856 val sel = typedSelect(untpd.Select (untpd.TypedSplice (tree), nme.apply), pt1)
@@ -3281,7 +3284,8 @@ class Typer extends Namer
32813284 ! ctx.isAfterTyper &&
32823285 ! ctx.isInlineContext) {
32833286 typr.println(i " insert apply on implicit $tree" )
3284- typed(untpd.Select (untpd.TypedSplice (tree), nme.apply), pt, locked)
3287+ val sel = untpd.Select (untpd.TypedSplice (tree), nme.apply).withAttachment(InsertedApply , ())
3288+ try typed(sel, pt, locked) finally sel.removeAttachment(InsertedApply )
32853289 }
32863290 else if (ctx.mode is Mode .Pattern ) {
32873291 checkEqualityEvidence(tree, pt)
0 commit comments