{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/129","repository_url":"https://api.github.com/repos/dotnet/csharplang","labels_url":"https://api.github.com/repos/dotnet/csharplang/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/csharplang/issues/129/comments","events_url":"https://api.github.com/repos/dotnet/csharplang/issues/129/events","html_url":"https://github.com/dotnet/csharplang/issues/129","id":208180733,"number":129,"title":"Type argument inference with unambiguous method group","user":{"login":"jnm2","id":8040367,"avatar_url":"https://avatars.githubusercontent.com/u/8040367?v=3","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-16T16:52:42Z","updated_at":"2017-02-16T16:52:42Z","closed_at":null,"body":"@jnm2 commented on [Mon Jan 30 2017](https://github.com/dotnet/roslyn/issues/16824)\n\nApologies if this is a dupe; I don't see another issue like this.\r\n\r\nPlease allow the following. I see no possible ambiguity in this scenario. The`IsEven` and `Test` method groups have only one overload which fits the delegate signature.\r\n\r\n```c#\r\nclass Program\r\n{\r\n    public static void Main()\r\n    {\r\n        Test(IsEven);\r\n    }\r\n\r\n    public static bool IsEven(int x) => x % 2 == 0;\r\n\r\n    public static void Test<T>(Func<T, bool> predicate)\r\n    {\r\n    }\r\n}\r\n```\r\n\r\n**Expected Behavior**:\r\nInfers `Test<int>(IsEven)` and compiles\r\n\r\n**Actual Behavior**:\r\nCS0411 The type arguments for method 'Program.Test<T>(Func<T, bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.\r\n\n\n---\n\n@jaredpar commented on [Mon Jan 30 2017](https://github.com/dotnet/roslyn/issues/16824#issuecomment-276143273)\n\nBelieve this is by design but will let @gafter comment on exactly how. \n\n---\n\n@gafter commented on [Mon Jan 30 2017](https://github.com/dotnet/roslyn/issues/16824#issuecomment-276177025)\n\nType inference [doesn't infer based on an argument that is a method group](https://github.com/ljw1004/csharpspec/blob/gh-pages/expressions.md#the-first-phase), no matter how many or few members the method group has. The conversion from a method group to a delegate (of some particular type) occurs *after* type inference has completed to determine what that delegate type is.\r\n\r\nHaving said that, I imagine it might be possible to modify (the specification for) type inference to get the behavior @jnm2 would like. Who would like to take a crack at it?\n\n---\n\n@jnm2 commented on [Tue Feb 14 2017](https://github.com/dotnet/roslyn/issues/16824#issuecomment-279878112)\n\n@gafter Should I move this to csharplang?\n\n---\n\n@gafter commented on [Wed Feb 15 2017](https://github.com/dotnet/roslyn/issues/16824#issuecomment-280097496)\n\n@jnm2 Sure, if you'd like to discuss it further. But without a suggestion as to *how* it would work, I don't see how it can move past the discussion phase. Perhaps that discussion will trigger an idea in someone's head?\n\n"}}
{"actor":{"display_login":"jnm2"}}