{"action":"created","comment":{"url":"https://api.github.com/repos/scala/scala/pulls/comments/64227771","id":64227771,"diff_hunk":"@@ -567,10 +567,49 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {\n \n     def varDecl(pos: Position, mods: Modifiers, tpt: Tree, name: TermName): ValDef = {\n       val tpt1 = optArrayBrackets(tpt)\n-      if (in.token == EQUALS && !mods.isParameter) skipTo(COMMA, SEMI)\n+\n+      /** Tries to detect final static literals syntactically and returns a constant type replacement */\n+      def optConstantTpe(): Tree = {\n+        in.nextToken()\n+\n+        def constantTpe(lit: Any): Tree =\n+          try TypeTree(ConstantType(Constant(lit)))\n+          finally in.nextToken()\n+\n+        if (mods.hasFlag(Flags.STATIC) && mods.isFinal) {\n+          def lit(negate: Boolean): Tree =\n+            if (in.lookaheadToken == SEMI)\n+              in.token match {\n+                case INTLIT if tpt.tpe == IntTpe => constantTpe(in.intVal(negate).toInt)\n+                case LONGLIT if tpt.tpe == LongTpe => constantTpe(in.intVal(negate))\n+                case FLOATLIT if tpt.tpe == FloatTpe => constantTpe(in.floatVal(negate).toFloat)\n+                case DOUBLELIT if tpt.tpe == DoubleTpe => constantTpe(in.floatVal(negate))\n+                case STRINGLIT =>\n+                  tpt match {\n+                    case Ident(TypeName(\"String\")) => constantTpe(in.name.toString)","path":"src/compiler/scala/tools/nsc/javac/JavaParsers.scala","position":24,"original_position":24,"commit_id":"aabee6d3b5c4b6812525c2583a5d57181fa8833b","original_commit_id":"aabee6d3b5c4b6812525c2583a5d57181fa8833b","user":{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"body":"I see now that we'll miss a check, `public static final NotString s = \"hi\"` would pass.","created_at":"2016-05-23T14:04:15Z","updated_at":"2016-05-23T14:04:16Z","html_url":"https://github.com/scala/scala/pull/5022#discussion_r64227771","pull_request_url":"https://api.github.com/repos/scala/scala/pulls/5022","_links":{"self":{"href":"https://api.github.com/repos/scala/scala/pulls/comments/64227771"},"html":{"href":"https://github.com/scala/scala/pull/5022#discussion_r64227771"},"pull_request":{"href":"https://api.github.com/repos/scala/scala/pulls/5022"}}},"pull_request":{"url":"https://api.github.com/repos/scala/scala/pulls/5022","id":62145830,"html_url":"https://github.com/scala/scala/pull/5022","diff_url":"https://github.com/scala/scala/pull/5022.diff","patch_url":"https://github.com/scala/scala/pull/5022.patch","issue_url":"https://api.github.com/repos/scala/scala/issues/5022","number":5022,"state":"open","locked":false,"title":"SI-3236 try to infer constant types for simple final static literal java expressions","user":{"login":"jrudolph","id":9868,"avatar_url":"https://avatars.githubusercontent.com/u/9868?v=3","gravatar_id":"","url":"https://api.github.com/users/jrudolph","html_url":"https://github.com/jrudolph","followers_url":"https://api.github.com/users/jrudolph/followers","following_url":"https://api.github.com/users/jrudolph/following{/other_user}","gists_url":"https://api.github.com/users/jrudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/jrudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrudolph/subscriptions","organizations_url":"https://api.github.com/users/jrudolph/orgs","repos_url":"https://api.github.com/users/jrudolph/repos","events_url":"https://api.github.com/users/jrudolph/events{/privacy}","received_events_url":"https://api.github.com/users/jrudolph/received_events","type":"User","site_admin":false},"body":"In a mixed Java/Scala project this will allow simple final static constants to be used in annotations from both Java and Scala. The workaround would be compiling the constants in a separate compilation run (which btw will prevent the original error from appearing in a usual developer setup involving separate compilation).\r\n\r\nThis is not yet finished, I just wanted to put that here for Jenkins to ponder upon it and to get some feedback if this would be a possible way to go. Of course, it still isn't as powerful as in Java where real constants can reference each other and would still be constants to be used in annotations (What would be necessary to get there? @soc told me something about constant folding / annotations that might have been related but I cannot remember the details).\r\n\r\nI guess the real thing would have to be targeted against 2.12.x, I just put it on 2.11.x for now to be able to test it immediately against existing code.\r\n\r\n/cc @magro","created_at":"2016-03-08T22:13:34Z","updated_at":"2016-05-23T14:04:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f0ad6b16eca89465a670c400ff9047c3b2ace614","assignee":null,"milestone":{"url":"https://api.github.com/repos/scala/scala/milestones/53","html_url":"https://github.com/scala/scala/milestones/2.11.9","labels_url":"https://api.github.com/repos/scala/scala/milestones/53/labels","id":1600019,"number":53,"title":"2.11.9","description":"Merge to 2.11.x.\r\n","creator":{"login":"SethTisue","id":161079,"avatar_url":"https://avatars.githubusercontent.com/u/161079?v=3","gravatar_id":"","url":"https://api.github.com/users/SethTisue","html_url":"https://github.com/SethTisue","followers_url":"https://api.github.com/users/SethTisue/followers","following_url":"https://api.github.com/users/SethTisue/following{/other_user}","gists_url":"https://api.github.com/users/SethTisue/gists{/gist_id}","starred_url":"https://api.github.com/users/SethTisue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SethTisue/subscriptions","organizations_url":"https://api.github.com/users/SethTisue/orgs","repos_url":"https://api.github.com/users/SethTisue/repos","events_url":"https://api.github.com/users/SethTisue/events{/privacy}","received_events_url":"https://api.github.com/users/SethTisue/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":28,"state":"open","created_at":"2016-02-23T15:35:43Z","updated_at":"2016-05-23T13:17:24Z","due_on":"2016-09-30T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/scala/scala/pulls/5022/commits","review_comments_url":"https://api.github.com/repos/scala/scala/pulls/5022/comments","review_comment_url":"https://api.github.com/repos/scala/scala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala/scala/issues/5022/comments","statuses_url":"https://api.github.com/repos/scala/scala/statuses/aabee6d3b5c4b6812525c2583a5d57181fa8833b","head":{"label":"jrudolph:w/java-constants","ref":"w/java-constants","sha":"aabee6d3b5c4b6812525c2583a5d57181fa8833b","user":{"login":"jrudolph","id":9868,"avatar_url":"https://avatars.githubusercontent.com/u/9868?v=3","gravatar_id":"","url":"https://api.github.com/users/jrudolph","html_url":"https://github.com/jrudolph","followers_url":"https://api.github.com/users/jrudolph/followers","following_url":"https://api.github.com/users/jrudolph/following{/other_user}","gists_url":"https://api.github.com/users/jrudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/jrudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrudolph/subscriptions","organizations_url":"https://api.github.com/users/jrudolph/orgs","repos_url":"https://api.github.com/users/jrudolph/repos","events_url":"https://api.github.com/users/jrudolph/events{/privacy}","received_events_url":"https://api.github.com/users/jrudolph/received_events","type":"User","site_admin":false},"repo":{"id":3154556,"name":"scala","full_name":"jrudolph/scala","owner":{"login":"jrudolph","id":9868,"avatar_url":"https://avatars.githubusercontent.com/u/9868?v=3","gravatar_id":"","url":"https://api.github.com/users/jrudolph","html_url":"https://github.com/jrudolph","followers_url":"https://api.github.com/users/jrudolph/followers","following_url":"https://api.github.com/users/jrudolph/following{/other_user}","gists_url":"https://api.github.com/users/jrudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/jrudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrudolph/subscriptions","organizations_url":"https://api.github.com/users/jrudolph/orgs","repos_url":"https://api.github.com/users/jrudolph/repos","events_url":"https://api.github.com/users/jrudolph/events{/privacy}","received_events_url":"https://api.github.com/users/jrudolph/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jrudolph/scala","description":"The Scala programming language","fork":true,"url":"https://api.github.com/repos/jrudolph/scala","forks_url":"https://api.github.com/repos/jrudolph/scala/forks","keys_url":"https://api.github.com/repos/jrudolph/scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jrudolph/scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jrudolph/scala/teams","hooks_url":"https://api.github.com/repos/jrudolph/scala/hooks","issue_events_url":"https://api.github.com/repos/jrudolph/scala/issues/events{/number}","events_url":"https://api.github.com/repos/jrudolph/scala/events","assignees_url":"https://api.github.com/repos/jrudolph/scala/assignees{/user}","branches_url":"https://api.github.com/repos/jrudolph/scala/branches{/branch}","tags_url":"https://api.github.com/repos/jrudolph/scala/tags","blobs_url":"https://api.github.com/repos/jrudolph/scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jrudolph/scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jrudolph/scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/jrudolph/scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jrudolph/scala/statuses/{sha}","languages_url":"https://api.github.com/repos/jrudolph/scala/languages","stargazers_url":"https://api.github.com/repos/jrudolph/scala/stargazers","contributors_url":"https://api.github.com/repos/jrudolph/scala/contributors","subscribers_url":"https://api.github.com/repos/jrudolph/scala/subscribers","subscription_url":"https://api.github.com/repos/jrudolph/scala/subscription","commits_url":"https://api.github.com/repos/jrudolph/scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/jrudolph/scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/jrudolph/scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/jrudolph/scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/jrudolph/scala/contents/{+path}","compare_url":"https://api.github.com/repos/jrudolph/scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jrudolph/scala/merges","archive_url":"https://api.github.com/repos/jrudolph/scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jrudolph/scala/downloads","issues_url":"https://api.github.com/repos/jrudolph/scala/issues{/number}","pulls_url":"https://api.github.com/repos/jrudolph/scala/pulls{/number}","milestones_url":"https://api.github.com/repos/jrudolph/scala/milestones{/number}","notifications_url":"https://api.github.com/repos/jrudolph/scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jrudolph/scala/labels{/name}","releases_url":"https://api.github.com/repos/jrudolph/scala/releases{/id}","deployments_url":"https://api.github.com/repos/jrudolph/scala/deployments","created_at":"2012-01-11T15:03:32Z","updated_at":"2014-06-25T09:30:39Z","pushed_at":"2016-03-08T22:02:38Z","git_url":"git://github.com/jrudolph/scala.git","ssh_url":"git@github.com:jrudolph/scala.git","clone_url":"https://github.com/jrudolph/scala.git","svn_url":"https://github.com/jrudolph/scala","homepage":"http://www.scala-lang.org/","size":77425,"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":"scala:2.11.x","ref":"2.11.x","sha":"1706a37eb84ec252aea77bccebad3e48448534ad","user":{"login":"scala","id":57059,"avatar_url":"https://avatars.githubusercontent.com/u/57059?v=3","gravatar_id":"","url":"https://api.github.com/users/scala","html_url":"https://github.com/scala","followers_url":"https://api.github.com/users/scala/followers","following_url":"https://api.github.com/users/scala/following{/other_user}","gists_url":"https://api.github.com/users/scala/gists{/gist_id}","starred_url":"https://api.github.com/users/scala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala/subscriptions","organizations_url":"https://api.github.com/users/scala/orgs","repos_url":"https://api.github.com/users/scala/repos","events_url":"https://api.github.com/users/scala/events{/privacy}","received_events_url":"https://api.github.com/users/scala/received_events","type":"Organization","site_admin":false},"repo":{"id":2888818,"name":"scala","full_name":"scala/scala","owner":{"login":"scala","id":57059,"avatar_url":"https://avatars.githubusercontent.com/u/57059?v=3","gravatar_id":"","url":"https://api.github.com/users/scala","html_url":"https://github.com/scala","followers_url":"https://api.github.com/users/scala/followers","following_url":"https://api.github.com/users/scala/following{/other_user}","gists_url":"https://api.github.com/users/scala/gists{/gist_id}","starred_url":"https://api.github.com/users/scala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala/subscriptions","organizations_url":"https://api.github.com/users/scala/orgs","repos_url":"https://api.github.com/users/scala/repos","events_url":"https://api.github.com/users/scala/events{/privacy}","received_events_url":"https://api.github.com/users/scala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala/scala","description":"The Scala programming language","fork":false,"url":"https://api.github.com/repos/scala/scala","forks_url":"https://api.github.com/repos/scala/scala/forks","keys_url":"https://api.github.com/repos/scala/scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala/scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala/scala/teams","hooks_url":"https://api.github.com/repos/scala/scala/hooks","issue_events_url":"https://api.github.com/repos/scala/scala/issues/events{/number}","events_url":"https://api.github.com/repos/scala/scala/events","assignees_url":"https://api.github.com/repos/scala/scala/assignees{/user}","branches_url":"https://api.github.com/repos/scala/scala/branches{/branch}","tags_url":"https://api.github.com/repos/scala/scala/tags","blobs_url":"https://api.github.com/repos/scala/scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala/scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala/scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala/scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala/scala/statuses/{sha}","languages_url":"https://api.github.com/repos/scala/scala/languages","stargazers_url":"https://api.github.com/repos/scala/scala/stargazers","contributors_url":"https://api.github.com/repos/scala/scala/contributors","subscribers_url":"https://api.github.com/repos/scala/scala/subscribers","subscription_url":"https://api.github.com/repos/scala/scala/subscription","commits_url":"https://api.github.com/repos/scala/scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala/scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala/scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala/scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala/scala/contents/{+path}","compare_url":"https://api.github.com/repos/scala/scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala/scala/merges","archive_url":"https://api.github.com/repos/scala/scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala/scala/downloads","issues_url":"https://api.github.com/repos/scala/scala/issues{/number}","pulls_url":"https://api.github.com/repos/scala/scala/pulls{/number}","milestones_url":"https://api.github.com/repos/scala/scala/milestones{/number}","notifications_url":"https://api.github.com/repos/scala/scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala/scala/labels{/name}","releases_url":"https://api.github.com/repos/scala/scala/releases{/id}","deployments_url":"https://api.github.com/repos/scala/scala/deployments","created_at":"2011-12-01T05:02:34Z","updated_at":"2016-05-23T12:36:00Z","pushed_at":"2016-05-23T13:50:30Z","git_url":"git://github.com/scala/scala.git","ssh_url":"git@github.com:scala/scala.git","clone_url":"https://github.com/scala/scala.git","svn_url":"https://github.com/scala/scala","homepage":"http://www.scala-lang.org/","size":143560,"stargazers_count":6185,"watchers_count":6185,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1564,"mirror_url":null,"open_issues_count":46,"forks":1564,"open_issues":46,"watchers":6185,"default_branch":"2.12.x"}},"_links":{"self":{"href":"https://api.github.com/repos/scala/scala/pulls/5022"},"html":{"href":"https://github.com/scala/scala/pull/5022"},"issue":{"href":"https://api.github.com/repos/scala/scala/issues/5022"},"comments":{"href":"https://api.github.com/repos/scala/scala/issues/5022/comments"},"review_comments":{"href":"https://api.github.com/repos/scala/scala/pulls/5022/comments"},"review_comment":{"href":"https://api.github.com/repos/scala/scala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala/scala/pulls/5022/commits"},"statuses":{"href":"https://api.github.com/repos/scala/scala/statuses/aabee6d3b5c4b6812525c2583a5d57181fa8833b"}}}}
{"actor":{"display_login":"lrytz"}}