Skip to content

Commit

Permalink
Fix #20458: do not expose ClassInfo in quotes reflect widenTermRefByN…
Browse files Browse the repository at this point in the history
…ame (#20468)
  • Loading branch information
hamzaremmal authored Jul 1, 2024
2 parents 771d1db + 5009065 commit 3d16f33
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 @@ -1811,7 +1811,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 dealiasKeepOpaques: TypeRepr = self.dealiasKeepOpaques
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 3d16f33

Please sign in to comment.