-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Quoted match on an exported definition? (matching the "original" definition) #12959
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
Comments
Note that this is a serious issue. If you have dozens of functions defined in the For this: object Dsl:
def stuff: String = ???
def otherStuff: String = ???
def otherOtherStuff: String = ??? Need to do this: any match
case '{ Dsl.stuff } => println("Matched!")
case '{ Dsl.otherStuff } => println("Matched!")
case '{ Dsl.otherOtherStuff } => println("Matched!")
case '{ stuff } => println("Matched!")
case '{ otherStuff } => println("Matched!")
case '{ otherOtherStuff } => println("Matched!") |
exports create forwarder methods, so |
@bishabosha However you choose to classify it, this is still a significant problem. It basically means that quoted-dsls can never be exported unless the writer of the parser is willing to reproduce all of the match-clauses over and over again (let alone the fact that this behavior is extremely unintuitive). |
We already have some de-virtualisation for overridden methods in quotes, so it could be worth exploring (following exports to their original definition) @nicolasstucki ? currently there is no efficient compiler machinery for this but it is possible to implement your own reverse map for exported definitions by checking for a symbol ref, where that ref has the |
I think that touches quoting more than exports. Should patterns in quotes be able to see through aliases? I am not sure about this. |
@odersky If quoted patterns won't see through aliases, it essentially makes Heh, maybe there should be a |
Compiler version
Latest Nightly:
scala-3.0.2-RC1-bin-20210626-f33bc8d-NIGHTLY
Minimized code
Create a global function in a namespace (e.g.
Dsl
). Then export it:Then make a quoted-match clause to match it:
Then use the macro to match it based on the export:
It will not match.
Output
The clause does not match i.e.
Did not match
is printed.Expectation
The clause should match the exported symbol.
Repo
Example code can be found here:
https://github.com/deusaquilus/export_match_issue
The text was updated successfully, but these errors were encountered: