Skip to content

Commit 3423cc1

Browse files
committed
Refactor isSyntheticApply: use the same logic for consistency
1 parent c0dcd9b commit 3423cc1

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
560560
case _ => false
561561
}
562562

563-
/** Is tree a compiler-generated `.apply` node that refers to the
564-
* apply of a function class?
565-
*/
566-
def isSyntheticApply(tree: Tree): Boolean = tree match {
567-
case Select(qual, nme.apply) => tree.span.end == qual.span.end
568-
case _ => false
569-
}
570-
571563
/** Strips layers of `.asInstanceOf[T]` / `_.$asInstanceOf[T]()` from an expression */
572564
def stripCast(tree: Tree)(implicit ctx: Context): Tree = {
573565
def isCast(sel: Tree) = sel.symbol.isTypeCast

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ object Typer {
7777
* search was tried on a tree. This will in some cases be reported in error messages
7878
*/
7979
private[typer] val HiddenSearchFailure = new Property.Key[SearchFailure]
80+
81+
/** Is tree a compiler-generated `.apply` node that refers to the
82+
* apply of a function class?
83+
*/
84+
private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match {
85+
case tree: tpd.Select => tree.hasAttachment(InsertedApply)
86+
case _ => false
87+
}
8088
}
8189

8290

@@ -2354,11 +2362,6 @@ class Typer extends Namer
23542362
case _ => false
23552363
}
23562364

2357-
def isSyntheticApply(tree: Tree): Boolean = tree match {
2358-
case tree: Select => tree.hasAttachment(InsertedApply)
2359-
case _ => false
2360-
}
2361-
23622365
def tryApply(implicit ctx: Context) = {
23632366
val pt1 = pt.withContext(ctx)
23642367
val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt1)
@@ -2728,7 +2731,8 @@ class Typer extends Namer
27282731
!ctx.isAfterTyper &&
27292732
!ctx.isInlineContext) {
27302733
typr.println(i"insert apply on implicit $tree")
2731-
typed(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt, locked)
2734+
val sel = untpd.Select(untpd.TypedSplice(tree), nme.apply).withAttachment(InsertedApply, ())
2735+
try typed(sel, pt, locked) finally sel.removeAttachment(InsertedApply)
27322736
}
27332737
else if (ctx.mode is Mode.Pattern) {
27342738
checkEqualityEvidence(tree, pt)

0 commit comments

Comments
 (0)