{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/760","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/760/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/760/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/760/events","html_url":"https://github.com/ceylon/ceylon-spec/issues/760","id":18621172,"number":760,"title":"more powerful annotation constraints","user":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/feature","name":"feature","color":"02e10c"},{"url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/request%20for%20feedback","name":"request for feedback","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/9","html_url":"https://github.com/ceylon/ceylon-spec/milestones/1.5","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/9/labels","id":432794,"number":9,"title":"1.5","description":"","creator":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"open_issues":57,"closed_issues":4,"state":"open","created_at":"2013-09-20T19:23:05Z","updated_at":"2015-05-13T11:44:52Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2013-08-27T17:19:48Z","updated_at":"2015-05-14T10:34:40Z","closed_at":null,"body":"We would like to be able to constrain an annotation to appear only at program elements of a certain (return) type, or with certain parameter types. However, we've left this out of M6. See the discussion in #698."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/101998354","html_url":"https://github.com/ceylon/ceylon-spec/issues/760#issuecomment-101998354","issue_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/760","id":101998354,"user":{"login":"gavinking","id":579974,"avatar_url":"https://avatars.githubusercontent.com/u/579974?v=3","gravatar_id":"","url":"https://api.github.com/users/gavinking","html_url":"https://github.com/gavinking","followers_url":"https://api.github.com/users/gavinking/followers","following_url":"https://api.github.com/users/gavinking/following{/other_user}","gists_url":"https://api.github.com/users/gavinking/gists{/gist_id}","starred_url":"https://api.github.com/users/gavinking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavinking/subscriptions","organizations_url":"https://api.github.com/users/gavinking/orgs","repos_url":"https://api.github.com/users/gavinking/repos","events_url":"https://api.github.com/users/gavinking/events{/privacy}","received_events_url":"https://api.github.com/users/gavinking/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T10:34:40Z","updated_at":"2015-05-14T10:34:40Z","body":"So, FTR, since we all seem to have forgotten the issue here, and why we didn't implement this at the time is this: types like `Function` and `Class` have a mix of `in` and `out` type parameters, and thus can't occur as type arguments to a satisfied supertype, according to a restriction invented by @RossTate that eliminates certain undecidable cases which I happen to forget right now. Thus, we can't use a supertype of the annotation type to encode constraints in terms of `Class`, `Function`, `Method`, or `Attribute`.\r\n\r\nI can see three possible solutions:\r\n\r\n1. Encode this info into an annotation instead. This can't be done right now because annotations don't accept typed models, only references.\r\n2. Invent new invariant subtypes of all the model types, just for expressing constraints. Yew!\r\n3. Encode `ReturnType` and `ParameterTypes` directly into the supertype. This isn't quite as powerful, but it's simple and can be implemented today. Seems like a pretty reasonable solution to me."}}