@@ -30,16 +30,13 @@ object Splicer {
30
30
*
31
31
* See: `ReifyQuotes`
32
32
*/
33
- def splice (tree : Tree , call : Tree , bindings : List [Tree ], pos : Position )(implicit ctx : Context ): Tree = tree match {
33
+ def splice (tree : Tree , call : Tree , bindings : List [Tree ], pos : Position , classLoader : ClassLoader )(implicit ctx : Context ): Tree = tree match {
34
34
case Quoted (quotedTree) => quotedTree
35
- case _ => reflectiveSplice(tree, call, bindings, pos)
36
- }
37
-
38
- private def reflectiveSplice (tree : Tree , call : Tree , bindings : List [Tree ], pos : Position )(implicit ctx : Context ): Tree = {
39
- val liftedArgs = getLiftedArgs(call, bindings)
40
- val interpreter = new Interpreter (pos)
41
- val interpreted = interpreter.interpretCallToSymbol[Seq [Any ] => Object ](call.symbol)
42
- interpreted.flatMap(lambda => evaluateLambda(lambda, liftedArgs, pos)).fold(tree)(PickledQuotes .quotedExprToTree)
35
+ case _ =>
36
+ val liftedArgs = getLiftedArgs(call, bindings)
37
+ val interpreter = new Interpreter (pos, classLoader)
38
+ val interpreted = interpreter.interpretCallToSymbol[Seq [Any ] => Object ](call.symbol)
39
+ interpreted.flatMap(lambda => evaluateLambda(lambda, liftedArgs, pos)).fold(tree)(PickledQuotes .quotedExprToTree)
43
40
}
44
41
45
42
/** Given the inline code and bindings, compute the lifted arguments that will be used to execute the macro
@@ -98,12 +95,7 @@ object Splicer {
98
95
* The interpreter assumes that all calls in the trees are to code that was
99
96
* previously compiled and is present in the classpath of the current context.
100
97
*/
101
- private class Interpreter (pos : Position )(implicit ctx : Context ) {
102
-
103
- private [this ] val classLoader = {
104
- val urls = ctx.settings.classpath.value.split(':' ).map(cp => java.nio.file.Paths .get(cp).toUri.toURL)
105
- new URLClassLoader (urls, getClass.getClassLoader)
106
- }
98
+ private class Interpreter (pos : Position , classLoader : ClassLoader )(implicit ctx : Context ) {
107
99
108
100
/** Returns the interpreted result of interpreting the code a call to the symbol with default arguments.
109
101
* Return Some of the result or None if some error happen during the interpretation.
0 commit comments