@@ -412,6 +412,9 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
412412 // Phase II: typecheck the right-hand side of the macro def
413413 val typed = typecheckRhs(macroDdef.rhs)
414414 typed match {
415+ case MacroImplReference (_, meth, _) if meth == Predef_??? =>
416+ bindMacroImpl(macroDef, typed)
417+ MacroDefIsQmarkQmarkQmark ()
415418 case MacroImplReference (owner, meth, targs) =>
416419 if (! meth.isMethod) MacroDefInvalidBodyError ()
417420 if (! meth.isPublic) MacroImplNotPublicError ()
@@ -521,26 +524,30 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
521524 val methName = binding.methName
522525 macroLogVerbose(s " resolved implementation as $className. $methName" )
523526
524- // I don't use Scala reflection here, because it seems to interfere with JIT magic
525- // whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20%
526- // I'm not sure what's the reason - for me it's pure voodoo
527- // upd. my latest experiments show that everything's okay
528- // it seems that in 2.10.1 we can easily switch to Scala reflection
529- try {
530- macroLogVerbose(s " loading implementation class: $className" )
531- macroLogVerbose(s " classloader is: ${ReflectionUtils .show(macroClassloader)}" )
532- val implObj = ReflectionUtils .staticSingletonInstance(macroClassloader, className)
533- // relies on the fact that macro impls cannot be overloaded
534- // so every methName can resolve to at maximum one method
535- val implMeths = implObj.getClass.getDeclaredMethods.find(_.getName == methName)
536- val implMeth = implMeths getOrElse { throw new NoSuchMethodException (s " $className. $methName" ) }
537- macroLogVerbose(s " successfully loaded macro impl as ( $implObj, $implMeth) " )
538- args => implMeth.invoke(implObj, ((args.c +: args.others) map (_.asInstanceOf [AnyRef ])): _* )
539- } catch {
540- case ex : Exception =>
541- macroLogVerbose(s " macro runtime failed to load: ${ex.toString}" )
542- macroDef setFlag IS_ERROR
543- null
527+ if (binding.className == Predef_??? .owner.fullName.toString && binding.methName == Predef_??? .name.encoded) {
528+ args => throw new AbortMacroException (args.c.enclosingPosition, " macro implementation is missing" )
529+ } else {
530+ // I don't use Scala reflection here, because it seems to interfere with JIT magic
531+ // whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20%
532+ // I'm not sure what's the reason - for me it's pure voodoo
533+ // upd. my latest experiments show that everything's okay
534+ // it seems that in 2.10.1 we can easily switch to Scala reflection
535+ try {
536+ macroLogVerbose(s " loading implementation class: $className" )
537+ macroLogVerbose(s " classloader is: ${ReflectionUtils .show(macroClassloader)}" )
538+ val implObj = ReflectionUtils .staticSingletonInstance(macroClassloader, className)
539+ // relies on the fact that macro impls cannot be overloaded
540+ // so every methName can resolve to at maximum one method
541+ val implMeths = implObj.getClass.getDeclaredMethods.find(_.getName == methName)
542+ val implMeth = implMeths getOrElse { throw new NoSuchMethodException (s " $className. $methName" ) }
543+ macroLogVerbose(s " successfully loaded macro impl as ( $implObj, $implMeth) " )
544+ args => implMeth.invoke(implObj, ((args.c +: args.others) map (_.asInstanceOf [AnyRef ])): _* )
545+ } catch {
546+ case ex : Exception =>
547+ macroLogVerbose(s " macro runtime failed to load: ${ex.toString}" )
548+ macroDef setFlag IS_ERROR
549+ null
550+ }
544551 }
545552 })
546553 }
0 commit comments