{"action":"created","issue":{"url":"https://api.github.com/repos/lihaoyi/autowire/issues/44","repository_url":"https://api.github.com/repos/lihaoyi/autowire","labels_url":"https://api.github.com/repos/lihaoyi/autowire/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/lihaoyi/autowire/issues/44/comments","events_url":"https://api.github.com/repos/lihaoyi/autowire/issues/44/events","html_url":"https://github.com/lihaoyi/autowire/issues/44","id":116593937,"number":44,"title":"diverging implicit expansion errors with Spray, Autowire and uPickle","user":{"login":"ozeebee","id":1236583,"avatar_url":"https://avatars.githubusercontent.com/u/1236583?v=3","gravatar_id":"","url":"https://api.github.com/users/ozeebee","html_url":"https://github.com/ozeebee","followers_url":"https://api.github.com/users/ozeebee/followers","following_url":"https://api.github.com/users/ozeebee/following{/other_user}","gists_url":"https://api.github.com/users/ozeebee/gists{/gist_id}","starred_url":"https://api.github.com/users/ozeebee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozeebee/subscriptions","organizations_url":"https://api.github.com/users/ozeebee/orgs","repos_url":"https://api.github.com/users/ozeebee/repos","events_url":"https://api.github.com/users/ozeebee/events{/privacy}","received_events_url":"https://api.github.com/users/ozeebee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-12T17:05:49Z","updated_at":"2016-03-05T20:22:14Z","closed_at":null,"body":"Hi there, I'm facing compile errors on the server-side while trying to integrate Autowire within my existing Spray code that uses uPickle for serialization.\r\nHere's my `UPickleJsonSupport` trait mixed into my Spray HttpService:\r\n```scala\r\ntrait UPickleJsonSupport {\r\n\timplicit def genericMarshaller[T: Writer]: Marshaller[T] =\r\n\t\tMarshaller.delegate(ContentTypes.`application/json`)(writeJs(_))\r\n\r\n\timplicit def jsValueMarshaller: Marshaller[Js.Value] =\r\n\t\tMarshaller.of[Js.Value](ContentTypes.`application/json`) {\r\n\t\t\t(value, contentType, context) => {\r\n\t\t\t\tval entity = HttpEntity(contentType, json.write(value))\r\n\r\n\t\t\t\tcontext.marshalTo(entity)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\timplicit def entityUnmarshaller[T: Reader]: Unmarshaller[T] =\r\n\t\tUnmarshaller[T](ContentTypeRange(MediaTypes.`application/json`)) {\r\n\t\t\tcase entity => read[T](entity.asString(HttpCharsets.`UTF-8`))\r\n\t\t}\r\n}\r\n```\r\nOk, this is for the integration with Spray marshalling and this works fine until I throw Autowire into the mix:\r\nHere's my `AutowireServer`:\r\n```scala\r\nobject AutowireServer extends autowire.Server[Js.Value, Reader, Writer] {\r\n\tdef read[Result: Reader](p: Js.Value) = upickle.default.readJs[Result](p)\r\n\tdef write[Result: Writer](r: Result) = upickle.default.writeJs(r)\r\n}\r\n```\r\nAnd my Spray route definition (rest of the code omitted for brevity):\r\n```scala\r\n\tdef apiRoute = post {\r\n\t\tpath(\"api\" / Segments) { s =>\r\n\t\t\textract(_.request.entity.asString) { e =>\r\n\t\t\t\tcomplete {\r\n\t\t\t\t\tAutowireServer.route[Api](ApiImpl)(\r\n\t\t\t\t\t\tautowire.Core.Request(\r\n\t\t\t\t\t\t\ts,\r\n\t\t\t\t\t\t\tupickle.json.read(e).asInstanceOf[Js.Obj].value.toMap\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n```\r\nWith this code, I've got a sh*tload of compile errors (all related to this problem), ending with these:\r\n```\r\n...\r\n[error]  both value derive$macro$173 of type => upickle.default.Writer[upickle.Js.Value]\r\n[error]  and value derive$macro$175 of type => upickle.default.Writer[upickle.Js.Value]\r\n[error]  match expected type upickle.default.Writer[upickle.Js.Value]\r\n[error] /Users/toto/someproject/jvm/src/main/scala/some/pkg/RouteProvider.scala:38: diverging implicit expansion for type upickle.default.Writer[T1]\r\n[error] starting with macro method macroW in trait LowPriX\r\n[error]           AutowireServer.route[Api](ApiImpl)(\r\n[error]                                             ^\r\n[error] 13 errors found\r\n```\r\nMy current knowledge of scala (which is rather poor) does not allow me to find the root cause of the problem. Looks like a clash between implicits generated by the macros ???\r\nNow, the problem may come from uPickle rather than Autowire but since uPickle was working before I added Autowire, I create the ticket here ;)\r\n\r\nIn the meantime, I will simply generate Spray's HttpEntity myself (thus skipping the Marshaller) by adding this transformation on the router result `.map(v => HttpEntity(jsonContentType, upickle.json.write(v)))` but I guess (and hope) it should be possible to combine both libs.\r\n\r\nThanks for your help.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lihaoyi/autowire/issues/comments/192727708","html_url":"https://github.com/lihaoyi/autowire/issues/44#issuecomment-192727708","issue_url":"https://api.github.com/repos/lihaoyi/autowire/issues/44","id":192727708,"user":{"login":"alexmojaki","id":3627481,"avatar_url":"https://avatars.githubusercontent.com/u/3627481?v=3","gravatar_id":"","url":"https://api.github.com/users/alexmojaki","html_url":"https://github.com/alexmojaki","followers_url":"https://api.github.com/users/alexmojaki/followers","following_url":"https://api.github.com/users/alexmojaki/following{/other_user}","gists_url":"https://api.github.com/users/alexmojaki/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmojaki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmojaki/subscriptions","organizations_url":"https://api.github.com/users/alexmojaki/orgs","repos_url":"https://api.github.com/users/alexmojaki/repos","events_url":"https://api.github.com/users/alexmojaki/events{/privacy}","received_events_url":"https://api.github.com/users/alexmojaki/received_events","type":"User","site_admin":false},"created_at":"2016-03-05T20:22:14Z","updated_at":"2016-03-05T20:22:14Z","body":"OK, I fixed my error by making sure that all classes to be pickled/unpickled had an `unapply` method. A more helpful error message would be nice."}}