{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/180607794","pull_request_review_id":111057655,"id":180607794,"diff_hunk":"@@ -1125,6 +1125,113 @@ .maxstack  2\n   IL_0013:  ret\n   IL_0014:  ldc.i4.0\n   IL_0015:  ret\n+}\");\n+        }\n+\n+        [Fact]\n+        [WorkItem(24550, \"https://github.com/dotnet/roslyn/issues/24550\")]\n+        [WorkItem(1284, \"https://github.com/dotnet/csharplang/issues/1284\")]\n+        public void ConstantPatternVsUnconstrainedTypeParameter01()\n+        {\n+            var source =\n+@\"using System;\n+class Program\n+{\n+    static void Main()\n+    {\n+        Console.WriteLine(Test1<object>(null));\n+        Console.WriteLine(Test1<int>(1));\n+        Console.WriteLine(Test1<int?>(null));\n+        Console.WriteLine(Test1<int?>(1));\n+\n+        Console.WriteLine(Test2<object>(0));\n+        Console.WriteLine(Test2<int>(1));\n+        Console.WriteLine(Test2<int?>(0));\n+        Console.WriteLine(Test2<string>(\"\"frog\"\"));\n+\n+        Console.WriteLine(Test3<object>(\"\"frog\"\"));\n+        Console.WriteLine(Test3<int>(1));\n+        Console.WriteLine(Test3<string>(\"\"frog\"\"));\n+        Console.WriteLine(Test3<int?>(1));\n+    }\n+\n+    public static bool Test1<T>(T t)\n+    {\n+        return t is null;\n+    }\n+    public static bool Test2<T>(T t)\n+    {\n+        return t is 0;\n+    }\n+    public static bool Test3<T>(T t)\n+    {\n+        return t is \"\"frog\"\";\n+    }\n+}\";\n+            var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe);\n+            compilation.VerifyDiagnostics();\n+            var expectedOutput =\n+@\"True\n+False\n+True\n+False\n+True\n+False\n+True\n+False\n+True\n+False\n+True\n+False\n+\";\n+            var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);\n+            compVerifier.VerifyIL(\"Program.Test1<T>(T)\",\n+@\"{\n+  // Code size       10 (0xa)\n+  .maxstack  2\n+  IL_0000:  ldarg.0\n+  IL_0001:  box        \"\"T\"\"","path":"src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs","position":69,"original_position":69,"commit_id":"a7c54253b49ee8064f105614b06b39165f3a4e7d","original_commit_id":"a7c54253b49ee8064f105614b06b39165f3a4e7d","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"body":"As far as I know, no. The CLR does not actually produce code for the box. If it is a reference type, the box goes away. If it is a value type, the whole method turns into `false`.\r\n\r\n---\r\nIn reply to: [180594436](https://github.com/dotnet/roslyn/pull/25995#discussion_r180594436) [](ancestors = 180594436)","created_at":"2018-04-11T00:48:31Z","updated_at":"2018-04-11T00:48:31Z","html_url":"https://github.com/dotnet/roslyn/pull/25995#discussion_r180607794","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/25995","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/180607794"},"html":{"href":"https://github.com/dotnet/roslyn/pull/25995#discussion_r180607794"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/25995"}},"in_reply_to_id":180594436},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/25995","id":180008393,"html_url":"https://github.com/dotnet/roslyn/pull/25995","diff_url":"https://github.com/dotnet/roslyn/pull/25995.diff","patch_url":"https://github.com/dotnet/roslyn/pull/25995.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/25995","number":25995,"state":"open","locked":false,"title":"recursive-patterns(18): Permit a constant pattern to be used with an open type as input","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"body":"Fixes #24550\r\nFixes https://github.com/dotnet/csharplang/issues/1284\r\nAlso includes a slight code improvement for these and related cases.\r\n\r\n@cston @agocke Please review\r\n@dotnet/roslyn-compiler Additional reviews welcome\r\n","created_at":"2018-04-06T17:28:45Z","updated_at":"2018-04-11T00:48:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca3457e0a198bfc8fb7f606a900ed62ed222ada2","assignee":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"assignees":[{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":167974280,"url":"https://api.github.com/repos/dotnet/roslyn/labels/4%20-%20In%20Review","name":"4 - In Review","color":"CCCCCC","default":false},{"id":166673288,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7","default":false},{"id":326633537,"url":"https://api.github.com/repos/dotnet/roslyn/labels/New%20Language%20Feature%20-%20Pattern%20Matching","name":"New Language Feature - Pattern Matching","color":"bfd4f2","default":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/18","html_url":"https://github.com/dotnet/roslyn/milestone/18","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/18/labels","id":1675130,"number":18,"title":"16.0","description":"The version *after* the next major version.","creator":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"open_issues":636,"closed_issues":162,"state":"open","created_at":"2016-03-31T00:06:25Z","updated_at":"2018-04-10T23:32:43Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/25995/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/25995/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/25995/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/a7c54253b49ee8064f105614b06b39165f3a4e7d","head":{"label":"gafter:rpatterns18","ref":"rpatterns18","sha":"a7c54253b49ee8064f105614b06b39165f3a4e7d","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"repo":{"id":30125216,"name":"roslyn","full_name":"gafter/roslyn","owner":{"login":"gafter","id":3804346,"avatar_url":"https://avatars3.githubusercontent.com/u/3804346?v=4","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gafter/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/gafter/roslyn","forks_url":"https://api.github.com/repos/gafter/roslyn/forks","keys_url":"https://api.github.com/repos/gafter/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gafter/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gafter/roslyn/teams","hooks_url":"https://api.github.com/repos/gafter/roslyn/hooks","issue_events_url":"https://api.github.com/repos/gafter/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/gafter/roslyn/events","assignees_url":"https://api.github.com/repos/gafter/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/gafter/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/gafter/roslyn/tags","blobs_url":"https://api.github.com/repos/gafter/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gafter/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gafter/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/gafter/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gafter/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/gafter/roslyn/languages","stargazers_url":"https://api.github.com/repos/gafter/roslyn/stargazers","contributors_url":"https://api.github.com/repos/gafter/roslyn/contributors","subscribers_url":"https://api.github.com/repos/gafter/roslyn/subscribers","subscription_url":"https://api.github.com/repos/gafter/roslyn/subscription","commits_url":"https://api.github.com/repos/gafter/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/gafter/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/gafter/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/gafter/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/gafter/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/gafter/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gafter/roslyn/merges","archive_url":"https://api.github.com/repos/gafter/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gafter/roslyn/downloads","issues_url":"https://api.github.com/repos/gafter/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/gafter/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/gafter/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/gafter/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gafter/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/gafter/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/gafter/roslyn/deployments","created_at":"2015-01-31T20:26:12Z","updated_at":"2018-04-03T20:00:07Z","pushed_at":"2018-04-11T00:28:09Z","git_url":"git://github.com/gafter/roslyn.git","ssh_url":"git@github.com:gafter/roslyn.git","clone_url":"https://github.com/gafter/roslyn.git","svn_url":"https://github.com/gafter/roslyn","homepage":"","size":317973,"stargazers_count":1,"watchers_count":1,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"dotnet:features/recursive-patterns","ref":"features/recursive-patterns","sha":"8de96ab87ecd16046b24eb65a5ca6973369abbba","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/roslyn/deployments","created_at":"2015-01-11T02:39:03Z","updated_at":"2018-04-10T21:09:53Z","pushed_at":"2018-04-11T00:28:13Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":340617,"stargazers_count":9131,"watchers_count":9131,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2190,"mirror_url":null,"archived":false,"open_issues_count":4635,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2190,"open_issues":4635,"watchers":9131,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/25995"},"html":{"href":"https://github.com/dotnet/roslyn/pull/25995"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/25995"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/25995/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/25995/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/25995/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/a7c54253b49ee8064f105614b06b39165f3a4e7d"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"gafter"}}