@@ -10,6 +10,7 @@ import Symbols._
1010import Types ._
1111import Decorators ._
1212import Constants ._
13+ import StagingContext ._
1314import StdNames ._
1415import transform .SymUtils ._
1516import Contexts .Context
@@ -957,20 +958,16 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
957958 assert(tree.hasType, tree)
958959 val qual1 = typed(tree.qualifier, selectionProto(tree.name, pt, this ))
959960 val res =
960- if (tree.symbol == defn.QuotedExpr_splice && StagingContext . level == 0 ) expandMacro(qual1, tree.span)
961+ if (tree.symbol == defn.QuotedExpr_splice && level == 0 ) expandMacro(qual1, tree.span)
961962 else untpd.cpy.Select (tree)(qual1, tree.name).withType(tree.typeOpt)
962963 ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.sourcePos)
963964 res
964965 }
965966
966967 private def expandMacro (body : Tree , span : Span )(implicit ctx : Context ) = {
967- assert(StagingContext .level == 0 )
968- // TODO cache macro classloader
969- val urls = ctx.settings.classpath.value.split(java.io.File .pathSeparatorChar).map(cp => java.nio.file.Paths .get(cp).toUri.toURL)
970- val macroClassLoader = new java.net.URLClassLoader (urls, getClass.getClassLoader)
971-
968+ assert(level == 0 )
972969 val inlinedFrom = enclosingInlineds.last
973- val evaluatedSplice = Splicer .splice(body, inlinedFrom.sourcePos, macroClassLoader )(ctx.withSource(inlinedFrom.source))
970+ val evaluatedSplice = Splicer .splice(body, inlinedFrom.sourcePos, MacroClassLoader .fromContext )(ctx.withSource(inlinedFrom.source))
974971 if (ctx.reporter.hasErrors) EmptyTree
975972 else evaluatedSplice.withSpan(span)
976973 }
0 commit comments