scalacompiler-errorsmacrossbtscalac

Could not find proxy for ... in Macro


I have been chasing the following issue for quite a while and am hoping someone with more experience on this than myself can help me resolve it.

In my test-case the exact error is as follows:

java.lang.IllegalArgumentException: Could not find proxy for val user: specs.BasicSpec#User in List(value user, method applyOrElse, , method $anonfun$new$97, value fiveLetterNames, method $anonfun$new$90, method $anonfun$new$20, value , class BasicSpec, package specs, package ) (currentOwner= value fiveLetterNames )

The test can be found here:

https://github.com/outr/reactify/blob/master/shared/src/test/scala/specs/BasicSpec.scala#L227

This is the offending Macro:

https://github.com/outr/reactify/blob/master/shared/src/main/scala/com/outr/reactify/Macros.scala#L72

Without more information from the error I'm at a loss how to resolve this. Any assistance is greatly appreciated.


Solution

  • I had the same problem in my project. The solution is not to use the same "lambda"* in macros more than one time.

    "lambda" is the following:

    def macroSample[A, B](c: blackbox.Context)
                         (lambda: c.Expr[A => B] /* <- lambda */) = { ... }
    

    p.s. actually I cannot see your original code right now. That's a solution working in my case