@@ -21,9 +21,11 @@ import dotty.tools.dotc.util.Positions.Position
2121import scala .reflect .ClassTag
2222
2323/** Utility class to splice quoted expressions */
24- object Splicer {
24+ class Splicer {
2525 import tpd ._
2626
27+ private var classLoader : URLClassLoader = _
28+
2729 /** Splice the Tree for a Quoted expression. `~'(xyz)` becomes `xyz`
2830 * and for `~xyz` the tree of `xyz` is interpreted for which the
2931 * resulting expression is returned as a `Tree`
@@ -93,22 +95,16 @@ object Splicer {
9395 }
9496 }
9597
96- private val classLoaders = scala.collection.mutable.HashMap .empty[String , URLClassLoader ]
97-
9898 /** Tree interpreter that can interpret calls to static methods with it's default arguments
9999 *
100100 * The interpreter assumes that all calls in the trees are to code that was
101101 * previously compiled and is present in the classpath of the current context.
102102 */
103103 private class Interpreter (pos : Position )(implicit ctx : Context ) {
104104
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)
112108 }
113109
114110 /** Returns the interpreted result of interpreting the code a call to the symbol with default arguments.
0 commit comments