{"action":"opened","issue":{"url":"https://api.github.com/repos/milessabin/shapeless/issues/574","repository_url":"https://api.github.com/repos/milessabin/shapeless","labels_url":"https://api.github.com/repos/milessabin/shapeless/issues/574/labels{/name}","comments_url":"https://api.github.com/repos/milessabin/shapeless/issues/574/comments","events_url":"https://api.github.com/repos/milessabin/shapeless/issues/574/events","html_url":"https://github.com/milessabin/shapeless/issues/574","id":145186647,"number":574,"title":"Typeable instance derived for generic case classes can be unsafe","user":{"login":"durban","id":1568978,"avatar_url":"https://avatars.githubusercontent.com/u/1568978?v=3","gravatar_id":"","url":"https://api.github.com/users/durban","html_url":"https://github.com/durban","followers_url":"https://api.github.com/users/durban/followers","following_url":"https://api.github.com/users/durban/following{/other_user}","gists_url":"https://api.github.com/users/durban/gists{/gist_id}","starred_url":"https://api.github.com/users/durban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durban/subscriptions","organizations_url":"https://api.github.com/users/durban/orgs","repos_url":"https://api.github.com/users/durban/repos","events_url":"https://api.github.com/users/durban/events{/privacy}","received_events_url":"https://api.github.com/users/durban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-01T13:53:21Z","updated_at":"2016-04-01T13:53:21Z","closed_at":null,"body":"The automatically derived/generated `shapeless.Typeable` instance for generic case classes can be unsafe in some cases. For example:\r\n```\r\nfinal case class C[A](s: String)(x: A) {\r\n  val y: A = x\r\n}\r\n```\r\nThe `Typeable[C[Int]]` instance can cast a `C[Double]` to a `C[Int]`, which then blows up with a `ClassCastException`, due to a `Double` not being an `Int` (full code: https://github.com/durban/akka-typed-examples/blob/7f7378979cbdb70615690a25207c70cf57f332fb/src/main/scala/com/example/shless/TypeableExample.scala). More variations: https://github.com/durban/akka-typed-examples/blob/7f7378979cbdb70615690a25207c70cf57f332fb/src/main/scala/com/example/shless/TypeableExample2.scala and https://github.com/durban/akka-typed-examples/blob/7f7378979cbdb70615690a25207c70cf57f332fb/src/main/scala/com/example/shless/TypeableExample3.scala.\r\n\r\nI guess the reason could be that the macro generating the instance misses some definitions involving `A` (it only seems to take into account the case class accessors)."}}