-
Notifications
You must be signed in to change notification settings - Fork 12
Fix Scala 3 Macros #26
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
Conversation
757481e
to
dd5d170
Compare
I have no status in the Apache Log4j project so I can't say if anyone from that team will merge this. It's over 3 years since the last release and in a recent email thread, I suggested my preference is to abandon this project. https://lists.apache.org/thread/wtjmrq94ql2vkovq16tpolcfnzd45qbp The change looks potentially useful but it would be better if there was a unit test added that demos that this works. It might be better to wait to see if any Apache Log4j team member is willing to merge this and do releases before spending time improving this PR. If you do want to proceed, I would suggest a test that does something like this (in pseudocode):
|
The charSequenceExprToStringExpr() caused (some?) strings to be evaluated to '{ ... } It turns out, the whole function is not necessary: every invocation of ${charSequenceExprToStringExpr(message)} can be replaced with ${message.toString}, which evaluates to the desired String (e.g., "{} failed because of {} (baz={})"). Furthermore, the return type of deconstructInterpolatedMessage() can be changed from Expr[String] to Expr[CharSequence]. This allows deconstructInterpolatedMessage() to drop its usage of charSequenceExprToStringExpr().
dd5d170
to
ed5864d
Compare
@Flowdalic, thanks so much for the fix and apologies for the late response. I have incorporated your fix in 66ac4a7. I would really appreciate it if you can double check it. For the record, the project went through a major facelift operation. A sanity check from an experienced Scala developer will be great. |
@pjfanning, I understand the reaction and apologies for the wait. I am trying to overhaul the project. I will really appreciate it if you can submit the test you shared in a separate PR. |
Could you provide build instructions? I tried maven build with Java 11 and fails saying I need Java 17. Tried Java 17 and it fails saying I need Java 8. Tried Java 8 and fails saying I need Java 17. |
I got the maven build to work using Java 17 and setting a toolchains.xml that had a link to a Java 8 install. |
@pjfanning See the build instructions in |
This adds a few simple and short tests for the Scala 3 macros. Especially for the central `deconstructMessageFormat()` macro, which was previously broken and fixed in #26. Signed-off-by: Florian Schmaus <flo@geekplace.eu>
The
charSequenceExprToStringExpr()
method caused (some?) strings to be evaluated to'{ ... }
It turns out, the whole function is not necessary: every invocation of ${charSequenceExprToStringExpr(message)} can be replaced with ${message.toString}, which evaluates to the desired String (e.g., "{} failed because of {} (baz={})").
Furthermore, the return type of deconstructInterpolatedMessage() can be changed from Expr[String] to Expr[CharSequence]. This allows deconstructInterpolatedMessage() to drop its usage of charSequenceExprToStringExpr().