@@ -60,6 +60,7 @@ object Typer {
60
60
assert(tree.pos.exists, s " position not set for $tree # ${tree.uniqueId}" )
61
61
62
62
private val ExprOwner = new Property .Key [Symbol ]
63
+ private val InsertedApply = new Property .Key [Unit ]
63
64
}
64
65
65
66
class Typer extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking with Docstrings {
@@ -1818,9 +1819,17 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1818
1819
*/
1819
1820
def tryInsertApplyOrImplicit (tree : Tree , pt : ProtoType )(fallBack : => Tree )(implicit ctx : Context ): Tree = {
1820
1821
1822
+ def isSyntheticApply (tree : Tree ): Boolean = tree match {
1823
+ case tree : Select => tree.getAttachment(InsertedApply ).isDefined
1824
+ case Apply (fn, _) => fn.getAttachment(InsertedApply ).isDefined
1825
+ case _ => false
1826
+ }
1827
+
1821
1828
def tryApply (implicit ctx : Context ) = {
1822
1829
val sel = typedSelect(untpd.Select (untpd.TypedSplice (tree), nme.apply), pt)
1823
- if (sel.tpe.isError) sel else adapt(sel, pt)
1830
+ sel.pushAttachment(InsertedApply , ())
1831
+ if (sel.tpe.isError) sel
1832
+ else try adapt(sel, pt) finally sel.removeAttachment(InsertedApply )
1824
1833
}
1825
1834
1826
1835
def tryImplicit =
@@ -1832,7 +1841,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1832
1841
pt.markAsDropped()
1833
1842
tree
1834
1843
case _ =>
1835
- if (isApplyProto(pt)) tryImplicit
1844
+ if (isApplyProto(pt) || isSyntheticApply(tree) ) tryImplicit
1836
1845
else tryEither(tryApply(_))((_, _) => tryImplicit)
1837
1846
}
1838
1847
}
0 commit comments