blob: 1999e525ffd4d8cdb6a933489bdb9528f1da1429 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package scala.reflect.macros
package runtime
import scala.reflect.runtime.{universe => ru}
trait ScalaReflectionRuntimes {
self: scala.tools.nsc.typechecker.Analyzer =>
trait ScalaReflectionResolvers {
self: MacroRuntimeResolver =>
import global._
def resolveScalaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = {
val macroMirror: ru.JavaMirror = ru.runtimeMirror(classLoader)
val implContainerSym = macroMirror.classSymbol(Class.forName(className, true, classLoader))
val implMethSym = implContainerSym.typeSignature.member(ru.TermName(methName)).asMethod
macroLogVerbose(s"successfully loaded macro impl as ($implContainerSym, $implMethSym)")
args => {
val implContainer =
if (isBundle) {
val implCtorSym = implContainerSym.typeSignature.member(ru.nme.CONSTRUCTOR).asMethod
macroMirror.reflectClass(implContainerSym).reflectConstructor(implCtorSym)(args.c)
} else {
macroMirror.reflectModule(implContainerSym.module.asModule).instance
}
val implMeth = macroMirror.reflect(implContainer).reflectMethod(implMethSym)
val implArgs = if (isBundle) args.others else args.c +: args.others
implMeth(implArgs: _*)
}
}
}
}
|