{"action":"created","comment":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/30306155","id":30306155,"diff_hunk":"@@ -0,0 +1,57 @@\n+package dotty.tools.dotc\n+package transform\n+\n+import core._\n+import TreeTransforms._\n+import Contexts.Context\n+import Flags._\n+import SymUtils._\n+import Symbols._\n+import SymDenotations._\n+import Types._\n+import Decorators._\n+import DenotTransformers._\n+import StdNames._\n+import NameOps._\n+import ast.Trees._\n+import dotty.tools.dotc.ast.tpd\n+import dotty.tools.dotc.core.Constants.Constant\n+import util.Positions._\n+import Names._\n+import collection.mutable\n+\n+/** This phase replaces calls to DottyPredef.classTag by code that synthesizes appropriate ClassTag\n+  */\n+class ClassTags extends MiniPhaseTransform with IdentityDenotTransformer { thisTransform =>\n+  import ast.tpd._\n+\n+  object names {\n+    val classTag = \"classTag\".toTermName\n+    val typeTag  = \"typeTag\".toTermName\n+  }\n+\n+  private var classTagCache: Symbol = null\n+  private var typeTagCache: Symbol  = null\n+  private var scala2ClassTagModule: Symbol = null\n+\n+\n+  override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context): TreeTransform = {\n+    val predefClass = defn.DottyPredefModule.moduleClass.asClass\n+    classTagCache = ctx.requiredMethod(predefClass,  names.classTag)\n+    typeTagCache = ctx.requiredMethod(predefClass,  names.typeTag)\n+    scala2ClassTagModule = ctx.requiredModule(\"scala.reflect.ClassTag\")\n+    this\n+  }\n+\n+  override def phaseName: String = \"classTags\"\n+\n+  override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context, info: TransformerInfo): tpd.Tree =\n+    if (tree.fun.symbol eq classTagCache) {\n+      val tp = tree.args.head.tpe\n+      val claz = tp.classSymbol","path":"src/dotty/tools/dotc/transform/ClassTags.scala","position":51,"original_position":51,"commit_id":"fe903c00027f0440207dc70c8b1d50ef3d0b3701","original_commit_id":"fe903c00027f0440207dc70c8b1d50ef3d0b3701","user":{"login":"odersky","id":795990,"avatar_url":"https://avatars.githubusercontent.com/u/795990?v=3","gravatar_id":"","url":"https://api.github.com/users/odersky","html_url":"https://github.com/odersky","followers_url":"https://api.github.com/users/odersky/followers","following_url":"https://api.github.com/users/odersky/following{/other_user}","gists_url":"https://api.github.com/users/odersky/gists{/gist_id}","starred_url":"https://api.github.com/users/odersky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odersky/subscriptions","organizations_url":"https://api.github.com/users/odersky/orgs","repos_url":"https://api.github.com/users/odersky/repos","events_url":"https://api.github.com/users/odersky/events{/privacy}","received_events_url":"https://api.github.com/users/odersky/received_events","type":"User","site_admin":false},"body":"On Thu, May 14, 2015 at 9:07 AM, Dmitry Petrashko <notifications@github.com>\nwrote:\n\n> In src/dotty/tools/dotc/transform/ClassTags.scala\n> <https://github.com/lampepfl/dotty/pull/563#discussion_r30301852>:\n>\n> > +\n> > +\n> > +  override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context): TreeTransform = {\n> > +    val predefClass = defn.DottyPredefModule.moduleClass.asClass\n> > +    classTagCache = ctx.requiredMethod(predefClass,  names.classTag)\n> > +    typeTagCache = ctx.requiredMethod(predefClass,  names.typeTag)\n> > +    scala2ClassTagModule = ctx.requiredModule(\"scala.reflect.ClassTag\")\n> > +    this\n> > +  }\n> > +\n> > +  override def phaseName: String = \"classTags\"\n> > +\n> > +  override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context, info: TransformerInfo): tpd.Tree =\n> > +    if (tree.fun.symbol eq classTagCache) {\n> > +      val tp = tree.args.head.tpe\n> > +      val claz = tp.classSymbol\n>\n> Thanks for Array example, It's indeed not handled correctly.\n> classSymbol for OrTypes is bugged, see comment\n> https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/core/Types.scala#L308.\n> It should not return NoSymbol.\n> Though this code will not work for some AndTypes.\n>\n> It seems that classSymbol.orElse(classSymbols.head) should do it\n> correctly.\n>\n> That will return a symbol. but how do you know it's the right one? We are\nmissing a spec here. I think the most robust would be to take the\nclassSymbol of the erased type. That has a simple spec and it is likely to\nbe the one we will want in the end.\n\n\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/lampepfl/dotty/pull/563/files#r30301852>.\n>\n\n\n\n-- \nMartin Odersky\nEPFL\n","created_at":"2015-05-14T08:48:30Z","updated_at":"2015-05-14T08:48:30Z","html_url":"https://github.com/lampepfl/dotty/pull/563#discussion_r30306155","pull_request_url":"https://api.github.com/repos/lampepfl/dotty/pulls/563","_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments/30306155"},"html":{"href":"https://github.com/lampepfl/dotty/pull/563#discussion_r30306155"},"pull_request":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/563"}}},"pull_request":{"url":"https://api.github.com/repos/lampepfl/dotty/pulls/563","id":35337833,"html_url":"https://github.com/lampepfl/dotty/pull/563","diff_url":"https://github.com/lampepfl/dotty/pull/563.diff","patch_url":"https://github.com/lampepfl/dotty/pull/563.patch","issue_url":"https://api.github.com/repos/lampepfl/dotty/issues/563","number":563,"state":"open","locked":false,"title":"ClassTags: New phase which synthesises class tags.","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":null,"created_at":"2015-05-13T15:18:49Z","updated_at":"2015-05-14T08:48:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97d721eaf72b42526c326e1ff310112ae947ee3d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lampepfl/dotty/pulls/563/commits","review_comments_url":"https://api.github.com/repos/lampepfl/dotty/pulls/563/comments","review_comment_url":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lampepfl/dotty/issues/563/comments","statuses_url":"https://api.github.com/repos/lampepfl/dotty/statuses/fe903c00027f0440207dc70c8b1d50ef3d0b3701","head":{"label":"dotty-staging:classtags","ref":"classtags","sha":"fe903c00027f0440207dc70c8b1d50ef3d0b3701","user":{"login":"dotty-staging","id":6998674,"avatar_url":"https://avatars.githubusercontent.com/u/6998674?v=3","gravatar_id":"","url":"https://api.github.com/users/dotty-staging","html_url":"https://github.com/dotty-staging","followers_url":"https://api.github.com/users/dotty-staging/followers","following_url":"https://api.github.com/users/dotty-staging/following{/other_user}","gists_url":"https://api.github.com/users/dotty-staging/gists{/gist_id}","starred_url":"https://api.github.com/users/dotty-staging/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotty-staging/subscriptions","organizations_url":"https://api.github.com/users/dotty-staging/orgs","repos_url":"https://api.github.com/users/dotty-staging/repos","events_url":"https://api.github.com/users/dotty-staging/events{/privacy}","received_events_url":"https://api.github.com/users/dotty-staging/received_events","type":"Organization","site_admin":false},"repo":{"id":17904384,"name":"dotty","full_name":"dotty-staging/dotty","owner":{"login":"dotty-staging","id":6998674,"avatar_url":"https://avatars.githubusercontent.com/u/6998674?v=3","gravatar_id":"","url":"https://api.github.com/users/dotty-staging","html_url":"https://github.com/dotty-staging","followers_url":"https://api.github.com/users/dotty-staging/followers","following_url":"https://api.github.com/users/dotty-staging/following{/other_user}","gists_url":"https://api.github.com/users/dotty-staging/gists{/gist_id}","starred_url":"https://api.github.com/users/dotty-staging/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotty-staging/subscriptions","organizations_url":"https://api.github.com/users/dotty-staging/orgs","repos_url":"https://api.github.com/users/dotty-staging/repos","events_url":"https://api.github.com/users/dotty-staging/events{/privacy}","received_events_url":"https://api.github.com/users/dotty-staging/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotty-staging/dotty","description":"Research platform for new language concepts and compiler technologies for Scala.","fork":true,"url":"https://api.github.com/repos/dotty-staging/dotty","forks_url":"https://api.github.com/repos/dotty-staging/dotty/forks","keys_url":"https://api.github.com/repos/dotty-staging/dotty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotty-staging/dotty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotty-staging/dotty/teams","hooks_url":"https://api.github.com/repos/dotty-staging/dotty/hooks","issue_events_url":"https://api.github.com/repos/dotty-staging/dotty/issues/events{/number}","events_url":"https://api.github.com/repos/dotty-staging/dotty/events","assignees_url":"https://api.github.com/repos/dotty-staging/dotty/assignees{/user}","branches_url":"https://api.github.com/repos/dotty-staging/dotty/branches{/branch}","tags_url":"https://api.github.com/repos/dotty-staging/dotty/tags","blobs_url":"https://api.github.com/repos/dotty-staging/dotty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotty-staging/dotty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotty-staging/dotty/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotty-staging/dotty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotty-staging/dotty/statuses/{sha}","languages_url":"https://api.github.com/repos/dotty-staging/dotty/languages","stargazers_url":"https://api.github.com/repos/dotty-staging/dotty/stargazers","contributors_url":"https://api.github.com/repos/dotty-staging/dotty/contributors","subscribers_url":"https://api.github.com/repos/dotty-staging/dotty/subscribers","subscription_url":"https://api.github.com/repos/dotty-staging/dotty/subscription","commits_url":"https://api.github.com/repos/dotty-staging/dotty/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotty-staging/dotty/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotty-staging/dotty/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotty-staging/dotty/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotty-staging/dotty/contents/{+path}","compare_url":"https://api.github.com/repos/dotty-staging/dotty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotty-staging/dotty/merges","archive_url":"https://api.github.com/repos/dotty-staging/dotty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotty-staging/dotty/downloads","issues_url":"https://api.github.com/repos/dotty-staging/dotty/issues{/number}","pulls_url":"https://api.github.com/repos/dotty-staging/dotty/pulls{/number}","milestones_url":"https://api.github.com/repos/dotty-staging/dotty/milestones{/number}","notifications_url":"https://api.github.com/repos/dotty-staging/dotty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotty-staging/dotty/labels{/name}","releases_url":"https://api.github.com/repos/dotty-staging/dotty/releases{/id}","created_at":"2014-03-19T13:06:15Z","updated_at":"2015-04-23T11:13:31Z","pushed_at":"2015-05-13T15:44:00Z","git_url":"git://github.com/dotty-staging/dotty.git","ssh_url":"git@github.com:dotty-staging/dotty.git","clone_url":"https://github.com/dotty-staging/dotty.git","svn_url":"https://github.com/dotty-staging/dotty","homepage":"","size":15282,"stargazers_count":3,"watchers_count":3,"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":3,"default_branch":"master"}},"base":{"label":"lampepfl:master","ref":"master","sha":"629f4ac808a72e9b7191212de649185a68405a0e","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-05-12T12:20:50Z","pushed_at":"2015-05-14T02:55:38Z","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":21838,"stargazers_count":352,"watchers_count":352,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":79,"forks":45,"open_issues":79,"watchers":352,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/563"},"html":{"href":"https://github.com/lampepfl/dotty/pull/563"},"issue":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/563"},"comments":{"href":"https://api.github.com/repos/lampepfl/dotty/issues/563/comments"},"review_comments":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/563/comments"},"review_comment":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lampepfl/dotty/pulls/563/commits"},"statuses":{"href":"https://api.github.com/repos/lampepfl/dotty/statuses/fe903c00027f0440207dc70c8b1d50ef3d0b3701"}}}}