Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #17615 #17749

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/scala/quoted/runtime/impl/QuoteMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ object QuoteMatcher {
/* Match new */
case New(tpt1) =>
pattern match
case New(tpt2) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol => matched
case New(tpt2) if tpt1.tpe.dealias.typeSymbol == tpt2.tpe.dealias.typeSymbol => matched
case _ => notMatched

/* Match this */
Expand Down
14 changes: 14 additions & 0 deletions tests/pos-macros/i17606/Macros_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package example

import scala.quoted.*

object A {
inline def f(inline a: Any): Boolean = ${ impl('a) }

def impl(a: Expr[Any])(using Quotes): Expr[Boolean] = {
a match {
case '{ new String($x: Array[Byte]) } => Expr(true)
case _ => quotes.reflect.report.errorAndAbort("Expected match", a)
}
}
}
8 changes: 8 additions & 0 deletions tests/pos-macros/i17606/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example

object Main {
def main(args: Array[String]): Unit = {
val x = A.f(new String(Array.empty[Byte]))
println(x)
}
}