From 098e4d0f1f8bad187c4f350fac11d5d60589c167 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Fri, 2 Aug 2024 20:00:30 +0200 Subject: [PATCH] Add Select.copy with symbol in Quotes --- compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala | 3 +++ library/src/scala/quoted/Quotes.scala | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index ce8d19aae46a..7d851947fb16 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -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 diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index d048d8d728d5..0206ff26bc7f 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -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 `.` */ def unapply(x: Select): (Term, String) } @@ -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) =>