@@ -21,9 +21,11 @@ import dotty.tools.dotc.util.Positions.Position
21
21
import scala .reflect .ClassTag
22
22
23
23
/** Utility class to splice quoted expressions */
24
- object Splicer {
24
+ class Splicer {
25
25
import tpd ._
26
26
27
+ private var classLoader : URLClassLoader = _
28
+
27
29
/** Splice the Tree for a Quoted expression. `~'(xyz)` becomes `xyz`
28
30
* and for `~xyz` the tree of `xyz` is interpreted for which the
29
31
* resulting expression is returned as a `Tree`
@@ -93,22 +95,16 @@ object Splicer {
93
95
}
94
96
}
95
97
96
- private val classLoaders = scala.collection.mutable.HashMap .empty[String , URLClassLoader ]
97
-
98
98
/** Tree interpreter that can interpret calls to static methods with it's default arguments
99
99
*
100
100
* The interpreter assumes that all calls in the trees are to code that was
101
101
* previously compiled and is present in the classpath of the current context.
102
102
*/
103
103
private class Interpreter (pos : Position )(implicit ctx : Context ) {
104
104
105
- private [this ] val classLoader = {
106
- val cp = ctx.settings.classpath.value
107
- def newClassLoader = {
108
- val urls = cp.split(':' ).map(cp => java.nio.file.Paths .get(cp).toUri.toURL)
109
- new URLClassLoader (urls, getClass.getClassLoader)
110
- }
111
- classLoaders.getOrElseUpdate(cp, newClassLoader)
105
+ if (classLoader == null ) {
106
+ val urls = ctx.settings.classpath.value.split(':' ).map(cp => java.nio.file.Paths .get(cp).toUri.toURL)
107
+ classLoader = new URLClassLoader (urls, getClass.getClassLoader)
112
108
}
113
109
114
110
/** Returns the interpreted result of interpreting the code a call to the symbol with default arguments.
0 commit comments