{"action":"created","comment":{"url":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments/112241913","pull_request_review_id":33541180,"id":112241913,"diff_hunk":"@@ -72,37 +70,53 @@ private fun resolveImport(name: String,\n             ?.let {\n                 it.qualifiedIdentifier.toString()\n                         .let(::FqName)\n-                        .let { it to javac.findClass(it) }\n+                        .let { javac.findClass(it) ?: javac.getKotlinClassifier(it) }\n             }\n     ?: filter { it.qualifiedIdentifier.toString().endsWith(\"*\") }\n             .map {\n                 javac.findClass(\"${it.qualifiedIdentifier.toString().substringBefore(\"*\")}$name\"\n                                 .let(::FqName))\n             }\n             .firstOrNull()\n-            ?.let { it.fqName!! to it }\n }\n \n private fun TreePath.tryToResolve(name: String,\n-                                  compilationUnit: JCTree.JCCompilationUnit,\n-                                  javac: JavacWrapper): Pair<FqName, JavaClass?> {\n-    val simpleName = name.substringAfterLast(\".\")\n-    val classes = javac.findClassesFromPackage(FqName(\"${compilationUnit.packageName}\"))\n-            .filter { it.name.asString() == simpleName }\n-\n-    val outerClass = parentPath.find { it is JCTree.JCClassDecl } as? JCTree.JCClassDecl\n-                     ?: return FqName(\"${compilationUnit.packageName}.$name\") to null\n+                          compilationUnit: JCTree.JCCompilationUnit,\n+                          javac: JavacWrapper): JavaClassifier? {\n+    // try to find an inner class\n+    (parentPath.find { it is JCTree.JCClassDecl } as? JCTree.JCClassDecl)?.let { outerClass ->\n+        javac.findClass(FqName(\"${compilationUnit.packageName}.${outerClass.name}.$name\"))\n+                ?.let { return it }\n+    }\n \n-    classes.find {\n-        it.fqName!!.asString().contains(simpleName)\n-        && it.fqName!!.asString().contains(outerClass.name.toString())\n-    }?.let { return it.fqName!! to it }\n+    // try to find a package class\n+    javac.findClass(FqName(\"${compilationUnit.packageName}.$name\"))?.let { return it }\n+    // try to find a class from java.lang package\n+    javac.findClass(FqName(\"java.lang.$name\"))?.let { return it }\n+    // try to find a class with fqName = name\n+    javac.findClass(FqName(name))?.let { return it }\n \n-    classes.find { it.outerClass == null }?.let { return it.fqName!! to it }\n+    // try to find a type parameter\n+    typeParameter(javac)?.let { return it }\n \n-    return FqName(\"${compilationUnit.packageName}.$name\") to null\n+    return javac.getKotlinClassifier(FqName(\"${compilationUnit.packageName}.$name\"))\n }\n \n+private fun TreePath.typeParameter(javac: JavacWrapper) = filter { it is JCTree.JCClassDecl || it is JCTree.JCMethodDecl }\n+        .flatMap {\n+            when (it) {\n+                is JCTree.JCClassDecl -> it.typarams\n+                is JCTree.JCMethodDecl -> it.typarams\n+                else -> emptyList<JCTree.JCTypeParameter>()\n+            }\n+        }\n+        .find { it.toString().substringBefore(\" \") == leaf.toString() }\n+        ?.let {\n+            JCTypeParameter(it,\n+                            javac.getTreePath(it, compilationUnit),\n+                            javac)\n+        }\n+","path":"compiler/javac-wrapper/src/org/jetbrains/kotlin/wrappers/trees/utils.kt","position":null,"original_position":91,"commit_id":"bfe650b7f0598f794ab1879457d02d2a62637310","original_commit_id":"72ddff8a3f93f73bc1c812f13bd6bd8d6c809c2d","user":{"login":"mglukhikh","id":1127631,"avatar_url":"https://avatars1.githubusercontent.com/u/1127631?v=3","gravatar_id":"","url":"https://api.github.com/users/mglukhikh","html_url":"https://github.com/mglukhikh","followers_url":"https://api.github.com/users/mglukhikh/followers","following_url":"https://api.github.com/users/mglukhikh/following{/other_user}","gists_url":"https://api.github.com/users/mglukhikh/gists{/gist_id}","starred_url":"https://api.github.com/users/mglukhikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mglukhikh/subscriptions","organizations_url":"https://api.github.com/users/mglukhikh/orgs","repos_url":"https://api.github.com/users/mglukhikh/repos","events_url":"https://api.github.com/users/mglukhikh/events{/privacy}","received_events_url":"https://api.github.com/users/mglukhikh/received_events","type":"User","site_admin":false},"body":"This one is also not actual","created_at":"2017-04-19T15:51:57Z","updated_at":"2017-04-19T15:51:57Z","html_url":"https://github.com/JetBrains/kotlin/pull/1045#discussion_r112241913","pull_request_url":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045","_links":{"self":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments/112241913"},"html":{"href":"https://github.com/JetBrains/kotlin/pull/1045#discussion_r112241913"},"pull_request":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045"}}},"pull_request":{"url":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045","id":114343044,"html_url":"https://github.com/JetBrains/kotlin/pull/1045","diff_url":"https://github.com/JetBrains/kotlin/pull/1045.diff","patch_url":"https://github.com/JetBrains/kotlin/pull/1045.patch","issue_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1045","number":1045,"state":"open","locked":false,"title":"Use Java compiler JCTree.*-s and Symbol.*-s for Kotlin files analysis and reuse them to compile Java files.","user":{"login":"baratynskiy","id":14249891,"avatar_url":"https://avatars3.githubusercontent.com/u/14249891?v=3","gravatar_id":"","url":"https://api.github.com/users/baratynskiy","html_url":"https://github.com/baratynskiy","followers_url":"https://api.github.com/users/baratynskiy/followers","following_url":"https://api.github.com/users/baratynskiy/following{/other_user}","gists_url":"https://api.github.com/users/baratynskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/baratynskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baratynskiy/subscriptions","organizations_url":"https://api.github.com/users/baratynskiy/orgs","repos_url":"https://api.github.com/users/baratynskiy/repos","events_url":"https://api.github.com/users/baratynskiy/events{/privacy}","received_events_url":"https://api.github.com/users/baratynskiy/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-04-05T10:24:08Z","updated_at":"2017-04-19T15:51:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2cc022761484025fa20a43dbf0ee97fdd75d917d","assignee":{"login":"mglukhikh","id":1127631,"avatar_url":"https://avatars1.githubusercontent.com/u/1127631?v=3","gravatar_id":"","url":"https://api.github.com/users/mglukhikh","html_url":"https://github.com/mglukhikh","followers_url":"https://api.github.com/users/mglukhikh/followers","following_url":"https://api.github.com/users/mglukhikh/following{/other_user}","gists_url":"https://api.github.com/users/mglukhikh/gists{/gist_id}","starred_url":"https://api.github.com/users/mglukhikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mglukhikh/subscriptions","organizations_url":"https://api.github.com/users/mglukhikh/orgs","repos_url":"https://api.github.com/users/mglukhikh/repos","events_url":"https://api.github.com/users/mglukhikh/events{/privacy}","received_events_url":"https://api.github.com/users/mglukhikh/received_events","type":"User","site_admin":false},"assignees":[{"login":"mglukhikh","id":1127631,"avatar_url":"https://avatars1.githubusercontent.com/u/1127631?v=3","gravatar_id":"","url":"https://api.github.com/users/mglukhikh","html_url":"https://github.com/mglukhikh","followers_url":"https://api.github.com/users/mglukhikh/followers","following_url":"https://api.github.com/users/mglukhikh/following{/other_user}","gists_url":"https://api.github.com/users/mglukhikh/gists{/gist_id}","starred_url":"https://api.github.com/users/mglukhikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mglukhikh/subscriptions","organizations_url":"https://api.github.com/users/mglukhikh/orgs","repos_url":"https://api.github.com/users/mglukhikh/repos","events_url":"https://api.github.com/users/mglukhikh/events{/privacy}","received_events_url":"https://api.github.com/users/mglukhikh/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045/commits","review_comments_url":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045/comments","review_comment_url":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JetBrains/kotlin/issues/1045/comments","statuses_url":"https://api.github.com/repos/JetBrains/kotlin/statuses/bfe650b7f0598f794ab1879457d02d2a62637310","head":{"label":"baratynskiy:baratynskiy/javac2","ref":"baratynskiy/javac2","sha":"bfe650b7f0598f794ab1879457d02d2a62637310","user":{"login":"baratynskiy","id":14249891,"avatar_url":"https://avatars3.githubusercontent.com/u/14249891?v=3","gravatar_id":"","url":"https://api.github.com/users/baratynskiy","html_url":"https://github.com/baratynskiy","followers_url":"https://api.github.com/users/baratynskiy/followers","following_url":"https://api.github.com/users/baratynskiy/following{/other_user}","gists_url":"https://api.github.com/users/baratynskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/baratynskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baratynskiy/subscriptions","organizations_url":"https://api.github.com/users/baratynskiy/orgs","repos_url":"https://api.github.com/users/baratynskiy/repos","events_url":"https://api.github.com/users/baratynskiy/events{/privacy}","received_events_url":"https://api.github.com/users/baratynskiy/received_events","type":"User","site_admin":false},"repo":{"id":80983071,"name":"kotlin","full_name":"baratynskiy/kotlin","owner":{"login":"baratynskiy","id":14249891,"avatar_url":"https://avatars3.githubusercontent.com/u/14249891?v=3","gravatar_id":"","url":"https://api.github.com/users/baratynskiy","html_url":"https://github.com/baratynskiy","followers_url":"https://api.github.com/users/baratynskiy/followers","following_url":"https://api.github.com/users/baratynskiy/following{/other_user}","gists_url":"https://api.github.com/users/baratynskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/baratynskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baratynskiy/subscriptions","organizations_url":"https://api.github.com/users/baratynskiy/orgs","repos_url":"https://api.github.com/users/baratynskiy/repos","events_url":"https://api.github.com/users/baratynskiy/events{/privacy}","received_events_url":"https://api.github.com/users/baratynskiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/baratynskiy/kotlin","description":"The Kotlin Programming Language","fork":true,"url":"https://api.github.com/repos/baratynskiy/kotlin","forks_url":"https://api.github.com/repos/baratynskiy/kotlin/forks","keys_url":"https://api.github.com/repos/baratynskiy/kotlin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baratynskiy/kotlin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baratynskiy/kotlin/teams","hooks_url":"https://api.github.com/repos/baratynskiy/kotlin/hooks","issue_events_url":"https://api.github.com/repos/baratynskiy/kotlin/issues/events{/number}","events_url":"https://api.github.com/repos/baratynskiy/kotlin/events","assignees_url":"https://api.github.com/repos/baratynskiy/kotlin/assignees{/user}","branches_url":"https://api.github.com/repos/baratynskiy/kotlin/branches{/branch}","tags_url":"https://api.github.com/repos/baratynskiy/kotlin/tags","blobs_url":"https://api.github.com/repos/baratynskiy/kotlin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baratynskiy/kotlin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baratynskiy/kotlin/git/refs{/sha}","trees_url":"https://api.github.com/repos/baratynskiy/kotlin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baratynskiy/kotlin/statuses/{sha}","languages_url":"https://api.github.com/repos/baratynskiy/kotlin/languages","stargazers_url":"https://api.github.com/repos/baratynskiy/kotlin/stargazers","contributors_url":"https://api.github.com/repos/baratynskiy/kotlin/contributors","subscribers_url":"https://api.github.com/repos/baratynskiy/kotlin/subscribers","subscription_url":"https://api.github.com/repos/baratynskiy/kotlin/subscription","commits_url":"https://api.github.com/repos/baratynskiy/kotlin/commits{/sha}","git_commits_url":"https://api.github.com/repos/baratynskiy/kotlin/git/commits{/sha}","comments_url":"https://api.github.com/repos/baratynskiy/kotlin/comments{/number}","issue_comment_url":"https://api.github.com/repos/baratynskiy/kotlin/issues/comments{/number}","contents_url":"https://api.github.com/repos/baratynskiy/kotlin/contents/{+path}","compare_url":"https://api.github.com/repos/baratynskiy/kotlin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baratynskiy/kotlin/merges","archive_url":"https://api.github.com/repos/baratynskiy/kotlin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baratynskiy/kotlin/downloads","issues_url":"https://api.github.com/repos/baratynskiy/kotlin/issues{/number}","pulls_url":"https://api.github.com/repos/baratynskiy/kotlin/pulls{/number}","milestones_url":"https://api.github.com/repos/baratynskiy/kotlin/milestones{/number}","notifications_url":"https://api.github.com/repos/baratynskiy/kotlin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baratynskiy/kotlin/labels{/name}","releases_url":"https://api.github.com/repos/baratynskiy/kotlin/releases{/id}","deployments_url":"https://api.github.com/repos/baratynskiy/kotlin/deployments","created_at":"2017-02-05T09:36:01Z","updated_at":"2017-02-05T09:36:57Z","pushed_at":"2017-04-19T10:47:25Z","git_url":"git://github.com/baratynskiy/kotlin.git","ssh_url":"git@github.com:baratynskiy/kotlin.git","clone_url":"https://github.com/baratynskiy/kotlin.git","svn_url":"https://github.com/baratynskiy/kotlin","homepage":"http://kotlinlang.org/","size":369997,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"JetBrains:master","ref":"master","sha":"83169ad78106ad407559492f617e6efa3107c020","user":{"login":"JetBrains","id":878437,"avatar_url":"https://avatars1.githubusercontent.com/u/878437?v=3","gravatar_id":"","url":"https://api.github.com/users/JetBrains","html_url":"https://github.com/JetBrains","followers_url":"https://api.github.com/users/JetBrains/followers","following_url":"https://api.github.com/users/JetBrains/following{/other_user}","gists_url":"https://api.github.com/users/JetBrains/gists{/gist_id}","starred_url":"https://api.github.com/users/JetBrains/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JetBrains/subscriptions","organizations_url":"https://api.github.com/users/JetBrains/orgs","repos_url":"https://api.github.com/users/JetBrains/repos","events_url":"https://api.github.com/users/JetBrains/events{/privacy}","received_events_url":"https://api.github.com/users/JetBrains/received_events","type":"Organization","site_admin":false},"repo":{"id":3432266,"name":"kotlin","full_name":"JetBrains/kotlin","owner":{"login":"JetBrains","id":878437,"avatar_url":"https://avatars1.githubusercontent.com/u/878437?v=3","gravatar_id":"","url":"https://api.github.com/users/JetBrains","html_url":"https://github.com/JetBrains","followers_url":"https://api.github.com/users/JetBrains/followers","following_url":"https://api.github.com/users/JetBrains/following{/other_user}","gists_url":"https://api.github.com/users/JetBrains/gists{/gist_id}","starred_url":"https://api.github.com/users/JetBrains/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JetBrains/subscriptions","organizations_url":"https://api.github.com/users/JetBrains/orgs","repos_url":"https://api.github.com/users/JetBrains/repos","events_url":"https://api.github.com/users/JetBrains/events{/privacy}","received_events_url":"https://api.github.com/users/JetBrains/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JetBrains/kotlin","description":"The Kotlin Programming Language","fork":false,"url":"https://api.github.com/repos/JetBrains/kotlin","forks_url":"https://api.github.com/repos/JetBrains/kotlin/forks","keys_url":"https://api.github.com/repos/JetBrains/kotlin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JetBrains/kotlin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JetBrains/kotlin/teams","hooks_url":"https://api.github.com/repos/JetBrains/kotlin/hooks","issue_events_url":"https://api.github.com/repos/JetBrains/kotlin/issues/events{/number}","events_url":"https://api.github.com/repos/JetBrains/kotlin/events","assignees_url":"https://api.github.com/repos/JetBrains/kotlin/assignees{/user}","branches_url":"https://api.github.com/repos/JetBrains/kotlin/branches{/branch}","tags_url":"https://api.github.com/repos/JetBrains/kotlin/tags","blobs_url":"https://api.github.com/repos/JetBrains/kotlin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JetBrains/kotlin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JetBrains/kotlin/git/refs{/sha}","trees_url":"https://api.github.com/repos/JetBrains/kotlin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JetBrains/kotlin/statuses/{sha}","languages_url":"https://api.github.com/repos/JetBrains/kotlin/languages","stargazers_url":"https://api.github.com/repos/JetBrains/kotlin/stargazers","contributors_url":"https://api.github.com/repos/JetBrains/kotlin/contributors","subscribers_url":"https://api.github.com/repos/JetBrains/kotlin/subscribers","subscription_url":"https://api.github.com/repos/JetBrains/kotlin/subscription","commits_url":"https://api.github.com/repos/JetBrains/kotlin/commits{/sha}","git_commits_url":"https://api.github.com/repos/JetBrains/kotlin/git/commits{/sha}","comments_url":"https://api.github.com/repos/JetBrains/kotlin/comments{/number}","issue_comment_url":"https://api.github.com/repos/JetBrains/kotlin/issues/comments{/number}","contents_url":"https://api.github.com/repos/JetBrains/kotlin/contents/{+path}","compare_url":"https://api.github.com/repos/JetBrains/kotlin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JetBrains/kotlin/merges","archive_url":"https://api.github.com/repos/JetBrains/kotlin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JetBrains/kotlin/downloads","issues_url":"https://api.github.com/repos/JetBrains/kotlin/issues{/number}","pulls_url":"https://api.github.com/repos/JetBrains/kotlin/pulls{/number}","milestones_url":"https://api.github.com/repos/JetBrains/kotlin/milestones{/number}","notifications_url":"https://api.github.com/repos/JetBrains/kotlin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JetBrains/kotlin/labels{/name}","releases_url":"https://api.github.com/repos/JetBrains/kotlin/releases{/id}","deployments_url":"https://api.github.com/repos/JetBrains/kotlin/deployments","created_at":"2012-02-13T17:29:58Z","updated_at":"2017-04-19T13:50:54Z","pushed_at":"2017-04-19T15:49:26Z","git_url":"git://github.com/JetBrains/kotlin.git","ssh_url":"git@github.com:JetBrains/kotlin.git","clone_url":"https://github.com/JetBrains/kotlin.git","svn_url":"https://github.com/JetBrains/kotlin","homepage":"http://kotlinlang.org/","size":374908,"stargazers_count":7750,"watchers_count":7750,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":827,"mirror_url":null,"open_issues_count":27,"forks":827,"open_issues":27,"watchers":7750,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045"},"html":{"href":"https://github.com/JetBrains/kotlin/pull/1045"},"issue":{"href":"https://api.github.com/repos/JetBrains/kotlin/issues/1045"},"comments":{"href":"https://api.github.com/repos/JetBrains/kotlin/issues/1045/comments"},"review_comments":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045/comments"},"review_comment":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/1045/commits"},"statuses":{"href":"https://api.github.com/repos/JetBrains/kotlin/statuses/bfe650b7f0598f794ab1879457d02d2a62637310"}}}}
{"actor":{"display_login":"mglukhikh"}}