Could not find proxy for … in Macro

吃可爱长大的小学妹 提交于 2020-01-05 01:13:52

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/42334608/could-not-find-proxy-for-in-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!