Skip to content

Commit 8f3b3c2

Browse files
authored
Backport #17615 (#17749)
Backport #17615 Fixes #17606
2 parents dfb23f9 + 8f01927 commit 8f3b3c2

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ object QuoteMatcher {
301301
/* Match new */
302302
case New(tpt1) =>
303303
pattern match
304-
case New(tpt2) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol => matched
304+
case New(tpt2) if tpt1.tpe.dealias.typeSymbol == tpt2.tpe.dealias.typeSymbol => matched
305305
case _ => notMatched
306306

307307
/* Match this */
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example
2+
3+
import scala.quoted.*
4+
5+
object A {
6+
inline def f(inline a: Any): Boolean = ${ impl('a) }
7+
8+
def impl(a: Expr[Any])(using Quotes): Expr[Boolean] = {
9+
a match {
10+
case '{ new String($x: Array[Byte]) } => Expr(true)
11+
case _ => quotes.reflect.report.errorAndAbort("Expected match", a)
12+
}
13+
}
14+
}

tests/pos-macros/i17606/Test_2.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package example
2+
3+
object Main {
4+
def main(args: Array[String]): Unit = {
5+
val x = A.f(new String(Array.empty[Byte]))
6+
println(x)
7+
}
8+
}

0 commit comments

Comments
 (0)