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
Quoted matching on imported method causes tuple class-cast exception #8745
Comments
I would like to add that this issue is very relevant to Quill because for things like query schemas, the following pattern is typically used: import QuotationContext._
quote {
querySchema[Table]("tableName", /*... */)
} In this case, |
It is interesting to note that this problem only occurs when importing from a companion. Instantiating the trait directly and then importing the methods, it will work: val inst = new Trait {}
import inst._
mac(fun("blah")) // Matching works! Also, there seems to be a curious workaround. If you write the companion object into a val comp = Companion
import comp._
mac(fun("blah")) This is very odd but will at least let me make progress for now. Definitely won't suffice for Quill users though. @nicolasstucki @liufengyun FYI, this is the only blocking issue I have at the moment, I've got a decent workaround for everything else. |
I was curious to see what happens if you use object Companion {
def fun(first: String): String = "anything"
} Matching against this: case vv @ '{ ($s: Companion.type).fun($arg) } => using this: import Companion._
mac(fun("blah")) This also causes the same:
|
We were ignoring the thee prefix when the scrutinee did not mention it explicitly in the tree. I will add a regression test for that one. |
Fix #8745: Match Ident prefixes to find potential holes
Minimized code
Let's say I have a trait with a method extended by a companion:
Then I try to match this code in a macro:
When invoking the macro with the
Companion
as an import:The following compiler error occurs:
Expectation
The code should compile and the match should work.
Code Sample
Full code sample can be found here:
https://github.com/deusaquilus/companion_bug
The text was updated successfully, but these errors were encountered: