-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Delayed Functional Invocation via Macro #8
Comments
Fix #8 by making of fsi.stringBuilder() call to be accessible from any package
Hi Matt, Thanks for reporting the bug! Please try with latest release, it is promoted to jCenter already: https://github.com/Sizmek/fast-string-interpolator/releases/tag/v0.2.0 |
That did fix the
|
@darkfrog26 I have tried to reproduce an error in the branch below but it works fine for me and prints log record like this:
Please check out and add missing to reproduce the error: |
This is a quick hack, but here's a gist that will reproduce the problem: https://gist.github.com/darkfrog26/fb97f0bf329cdc6141e1599087e58854 Reminder: you need to have |
The reason you can't reproduce it on Scribe 2.3.4 is because the problem only exists on the |
I reproduced it. Will it be acceptable for you to a workaround through an additional |
No, I considered that, but the whole reason it's directly hitting a Macro is to get compile-time access to the class, method, and line number that invoked it. If I go through an additional method that will be lost. |
It looks more like a bug in scalac... Here I reproduced it with the standard formatting interpolator: aa83fd5 |
@darkfrog26 could you, please, create an issue in https://github.com/scala/bug ? |
FINALLY FIGURED IT OUT! This is not a bug in def example(c: blackbox.Context)(message: c.Tree): c.Tree = {
import c.universe._
val f = c.typecheck(q"() => $message")
c.internal.changeOwner(message, c.internal.enclosingOwner, f.symbol)
q"example.LogRecord($f)"
} That compiles and works! |
Okay, this is a fairly corner-case scenario, but a big problem for me. I'm attempting to use this within my Scribe logging library. It takes in an anonymous function (
message: => String
) that gets passed into a Macro to set up lazy invocation when/if that message is actually logged (for performance). This works fine unless I try to usefs""
interpolation. In the following example:I get the following compile-time exception:
Any thoughts?
The text was updated successfully, but these errors were encountered: