Skip to content

Commit

Permalink
Add Select.copy with symbol in Quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Aug 2, 2024
1 parent 1809917 commit 098e4d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
withDefaultPos(tpd.applyOverloaded(qualifier, name.toTermName, args, targs, returnType))
def copy(original: Tree)(qualifier: Term, name: String): Select =
tpd.cpy.Select(original)(qualifier, name.toTermName)

def copy(original: Tree)(qualifier: Term, sym: Symbol): Select =
tpd.cpy.Select(original)(qualifier, sym.name)
def unapply(x: Select): (Term, String) =
(x.qualifier, x.name.toString)
end Select
Expand Down
4 changes: 3 additions & 1 deletion library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>

def copy(original: Tree)(qualifier: Term, name: String): Select

def copy(original: Tree)(qualifier: Term, sym: Symbol): Select

/** Matches `<qualifier: Term>.<name: String>` */
def unapply(x: Select): (Term, String)
}
Expand Down Expand Up @@ -5083,7 +5085,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
case Ident(name) =>
tree
case Select(qualifier, name) =>
Select.copy(tree)(transformTerm(qualifier)(owner), name)
Select.copy(tree)(transformTerm(qualifier)(owner), tree.symbol)
case This(qual) =>
tree
case Super(qual, mix) =>
Expand Down

0 comments on commit 098e4d0

Please sign in to comment.