Skip to content

Commit 454284f

Browse files
committed
Handle this prefix in objects (in quote patterns)
Fix #14536
1 parent 347a730 commit 454284f

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler/src/scala/quoted/runtime/impl/QuoteMatcher.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ object QuoteMatcher {
247247
case ref: Ident =>
248248
ref.tpe match
249249
case TermRef(qual: TermRef, _) => tpd.ref(qual) =?= qual2
250+
case TermRef(qual: ThisType, _) if qual.classSymbol.is(Module) =>
251+
tpd.ref(ref.symbol) =?= pattern
250252
case _ => matched
251253
/* Match reference */
252254
case _: Ident if symbolMatch(scrutinee, pattern) => matched

tests/pos-macros/i14536/Macro_1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import quoted.*
2+
3+
inline def isFoo(inline x: Any): Boolean = ${ isFooImpl('x) }
4+
5+
def isFooImpl(x: Expr[Any])(using Quotes): Expr[Boolean] =
6+
x match
7+
case '{ ($p: Parent).foo } => '{ true }
8+
case _ => '{ false }
9+
10+
trait Parent:
11+
def foo = 0

tests/pos-macros/i14536/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
object Child extends Parent:
2+
def bar = isFoo(foo)

0 commit comments

Comments
 (0)