-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MethodHandle invoke does not play well with macros #17079
Comments
This example is a bit long, mainly to show my attempts using compile-time reflection. In theory though, this should work with fn2 at least, and that is a much simpler example of the problem. |
@markehammons how exactly do you run these snippets? import scala.util.Try
object Test:
Try(FnTest.fn3()).recover(t => println(t.getMessage()))
Try(FnTest.fn2()).recover(t => println(t.getMessage()))
Try(FnTest.fn()).recover(t => println(t.getMessage())) But then everything compiles without errors (I'm using scala-cli to compile the files). -- Error: ----------------------------------------------------------------------
3 |Try(FnTest.fn3()).recover(t => println(t.getMessage()))
| ^^^^^^^^^^^^
| Could not find class rs$line$1$FnTest$ in classpath |
The errors are runtime errors, not compiletime. |
Ok, I can now reproduce it when I run it with import scala.util.Try
@main def run() =
Try(FnTest.fn3()).recover(t => println(t.getMessage()))
Try(FnTest.fn2()).recover(t => println(t.getMessage()))
Try(FnTest.fn()).recover(t => println(t.getMessage())) as |
Compiler version
Scala 3.3.0-RC3
Minimized code
File1:
File2:
Output
Expectation
All three of these macros should work, while only fn3 works in practice. What this means is that to deal with n-arity invocations of invoke on MethodHandles I have to manually write out the inputs for each arity by hand.
The text was updated successfully, but these errors were encountered: