-
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
Change top-level ~ evaluation scheme #4822
Conversation
0ceb710
to
f709ac4
Compare
7a4adee
to
7f22ab0
Compare
Rebased on #4616 |
af311a8
to
6055441
Compare
c98ec3e
to
7ea2810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
// replace macro code by lambda used to evaluate the macro expansion | ||
cpy.DefDef(tree)(tpt = TypeTree(macroReturnType), rhs = lambda) | ||
reifier.transform(tree) // Ignore output, only check PCP | ||
cpy.DefDef(tree)(rhs = defaultValue(tree.rhs.tpe)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the comment that was here before apply here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Now we just remove the RHS to prune the tree earlier in the pipeline. Maybe this could be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic will be simplified later in #4826.
* top-level ~ must contain a call to a static method * arguments must be quoted * inline arguments can be passed directly * removed dependency on the original inlined code (removed in PostTyper) * ReifyQuotes is no longer an InfoTransformer * Splicer implements both checking and evaluation of splices in a single abstraction * Fix scala#4773 * Fix scala#4735
38923de
to
1308cd0
Compare
* previously compiled and is present in the classpath of the current context. | ||
*/ | ||
private class Interpreter(pos: Position, classLoader: ClassLoader)(implicit ctx: Context) { | ||
type Res = Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Res for "result"? I'd use the full name.
@@ -172,6 +158,15 @@ object Splicer { | |||
ex.printStackTrace(new PrintWriter(sw)) | |||
sw.write("\n") | |||
throw new StopInterpretation(sw.toString, pos) | |||
case ex: InvocationTargetException => | |||
val sw = new StringWriter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a low-level method to compose the output? Is it to avoid a stackoverflow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was just to pass it simply to the ex. printStackTrace
method of Exception
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later I will need to improve the format of the output, then we will switch to a high level abstraction.
The new scheme consists in only allowing simple interpretable expressions in top-level splices. Then, the inlined splice can be evaluated directly.
Changes:
PR followed by #4823