{"action":"created","comment":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/27349177","id":27349177,"diff_hunk":"@@ -170,15 +170,27 @@ object Erasure extends TypeTestsCasts{\n     def unbox(tree: Tree, pt: Type)(implicit ctx: Context): Tree = ctx.traceIndented(i\"unboxing ${tree.showSummary}: ${tree.tpe} as a $pt\") {\n       pt match {\n         case ErasedValueType(clazz, underlying) =>\n+          def unboxedTree(t: Tree) =\n+            adaptToType(t, clazz.typeRef)\n+            .select(valueClassUnbox(clazz))\n+            .appliedToNone\n+\n+          // Null unboxing needs to be treated separately since we cannot call a method on null.\n+          // See tests/pos/vcnull.scala for cases where this might happen.\n           val tree1 =\n-            if ((tree.tpe isRef defn.NullClass) && underlying.isPrimitiveValueType)\n-              // convert `null` directly to underlying type, as going\n-              // via the unboxed type would yield a NPE (see SI-5866)\n-              unbox(tree, underlying)\n-            else\n-              adaptToType(tree, clazz.typeRef)\n-                .select(valueClassUnbox(clazz))\n-                .appliedToNone\n+            if (tree.tpe isRef defn.NullClass)\n+              adaptToType(tree, underlying)\n+            else if (!(tree.tpe <:< clazz.typeRef)) {\n+              assert(!(tree.tpe.typeSymbol.isPrimitiveValueClass))\n+              val nullTree = Literal(Constant(null))","path":"src/dotty/tools/dotc/transform/Erasure.scala","position":33,"original_position":33,"commit_id":"650ef9aab90bffd66e2cba0152db822c1e3a0de7","original_commit_id":"650ef9aab90bffd66e2cba0152db822c1e3a0de7","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":"`unboxedNull` -> `zeroOfValueType`","created_at":"2015-03-28T22:12:25Z","updated_at":"2015-03-28T22:12:25Z","html_url":"https://github.com/lampepfl/dotty/pull/411#discussion_r27349177","pull_request_url":"https://api.github.com/repos/lampepfl/dotty/pulls/411","_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/27349177"},"html":{"href":"https://github.com/lampepfl/dotty/pull/411#discussion_r27349177"},"pull_request":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/411"}}},"pull_request":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/411","id":31300697,"html_url":"https://github.com/lampepfl/dotty/pull/411","diff_url":"https://github.com/lampepfl/dotty/pull/411.diff","patch_url":"https://github.com/lampepfl/dotty/pull/411.patch","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/411","number":411,"state":"open","locked":false,"title":"Implement value classes","user":{"login":"smarter","id":63430,"avatar_url":"https://avatars.githubusercontent.com/u/63430?v=3","gravatar_id":"","url":"https://api.github.com/users/smarter","html_url":"https://github.com/smarter","followers_url":"https://api.github.com/users/smarter/followers","following_url":"https://api.github.com/users/smarter/following{/other_user}","gists_url":"https://api.github.com/users/smarter/gists{/gist_id}","starred_url":"https://api.github.com/users/smarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarter/subscriptions","organizations_url":"https://api.github.com/users/smarter/orgs","repos_url":"https://api.github.com/users/smarter/repos","events_url":"https://api.github.com/users/smarter/events{/privacy}","received_events_url":"https://api.github.com/users/smarter/received_events","type":"User","site_admin":false},"body":"This implements value classes by roughly following [SIP-15](https://docs.google.com/document/d/10TQKgMiJTbVtkdRG53wsLYwWM2MkhtmdV25-NZvLLMA/edit?hl=en_US), see the description of each individual commit for the details.","created_at":"2015-03-17T01:37:14Z","updated_at":"2015-03-28T22:12:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85deea486bf013a614da611df5749b469262e5bb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lampepfl/dotty/pulls/411/commits","review_comments_url":"https://api.github.com/repos/lampepfl/dotty/pulls/411/comments","review_comment_url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/411/comments","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/650ef9aab90bffd66e2cba0152db822c1e3a0de7","head":{"label":"smarter:add/value-classes","ref":"add/value-classes","sha":"650ef9aab90bffd66e2cba0152db822c1e3a0de7","user":{"login":"smarter","id":63430,"avatar_url":"https://avatars.githubusercontent.com/u/63430?v=3","gravatar_id":"","url":"https://api.github.com/users/smarter","html_url":"https://github.com/smarter","followers_url":"https://api.github.com/users/smarter/followers","following_url":"https://api.github.com/users/smarter/following{/other_user}","gists_url":"https://api.github.com/users/smarter/gists{/gist_id}","starred_url":"https://api.github.com/users/smarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarter/subscriptions","organizations_url":"https://api.github.com/users/smarter/orgs","repos_url":"https://api.github.com/users/smarter/repos","events_url":"https://api.github.com/users/smarter/events{/privacy}","received_events_url":"https://api.github.com/users/smarter/received_events","type":"User","site_admin":false},"repo":{"id":19007864,"name":"dotty","full_name":"smarter/dotty","owner":{"login":"smarter","id":63430,"avatar_url":"https://avatars.githubusercontent.com/u/63430?v=3","gravatar_id":"","url":"https://api.github.com/users/smarter","html_url":"https://github.com/smarter","followers_url":"https://api.github.com/users/smarter/followers","following_url":"https://api.github.com/users/smarter/following{/other_user}","gists_url":"https://api.github.com/users/smarter/gists{/gist_id}","starred_url":"https://api.github.com/users/smarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarter/subscriptions","organizations_url":"https://api.github.com/users/smarter/orgs","repos_url":"https://api.github.com/users/smarter/repos","events_url":"https://api.github.com/users/smarter/events{/privacy}","received_events_url":"https://api.github.com/users/smarter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smarter/dotty","description":"Research platform for new language concepts and compiler technologies for Scala.","fork":true,"url":"https://api.github.com/repos/smarter/dotty","forks_url":"https://api.github.com/repos/smarter/dotty/forks","keys_url":"https://api.github.com/repos/smarter/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarter/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarter/dotty/teams","hooks_url":"https://api.github.com/repos/smarter/dotty/hooks","issue_events_url":"https://api.github.com/repos/smarter/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/smarter/dotty/events","assignees_url":"https://api.github.com/repos/smarter/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/smarter/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/smarter/dotty/tags","blobs_url":"https://api.github.com/repos/smarter/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarter/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarter/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarter/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarter/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/smarter/dotty/languages","stargazers_url":"https://api.github.com/repos/smarter/dotty/stargazers","contributors_url":"https://api.github.com/repos/smarter/dotty/contributors","subscribers_url":"https://api.github.com/repos/smarter/dotty/subscribers","subscription_url":"https://api.github.com/repos/smarter/dotty/subscription","commits_url":"https://api.github.com/repos/smarter/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarter/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarter/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarter/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/smarter/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/smarter/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarter/dotty/merges","archive_url":"https://api.github.com/repos/smarter/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarter/dotty/downloads","issues_url":"https://api.github.com/repos/smarter/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/smarter/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/smarter/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/smarter/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarter/dotty/labels{/name}","releases_url":"https://api.github.com/repos/smarter/dotty/releases{/id}","created_at":"2014-04-21T21:37:16Z","updated_at":"2014-10-24T14:22:31Z","pushed_at":"2015-03-28T21:54:49Z","git_url":"git://github.com/smarter/dotty.git","ssh_url":"git@github.com:smarter/dotty.git","clone_url":"https://github.com/smarter/dotty.git","svn_url":"https://github.com/smarter/dotty","homepage":"","size":10876,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"lampepfl:master","ref":"master","sha":"dbb48c85e9960681e97888d18b717d5e23136889","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}","created_at":"2012-12-06T12:57:33Z","updated_at":"2015-03-28T20:37:13Z","pushed_at":"2015-03-28T21:54:49Z","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":19895,"stargazers_count":329,"watchers_count":329,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":69,"forks":43,"open_issues":69,"watchers":329,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/411"},"html":{"href":"https://github.com/lampepfl/dotty/pull/411"},"issue":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/411"},"comments":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/411/comments"},"review_comments":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/411/comments"},"review_comment":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/411/commits"},"statuses":{"href":"https://api.github.com/repos/lampepfl/dotty/statuses/650ef9aab90bffd66e2cba0152db822c1e3a0de7"}}}}