-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix debug print of QuoteMatcher to work on match failure #18023
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
Fix debug print of QuoteMatcher to work on match failure #18023
Conversation
We could enable debugging using a - private inline val debug = false
+ private val debug = ctx.settings.YdebugMacros.value and add |
4ce87d9
to
8100200
Compare
The test failed due to #18033. We need to wait until this PR is merged to re-test. |
00e85aa
to
9e379d1
Compare
Still requires the private val debug = ctx.settings.YdebugMacros.value |
For this, where can we get private val debug = ctx.settings.YdebugMacros.value |
I overlooked that. We could make this change. - object QuoteMatcher:
+ class QuoteMatcher(debug: Boolean): And then, create the quote matcher using |
I made a change so that QuoteMatcher hold a value for debug print f744a13. Does it look good to you? @nicolasstucki |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
|
||
extension [T](self: scala.quoted.Expr[T]) | ||
def show: String = | ||
reflect.Printer.TreeCode.show(reflect.asTerm(self)) | ||
|
||
def matches(that: scala.quoted.Expr[Any]): Boolean = | ||
QuoteMatcher.treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty | ||
quoteMatcher.treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quoteMatcher.treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty | |
QuoteMatcher(yDebugMacros).treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, can I ask the reason for this change? Is it the case where creating QuoteMatcher
instance for each method call is not very costful?
This compiler option shows debug information when quote pattern matching fails. This commmit also fix a bug of current imiplementation of debug print
9729d35
to
be0c98a
Compare
Thank you! I've applied your suggestions and made a squashed commit. |
The current logic of debug print in
QuoteMatcher
is intended to show debug information when a pattern match fails. However, it does not work becausenotMatched
invokes a global escape that skips debug-print logic.This PR proposes to catch global escape when
debug=1
and show debug information.