{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2072","labels_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2072/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2072/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2072/events","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2072","id":58786967,"number":2072,"title":"A generic method cannot define an instance of its containing interface","user":{"login":"jvasileff","id":236050,"avatar_url":"https://avatars.githubusercontent.com/u/236050?v=3","gravatar_id":"","url":"https://api.github.com/users/jvasileff","html_url":"https://github.com/jvasileff","followers_url":"https://api.github.com/users/jvasileff/followers","following_url":"https://api.github.com/users/jvasileff/following{/other_user}","gists_url":"https://api.github.com/users/jvasileff/gists{/gist_id}","starred_url":"https://api.github.com/users/jvasileff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvasileff/subscriptions","organizations_url":"https://api.github.com/users/jvasileff/orgs","repos_url":"https://api.github.com/users/jvasileff/repos","events_url":"https://api.github.com/users/jvasileff/events{/privacy}","received_events_url":"https://api.github.com/users/jvasileff/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/labels/BUG","name":"BUG","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/milestones/11","html_url":"https://github.com/ceylon/ceylon-compiler/milestones/1.2","labels_url":"https://api.github.com/repos/ceylon/ceylon-compiler/milestones/11/labels","id":809477,"number":11,"title":"1.2","description":"","creator":{"login":"tombentley","id":879487,"avatar_url":"https://avatars.githubusercontent.com/u/879487?v=3","gravatar_id":"","url":"https://api.github.com/users/tombentley","html_url":"https://github.com/tombentley","followers_url":"https://api.github.com/users/tombentley/followers","following_url":"https://api.github.com/users/tombentley/following{/other_user}","gists_url":"https://api.github.com/users/tombentley/gists{/gist_id}","starred_url":"https://api.github.com/users/tombentley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tombentley/subscriptions","organizations_url":"https://api.github.com/users/tombentley/orgs","repos_url":"https://api.github.com/users/tombentley/repos","events_url":"https://api.github.com/users/tombentley/events{/privacy}","received_events_url":"https://api.github.com/users/tombentley/received_events","type":"User","site_admin":false},"open_issues":26,"closed_issues":181,"state":"open","created_at":"2014-10-01T08:51:07Z","updated_at":"2015-02-25T12:41:20Z","due_on":"2014-11-02T23:00:00Z","closed_at":null},"comments":1,"created_at":"2015-02-24T19:01:16Z","updated_at":"2015-02-25T13:45:14Z","closed_at":null,"body":"The problem occurs when a method attempts to define an implementation of its interface, and the method has a parameter that involves a type parameter of the interface.\r\n\r\nThis:\r\n\r\n```ceylon\r\ninterface Foo<T> {\r\n    shared Foo<U> map<U>(T f)\r\n        =>  object satisfies Foo<U> {};\r\n}\r\n```\r\n\r\nfails with:\r\n\r\n```\r\nanonymous_0_ is not abstract and does not override abstract method <U>map(com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor,U) in Foo - Ceylon Backend Error\r\n```\r\n\r\nThis *does* work:\r\n\r\n```ceylon\r\ninterface Foo<T> given T satisfies Object {\r\n    shared Foo<U> map<U>(Callable<U, [T]> f)\r\n            given U satisfies Object \r\n        =>  object satisfies Foo<U> {};\r\n}\r\n```\r\n\r\nwhich is fairly common, but this slight variation doesn't:\r\n\r\n```ceylon\r\ninterface Callable2<out Return, in Arguments> \r\n        given Arguments satisfies Anything[] {}\r\n\r\ninterface Foo<T> given T satisfies Object {\r\n    shared Foo<U> map<U>(Callable2<U, [T]> f)\r\n            given U satisfies Object \r\n        =>  object satisfies Foo<U> {};\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/comments/75961391","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2072#issuecomment-75961391","issue_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2072","id":75961391,"user":{"login":"tombentley","id":879487,"avatar_url":"https://avatars.githubusercontent.com/u/879487?v=3","gravatar_id":"","url":"https://api.github.com/users/tombentley","html_url":"https://github.com/tombentley","followers_url":"https://api.github.com/users/tombentley/followers","following_url":"https://api.github.com/users/tombentley/following{/other_user}","gists_url":"https://api.github.com/users/tombentley/gists{/gist_id}","starred_url":"https://api.github.com/users/tombentley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tombentley/subscriptions","organizations_url":"https://api.github.com/users/tombentley/orgs","repos_url":"https://api.github.com/users/tombentley/repos","events_url":"https://api.github.com/users/tombentley/events{/privacy}","received_events_url":"https://api.github.com/users/tombentley/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T13:45:14Z","updated_at":"2015-02-25T13:45:14Z","body":"The issue here is that when we generate the implementation of `map()` in the companion class we use the type parameter name `U` but then redeclare a `U` in the implementation of the anonymous class's `map()` but in the same declaration we're still using `U` to refer to the outer classes `U`. \r\n\r\nWe can see the same thing going on if `Foo` has the following member class:\r\n\r\n    class C<U>() satisfies Bug2072<U> {}\r\n\r\n(Note there that `C`'s type parameter, `U`, has to be the same as `map()`'s).\r\n\r\nI suppose the solution is to rename the masking `U` to something else, and use the same name consistently."}}