{"action":"closed","issue":{"url":"https://api.github.com/repos/lihaoyi/upickle/issues/70","labels_url":"https://api.github.com/repos/lihaoyi/upickle/issues/70/labels{/name}","comments_url":"https://api.github.com/repos/lihaoyi/upickle/issues/70/comments","events_url":"https://api.github.com/repos/lihaoyi/upickle/issues/70/events","html_url":"https://github.com/lihaoyi/upickle/issues/70","id":57748319,"number":70,"title":"Retain unused type parameters","user":{"login":"tindzk","id":196819,"avatar_url":"https://avatars.githubusercontent.com/u/196819?v=3","gravatar_id":"","url":"https://api.github.com/users/tindzk","html_url":"https://github.com/tindzk","followers_url":"https://api.github.com/users/tindzk/followers","following_url":"https://api.github.com/users/tindzk/following{/other_user}","gists_url":"https://api.github.com/users/tindzk/gists{/gist_id}","starred_url":"https://api.github.com/users/tindzk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tindzk/subscriptions","organizations_url":"https://api.github.com/users/tindzk/orgs","repos_url":"https://api.github.com/users/tindzk/repos","events_url":"https://api.github.com/users/tindzk/events{/privacy}","received_events_url":"https://api.github.com/users/tindzk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-15T22:04:43Z","updated_at":"2015-07-05T04:26:00Z","closed_at":"2015-07-05T04:26:00Z","body":"The following trait hierarchy cannot be serialised with uPickle:\r\n\r\n```scala\r\nsealed trait Delta[A, B]\r\nobject Delta {\r\n  case class Insert[A, B](key: A, value: B) extends Delta[A, B]\r\n  case class Remove[A, B](key: A) extends Delta[A, B]\r\n  case class Clear[A, B]() extends Delta[A, B]\r\n}\r\n```\r\n\r\nThe reason is that ``Clear[A, B]()`` does not bind its type parameters to arguments. As a consequence, every ``Clear[A, B]`` instance becomes ``Clear[Nothing, Nothing]``, leading to type mismatches.\r\n\r\nI came up with a quick workaround (which requires https://github.com/tindzk/upickle/commit/4b1345f288b9d4a8bcbd1675503eb50f06d8cfef):\r\n\r\n```scala\r\nimplicit def DictDeltaW[A: W, B: W]: W[Dict.Delta[A, B]] = W[Dict.Delta[A, B]] {\r\n  case x: Dict.Delta.Insert[A, B] => upickle.writeJs(x)\r\n  case x: Dict.Delta.Remove[A, B] => upickle.writeJs(x)\r\n  case x: Dict.Delta.Clear[A, B] => upickle.writeJs[Dict.Delta[A, B]](x)\r\n}\r\n\r\nimplicit def DictDeltaR[A: R, B: R]: R[Dict.Delta[A, B]] = R[Dict.Delta[A, B]] {\r\n  implicitly[R[Dict.Delta.Insert[A, B]]].read\r\n    .orElse(implicitly[R[Dict.Delta.Remove[A, B]]].read)\r\n    .orElse(implicitly[R[Dict.Delta.Clear[Nothing, Nothing]]].asInstanceOf[R[Dict.Delta.Clear[A, B]]].read)\r\n}\r\n```"}}