{"action":"created","comment":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/52031852","id":52031852,"diff_hunk":"@@ -303,8 +303,134 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans\n     def optimizeCases(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type): (List[List[TreeMaker]], List[Tree])\n     def analyzeCases(prevBinder: Symbol, cases: List[List[TreeMaker]], pt: Type, suppression: Suppression): Unit = {}\n \n-    def emitSwitch(scrut: Tree, scrutSym: Symbol, cases: List[List[TreeMaker]], pt: Type, matchFailGenOverride: Option[Symbol => Tree], unchecked: Boolean): Option[Tree] =\n-      None // todo\n+    def emitSwitch(scrut: Tree, scrutSym: Symbol, cases: List[List[TreeMaker]], pt: Type, matchFailGenOverride: Option[Symbol => Tree], unchecked: Boolean): Option[Tree] = {\n+      // TODO Deal with guards?\n+\n+      def isSwitchableType(tpe: Type): Boolean = {\n+        (tpe isRef defn.IntClass) ||\n+        (tpe isRef defn.ByteClass) ||\n+        (tpe isRef defn.ShortClass) ||\n+        (tpe isRef defn.CharClass)","path":"src/dotty/tools/dotc/transform/PatternMatcher.scala","position":13,"original_position":13,"commit_id":"004401b406b869957dbecc2390285b857eb3c7ed","original_commit_id":"004401b406b869957dbecc2390285b857eb3c7ed","user":{"login":"DarkDimius","id":1084930,"avatar_url":"https://avatars.githubusercontent.com/u/1084930?v=3","gravatar_id":"","url":"https://api.github.com/users/DarkDimius","html_url":"https://github.com/DarkDimius","followers_url":"https://api.github.com/users/DarkDimius/followers","following_url":"https://api.github.com/users/DarkDimius/following{/other_user}","gists_url":"https://api.github.com/users/DarkDimius/gists{/gist_id}","starred_url":"https://api.github.com/users/DarkDimius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarkDimius/subscriptions","organizations_url":"https://api.github.com/users/DarkDimius/orgs","repos_url":"https://api.github.com/users/DarkDimius/repos","events_url":"https://api.github.com/users/DarkDimius/events{/privacy}","received_events_url":"https://api.github.com/users/DarkDimius/received_events","type":"User","site_admin":false},"body":"After a bit of discussion: let's leave this possibility for future as it's not clear what is a constant for a value class.","created_at":"2016-02-05T15:48:45Z","updated_at":"2016-02-05T15:48:45Z","html_url":"https://github.com/lampepfl/dotty/pull/1061#discussion_r52031852","pull_request_url":"https://api.github.com/repos/lampepfl/dotty/pulls/1061","_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/52031852"},"html":{"href":"https://github.com/lampepfl/dotty/pull/1061#discussion_r52031852"},"pull_request":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/1061"}}},"pull_request":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/1061","id":58440840,"html_url":"https://github.com/lampepfl/dotty/pull/1061","diff_url":"https://github.com/lampepfl/dotty/pull/1061.diff","patch_url":"https://github.com/lampepfl/dotty/pull/1061.patch","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/1061","number":1061,"state":"open","locked":false,"title":"Fix #854: Optimize matches on primitive constants as switches.","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"body":"This does not yet unable the checks that `@switch` verifies that the compiler was indeed able to perform the optimization.\r\n\r\nThis implementation also does not support guards. A match with guards will never be optimized as a switch.","created_at":"2016-02-05T15:14:20Z","updated_at":"2016-02-05T15:48:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8cc71746b6da37ce00e23396a39e531df52010c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lampepfl/dotty/pulls/1061/commits","review_comments_url":"https://api.github.com/repos/lampepfl/dotty/pulls/1061/comments","review_comment_url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/1061/comments","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/004401b406b869957dbecc2390285b857eb3c7ed","head":{"label":"sjrd:switches","ref":"switches","sha":"004401b406b869957dbecc2390285b857eb3c7ed","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"repo":{"id":16916977,"name":"dotty","full_name":"sjrd/dotty","owner":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sjrd/dotty","description":"The experimental compiler for a Scala dialect based on DOT","fork":true,"url":"https://api.github.com/repos/sjrd/dotty","forks_url":"https://api.github.com/repos/sjrd/dotty/forks","keys_url":"https://api.github.com/repos/sjrd/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sjrd/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sjrd/dotty/teams","hooks_url":"https://api.github.com/repos/sjrd/dotty/hooks","issue_events_url":"https://api.github.com/repos/sjrd/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/sjrd/dotty/events","assignees_url":"https://api.github.com/repos/sjrd/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/sjrd/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/sjrd/dotty/tags","blobs_url":"https://api.github.com/repos/sjrd/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sjrd/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sjrd/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/sjrd/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sjrd/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/sjrd/dotty/languages","stargazers_url":"https://api.github.com/repos/sjrd/dotty/stargazers","contributors_url":"https://api.github.com/repos/sjrd/dotty/contributors","subscribers_url":"https://api.github.com/repos/sjrd/dotty/subscribers","subscription_url":"https://api.github.com/repos/sjrd/dotty/subscription","commits_url":"https://api.github.com/repos/sjrd/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/sjrd/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/sjrd/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/sjrd/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/sjrd/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/sjrd/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sjrd/dotty/merges","archive_url":"https://api.github.com/repos/sjrd/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sjrd/dotty/downloads","issues_url":"https://api.github.com/repos/sjrd/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/sjrd/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/sjrd/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/sjrd/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sjrd/dotty/labels{/name}","releases_url":"https://api.github.com/repos/sjrd/dotty/releases{/id}","deployments_url":"https://api.github.com/repos/sjrd/dotty/deployments","created_at":"2014-02-17T15:23:36Z","updated_at":"2016-02-02T18:08:00Z","pushed_at":"2016-02-05T15:13:43Z","git_url":"git://github.com/sjrd/dotty.git","ssh_url":"git@github.com:sjrd/dotty.git","clone_url":"https://github.com/sjrd/dotty.git","svn_url":"https://github.com/sjrd/dotty","homepage":null,"size":15322,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lampepfl:master","ref":"master","sha":"9d8c92d1d52fcfa95d57ce88d91dbb84c8ecfbd1","user":{"login":"lampepfl","id":2684793,"avatar_url":"https://avatars.githubusercontent.com/u/2684793?v=3","gravatar_id":"","url":"https://api.github.com/users/lampepfl","html_url":"https://github.com/lampepfl","followers_url":"https://api.github.com/users/lampepfl/followers","following_url":"https://api.github.com/users/lampepfl/following{/other_user}","gists_url":"https://api.github.com/users/lampepfl/gists{/gist_id}","starred_url":"https://api.github.com/users/lampepfl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lampepfl/subscriptions","organizations_url":"https://api.github.com/users/lampepfl/orgs","repos_url":"https://api.github.com/users/lampepfl/repos","events_url":"https://api.github.com/users/lampepfl/events{/privacy}","received_events_url":"https://api.github.com/users/lampepfl/received_events","type":"Organization","site_admin":false},"repo":{"id":7035651,"name":"dotty","full_name":"lampepfl/dotty","owner":{"login":"lampepfl","id":2684793,"avatar_url":"https://avatars.githubusercontent.com/u/2684793?v=3","gravatar_id":"","url":"https://api.github.com/users/lampepfl","html_url":"https://github.com/lampepfl","followers_url":"https://api.github.com/users/lampepfl/followers","following_url":"https://api.github.com/users/lampepfl/following{/other_user}","gists_url":"https://api.github.com/users/lampepfl/gists{/gist_id}","starred_url":"https://api.github.com/users/lampepfl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lampepfl/subscriptions","organizations_url":"https://api.github.com/users/lampepfl/orgs","repos_url":"https://api.github.com/users/lampepfl/repos","events_url":"https://api.github.com/users/lampepfl/events{/privacy}","received_events_url":"https://api.github.com/users/lampepfl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lampepfl/dotty","description":"Research platform for new language concepts and compiler technologies for Scala.","fork":false,"url":"https://api.github.com/repos/lampepfl/dotty","forks_url":"https://api.github.com/repos/lampepfl/dotty/forks","keys_url":"https://api.github.com/repos/lampepfl/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lampepfl/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lampepfl/dotty/teams","hooks_url":"https://api.github.com/repos/lampepfl/dotty/hooks","issue_events_url":"https://api.github.com/repos/lampepfl/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/lampepfl/dotty/events","assignees_url":"https://api.github.com/repos/lampepfl/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/lampepfl/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/lampepfl/dotty/tags","blobs_url":"https://api.github.com/repos/lampepfl/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lampepfl/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lampepfl/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/lampepfl/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/lampepfl/dotty/languages","stargazers_url":"https://api.github.com/repos/lampepfl/dotty/stargazers","contributors_url":"https://api.github.com/repos/lampepfl/dotty/contributors","subscribers_url":"https://api.github.com/repos/lampepfl/dotty/subscribers","subscription_url":"https://api.github.com/repos/lampepfl/dotty/subscription","commits_url":"https://api.github.com/repos/lampepfl/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/lampepfl/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/lampepfl/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/lampepfl/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/lampepfl/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/lampepfl/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lampepfl/dotty/merges","archive_url":"https://api.github.com/repos/lampepfl/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lampepfl/dotty/downloads","issues_url":"https://api.github.com/repos/lampepfl/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/lampepfl/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/lampepfl/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/lampepfl/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lampepfl/dotty/labels{/name}","releases_url":"https://api.github.com/repos/lampepfl/dotty/releases{/id}","deployments_url":"https://api.github.com/repos/lampepfl/dotty/deployments","created_at":"2012-12-06T12:57:33Z","updated_at":"2016-02-05T07:40:12Z","pushed_at":"2016-02-05T15:14:20Z","git_url":"git://github.com/lampepfl/dotty.git","ssh_url":"git@github.com:lampepfl/dotty.git","clone_url":"https://github.com/lampepfl/dotty.git","svn_url":"https://github.com/lampepfl/dotty","homepage":"","size":22676,"stargazers_count":717,"watchers_count":717,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":96,"mirror_url":null,"open_issues_count":141,"forks":96,"open_issues":141,"watchers":717,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/1061"},"html":{"href":"https://github.com/lampepfl/dotty/pull/1061"},"issue":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/1061"},"comments":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/1061/comments"},"review_comments":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/1061/comments"},"review_comment":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/1061/commits"},"statuses":{"href":"https://api.github.com/repos/lampepfl/dotty/statuses/004401b406b869957dbecc2390285b857eb3c7ed"}}}}