Skip to content

Commit f744a13

Browse files
committed
Fix debug print of QuoteMatcher to work on match failure
1 parent 9f15be2 commit f744a13

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ object QuoteMatcher {
234234
case _ => None
235235
end TypeTreeTypeTest
236236

237-
val res = pattern match
237+
def runMatch (): optional[MatchingExprs] = pattern match
238238

239239
/* Term hole */
240240
// Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
@@ -463,24 +463,32 @@ object QuoteMatcher {
463463
// No Match
464464
case _ =>
465465
notMatched
466+
end runMatch
467+
468+
if (debug)
469+
try {
470+
runMatch()
471+
} catch {
472+
case e: util.boundary.Break[?] =>
473+
val quotes = QuotesImpl()
474+
println(
475+
s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
476+
|Scrutinee
477+
| ${scrutinee.show}
478+
|did not match pattern
479+
| ${pattern.show}
480+
|
481+
|with environment: ${summon[Env]}
482+
|
483+
|Scrutinee: ${quotes.reflect.Printer.TreeStructure.show(scrutinee.asInstanceOf)}
484+
|Pattern: ${quotes.reflect.Printer.TreeStructure.show(pattern.asInstanceOf)}
485+
|
486+
|""".stripMargin)
487+
throw e
488+
}
489+
else
490+
runMatch()
466491

467-
if (debug && res == notMatched)
468-
val quotes = QuotesImpl()
469-
println(
470-
s""">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
471-
|Scrutinee
472-
| ${scrutinee.show}
473-
|did not match pattern
474-
| ${pattern.show}
475-
|
476-
|with environment: ${summon[Env]}
477-
|
478-
|Scrutinee: ${quotes.reflect.Printer.TreeStructure.show(scrutinee.asInstanceOf)}
479-
|Pattern: ${quotes.reflect.Printer.TreeStructure.show(pattern.asInstanceOf)}
480-
|
481-
|""".stripMargin)
482-
483-
res
484492
end =?=
485493

486494
end extension

0 commit comments

Comments
 (0)