{"action":"created","issue":{"url":"https://api.github.com/repos/milessabin/shapeless/issues/453","labels_url":"https://api.github.com/repos/milessabin/shapeless/issues/453/labels{/name}","comments_url":"https://api.github.com/repos/milessabin/shapeless/issues/453/comments","events_url":"https://api.github.com/repos/milessabin/shapeless/issues/453/events","html_url":"https://github.com/milessabin/shapeless/issues/453","id":104378465,"number":453,"title":"Generic instance exists for AnyRef","user":{"login":"rhendric","id":1570964,"avatar_url":"https://avatars.githubusercontent.com/u/1570964?v=3","gravatar_id":"","url":"https://api.github.com/users/rhendric","html_url":"https://github.com/rhendric","followers_url":"https://api.github.com/users/rhendric/followers","following_url":"https://api.github.com/users/rhendric/following{/other_user}","gists_url":"https://api.github.com/users/rhendric/gists{/gist_id}","starred_url":"https://api.github.com/users/rhendric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhendric/subscriptions","organizations_url":"https://api.github.com/users/rhendric/orgs","repos_url":"https://api.github.com/users/rhendric/repos","events_url":"https://api.github.com/users/rhendric/events{/privacy}","received_events_url":"https://api.github.com/users/rhendric/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-02T00:07:30Z","updated_at":"2015-09-02T15:18:29Z","closed_at":null,"body":"`implicitly[shapeless.Generic[AnyRef]]` should fail, doesn't.\r\n\r\nThis also seems to affect other empty-constructor non-case classes (of which `java.lang.Object` is a special case). If I may editorialize on a fix, I'd propose adding a check to [`CaseClassMacros.isCaseClassLike.checkCtor`](https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/generic.scala#L575) requiring `params` to be non-empty, rather than just adding a guard for `AnyRef` specifically."},"comment":{"url":"https://api.github.com/repos/milessabin/shapeless/issues/comments/137125042","html_url":"https://github.com/milessabin/shapeless/issues/453#issuecomment-137125042","issue_url":"https://api.github.com/repos/milessabin/shapeless/issues/453","id":137125042,"user":{"login":"rhendric","id":1570964,"avatar_url":"https://avatars.githubusercontent.com/u/1570964?v=3","gravatar_id":"","url":"https://api.github.com/users/rhendric","html_url":"https://github.com/rhendric","followers_url":"https://api.github.com/users/rhendric/followers","following_url":"https://api.github.com/users/rhendric/following{/other_user}","gists_url":"https://api.github.com/users/rhendric/gists{/gist_id}","starred_url":"https://api.github.com/users/rhendric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhendric/subscriptions","organizations_url":"https://api.github.com/users/rhendric/orgs","repos_url":"https://api.github.com/users/rhendric/repos","events_url":"https://api.github.com/users/rhendric/events{/privacy}","received_events_url":"https://api.github.com/users/rhendric/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T15:18:29Z","updated_at":"2015-09-02T15:18:29Z","body":"I agree that `AnyRef` is pretty special, and I don't think special-casing it is an awful idea. But I also think that having Generic support for empty-constructor classes can be a little dangerous.\r\n\r\nA class with only an empty constructor is much more likely to have object identity semantics than value equality semantics. Take, as just an example, a custom Exception class that doesn't expose a message constructor. This CustomException and that CustomException are different things—they have different stack traces and so on. But if CustomException is used in a class that gets put through some scrap-your-boilerplate machinery, as far as Generic is concerned, that CustomException can be crushed into HNil and then rematerialized as a new CustomException with the wrong stack trace and so on. I'd much rather have a compiler error.\r\n\r\nThe power of scrap-your-boilerplate makes this an especially easy thing to overlook, too—it's hard to just follow the advice of the proverbial doctor who says ‘so don't do that’, because your identity-semantics-having class might be far removed from the root object that gets put into the machine, and it's very non-obvious that a failure of this kind is happening.\r\n\r\nGranted, losing some out-of-band state like a stack trace is always a risk if you want to have a la carte case class functionality, and ordinarily I'd say that your trade-off in favor of a la carte is worth it (along with the good advice to use functional idioms instead of mutable state and object identity and so on). I'm arguing that in the specific case of empty constructor classes, the likelihood of out-of-band state goes way up (because there's no other way to supply state!), and the utility of those classes in an a la carte scheme goes way down (why wouldn't the a la carter just use an object instead of a class with an empty constructor?), and does that convince you to err on the side of safety for this case (and as a bonus it excludes the `AnyRef` problem)?"}}