macwire
macwire copied to clipboard
Unclear compilation error using valsByClass
I get the following error trying to compile Global.scala for play framework
[error] C:\Trader\app\Global.scala:7: type mismatch; [error] found : Any [error] required: AnyRef [error] val instanceLookup = InstanceLookup(valsByClass(ProdModule)) [error] ^
ProdModule is an object and inherits from other traits. My problem is I cannot understand what causes this error or how to debug it.
Looks quite weird :) Can you try splitting InstanceLookup and valsByClass, to see where the type error exactly is? So: val vbc = valsByClass(ProdModule) val instanceLookup = InstanceLookup(vbc)
It fails on: [error] val instanceMap = valsByClass(ProdModule)
With some trial and error I localized the line of code in one of the traits that causes it. val connectionsActor = actorSystem.actorOf(Props(wire[ConnectionsActor]), "connections")
when I comment it out compilation works fine, but it still fails even with 'new' instead of wire. This is the case where I don't really need wire macro. val connectionsActor = actorSystem.actorOf(Props(new ConnectionsActor), "connections")
Please, note that actorSystem is defined in another trait that current trait extends from.
Weird :) What if you add an explicit type annotation to "connectionsActor"? E.g.:
val connectionsActor: ActorRef = ...
Adding ActorRef fixed it. Thanks a lot for your help and MacWire! I really like simplicity of MacWire.
Do you think there is a way to make the cryptic error I ran into less cryptic?
Definitely, I don't know yet why exactly this happens, but I'll try :)