{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1302","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1302/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1302/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1302/events","html_url":"https://github.com/ceylon/ceylon-spec/issues/1302","id":77394685,"number":1302,"title":"Type inference bug","user":{"login":"renatoathaydes","id":1901277,"avatar_url":"https://avatars.githubusercontent.com/u/1901277?v=3","gravatar_id":"","url":"https://api.github.com/users/renatoathaydes","html_url":"https://github.com/renatoathaydes","followers_url":"https://api.github.com/users/renatoathaydes/followers","following_url":"https://api.github.com/users/renatoathaydes/following{/other_user}","gists_url":"https://api.github.com/users/renatoathaydes/gists{/gist_id}","starred_url":"https://api.github.com/users/renatoathaydes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatoathaydes/subscriptions","organizations_url":"https://api.github.com/users/renatoathaydes/orgs","repos_url":"https://api.github.com/users/renatoathaydes/repos","events_url":"https://api.github.com/users/renatoathaydes/events{/privacy}","received_events_url":"https://api.github.com/users/renatoathaydes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-spec/labels/bug","name":"bug","color":"e10c02"}],"state":"open","locked":false,"assignee":{"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},"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/11","html_url":"https://github.com/ceylon/ceylon-spec/milestones/1.2","labels_url":"https://api.github.com/repos/ceylon/ceylon-spec/milestones/11/labels","id":798020,"number":11,"title":"1.2","description":"Serialization.","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":8,"closed_issues":152,"state":"open","created_at":"2014-09-22T09:55:40Z","updated_at":"2015-05-23T10:39:04Z","due_on":"2014-10-28T23:00:00Z","closed_at":null},"comments":57,"created_at":"2015-05-17T20:45:37Z","updated_at":"2015-05-23T17:42:00Z","closed_at":null,"body":"In the following code, the wrong type is inferred in the last call, and this does not compile:\r\n\r\n```ceylon\r\nclass X<out Y>(shared Y y) {}\r\nX<To> transform<From, To>(X<From> x, To(From) convert)\r\n        => X(convert(x.y));\r\n\r\nX<String> x1 = X(\"10\");\r\nX<Integer?> x2 = transform(x1, parseInteger); // Error\r\n```\r\n\r\nThe error is on `parseInteger`:\r\n\r\n```\r\nArgument must be assignable to parameter convert of transform: Integer?(String, Integer=) is not assignable to Integer?(String|Integer)\r\n```\r\n\r\nBut there is no way that `From` could be an `Integer` in the above code.\r\n\r\nIf the type parameters are explicitly given, it compiles:\r\n\r\n```ceylon\r\nX<Integer?> x2 = transform<String, Integer?>(x1, parseInteger); // OK\r\n```"},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/comments/104929157","html_url":"https://github.com/ceylon/ceylon-spec/issues/1302#issuecomment-104929157","issue_url":"https://api.github.com/repos/ceylon/ceylon-spec/issues/1302","id":104929157,"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-23T17:42:00Z","updated_at":"2015-05-23T17:42:00Z","body":"@RossTate Well, it infers `Reference<Anything,String>` because `Input` in contravariant, so the occurrence of `String` in a _covariant_ location of the parameter list does not constraint it. On the other hand, this covariant occurrence of `Input`, which has `Output` as a supertype, _does_ push `Output` upward, because `Output` is _covariant_. Thus far it's all quite sound.\r\n\r\nWhat I need to look into, like I said above, is then coming back and substituting `Output=String` when I apply the upper bound on `Input` to the inferred value for `Input`. Right now the upper bound gets thrown away."}}