Skip to content

Commit f8e88ac

Browse files
committed
Fix debug print of QuoteMatcher to work on match failure
1 parent 7a683ab commit f8e88ac

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

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

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

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

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

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
484493
end =?=
485494

486495
end extension

0 commit comments

Comments
 (0)