Skip to content

Commit

Permalink
Backport "Fix #20458: do not expose ClassInfo in quotes reflect widen…
Browse files Browse the repository at this point in the history
…TermRefByName" to LTS (#21152)

Backports #20468 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 10, 2024
2 parents 5310094 + 680b045 commit c192315
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
def =:=(that: TypeRepr): Boolean = self =:= that
def <:<(that: TypeRepr): Boolean = self <:< that
def widen: TypeRepr = self.widen
def widenTermRefByName: TypeRepr = self.widenTermRefExpr
def widenTermRefByName: TypeRepr =
self.widenTermRefExpr match
case dotc.core.Types.ClassInfo(prefix, sym, _, _, _) => prefix.select(sym)
case other => other
def widenByName: TypeRepr = self.widenExpr
def dealias: TypeRepr = self.dealias
def simplified: TypeRepr = self.simplified
Expand Down
12 changes: 12 additions & 0 deletions tests/pos-macros/i20458/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import scala.quoted._

inline def matchCustom[F](): Unit = ${ matchCustomImpl[F] }

private def matchCustomImpl[F: Type](using q: Quotes): Expr[Unit] = {
import q.reflect.*
val any = TypeRepr.of[Any].typeSymbol
assert(!any.termRef.widenTermRefByName.toString.contains("ClassInfo"))
any.termRef.widenTermRefByName.asType match
case '[t] => ()
'{ () }
}
1 change: 1 addition & 0 deletions tests/pos-macros/i20458/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def main() = matchCustom()

0 comments on commit c192315

Please sign in to comment.