{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2208","labels_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2208/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2208/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2208/events","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2208","id":89819179,"number":2208,"title":"Incorrect erasure with union type argument to constrained type param and default argument","user":{"login":"lucaswerkmeister","id":2346599,"avatar_url":"https://avatars.githubusercontent.com/u/2346599?v=3","gravatar_id":"","url":"https://api.github.com/users/lucaswerkmeister","html_url":"https://github.com/lucaswerkmeister","followers_url":"https://api.github.com/users/lucaswerkmeister/followers","following_url":"https://api.github.com/users/lucaswerkmeister/following{/other_user}","gists_url":"https://api.github.com/users/lucaswerkmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaswerkmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaswerkmeister/subscriptions","organizations_url":"https://api.github.com/users/lucaswerkmeister/orgs","repos_url":"https://api.github.com/users/lucaswerkmeister/repos","events_url":"https://api.github.com/users/lucaswerkmeister/events{/privacy}","received_events_url":"https://api.github.com/users/lucaswerkmeister/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/labels/BUG","name":"BUG","color":"e10c02"},{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/labels/IN%20PROGRESS","name":"IN PROGRESS","color":"02d7e1"}],"state":"open","locked":false,"assignee":{"login":"FroMage","id":179265,"avatar_url":"https://avatars.githubusercontent.com/u/179265?v=3","gravatar_id":"","url":"https://api.github.com/users/FroMage","html_url":"https://github.com/FroMage","followers_url":"https://api.github.com/users/FroMage/followers","following_url":"https://api.github.com/users/FroMage/following{/other_user}","gists_url":"https://api.github.com/users/FroMage/gists{/gist_id}","starred_url":"https://api.github.com/users/FroMage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FroMage/subscriptions","organizations_url":"https://api.github.com/users/FroMage/orgs","repos_url":"https://api.github.com/users/FroMage/repos","events_url":"https://api.github.com/users/FroMage/events{/privacy}","received_events_url":"https://api.github.com/users/FroMage/received_events","type":"User","site_admin":false},"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":18,"closed_issues":297,"state":"open","created_at":"2014-10-01T08:51:07Z","updated_at":"2015-07-01T12:17:09Z","due_on":"2014-11-02T23:00:00Z","closed_at":null},"comments":3,"created_at":"2015-06-20T21:19:37Z","updated_at":"2015-07-01T15:05:42Z","closed_at":null,"body":"```ceylon\r\nshared abstract class Sup() {}\r\nshared class Sub1() extends Sup() {}\r\nshared class Sub2() extends Sup() {}\r\n\r\nshared interface I<T,S>\r\n        given S satisfies Sup {\r\n    shared formal T toT(S s = nothing);\r\n}\r\n\r\nshared object string satisfies I<String,Sub1|Sub2> {\r\n    toT(Sub1|Sub2 s) => \"\";\r\n}\r\n```\r\n> source/tmp/run.ceylon:10: error: `string_` is not abstract and does not override abstract method `toT(Sup)` in `I`\r\n```ceylon\r\nshared object string satisfies I<String,Sub1|Sub2> {\r\n^\r\n```\r\nerror: `toT$s()` in `string_` cannot implement `toT$s()` in `I`\r\n  return type `Object` is not compatible with `Sup`\r\n  where `S` is a type-variable:\r\n    `S extends Sup` declared in interface `I`\r\n\r\nThe error vanishes if you do any of the following:\r\n- remove the `given S satisfies Sup` constraint from `I`\r\n- remove the default argument from `toT`\r\n- remove the union type from `string`’s type argument to `I` (use `Sup`, `Sub1` or `Sub2` instead)\r\n- add an `@noanno` compiler annotation to `string` itself – this only removes the second error (“cannot implement”), the first (“does not override”) remains; other `@noanno`s have no such effect\r\n\r\nThe error remains if you do any of the following:\r\n- implement `string.toT` as a full function definition (`shared actual `etc.)\r\n- implement `string.toT` as a function reference (`toT = toString;`)\r\n- remove the default argument from `toT.s` and instead add a second defaulted parameter (e. g. `Null n = null`); the error looks a bit different in that case (“`toT$n` cannot be applied to given types”), but it’s still `Sup` vs. `Object`\r\n\r\nAs always, [generated code](https://gist.github.com/lucaswerkmeister/8ea52081dd0104c5759d), `@noanno`’d (except for `string`, see above). If you go through the gist’s [history](https://gist.github.com/lucaswerkmeister/8ea52081dd0104c5759d/revisions), you can see how I gradually simplified it further and further. Perhaps you want to test the earliest and largest version manually when you think you’ve fixed the issue, just in case I oversimplified it."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/comments/117710040","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2208#issuecomment-117710040","issue_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2208","id":117710040,"user":{"login":"FroMage","id":179265,"avatar_url":"https://avatars.githubusercontent.com/u/179265?v=3","gravatar_id":"","url":"https://api.github.com/users/FroMage","html_url":"https://github.com/FroMage","followers_url":"https://api.github.com/users/FroMage/followers","following_url":"https://api.github.com/users/FroMage/following{/other_user}","gists_url":"https://api.github.com/users/FroMage/gists{/gist_id}","starred_url":"https://api.github.com/users/FroMage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FroMage/subscriptions","organizations_url":"https://api.github.com/users/FroMage/orgs","repos_url":"https://api.github.com/users/FroMage/repos","events_url":"https://api.github.com/users/FroMage/events{/privacy}","received_events_url":"https://api.github.com/users/FroMage/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T15:05:42Z","updated_at":"2015-07-01T15:05:42Z","body":"OK, two days in, I fixed this one. Now let's see how many others I broke."}}