Compare commits

...

362 Commits

Author SHA1 Message Date
Yan Zhulanow
b690e3991e Remove invalid imports in test generator 2018-02-26 12:55:22 +03:00
Yan Zhulanow
101bac3f99 Replace AndroidGradleModel with AndroidModuleModel 2018-02-26 12:55:21 +03:00
Alexey Sedunov
303d396735 Minor: Fix compilation 2018-02-26 12:55:20 +03:00
Alexey Sedunov
751dbfcda4 Misc: Drop addBuildTask() method as it can be used in IDEA 171
(cherry picked from commit 2c367f3)
2018-02-26 12:55:18 +03:00
Nicolay Mitropolsky
ccb438a600 facetUtils.kt compilation fix (configureSdkIfPossible-nullability) 2018-02-26 12:55:17 +03:00
Vyacheslav Gerasimov
332d439c91 Set until-build for AS 3.0 to 171.* otherwise tests massively fail
Since AS 3.1 C6 with 173 platform released it should be ok
2018-02-26 12:55:16 +03:00
Vyacheslav Gerasimov
0efe1a7295 Get AS from release site instead of preview 2018-02-26 12:55:15 +03:00
Dmitry Jemerov
db34868fa6 Set until-build for AS 3.0
(cherry picked from commit 86f873c)

(cherry picked from commit b6dae90)
2018-02-26 12:55:14 +03:00
Alexander Udalov
b38d304c2a Fix compilation of GenerateTests 2018-02-26 12:55:12 +03:00
Alexey Sedunov
e6387b9728 Misc: Do not use sourceSetNode in AS (compilation fix) 2018-02-26 12:55:11 +03:00
Vyacheslav Gerasimov
d118182db8 Fix test data for testAddArrayOfTypeForJavaAnnotation 2018-02-26 12:55:10 +03:00
Vyacheslav Gerasimov
f37113c99f Fix GradleFacetImportTest for AS 2018-02-26 12:55:09 +03:00
Simon Ogorodnik
6805149b9c Load resources from resources.jar instead of idea.jar
In AS idea.jar contains wrong ProductivityFeaturesRegistry.xml
2018-02-26 12:55:07 +03:00
Simon Ogorodnik
c3c4e8900c Fix AbstractImportsTest, add missing project parameter
Settings by default taken from per-project settings manager
instead of app settings
2018-02-26 12:55:06 +03:00
Vyacheslav Gerasimov
757dcce2ec Make bundled jre executable on linux 2018-02-26 12:55:05 +03:00
Vyacheslav Gerasimov
0e20efe739 Remove duplicate registration of KotlinUastBindingContextProviderService
from android-lint.xml, it is already registered in plugin.xml
2018-02-26 12:55:04 +03:00
Vyacheslav Gerasimov
00d32169f5 Fix test data for android lint based tests for AS 3.0 2018-02-26 12:55:03 +03:00
Vyacheslav Gerasimov
b2d88cc73a Fix TypeParameterFindViewByIdInspection for AS 3.0 2018-02-26 12:55:01 +03:00
Vyacheslav Gerasimov
206d0a1a50 Fix compilation AndroidGradleModelFacade for AS 3.0 2018-02-26 12:55:00 +03:00
Vyacheslav Gerasimov
6a4a4997a7 Add smali plugin required by android plugin to test runtime 2018-02-26 12:54:59 +03:00
Nikolay Krasko
af3c484477 Remove ultimate settings from AS branch 2018-02-26 12:54:57 +03:00
Nicolay Mitropolsky
c3a030833e Revert "Add uast-common and uast-java jars to plugin dependencies"
This reverts commit 34910e2
2018-02-26 12:54:56 +03:00
Ilya Gorbunov
a693136da8 Comment out some new code in ClasspathRootsResolver
Relates to disabled modular JDK9 support.
2018-02-26 12:54:55 +03:00
Simon Ogorodnik
d1cda47077 Fix dependencies of idea-android-output-parser for AS30 2018-02-26 12:54:54 +03:00
Simon Ogorodnik
aa8ff5b9b6 Fix dependencies of Android plugin parts in AS30 2018-02-26 12:54:52 +03:00
Yan Zhulanow
6cdc3435ad Add typealias for AndroidGradleModel
(cherry picked from commit f6c6845)

(cherry picked from commit d13c2c2)
2018-02-26 12:54:51 +03:00
Simon Ogorodnik
5b514adb3f Fix dependencies on common.jar of Android plugin in AS30 2018-02-26 12:54:50 +03:00
Simon Ogorodnik
023f5f9990 Remove uast-common, uast-java dependencies for AS30 2018-02-26 12:54:49 +03:00
Simon Ogorodnik
c69a4b87c1 Remove dependencies on jps/test for AS30 2018-02-26 12:54:48 +03:00
Simon Ogorodnik
1346121eee Disable maven for AS30 2018-02-26 12:54:46 +03:00
Alexey Sedunov
2fe1c17543 Kotlin Facet: Configure facet based on Android build variant (in AS)
#KT-19958 Fixed
2018-02-26 12:54:45 +03:00
Anton Bannykh
7f40700c72 Revert "Fix JUnit configuration producer for AS 2.4"
This reverts commit 384df1c
2018-02-26 12:54:44 +03:00
Anton Bannykh
dc329ae4d6 Fix compilation (TypeParameterFindViewByIdInspection.kt) 2018-02-26 12:54:42 +03:00
Vyacheslav Gerasimov
64f5717aae Fix compilation IDEAndroidLayoutXmlFileManager 2018-02-26 12:54:41 +03:00
Alexey Sedunov
225a0c6765 Misc: Revert usage of newer API 2018-02-26 12:54:40 +03:00
Alexey Sedunov
481da6ae28 Misc: Fix compilation 2018-02-26 12:54:39 +03:00
Dmitry Jemerov
48ae98e7a4 Fix compilation
(cherry picked from commit bc0bc0e)
2018-02-26 12:54:37 +03:00
Mikhael Bogdanov
eb0d39ed0d Update AndroidProjectKey package 2018-02-26 12:54:36 +03:00
Mikhael Bogdanov
9c273cdfcb Revert "Fix codegen tests on JDK 9 with jdkKind = FULL_JDK" 2018-02-26 12:54:35 +03:00
Dmitry Jemerov
75a67363fb No Maven in AS 2018-02-26 12:54:34 +03:00
Dmitry Jemerov
2c8410212a Implement ConvertJavaToKotlinProvider
(cherry picked from commit 34dfa24)
2018-02-26 12:54:32 +03:00
Vyacheslav Gerasimov
0d61677cac Fix KotlinAndroidLineMarkerProvider for AS 3.0 2018-02-26 12:54:31 +03:00
Vyacheslav Gerasimov
b83397fcc4 Moved getRequiredVersion to KotlinAndroidQuickFixProvider 2018-02-26 12:54:30 +03:00
Vyacheslav Gerasimov
b15902f4e0 Drop custom Kotlin Android lint, register quickfixes with extension point 2018-02-26 12:54:29 +03:00
Dmitry Jemerov
1fc4f64cf7 Compilation fixes for as24 2018-02-26 12:54:27 +03:00
Vyacheslav Gerasimov
ee4784cf1d Fix compilation AndroidTestCase 2018-02-26 12:54:26 +03:00
Vyacheslav Gerasimov
45488f4f23 Fix compilation AndroidResourceReferenceAnnotator 2018-02-26 12:54:24 +03:00
Vyacheslav Gerasimov
56a5b0e1ca Revert "Quickfix to enable language feature works for Maven project"
This reverts commit aabd560eef.
2018-02-26 12:54:23 +03:00
Vyacheslav Gerasimov
57e01fe42e Revert "Quickfix to enable coroutine support works in Maven projects"
This reverts commit 7346fee513.
2018-02-26 12:54:22 +03:00
Vyacheslav Gerasimov
5db22a2600 Fix compilation JavaRuntimePresentationProvider 2018-02-26 12:54:21 +03:00
Vyacheslav Gerasimov
5d914bf048 Fix build for AS 2.4.0.3
(cherry picked from commit a79f7a7)
2018-02-26 12:54:20 +03:00
Vyacheslav Gerasimov
c69625e644 Fix JUnit configuration producer for AS 2.4
(cherry picked from commit 09a49e8)
2018-02-26 12:54:18 +03:00
Pavel V. Talanov
e41fa2de6d Add step to patch plugin xml so that it only works in Android Studio
(cherry picked from commit fcee4eb)

(cherry picked from commit 14f7731)

(cherry picked from commit b1f5df2)
2018-02-26 12:54:17 +03:00
Vyacheslav Gerasimov
ed450af776 Kotlin Facet: Configure facet on Gradle project sync in Android Studio 2.3
#KT-15909 Fixed

(cherry picked from commit 6a490bc681)
2018-02-26 12:54:16 +03:00
Vyacheslav Gerasimov
6c9feaac7c Remove duplicate registration of UAST components
(cherry picked from commit e2f78a1)
2018-02-26 12:54:15 +03:00
Vyacheslav Gerasimov
46b59178f1 Fix compilation for Android Studio 2.4 2018-02-26 12:54:13 +03:00
Vyacheslav Gerasimov
2df8253587 Fix gotoResourceHelper: MyReferredResourceFieldInfo now requires module 2018-02-26 12:54:12 +03:00
Vyacheslav Gerasimov
2f79978527 Fix ResourceFoldingBuilder for AS 2.4 2018-02-26 12:54:11 +03:00
Yan Zhulanow
97a8487d90 Fix: MyReferredResourceFieldInfo now requires module
(cherry picked from commit 02e6bfb)
2018-02-26 12:54:09 +03:00
Dmitry Jemerov
73f49255c4 Update for moved Gradle sync classes
(cherry picked from commit db78387)
2018-02-26 12:54:08 +03:00
Yan Zhulanow
916fdf56e5 Remove Maven components from all-open and no-arg plugins 2018-02-26 12:54:07 +03:00
Yan Zhulanow
137b76de70 Disable Maven and JPS modules which is not available in AS 2018-02-26 12:54:06 +03:00
Nikolay Krasko
82b98d647b Run AS properly 2018-02-26 12:54:04 +03:00
Vyacheslav Gerasimov
338e0569a3 update_dependencies.xml for AS 3.0
Fix update_dependencies.xml jps-standalone should be re-unzipped even if
target directory already exists. It may be another version.

Download correct build of Android Studio (KT-20654)

In the latest version of the download page, there's a commented
block with links to downloads of older versions. Use non-greedy
matching to make sure we pick up the first link (the real one),
not the last one (the archive one).
2018-02-26 12:54:03 +03:00
Nikolay Krasko
beabc56fc0 == 171 -> as30 ^^^ == 2018-02-26 12:54:02 +03:00
Alexey Sedunov
789cd19515 Misc: Do not use unavailable property shouldUseJpsOutput 2018-02-26 12:31:39 +03:00
Yan Zhulanow
bb8ef038e6 Replace AndroidModuleModel to AndroidGradleModel in illegal identifier inspection 2018-02-26 12:31:38 +03:00
Alexey Sedunov
79e1842709 Misc: Drop rcUtils.kt as it can't be used in IDEA 171 2018-02-26 12:31:37 +03:00
Alexey Sedunov
7cc131896d Misc: Fix compilation of KotlinJestRunConfigurationProducer 2018-02-26 12:31:35 +03:00
Alexey Sedunov
a97749502d Revert: Kotlin Ultimate: Support NodeJS CLI run configuration 2018-02-26 12:31:30 +03:00
Alexey Sedunov
e93eccf197 Misc: Drop addBuildTask() method as it can be used in IDEA 171 2018-02-26 12:29:59 +03:00
Nikolay Krasko
4fc1519e02 Downgrade code style settings to idea 171 2018-02-26 12:29:57 +03:00
Yan Zhulanow
9a7b564907 lightAnnotations.kt: PsiLiteralValue -> PsiLiteral
because there is no `PsiLiteralValue` in 171
2018-02-26 12:29:56 +03:00
Mikhail Glukhikh
58d689d583 Fix compilation: PlatformExtensionReceiverOfInlineInspection
(cherry picked from commit f0a1f69)
2018-02-26 12:29:55 +03:00
Nicolay Mitropolsky
8a761db279 KotlinExternalSystemSyncListener.kt compilation fix
reverts part of b701117ffb
2018-02-26 12:29:53 +03:00
Vyacheslav Gerasimov
38fa49fd72 Drop KotlinCommonIntentionActionsFactory missing in idea 171 2018-02-26 12:29:52 +03:00
Dmitry Jemerov
b88ea7b9da Restore usage of ProgressWindowWithNotification in branch 171 2018-02-26 12:29:50 +03:00
Simon Ogorodnik
968cd71305 Fix compilation of PerModulePackageCacheService
Use rootManager helper from kotlin.idea.util instead of platform
2018-02-26 12:29:48 +03:00
Alexey Sedunov
9f09ff786c Revert: MPP: Support Mocha/Protractor run configuration for common modules
This reverts commit 97332aaeea
2018-02-26 12:29:47 +03:00
Dmitry Jemerov
72c734c3f8 Fix merge of AndroidGradleModelFacade 2018-02-26 12:29:45 +03:00
Yan Zhulanow
1a13f2a594 Android Extensions: Update model class name 2018-02-26 12:29:43 +03:00
Vyacheslav Gerasimov
b75c8f2a60 Add uast-common and uast-java jars to plugin dependencies 2018-02-26 12:29:41 +03:00
Simon Ogorodnik
8273cc00d4 Fix dependency of android-extensions-ide
Add dependency on common.jar from android plugin to bring
SdkConstants
2018-02-26 12:29:40 +03:00
Vyacheslav Gerasimov
d8b7fd6ac2 Fix compilation GradleModuleBuilder
(cherry picked from commit 2c2f9eb)
2018-02-26 12:29:38 +03:00
Simon Ogorodnik
2c4b8fc181 Fix dependencies of idea-android 2018-02-26 12:29:37 +03:00
Simon Ogorodnik
33f9798905 Fix compilation with gradle 2018-02-26 12:29:35 +03:00
Vyacheslav Gerasimov
96b9e4c334 Fix compilation KaptProjectResolverExtension 2018-02-26 12:29:34 +03:00
Dmitry Jemerov
e009ddc21b Fix compilation of MultiplatformGradleProjectTaskRunner in 171
(cherry picked from commit f8c72a8)
2018-02-26 12:29:32 +03:00
Nikolay Krasko
9dbc1da03a Revert "Remove UAST services registration from Kotlin plugin"
This reverts commit 7fffb7b553.
2018-02-26 12:29:31 +03:00
Nikolay Krasko
44e0428c3c Revert "Fix compilation KotlinModuleBuilder"
This reverts commit 768305adc8.
2018-02-26 12:29:30 +03:00
Nikolay Krasko
9b3acd316f Revert "Fix compilation AbstractParameterInfoTest"
This reverts commit c07096c9d7.
2018-02-26 12:29:28 +03:00
Nikolay Krasko
79ac56aa61 Revert "Fix compilation IntelliJLintClient, IntelliJLintProject, IDEAndroidLayoutXmlFileManager"
This reverts commit a142c2f8fa.
2018-02-26 12:29:26 +03:00
Nikolay Krasko
cd76c16d4a Revert "Fix compilation NewKotlinActivityAction, gradle sync classes moved"
This reverts commit be1022db2b.
2018-02-26 12:29:25 +03:00
Nikolay Krasko
8cc6654d23 Revert "Fix compilation androidUtil, MyReferredResourceFieldInfo requires module"
This reverts commit 6336c4ee98.
2018-02-26 12:29:23 +03:00
Nikolay Krasko
cdec806cb2 Revert "Fix compilation PlatformAndroidGradleDetector"
This reverts commit c675824c0a.
2018-02-26 12:29:22 +03:00
Nikolay Krasko
e0578401c2 Revert "Fix compilation gotoResourceHelper, KotlinAndroidTestCase"
This reverts commit 62e583903e.
2018-02-26 12:29:20 +03:00
Nikolay Krasko
ea7199e6b2 Revert "Android Extensions: Allow to disable IDE support (KT-12741)"
This reverts commit 298d29a962.
2018-02-26 12:29:19 +03:00
Nikolay Krasko
06f0c3634c Revert "Move Kotlin UAST registration to main plugin.xml"
This reverts commit 282da4cab5.
2018-02-26 12:29:17 +03:00
Nikolay Krasko
947a71ab82 Revert "Fix compilation AbstractKotlinEvaluateExpressionTest"
This reverts commit 83a8395287.
2018-02-26 12:29:16 +03:00
Nikolay Krasko
506921b2a0 Revert "Fix compilation MockUpdateParameterInfoContext"
This reverts commit 23e606d179.
2018-02-26 12:29:14 +03:00
Nikolay Krasko
47b6c52ce3 Revert "Fix compilation AndroidResourceReferenceAnnotator"
This reverts commit b825a8db43.
2018-02-26 12:29:13 +03:00
Nikolay Krasko
0d49b3a70f Revert "Fix tests compilation"
This reverts commit c1cfd70ae7.
2018-02-26 12:29:11 +03:00
Nikolay Krasko
f3ac58b1e6 Revert "Compilation fixes for 172 branch"
This reverts commit 48d4f5f5c2.
2018-02-26 12:29:10 +03:00
Nikolay Krasko
b458b44412 Revert "JvmCommonIntentionActionsFactory in Kotlin"
This reverts commit 0694f2d0c5.
2018-02-26 12:29:08 +03:00
Nikolay Krasko
53dd4c4600 Revert "Fixup for "JvmCommonIntentionActionsFactory in Kotlin""
This reverts commit 08673bfb0c.
2018-02-26 12:29:07 +03:00
Nikolay Krasko
dc35a3c062 Revert "Fix test compilation errors"
This reverts commit 11086192bc.
2018-02-26 12:29:05 +03:00
Nikolay Krasko
a1807fc041 Revert "Add missing implementation of abstract method to MockPsiManager"
This reverts commit 4d72f0ef66.
2018-02-26 12:29:03 +03:00
Nikolay Krasko
a5225407f3 Revert "Fix compilation for IDEA 172"
This reverts commit e56f9f6040.
2018-02-26 12:29:02 +03:00
Nikolay Krasko
47904fe1c4 Revert "KotlinCommonIntentionActionsFactory extensions for IDEA-85507 and KT-11906 (#1093)"
This reverts commit a36cbad7cd.
2018-02-26 12:29:00 +03:00
Nikolay Krasko
162a7731e3 Revert "Pass required Project parameter to constructor of NullableNotNullManager"
This reverts commit 13349086ac.
2018-02-26 12:28:59 +03:00
Nikolay Krasko
66c3f6db8a Revert ""Final Kotlin class or function with Spring annotation" inspection deprecation and disabling by default (KT-18506)"
This reverts commit 6ae247ba61.
2018-02-26 12:28:57 +03:00
Nikolay Krasko
42778169d2 Revert "Spring Constructor Injection falling test"
This reverts commit ce77751349.
2018-02-26 12:28:56 +03:00
Nikolay Krasko
f481041cd4 Revert "KotlinSpringClassAnnotator ignores duplicate gutter handlers (IDEA-173995, KT-18298)"
This reverts commit ca19ea8205.
2018-02-26 12:28:54 +03:00
Nikolay Krasko
0f522b48de Revert "Spring dependency-generations actions: runWriteAction moved to the proper place (KT-18385)"
This reverts commit 532560ef43.
2018-02-26 12:28:53 +03:00
Nikolay Krasko
6acc9fb9a7 Revert "Ultimate tests repair (KT-18847)"
This reverts commit 384ae8d8b5.
2018-02-26 12:28:51 +03:00
Nikolay Krasko
2df8f176f9 Revert "A check for AbstractSpringClassAnnotatorTest that ultimate plugin is properly set up"
This reverts commit 62dc3c8da4.
2018-02-26 12:28:50 +03:00
Nikolay Krasko
30c16f3e35 Revert "Update AndroidProjectKey package"
This reverts commit 4e868c5232.
2018-02-26 12:28:48 +03:00
Nikolay Krasko
dd6942c829 Revert "Fix 'isProjectOrWorkspaceFile' import"
This reverts commit 2954c41848.
2018-02-26 12:28:47 +03:00
Nikolay Krasko
2482003529 Revert "JPS: completely skip chunk containing only dummy targets"
This reverts commit 99439620d4.
2018-02-26 12:28:45 +03:00
Nikolay Krasko
4927684b30 Revert "Don't pack jps services into compiler"
This reverts commit 0d6cf19896.
2018-02-26 12:28:44 +03:00
Nikolay Krasko
f391b894e1 Revert "Fix debugger test in 172 (KT-18848)"
This reverts commit d8c20ed9c0.
2018-02-26 12:28:43 +03:00
Nikolay Krasko
7690c8d9fd Revert "Fix test behaviour in branch 172"
This reverts commit 2cf4da8564.
2018-02-26 12:28:41 +03:00
Nikolay Krasko
13adfa37d8 Revert "Drop usage of deprecated ProjectDataManager in branch 172"
This reverts commit eeede71d9d.
2018-02-26 12:28:40 +03:00
Nikolay Krasko
2bd123eef0 Revert "Update spring test data for 172 idea"
This reverts commit 10bf49118a.
2018-02-26 12:28:38 +03:00
Nikolay Krasko
dd1459590b Revert "Fix AbstractGenerateSpringDependencyActionTest.kt in branch 172"
This reverts commit 6d66fb35d6.
2018-02-26 12:28:37 +03:00
Nikolay Krasko
144e3ff7a0 Restrict 171 plugin for 171 idea only 2018-02-26 12:28:35 +03:00
Nikolay Krasko
6c3daf7e5f Revert update-dependencies and proguard changes for idea 172
Revert "Build against UAST bundled in IDEA"
This reverts commit bb7521a142.

Revert "Fix 'ant dist' build against 172 branch"
This reverts commit 548e86285c.

Revert "Bump guava to 21.0 in update_dependencies.xml"
This reverts commit e8d2782089.

Revert "Download IDEA from 172 branch"
This reverts commit b50d5fb998.

Revert "Download asm-all sources for idea 172"
This reverts commit 4b2b5dec75.

Revert "Advance Guava version"
This reverts commit 20d0d49cc3.

Revert "Make 172 plugin applicable for IDEA 173"
This reverts commit 4a15870e59.

Revert "Ignore absent net.jpountz.lz4.LZ4Factory in proguard"
This reverts commit c2b54c3e8a.

Revert "Correct 172 plugin 'since' field (no more compatible with 171)"
This reverts commit 85ecde6ec9.

Revert "Fix guava version"
This reverts commit cf4d0fb977.
2018-02-26 12:28:33 +03:00
Nikolay Krasko
f0e8d44c9a == 172 -> 171 ^^^ == 2018-02-26 12:28:32 +03:00
Nikolay Krasko
9c1c5a21f2 Restore KotlinCommonCodeStyleSettings behaviour for 172 Idea
There are no soft margins in CommonCodeStyleSettings.

(cherry picked from commit d600c4e)
2018-02-26 12:28:30 +03:00
Nikolay Krasko
701836d9ea Fix compilation in 172 after AbstractApplicationUsagesCollector rename
See c299f7d10a93a055cc868a9d9d20d68cc47c35e3 to intellij_community

(cherry picked from commit 36c60f6)
2018-02-26 12:28:29 +03:00
Nicolay Mitropolsky
494d2d0224 Uast-revert: test-data-revert 2018-02-26 12:28:27 +03:00
Nicolay Mitropolsky
919ceb1f2a UAST-reverted 2018-02-26 12:28:26 +03:00
Vyacheslav Gerasimov
d598ff8741 Restore missing gradleFrameworkSupport extension point registration 2018-02-26 12:28:24 +03:00
Vyacheslav Gerasimov
838179ff19 Update ideaVersion to 172.4343.14 2018-02-26 12:28:23 +03:00
Nikolay Krasko
6297b6b5b1 Restore usage of PathUtil.getLocalFile in 172 idea
There's no VfsUtil.getLocalFile
2018-02-26 12:28:21 +03:00
Vyacheslav Gerasimov
37b6cee6e8 Revert "Quick Fixes: Support cross-language "Create from Usage" with Kotlin target"
This reverts commit 908bf71
2018-02-26 12:28:20 +03:00
Vyacheslav Gerasimov
11e8f3a53f Revert "Quick Fixes: Drop deprecated KotlinCommonIntentionActionsFactory"
This reverts commit ba0a91d
2018-02-26 12:28:18 +03:00
Vyacheslav Gerasimov
b1d8648d7c Revert "Refactoring: Use modifier list in CallableInfo where possible"
This reverts commit 99be75c
2018-02-26 12:28:17 +03:00
Nikolay Krasko
a4a50eeed3 Try to remove unneeded commits in 172 branch
Revert "[Unneeded?] Revert "ExpressionOfTypeProcessor: get member name in read action""
This reverts commit 7ec59fc

Revert "[Unneeded] Revert "AbstractNavigateToLibraryTest: fix for invalid files""
This reverts commit 9e80c60

Revert "[Unneeded?] Revert "AbstractExtractionTest: fix for invalid files""
This reverts commit 0b2113b

Revert "[Unneeded] Revert "AbstractIntentionTest: `isApplicableOnPooled` made run under ProgressIndicator""
This reverts commit a41c247
2018-02-26 12:28:15 +03:00
Nikolay Krasko
3585ceab42 [Unneeded?] Revert "ExpressionOfTypeProcessor: get member name in read action"
This reverts commit 32d8e0c72b877f0c0123bb56e0d92beaab410daa.
2018-02-26 12:28:14 +03:00
Nikolay Krasko
0e324d1db1 [Unneeded] Revert "AbstractNavigateToLibraryTest: fix for invalid files"
This reverts commit e71b1757be6ca4b9ef49d65c6250a94f5f724f53.
2018-02-26 12:28:12 +03:00
Nikolay Krasko
8579dec6d0 [Unneeded?] Revert "AbstractExtractionTest: fix for invalid files"
This reverts commit b3b71ac53bb5150457ff228ecccb15060dd2de1f.
2018-02-26 12:28:11 +03:00
Nikolay Krasko
ce7f7ef2f6 [Unneeded] Revert "AbstractIntentionTest: isApplicableOnPooled made run under ProgressIndicator"
This reverts commit d1ad207fdbed6698ec352bd8b759f9ae62baebb3.
2018-02-26 12:28:09 +03:00
Nikolay Krasko
93ad8591cd Reverting Uast to 172 state 2018-02-26 12:28:08 +03:00
Nikolay Krasko
32d7cf8286 Revert "Ultimate-plugin: UAST added as dependency"
This reverts commit abae2af56f959330091f16daa507887c5edd56ee.
2018-02-26 12:28:06 +03:00
Nikolay Krasko
5a0e57814f [Spring] Revert "Fixes for 173 after 28.08.17 changes in IDEA (#1271)"
This reverts commit 3a37d18e5d65043fc99a28772303d948e0f89f6c.
2018-02-26 12:28:05 +03:00
Nikolay Krasko
923a6e59f5 [Spring] Revert "Spring-Kotlin: Gutter repaired (KT-20550, KT-20566)"
This reverts commit 37752694df794cc07492d21a3924ee735e6d3b9d.
2018-02-26 12:28:03 +03:00
Nikolay Krasko
d7d89e3f73 [Srping] Revert "Spring gutter icons SpringApiIcons -> SpringApiIcons.Gutter fix."
This reverts commit 2323e9dc75dbdf109564f1a0d28494e6b5e41075.
2018-02-26 12:28:02 +03:00
Nikolay Krasko
af4f06cbc1 [Spring] Revert "SpringKotlinAutowiringInspection: getting rid of SpringJavaInjectionPointsAutowiringInspection"
This reverts commit d0446b0aed0707ef616484c9fda04915c08598b0.
2018-02-26 12:28:00 +03:00
Nikolay Krasko
19f4b7e530 [Spring] Revert "SpringTestFixtureExtension: option to forbid facet autoconfigure added"
This reverts commit 0c90753c5bd9ac3fa492a61589d2c8aad3b96cc1.
2018-02-26 12:27:59 +03:00
Nikolay Krasko
4c76e93af7 [Spring] Revert "KotlinSpringComponentScanInspection made to support platform JamReferenceContributor"
This reverts commit f6a3b2eae4b0c49359bb477b320bc433988bec37.
2018-02-26 12:27:57 +03:00
Nikolay Krasko
844ae35d42 [Spring] Revert "Spring: removing needless EP-s because they ported to UAST in platform"
This reverts commit 9355f79c6b06fdcd365f23b40e93ea841b372b27.
2018-02-26 12:27:55 +03:00
Nikolay Krasko
a64e23c703 Revert "Download IDEA 173.3188.16"
This reverts commit e1d7419e7680d99d867ebfdecfb361e52298f3c9.
2018-02-26 12:27:53 +03:00
Nikolay Krasko
cc85636784 Revert "Fix compilation after moving to idea 173"
This reverts commit fe121cc6aeadf63ca2c2819c9c7df59cc81caf5d.
2018-02-26 12:27:52 +03:00
Nikolay Krasko
ff78ae4299 Restore compilation against Idea 172
Revert "Fix proguard settings for 173"
4dadae2e9c8419bfda9d77f56797e68edbd8ecd7.

Revert "Fix compilation in 173"
0633aa925c8e862519ae699e5e3fe81a2bd227c2.

Revert "Fix compilation (MockParameterInfoUIContext.java)"
01a7fbfb60d786c56c54f4fd77d9f1233f599ede.

Revert "Fix compilation"
043a5dac796f6bf92bbe6c9573c1af07fadcfe4e.

Revert "Fix compatibility with BuildScriptDataBuilder API changes"
c7df054d0e90a86fbe67f23802e9be49b2117ded.
2018-02-26 12:27:50 +03:00
Nikolay Krasko
ff8ab82649 Restore KotlinCoreEnvironment for 172 branch
Revert "`KotlinCoreEnvironment`: set `ideaCompatibleBuildNumber = "173.1"`"
This reverts commit d3321cc77a6b55d8b8ff3c3a16473f2f3b378533.

Revert "`JvmFacade`-related tests repair"
This reverts commit faeacdd17d37a4d733b686f3a1d5e8fc6ea54d79.

Revert "Register new service and EPs added in 173"
This reverts commit 5d227c0e714c1b4316e7b8daca1f208ee423f448.
2018-02-26 12:27:49 +03:00
Nikolay Krasko
f520fe3d10 Revert "KtLightAbstractAnnotation build fix for 173 (#1283)"
This reverts commit b401cc19e07ad632d61ca0d402dc6017f9559d18.
2018-02-26 12:27:48 +03:00
Nikolay Krasko
81d3407d32 Revert 173 specific changes in language injection
Revert "`KotlinLanguageInjector` using Registry to enable annotation injections"
This reverts commit c16a1d598c2bacc849dd16fed974ccdbf8b80754.

Revert "`KotlinLanguageInjector#injectInAnnotationCall` optimization: using `PsiClassNamePatternCondition` to avoid calling `getResolvedCall`"
This reverts commit f9eaaeab61b1dd50de9341846e129b58eb47f247.

Revert "`KotlinLanguageInjector` can inject into files modified for autocompletion"
This reverts commit 7212b22b083023201700696d775355051321b120.

Revert "`KotlinLanguageInjector` understands patterns-injections into Java annotations"
This reverts commit 45847b515bdfd27cfa5d23ff8b9147054ffa6f60.
2018-02-26 12:27:46 +03:00
Nikolay Krasko
ebec5d3b7b Revert "Fix GradleNoduleBuilder use qualified names check"
This reverts commit aec020a404d367195d58c7bb5d30185bfb85f202.
2018-02-26 12:27:44 +03:00
Nikolay Krasko
89e0be80e3 Revert "idea-version set to since-build="173.1" until-build="181.*""
This reverts commit 48701780db05e3c0928521f5fb95a5b89d417d95.
2018-02-26 12:27:43 +03:00
Nikolay Krasko
ec02eaa414 Revert "streamex version was changed in 173-snapshot to 0.6.5"
This reverts commit e418811d76b7519e6edda381285f205b6d2f1970.
2018-02-26 12:27:42 +03:00
Nikolay Krasko
e7bcdbeb5a Revert "Update file structure tests as FileStructurePopup api was changed in 173"
This reverts commit 5244d48fde8e373b046a8ccb602a280b946f8d41.
2018-02-26 12:27:40 +03:00
Nikolay Krasko
da727446ef Downgrade idea version from 173.4127.27 to 173.3302.8 2018-02-26 12:27:39 +03:00
Nikolay Krasko
1108572523 Revert "Workaround for CoreEnvironment initialization: explicitly setting versions for extensions"
This reverts commit 2e50bd19a83ab4a4f2b3a5d0cc09300ec1b7b1f7.
2018-02-26 12:27:37 +03:00
Nikolay Krasko
9e93f6cdb7 Revert "Fix find usages tests in 173 (run via ProgressIndicator)"
This reverts commit 1363306d562ad7ef5af9fd1642e139aa23abdd32.
2018-02-26 12:27:36 +03:00
Nikolay Krasko
e543ba50bc Revert "AbstractJavaToKotlinConverterForWebDemoTest: setup fix: JvmElementProvider and JavaModuleSystem added"
This reverts commit e1f340f59a9ec83c38ad2a0fe32ba47dbf4cdfb1.
2018-02-26 12:27:34 +03:00
Nikolay Krasko
322d5b9347 Revert "EdtTestUtil.runInEdtAndWait fix for proper user action emulation"
This reverts commit 4ebe750d36e86545a72177f91dc3baaa235fa92d.
2018-02-26 12:27:32 +03:00
Nikolay Krasko
5d19758197 Revert "RecursiveMethodCallMarkerInfo and SuspendCallMarkerInfo forced to target Leaf-elements"
This reverts commit c78ec71e17c09ddb1094e44c84d9a1b92a3b509f.
2018-02-26 12:27:31 +03:00
Nikolay Krasko
185e2a882b Revert "AbstractQuickFixTest: FORCE_PACKAGE_FOLDER directive added"
This reverts commit 91e10ae8bb6d2748a7a8b02fa661daa4cb00d0f8.
2018-02-26 12:27:29 +03:00
Nikolay Krasko
cfc7fb3b72 Revert "Ultimate-plugin: multiplePropertiesAnnotationConfig.kt test data fixes"
This reverts commit 4f2ee7359f8dfd3322329799475ff99dd88ed756.
2018-02-26 12:27:28 +03:00
Nikolay Krasko
57beb68690 Revert "Drop new Kotlin Dsl gradle project wizard which has been merged to idea"
This reverts commit 742d337ad722fe6ddcd6ad5dab27d52eda970489.
2018-02-26 12:27:26 +03:00
Nikolay Krasko
1f2cdb9859 Revert "Fix formatting for new kotlin dsl gradle project build script"
This reverts commit 75a46e66d18f69ff196749ba436b572b4462ea0d.
2018-02-26 12:27:25 +03:00
Nikolay Krasko
88865a8183 Revert "Move: Fix applicability check in IDEA 173"
This reverts commit 74c28b2a564a859a20b3f799df24405ba634c175.
2018-02-26 12:27:23 +03:00
Nikolay Krasko
242d4ab203 Revert "Line Markers: Respect subclass module when filtering out duplicates"
This reverts commit 8df0a58586abf42572aff15d4bdd70e51e5cad29.
2018-02-26 12:27:22 +03:00
Nikolay Krasko
bd7a4f48b5 Revert "Drop missing gradle extensions from gradle.xml"
This reverts commit 1f7a145942f0489e18b281878ac711e7505dce15.
2018-02-26 12:27:20 +03:00
Nikolay Krasko
e468fc6514 Revert "Update file name replace in QuickFix tests"
This reverts commit 01051618aa21c3502463c699f1d178136ef7c6b6.
2018-02-26 12:27:18 +03:00
Nikolay Krasko
26fc8d1106 Revert "Fix inAnnotation test in 173 branch"
This reverts commit 955842f2009a2c5aa9ac955340696bd7e1a2651d.
2018-02-26 12:27:17 +03:00
Nikolay Krasko
b0b12c96da Revert "Safe Delete: Suppress walking through light field initializer"
This reverts commit 34d3173ba79535591adb3e55a7af7cb9d1e49e40.
2018-02-26 12:27:15 +03:00
Nikolay Krasko
3007bf7306 Revert "Data Inflow: Support grouping by leaf expressions"
This reverts commit d5af2db2f259c7d55d38be73b9a5136e3aefd580.
2018-02-26 12:27:13 +03:00
Nikolay Krasko
db89c3bc38 Revert "Data Inflow: Support grouping by expression nullability"
This reverts commit e608f1ca159d55df39c8f33704220f360d54ba92.
2018-02-26 12:27:12 +03:00
Nikolay Krasko
7c444471e2 Revert "Fixing non-running tests, that used MockApplication environment"
This reverts commit 49fb7aab2a67f09c2832d759448ad07c1bb3023a.
2018-02-26 12:27:09 +03:00
Nikolay Krasko
30edc3ee22 [172] Revert "Set correct until-build for Idea 173 plugin"
This reverts commit 0f378217684879491c3184b7db84e3ce3750a8b5.
2018-02-26 12:27:07 +03:00
Nikolay Krasko
d8b2471253 [Tests] Revert "Allow different diagnostics in Javac tests - workaround for IDEA-184289"
This reverts commit 5212153463dcefbde28b4ca1814f6888fa9c57c1.
2018-02-26 12:27:06 +03:00
Nikolay Krasko
9bc13ebd2b [Tests] Revert "Modify incremental test in 173 branch - files are not create anymore"
This reverts commit 0cc5d163d7d620565a28681dab31f3d3061a1324.
2018-02-26 12:27:04 +03:00
Nikolay Krasko
e46b983699 == 173 -> 172 ^^^ == 2018-02-26 12:27:03 +03:00
Alexey Sedunov
2619dc5e0d Minor: Fix NPE
#KT-22724 Fixed

(cherry picked from commit 1bc6f5c)
2018-02-26 12:14:00 +03:00
Ilya Gorbunov
97848dd194 Update paths of the moved sources for building the documentation 2018-02-26 11:25:58 +03:00
Stanislav Erokhin
814858a2b7 Move runtime.jvm sources to stdlib/jvm/runtime
Update path in kotlin-runtime
Update path in kotlin-mock-runtime-for-tests
2018-02-26 11:25:57 +03:00
Simon Ogorodnik
8acc3c0b97 Propose convert to string template as inspection more frequent 2018-02-22 20:06:20 +03:00
Zalim Bashorov
0a829be3db Add missed references to license/README.md 2018-02-22 20:06:19 +03:00
Denis Zharkov
5a0d10464a Convert SwitchCodegen to Kotlin, prettify and optimize codegen 2018-02-22 11:47:41 +03:00
Mikhail Glukhikh
559e0848d8 Downgrade LoopToCallChainInspection to INFORMATION level
(cherry picked from commit fda4072)
2018-02-21 14:30:24 +03:00
Dmitry Jemerov
44d21c0db5 Fix ISE in KotlinPairMatcher.getCodeConstructStart()
(cherry picked from commit 9e30ede)
2018-02-21 10:59:38 +01:00
Yan Zhulanow
e50c18bbd6 Evaluator: Send class bytecode array in loop with a limited chunk size (#KT-22967)
JDI in Android has a limited byte buffer size (8192), and we must not exceed it.
2018-02-20 23:17:18 +03:00
Yan Zhulanow
8719796d97 Use thread-safe WeakHashMap implementation in annotation-based IDE plugins (#KT-22514) 2018-02-20 23:17:17 +03:00
Nicolay Mitropolsky
d2ff212b43 LightAnnotations: wrapping all PsiLiterals (not only Strings)
(cherry picked from commit bc543b4)
2018-02-20 18:02:59 +03:00
Denis Zharkov
fbaf90bc60 Add @SinceKotlin("1.2") to kotlin.suspend 2018-02-20 12:00:32 +03:00
Dmitry Petrov
88f8102bed Turn off intrinsics for 'withIndex' in 1.2.3x 2018-02-20 08:49:52 +03:00
Ilya Chernikov
c7533b91f9 Add missing reflect dependency to the gradle plugin
fixes #KT-22895
2018-02-19 17:19:16 +01:00
Denis Zharkov
f4c2f5d164 Prohibit labeled returns inside kotlin.suspend argument lambdas
Probably, it would be more correct to skip such lambdas when resolving
the returns' references, but it'd be more complicated and still useless
since non-local returns are impossible in such lambdas
(relevant parameter is noinline)

 #KT-22900 Fixed
2018-02-19 17:31:38 +03:00
Mikhail Zarechenskiy
fb940cec71 Improve message for exception about absence of common supertype
Relates to #KT-16253
2018-02-19 17:18:23 +03:00
Mikhael Bogdanov
25a136aeb2 Revert "Don't generate hash in sam wrapper class name"
This reverts commit 08f7829
2018-02-19 14:13:24 +01:00
Nikolay Krasko
9a00dc3355 Expression can be parenthesized on replace with if (KT-22874, EA-91186)
#KT-22874 Fixed
2018-02-19 13:00:33 +03:00
Nikolay Krasko
fbc01468dc Fix class cast exception in KotlinFunctionParameterInfoHandler (EA-91186) 2018-02-19 13:00:22 +03:00
Nikolay Krasko
fc43cb4767 Disable outdate runtime check for developers builds
We can't update them properly anyway.
2018-02-19 13:00:12 +03:00
Nikolay Krasko
7ffb405968 Fix isModified check in Kotlin compiler tab (KT-22851)
outputPostfix and outputPrefix is saved with nullize in apply, but
modification check was without it.

 #KT-22851 Fixed
2018-02-19 13:00:01 +03:00
Denis Zharkov
cd95e7ae16 Fix CCE caused by KotlinPackageSourcesMemberNamesIndex
FileContentImpl::getPsiFile is not-nullable and at the same time
it contains an explicit case of its fileType to LanguageFileType
that leads to the following exception in case when kt-file is marked as plain text:

java.lang.ClassCastException: com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeFactory$1 cannot be cast to com.intellij.openapi.fileTypes.LanguageFileType
	at com.intellij.util.indexing.FileContentImpl.createFileFromText(FileContentImpl.java:135)
	at com.intellij.util.indexing.FileContentImpl.getPsiFile(FileContentImpl.java:104)

 #EA-114338 Fixed
2018-02-19 10:32:25 +03:00
Ilya Gorbunov
cb0d27ca0d kotlin-test-testng: change actual package name for test annotation typealiases
to avoid potential split package situation

(cherry picked from commit 8c8caa4)
2018-02-14 23:52:32 +03:00
Alexey Tsvetkov
f75a5ff905 Avoid removing target/classes dir during IC in Maven
#KT-21581 fixed
2018-02-14 18:17:19 +03:00
Dmitry Savvinov
fee60f4f40 Update changelog for 1.2.30 2018-02-14 13:10:03 +03:00
Vyacheslav Karpukhin
64c1e9d345 Do not use hardcoded plugin ID for update checks
When Kotlin plugin is bundled into another plugin, there won't be a plugin with ID org.jetbrains.kotlin registered in PluginManager, which leads to runtime exceptions. To fix that let's determine the plugin ID dynamically instead.
2018-02-12 17:53:23 +03:00
Nikolay Krasko
3c61760a70 Collect statistics of used defaults set in formatting (KT-22252)
^KT-22252 In Progress
2018-02-12 17:53:22 +03:00
Anton Bannykh
9a8f283d6b JS: fix corner case in when translation (fix crash in KT-22544)
(cherry picked from commit cd3a797f2a)
2018-02-12 17:18:53 +03:00
Ilya Gorbunov
e089919ab8 Remove configureDist call not yet available in this branch 2018-02-12 15:36:55 +03:00
Alexey Sedunov
73eb07b6c4 Gradle: Fix dependency import when "module per sourceset" is disabled
#KT-22360 Fixed

(cherry picked from commit b315e0c)
2018-02-12 15:22:56 +03:00
Alexey Sedunov
8abc113f14 Configuration: Set up Kotlin SDK (if necessary) on plugin startup
#KT-22590 Fixed

(cherry picked from commit e1aec46)
2018-02-12 15:22:19 +03:00
Ilya Gorbunov
66177fb184 Add documentation for kotlin-test-testng artifact
(cherry picked from commit 0f130a0)
2018-02-12 08:27:32 +03:00
Ilya Gorbunov
6875bb4628 Select the asserter based on test framework presence in classpath
Simplify asserter lookup: enumerate all AsserterContributors when
the file class with lookupAsserter function is initialized.

It's assumed that AsserterContributor initialization should be fast.

#KT-21154 Fixed

(cherry picked from commit 5e3edf4)
2018-02-12 08:27:32 +03:00
Ilya Gorbunov
30945b8081 Include kotlin-test-testng into dist, setup JDK 7 required to run tests
(cherry picked from commit 9dfa54e)
2018-02-12 08:27:32 +03:00
Ilya Gorbunov
5a0dced10f Minor: kotlin-test reformat sources, fix test package names
(cherry picked from commit d1f00a9)
2018-02-12 08:27:32 +03:00
Valeriy Zhirnov
a2a340dd74 TestNG support in kotlin.test #KT-22620
(cherry picked from commit ad77019)
2018-02-12 08:27:32 +03:00
Nikolay Krasko
b42592c947 Store selected set of defaults in code style settings (KT-22252)
#KT-22252 In Progress

(cherry picked from commit 1e56743)
2018-02-11 22:18:53 +03:00
Nikolay Krasko
c903ce5d00 Control serialize/deserialize of CommonCodeStyleSettings
(cherry picked from commit 5d25b8b)
2018-02-11 22:17:35 +03:00
Nikolay Krasko
ce09e4cbbb Collect statistics about used Kotlin formatter
(cherry picked from commit 5a9ea89)
2018-02-11 22:16:54 +03:00
Nikolay Krasko
682c8723a6 Fix testInGlobalPropertyWithGetter test in 173 branch
Workaround for IDEA-185462. It was introduced in 173 idea and
fixed in 181.

(cherry picked from commit d1e6a61)
2018-02-11 22:13:42 +03:00
Mikhail Zarechenskiy
18bdede561 Fix type parameters indexes of MockClassDescriptor
Exception was thrown during mapping of arguments to parameters in `computeSupertypeProjections`

 #KT-18522 Fixed
2018-02-11 16:31:29 +03:00
Yan Zhulanow
d8b400a725 REPL, minor: Ignore empty lines (#KT-21611)
(cherry picked from commit 310ee67c35)
2018-02-09 19:26:41 +03:00
Yan Zhulanow
7c6641ae8c Kapt: Allow Kotlin @Repeatable annotations (KT-22451)
We don't generate a wrapper for repeatable annotations, and Javac complains to it.

(cherry picked from commit edcf0aef53)
2018-02-09 19:11:49 +03:00
Alexey Sedunov
233b0627c5 Configuration: Show Koltin plugin path as "home path" of Kotlin SDK
#KT-22640 Fixed

(cherry picked from commit e5e583e)
2018-02-09 15:07:30 +03:00
Alexey Sedunov
b5fc34be29 Create from Usage: Support target directory selection for "Create class"
#KT-22152 Fixed

(cherry picked from commit 84fed80)
2018-02-09 15:07:30 +03:00
Alexey Sedunov
592dc00fb4 Rename: Support retargeting/shadowing conflict checking for functions
#KT-22564 Fixed

(cherry picked from commit 695a2a4)
2018-02-09 15:07:29 +03:00
Alexey Sedunov
71bb9326b6 Rename: Fix qualified expression replacement for the case 'invoke' <-> 'get'
#KT-22705 Fixed

(cherry picked from commit 5c6bba9)
2018-02-09 15:07:29 +03:00
Alexey Sedunov
68fac8bc2d Refactor: Move canMoveLambdaOutsideParentheses() function to idea-core module
(cherry picked from commit fffd74f)
2018-02-09 15:07:29 +03:00
Alexey Sedunov
594fa29d0f J2K: KtArrayAccessReference
(cherry picked from commit 4870586)
2018-02-09 15:07:29 +03:00
Alexey Sedunov
556dcc53b6 J2K: KtArrayAccessReference (rename to .kt)
(cherry picked from commit 9150322)
2018-02-09 15:07:28 +03:00
Alexey Sedunov
e4eabfa961 Rename: Add quotes to declaration name if necessary
#KT-22708 Fixed

(cherry picked from commit e88f146)
2018-02-09 15:07:28 +03:00
Alexey Sedunov
d16ad96a41 Refactor: Move 'isIdentifier' and 'quoteIfNeeded' functions to frontend
(cherry picked from commit 428b086)
2018-02-09 15:07:28 +03:00
kenji tomita
62dc54b449 Inspection to get rid of unnecessary ticks in references #KT-18124 Fixed
(cherry picked from commit 1875d12)
2018-02-09 15:07:27 +03:00
Alexey Sedunov
6465536491 Change Signature: Support implicit calls of 'invoke' and 'get'
Also drop 'operator' keyword when necessary

 #KT-22718 Fixed

(cherry picked from commit fddfbf2)
2018-02-09 15:07:27 +03:00
Alexey Sedunov
e37f801aeb Slicer: Sort tree nodes to produce stable test data
(cherry picked from commit c602c51)
2018-02-09 15:07:27 +03:00
Alexey Sedunov
5bb938331b Rename: Substitute synthetic expression parent before analysis
This fixes rename conflicts test

(cherry picked from commit adca8eb)
2018-02-09 15:07:26 +03:00
Alexey Sedunov
4221ca0f8a Rename: Update test data (follow-up for unnecessary reformatting fix)
(cherry picked from commit 049439c)
2018-02-09 15:07:26 +03:00
Alexey Sedunov
e4cabda82d Rename: Make improvements for "by-convention" calls
- Convert between conventions call for 'get' and 'invoke'
- Drop 'operator' when converting 'get'/'invoke' to something other than
  'invoke'/'get' respectively

 #KT-12365 Fixed

(cherry picked from commit f35af11)
2018-02-09 15:07:25 +03:00
Alexey Sedunov
f3d9c09340 Rename: Replace name identifiers via AST to prevent unwanted reformatting
#KT-8563 Fixed

(cherry picked from commit caeb594)
2018-02-09 15:07:25 +03:00
Alexey Sedunov
4e41040dd7 Rename: Support KtTypeAlias in RenameKotlinClassProcessor
#KT-21719 Fixed

(cherry picked from commit 58bf42c)
2018-02-09 15:07:25 +03:00
Alexey Sedunov
6785341ab1 Loop to Call Chain: Do not generate lambda with double wrapping block
#KT-22476 Fixed

(cherry picked from commit 90392a8)
2018-02-09 15:07:24 +03:00
Alexey Sedunov
17b17ed90e Move Class to Top Leve: Suggest file name based on new class name
#KT-17977 Fixed

(cherry picked from commit 8c9c160)
2018-02-09 15:07:24 +03:00
Alexey Sedunov
73c0ee4035 Kotlin Ultimate: Support NodeJS CLI run configuration
#KT-16710 Fixed

(cherry picked from commit 4d52bf0)
2018-02-09 15:07:24 +03:00
Alexey Sedunov
4da7a0b3b1 Gradle: Import production output path for JavaScript modules
(cherry picked from commit 1f7fab8)
2018-02-09 15:07:24 +03:00
Alexey Sedunov
b09803c65e Kotlin Ultimate: Add "Build" action to JS run configurations
#KT-20522 Fixed

(cherry picked from commit 80887a8)
2018-02-09 15:07:23 +03:00
Alexey Sedunov
1d36a4601a Kotlin Ultimate: Support Jest run configurations for Kotlin sources
#KT-21531 Fixed

(cherry picked from commit 82a997e)
2018-02-09 15:07:23 +03:00
Alexey Sedunov
e6126e399e JS: Drop obsolete "Kotlin (JavaScript)" run configuration
#KT-21312 Fixed

(cherry picked from commit 2c0af79)
2018-02-09 15:07:23 +03:00
Sergey Igushkin
e04c32ca4d Delay kapt dependencies resolution from configuration phase
Store kapt configurations instead of classpath files in the tasks
Delay wrapping kapt subplugin options to task execution (when the
classpath can be safely resovled)

Issue #KT-18821 Fixed

(cherry picked from commit e8cd8b5)
2018-02-09 14:56:34 +03:00
Ilya Chernikov
5b4844b11e Pass previous dependencies to the legacy script dependency resolvers
fixes #KT-22753

(cherry picked from commit e38d539)
2018-02-09 11:06:45 +01:00
Rodrigo B. de Oliveira
e12052d6eb Make Kotlin Idea plugin aware of the Gradle initscript template
See gradle/kotlin-dsl#662

(cherry picked from commit de57951)
2018-02-09 11:06:24 +01:00
Dmitry Jemerov
df53bee809 Indent default parameter values
#KT-22508 Fixed

(cherry picked from commit 3aaad0c)
2018-02-09 10:51:15 +01:00
Dmitry Jemerov
8923464bb6 No space between label and lambda in labeled expressions
#KT-22301 Fixed

(cherry picked from commit 5bb195d)
2018-02-09 10:51:04 +01:00
Dmitry Jemerov
a9124635aa Do not indent closing bracket of array access expression
#KT-22641 Fixed

(cherry picked from commit 8f9b818)
2018-02-09 10:50:53 +01:00
Dmitry Jemerov
55f35404e1 Call chain indentation logic that actually makes sense
#KT-22346 Fixed

(cherry picked from commit 36f5525)
2018-02-09 10:50:43 +01:00
Dmitry Jemerov
15129e6e0b Group all call chain-related tests in a single directory
(cherry picked from commit 2c88b26)
2018-02-09 10:50:26 +01:00
Mikhail Glukhikh
e7eec55da0 Redundant object type check: fix problem highlighting #KT-22484 Fixed
(cherry picked from commit d554a42)
2018-02-09 11:08:29 +03:00
Mikhail Glukhikh
65f5c6d8ef Redundant object type check: use referential equality, forbid for when
So #KT-22538 Fixed

(cherry picked from commit 901ae08)
2018-02-09 11:08:11 +03:00
Mikhail Glukhikh
3874facce0 Reformat: RedundantObjectTypeCheckInspection
(cherry picked from commit fbe6929)
2018-02-09 11:07:55 +03:00
Mikhail Glukhikh
5f4943fd6b Detect library kind in Gradle if name looks like non-JVM
Related to KT-20971

(cherry picked from commit 198b054)
2018-02-09 11:07:40 +03:00
Mikhail Glukhikh
c690b8d9db Search for source of platform binary also in common sources
So #KT-20971 Fixed

(cherry picked from commit dcbb29e)
2018-02-09 11:07:23 +03:00
Mikhail Glukhikh
b7f87cf76e SourceNavigationHelper: reformat + style fix
(cherry picked from commit 76976f7)
2018-02-09 11:07:07 +03:00
Denis Zharkov
35c1d06dbc Minor. Remove irrelevant JAVAC_EXPECTED_FILE directive in tests
This change fixes these tests
2018-02-09 10:55:52 +03:00
Yan Zhulanow
620fdf3881 REPL: Fix crash on trying to :load with incorrect filename (KT-12037)
(cherry picked from commit 0238575a36)
2018-02-08 20:46:10 +03:00
Yan Zhulanow
e39e8632ac Debugger: (EA-112731) Do not crash miserably if we don't know the anonymous class name
Continue to log the exception, avoid breaking UX

(cherry picked from commit a25e93d82a)
2018-02-08 19:39:04 +03:00
Yan Zhulanow
2c3a3bd5c4 Kapt: Register additional source directories without modifying the raw Gradle model
Unfortunately, this works only for the newer Android Studio versions, so we need to keep the old code until IDEA will migrate at least to AS 3.1.

(cherry picked from commit 2a3bab0a0f)
2018-02-08 19:39:04 +03:00
Yan Zhulanow
5e65b6eca1 Kapt: Enums inside enum values should be forbidden (KT-22582)
(cherry picked from commit 6c4a2db34b)
2018-02-08 19:39:03 +03:00
Yan Zhulanow
447f796066 Android Extensions: Support '.', '-' and ':' in View identifiers (KT-22700)
(cherry picked from commit 510d5ece0f)
2018-02-08 19:39:03 +03:00
Yan Zhulanow
82ba00112b Kapt: Forbid using the deprecated (original) kapt
(cherry picked from commit ba61a93dc7)
2018-02-08 19:39:03 +03:00
Yan Zhulanow
6542559311 Kapt: Mute Java 9 tests temporarily on Windows
(cherry picked from commit bdd7ab3a09)
2018-02-08 19:39:03 +03:00
Yan Zhulanow
1e0589299a Uast: Fix an exception while converting type alias KotlinType to PsiType (KT-21874)
(cherry picked from commit 03a20384ef)
2018-02-08 19:39:03 +03:00
Yan Zhulanow
0493f3c864 Kapt: Map URLs to absolute file paths properly, also add some logging 2018-02-08 19:39:03 +03:00
Alexander Udalov
5cd5b83d05 Add test on experimental const val in annotation argument
This test checks that a usage inside an annotation argument is a
signature usage, which may be too restricting but easier to support at
the moment (and the restriction can be lifted in the future)
2018-02-08 17:38:05 +01:00
Alexander Udalov
978003eadf Always consider container's experimentality in ExperimentalUsageChecker
This results in more diagnostics usually, but allows library authors to
avoid annotating everything in each experimental class with the marker
(only the class needs to be annotated now)

 #KT-22759
2018-02-08 17:38:05 +01:00
Alexander Udalov
100e148db8 Add getExtensionOrNull utility for protobuf messages 2018-02-08 17:38:05 +01:00
Alexander Udalov
8da4550f95 Add test on Experimental in scripts 2018-02-08 17:38:05 +01:00
Alexander Udalov
d5a49d7c7d Load module annotations in IDE
#KT-22759 Fixed
2018-02-08 17:38:05 +01:00
Alexander Udalov
2d589dec43 Load module annotations for JVM and JS modules in compiler
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
be1439f5fe JS: write/read module annotation FQ names to/from metadata
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
3f3c6a9f71 Write/read module annotation FQ names to/from metadata on JVM
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
005669a935 Add packageProto/nameResolver to JvmPackagePartSource
May be useful for loading platform-specific protobuf extensions (such as
package_module_name on JVM) when analyzing deserialized top level
members
2018-02-08 17:38:04 +01:00
Alexander Udalov
0a66b5c4de Check experimental API markers for deprecation
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
af8f232bbf Support -Xexperimental/-Xuse-experimental in ExperimentalUsageChecker
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
e5f2c2580c Support -Xexperimental and -Xuse-experimental, validate their values
#KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
3463d5a0d1 Report diagnostic on overrides of experimental members
Unless they're experimental themselves

 #KT-22759 In Progress
2018-02-08 17:38:04 +01:00
Alexander Udalov
e6bb1610ec Do not require experimental propagation for body usages in same module
Unless it's a usage inside the body of an effectively public inline
function

 #KT-22759 In Progress
2018-02-08 17:38:03 +01:00
Alexander Udalov
1471f08731 Add some validation for Experimental/UseExperimental usages
#KT-22759 In Progress
2018-02-08 17:38:03 +01:00
Alexander Udalov
af7bb3f36b Introduce Experimental and UseExperimental annotations
#KT-22759 In Progress
2018-02-08 17:38:03 +01:00
Alexander Udalov
2dbae78a6c Remove unneeded constructor parameters in CallCheckerContext
(cherry picked from commit 0ad3872d1b)
2018-02-08 17:38:03 +01:00
Ilmir Usmanov
14561feada Take coroutineContext into account in RedundantSuspendModifierInspection
#KT-22651: Fixed
2018-02-08 19:34:55 +03:00
Alexander Podkhalyuzin
12f1f521d0 Ask just extensions, not in some area #KT-21978 Fixed
(cherry picked from commit 09d167e)
2018-02-08 19:15:04 +03:00
Denis Zharkov
8778433836 Add @RequireKotlin(1.2.30) for kotlin.suspend
#KT-22562 Fixed
2018-02-08 17:53:27 +03:00
Alexander Udalov
dada8a4207 Support patch versions in RequireKotlin with kind=COMPILER_VERSION 2018-02-08 17:53:27 +03:00
Denis Zharkov
82ce8649c8 Highlight callees resolved to kotlin.suspend as a keywords
#KT-22562 In Progress
2018-02-08 17:53:27 +03:00
Denis Zharkov
9620eb928f Add call checks related to suspend lambda modifier's introduction
- Prohibit non-modifier-like calls on kotlin.suspend
- Add warning on modifier-like calls to anything but kotlin.suspend

 #KT-22766 In Progress
 #KT-22562 In Progress
2018-02-08 17:49:34 +03:00
Denis Zharkov
2ead25467c Imitate support for suspend modifier on parameterless lambdas
#KT-22766 In Progress
2018-02-08 17:48:47 +03:00
Denis Zharkov
99892f352f Minor. Make function private 2018-02-08 17:48:47 +03:00
Denis Zharkov
fba0ababb4 Minor. Inline parameters 2018-02-08 17:48:47 +03:00
Denis Zharkov
c65e3e33cb Ignore @Nullable annotation for vararg parameter
See the comment in code for clarification

 #KT-19786 Fixed
2018-02-08 13:37:06 +03:00
Denis Zharkov
e2e6b1af85 Minor. Reformat signatureEnhancement.kt 2018-02-08 13:36:55 +03:00
Denis Zharkov
68d8c65242 Use extension registry when unpacking serialized type alias
It's funny here that "extension" here means protobuf extensions
while initial issue is about extension function types

 #Fixed KT-22728
2018-02-08 12:39:54 +03:00
Alexander Udalov
047dc8e8cc Update bootstrap to 1.2.40-dev-165
(cherry picked from commit bb013ec2bf)
2018-02-08 10:19:28 +01:00
Alexander Udalov
852a0a07e0 Rename JvmPackageTable -> JvmModuleProtoBuf, PackageTable -> Module
This protobuf message is going to contain more information about the
module than just the table of package parts

(cherry picked from commit ba5cc65792)
2018-02-08 10:19:27 +01:00
Mikhael Bogdanov
08f78291f3 Don't generate hash in sam wrapper class name
#KT-17091 Fixed

(cherry picked from commit 0954d1a)
2018-02-08 10:14:11 +01:00
Nicolay Mitropolsky
cfbb13f4c2 Uast: KotlinUNestedAnnotation with light annotation (IDEA-185890)
(cherry picked from commit 91a4bbe)
2018-02-07 12:56:35 +03:00
Nicolay Mitropolsky
c107ead158 LightAnnotations: wrapping nested annotations with KtLightAnnotationForSourceEntry
(cherry picked from commit cb05baa)
2018-02-07 12:53:39 +03:00
Nicolay Mitropolsky
0061312f8e Uast: KotlinUNestedAnnotation for processing nested annotations (IDEA-185890)
(cherry picked from commit 48ea52d)
2018-02-07 12:51:02 +03:00
Nicolay Mitropolsky
b5987627c7 Uast: support for Kotlin array literals
(cherry picked from commit 8ac95b5)
2018-02-07 12:48:17 +03:00
Mikhail Glukhikh
4020ee6a85 Fix a pack of broken IDE action tests
Related to KT-20281.
For Java resolve we can use also resolve with 'null' platform,
which is possible situation in tests.

(cherry picked from commit 81122ed)
2018-02-07 10:52:27 +03:00
Mikhail Glukhikh
b37a44ca07 Introduce inspection for redundant not-null extension receiver of inline
Related to KT-22303

(cherry picked from commit 7995ae0)
2018-02-07 10:52:00 +03:00
Yan Zhulanow
5c681d6cb5 Kapt: Fix compilation errors when the referenced class has '$' in the beginning of its name (KT-22493) 2018-02-06 22:25:18 +03:00
Yan Zhulanow
196acfb6fe Kapt: Escape nested comments in doc comments (KT-22469) 2018-02-06 22:25:08 +03:00
Yan Zhulanow
db9bbc8202 Kapt: Remove comments inside enum values (KT-22350) 2018-02-06 22:24:57 +03:00
Yan Zhulanow
5e80e1721b Fix "Illegal Android Identifier" inspection reports non-instrumentation unit tests (KT-22168) 2018-02-06 22:24:48 +03:00
Yan Zhulanow
fcdbe482e2 Kapt: Fix array of anonymous type handling (KT-22468) 2018-02-06 22:24:38 +03:00
Yan Zhulanow
90ce7369e8 Minor: Get rid of duplicating option descriptions in Kapt plugin 2018-02-06 22:24:27 +03:00
Yan Zhulanow
aa8a6b1936 Evaluate: Fix compiling evaluator issues led to improper expression caching
1. Do not save a ClassLoader reference inside the context, as we don't use it anyway after evaluation.
This is to avoid custom ClassLoader nesting.

2. Do not use 'findClass()' as it caches the loaded classes and always returns the first evaluated class if it's in cache.
2018-02-06 22:24:17 +03:00
Yan Zhulanow
4eb6071140 Evaluate: Support dex in newer Android build tools 2018-02-06 22:23:23 +03:00
Yan Zhulanow
eea6fa5f19 Kapt: Disable location mapping by default, allow to enable it manually 2018-02-06 22:23:13 +03:00
Yan Zhulanow
8e1222df83 Kapt: Replace original Javac diagnostic messages with those with Kotlin location mapped
There is no Messages dialog in newer versions of IDEA/Android Studio in which the error messages were mapped before. The new Build window shows only the original locations, so now we need to replace Java file diagnostics with ones mapped to Kotlin source files.

The side effect is that diagnostics on the same locations are automatically merged.
2018-02-06 22:23:02 +03:00
Yan Zhulanow
b36a0e6ea8 Kapt: Move line metadata to .kaptMetadata external files (KT-22386)
Placing location table inside .java file triggers annotation processor to run on each line table modification (even when the stub declarations themselves are the same). So we move it to the separate file.
2018-02-06 22:22:52 +03:00
Yan Zhulanow
3960dacde9 Parcelable: Fix 'Simple' test (new boolean serializer) 2018-02-06 22:22:40 +03:00
Yan Zhulanow
cb6a7b556a Parcelable: Add CREATOR field (and other generated declarations) in light classes (KT-19300, KT-19853) 2018-02-06 22:22:30 +03:00
Ilmir Usmanov
1aa9766ae1 Fix continuaion retrieval on generated coroutineContext intrinsic code
Use fake continuation instead on real one in JVM BE.
Pass continuation parameter to closure generator in JS BE.

 #KT-22577: Fixed
2018-02-06 21:19:10 +03:00
Ilmir Usmanov
7a94dadf17 Reformat coroutineContext related code 2018-02-06 21:19:01 +03:00
Mikhail Glukhikh
304d21be91 Show expect / actual gutter even for incomplete compatibility
So #KT-18445 Fixed
So #KT-21115 Fixed

(cherry picked from commit 3ba6b70)
2018-02-06 10:19:36 +03:00
Mikhail Glukhikh
1ba5a7e733 JVM facade: for Java resolve, always use JvmPlatform resolver
So #KT-20281 Fixed

(cherry picked from commit 19beaf5)
2018-02-06 10:16:38 +03:00
Mikhail Glukhikh
d4e5052bfc Introduce inspection for nullable extension receiver of inline function
So #KT-22303 Fixed

(cherry picked from commit c90056f)
2018-02-06 10:16:17 +03:00
Denis Zharkov
6a43ff2a9d Make precise java classes tracking in Gradle enabled by default
#KT-22192 Fixed
2018-02-05 11:56:37 +03:00
Anton Bannykh
0824ea9ad5 JS: fix callable reference with implicit extension receiver (KT-22638 fixed)
(cherry picked from commit 3ead464671)
2018-02-02 14:39:00 +03:00
Ilmir Usmanov
f42c282f90 Move coroutineContext to correct package
from kotlin.coroutines.experimental.instrinsics to kotlin.coroutines.experimental

 #KT-22400
2018-02-01 20:49:24 +03:00
Pavel V. Talanov
8c1dee41e8 JavaResolveExtension: create facade by original element
Fixes semantic difference erroneously introduced in c030a047aa
 #KT-22593 Fixed
2018-01-31 20:23:04 +03:00
Nicolay Mitropolsky
3ddeec6f3b Revert "Light annotations made strictly non-physical (KT-22565)"
This reverts commit 99746b5
It looks like it could bring some issues in IDEA 173, so moving to 181 only
2018-01-31 20:07:18 +03:00
Nicolay Mitropolsky
99746b5094 Light annotations made strictly non-physical (KT-22565)
(cherry picked from commit cf6e21d)
2018-01-31 16:55:15 +03:00
Mikhail Glukhikh
34e8a720df Fix completion test (companion object is allowed in annotation scope)
(cherry picked from commit babcea9)
2018-01-31 14:48:00 +03:00
Mikhail Glukhikh
17d4e92e6c Fix "create enum constant" test (create type alias is no longer here)
(cherry picked from commit 00ceac5)
2018-01-31 14:01:21 +03:00
Nikolay Krasko
5871a5e8e7 Set better defaults on Imports tab in Code Style -> Kotlin (KT-22575)
"Top level symbols" and "Java Statics and Enum Members" are always
returned to 2 after saving to not-number option

 #KT-22575 Fixed
2018-01-31 13:56:24 +03:00
Nikolay Krasko
f99907977e Can't add import for using with '*' in settings (KT-22570)
#KT-22570 Fixed
2018-01-31 13:56:23 +03:00
Nikolay Krasko
1e0b0aa5ce Fix modification check for Kotlin import settings (KT-22557)
#KT-22557 Fixed
2018-01-31 13:56:22 +03:00
Nikolay Krasko
93d8b2b9dc Lost IF_RPAREN_ON_NEW_LINE settings from Kotlin code style 2018-01-31 13:56:21 +03:00
Nikolay Krasko
8cdababa48 Add ability to customize and save IF_RPAREN_ON_NEW_LINE setting 2018-01-31 13:56:20 +03:00
Ilya Chernikov
50f34dbad0 Detect new activity after delayed shutdown correctly
fixes #KT-22549, test
2018-01-31 10:12:32 +01:00
Mikhail Glukhikh
026df68206 Fix two psi checker tests (related to annotation diagnostic / parsing)
(cherry picked from commit f46fa26)
2018-01-31 12:00:06 +03:00
Mikhail Glukhikh
6e75ff5b6b KtVisitor: delegate constructors to KtNamedDeclaration
In particular, enables back "Unused symbol" on constructors

(cherry picked from commit 86f25bf)
2018-01-31 11:59:34 +03:00
Mikhail Glukhikh
0fa5bf7e58 Fix testAnnotation in "member visibility can be private"
(cherry picked from commit 899da99)
2018-01-31 11:58:50 +03:00
Mikhail Glukhikh
6045110e94 Fix parcelize delete creator field test (companion is retained now)
(cherry picked from commit 98b0f91)
2018-01-31 11:58:22 +03:00
Mikhail Glukhikh
f0141571b1 Fix J2K 'testAnnotationInterface3' (annotation diagnostic changed)
(cherry picked from commit 294dcf3)
2018-01-31 11:58:02 +03:00
Mikhail Glukhikh
b5b355eac7 Fix testAnnotationInterface3 in J2K (error message)
(cherry picked from commit 4606885)
2018-01-31 11:57:39 +03:00
Toshiaki Kameyama
08536661bd KT-22167 "Add annotation target" quick fix does nothing and disappears from menu
(cherry picked from commit 677b05c)
2018-01-31 11:56:35 +03:00
Mikhail Glukhikh
05183068c2 Delete companion manually during pull up
(cherry picked from commit d88b574)
2018-01-30 16:35:20 +03:00
Mikhail Glukhikh
1abf134c8f Delete companion manually during callable inlining
(cherry picked from commit 6181ba4)
2018-01-30 16:34:22 +03:00
Mikhail Glukhikh
c462a74d35 Retain empty companion in KtNamedDeclarationStub.remove
(cherry picked from commit 9b1f323)
2018-01-30 16:34:12 +03:00
Mikhail Glukhikh
36f796dfb9 Create actual fix: handle companions correctly #KT-21114 Fixed
(cherry picked from commit 5abb9dd)
2018-01-30 16:34:01 +03:00
Dmitry Savvinov
d2833ccae1 Add changelog for 1.2.30 2018-01-30 11:21:02 +03:00
Mikhail Glukhikh
05849b0ea3 Redundant Unit expression: simplify code a bit
(cherry picked from commit 1298ef7)
2018-01-30 11:19:59 +03:00
Mikhail Glukhikh
a4d7488391 getParentOfTypesAndPredicate: Class<T> -> Class<out T>
(cherry picked from commit cd9e298)
2018-01-30 11:19:48 +03:00
Toshiaki Kameyama
a21fb3f2e0 Redundant Unit inspection: fix false positive for single expression
So #KT-22097 Fixed

(cherry picked from commit 18de0f7)
2018-01-30 11:19:34 +03:00
Toshiaki Kameyama
074429ff50 Correct report of "redundant setter" for override & empty block cases
So #KT-22364 Fixed

(cherry picked from commit 69f3f04)
2018-01-30 10:00:53 +03:00
1671 changed files with 23128 additions and 78297 deletions

View File

@@ -63,6 +63,7 @@
<option name="CONTINUATION_INDENT_IN_SUPERTYPE_LISTS" value="false" />
<option name="CONTINUATION_INDENT_IN_IF_CONDITIONS" value="false" />
<option name="WRAP_EXPRESSION_BODY_FUNCTIONS" value="1" />
<option name="IF_RPAREN_ON_NEW_LINE" value="true" />
</JetCodeStyleSettings>
<MarkdownNavigatorCodeStyleSettings>
<option name="RIGHT_MARGIN" value="72" />

View File

@@ -3,6 +3,8 @@
<words>
<w>checkcast</w>
<w>coroutine</w>
<w>experimentalities</w>
<w>experimentality</w>
<w>insn</w>
<w>liveness</w>
</words>

File diff suppressed because it is too large Load Diff

View File

@@ -148,7 +148,7 @@
<print-file-size-statistic path="${basedir}/libraries/stdlib/js/build/classes/main" file-name="kotlin.meta.js"/>
</target>
<target name="post_build" depends="zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
<target name="post_build" depends="patchXmlForAndroidStudio, zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
<target name="none">
<fail message="Either specify pre_build or post_build"/>
@@ -186,4 +186,28 @@
<target name="dont_remove_internal_artifacts" unless="need.remove.artifacts">
<echo message="Internal artifacts left untouched"/>
</target>
<macrodef name="patch_plugin_xml">
<attribute name="plugin.xml" />
<sequential>
<replace file="@{plugin.xml}" token="&lt;!-- DEPENDS-ON-AS-PLACEHOLDER --&gt;" value="&lt;depends&gt;com.intellij.modules.androidstudio&lt;/depends&gt;"/>
</sequential>
</macrodef>
<target name="patchXmlForAndroidStudio">
<unzip src="${artifact.output.path}/Kotlin/lib/kotlin-plugin.jar" dest="tmpAndroidStudio">
<patternset>
<include name="META-INF/plugin.xml"/>
</patternset>
</unzip>
<patch_plugin_xml plugin.xml="tmpAndroidStudio/META-INF/plugin.xml"/>
<jar destfile="${artifact.output.path}/Kotlin/lib/kotlin-plugin.jar" update="true">
<fileset dir="tmpAndroidStudio"/>
<file file="META-INF/plugin.xml"/>
</jar>
<delete file="tmpAndroidStudio"/>
</target>
</project>

View File

@@ -19,12 +19,16 @@ package org.jetbrains.kotlin.incremental
import com.intellij.util.io.DataExternalizer
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.incremental.storage.BasicStringMap
import org.jetbrains.kotlin.incremental.storage.DirtyClassesFqNameMap
import org.jetbrains.kotlin.incremental.storage.SourceToFqNameMap
import org.jetbrains.kotlin.incremental.storage.StringToLongMapExternalizer
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
import org.jetbrains.kotlin.serialization.js.JsProtoBuf
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
import java.io.DataInput
@@ -177,11 +181,7 @@ fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData>
}
proto.`package`.apply {
val packageFqName = if (hasExtension(JsProtoBuf.packageFqName)) {
nameResolver.getPackageFqName(getExtension(JsProtoBuf.packageFqName))
}
else FqName.ROOT
val packageFqName = getExtensionOrNull(JsProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName) ?: FqName.ROOT
val packagePartClassId = ClassId(packageFqName, Name.identifier(sourceFile.nameWithoutExtension.capitalize() + "Kt"))
classes[packagePartClassId] = PackagePartProtoData(this, nameResolver, packageFqName)
}

View File

@@ -1,15 +1,15 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: core/descriptors.jvm/src/jvm_package_table.debug.proto
// source: core/descriptors.jvm/src/jvm_module.debug.proto
package org.jetbrains.kotlin.serialization.jvm;
public final class DebugJvmPackageTable {
private DebugJvmPackageTable() {}
public final class DebugModuleProtoBuf {
private DebugModuleProtoBuf() {}
public static void registerAllExtensions(
org.jetbrains.kotlin.protobuf.ExtensionRegistry registry) {
}
public interface PackageTableOrBuilder extends
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.serialization.jvm.PackageTable)
public interface ModuleOrBuilder extends
// @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.serialization.jvm.Module)
org.jetbrains.kotlin.protobuf.MessageOrBuilder {
/**
@@ -19,7 +19,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>
getPackagePartsList();
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
@@ -28,7 +28,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index);
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
*
@@ -44,7 +44,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getPackagePartsOrBuilderList();
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
@@ -53,7 +53,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
int index);
/**
@@ -63,7 +63,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>
java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>
getMetadataPartsList();
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
@@ -72,7 +72,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index);
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
*
@@ -88,7 +88,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getMetadataPartsOrBuilderList();
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
@@ -97,7 +97,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
int index);
/**
@@ -140,25 +140,25 @@ public final class DebugJvmPackageTable {
getJvmPackageNameBytes(int index);
}
/**
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.PackageTable}
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.Module}
*/
public static final class PackageTable extends
public static final class Module extends
org.jetbrains.kotlin.protobuf.GeneratedMessage implements
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.serialization.jvm.PackageTable)
PackageTableOrBuilder {
// Use PackageTable.newBuilder() to construct.
private PackageTable(org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<?> builder) {
// @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.serialization.jvm.Module)
ModuleOrBuilder {
// Use Module.newBuilder() to construct.
private Module(org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<?> builder) {
super(builder);
this.unknownFields = builder.getUnknownFields();
}
private PackageTable(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.UnknownFieldSet.getDefaultInstance(); }
private Module(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.UnknownFieldSet.getDefaultInstance(); }
private static final PackageTable defaultInstance;
public static PackageTable getDefaultInstance() {
private static final Module defaultInstance;
public static Module getDefaultInstance() {
return defaultInstance;
}
public PackageTable getDefaultInstanceForType() {
public Module getDefaultInstanceForType() {
return defaultInstance;
}
@@ -168,7 +168,7 @@ public final class DebugJvmPackageTable {
getUnknownFields() {
return this.unknownFields;
}
private PackageTable(
private Module(
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
@@ -193,18 +193,18 @@ public final class DebugJvmPackageTable {
}
case 10: {
if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>();
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>();
mutable_bitField0_ |= 0x00000001;
}
packageParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.PARSER, extensionRegistry));
packageParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.PARSER, extensionRegistry));
break;
}
case 18: {
if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>();
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>();
mutable_bitField0_ |= 0x00000002;
}
metadataParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.PARSER, extensionRegistry));
metadataParts_.add(input.readMessage(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.PARSER, extensionRegistry));
break;
}
case 26: {
@@ -239,33 +239,33 @@ public final class DebugJvmPackageTable {
}
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
}
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.Builder.class);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.Builder.class);
}
public static org.jetbrains.kotlin.protobuf.Parser<PackageTable> PARSER =
new org.jetbrains.kotlin.protobuf.AbstractParser<PackageTable>() {
public PackageTable parsePartialFrom(
public static org.jetbrains.kotlin.protobuf.Parser<Module> PARSER =
new org.jetbrains.kotlin.protobuf.AbstractParser<Module>() {
public Module parsePartialFrom(
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return new PackageTable(input, extensionRegistry);
return new Module(input, extensionRegistry);
}
};
@java.lang.Override
public org.jetbrains.kotlin.protobuf.Parser<PackageTable> getParserForType() {
public org.jetbrains.kotlin.protobuf.Parser<Module> getParserForType() {
return PARSER;
}
public static final int PACKAGE_PARTS_FIELD_NUMBER = 1;
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> packageParts_;
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> packageParts_;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
*
@@ -273,7 +273,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getPackagePartsList() {
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getPackagePartsList() {
return packageParts_;
}
/**
@@ -283,7 +283,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getPackagePartsOrBuilderList() {
return packageParts_;
}
@@ -304,7 +304,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index) {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index) {
return packageParts_.get(index);
}
/**
@@ -314,13 +314,13 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
int index) {
return packageParts_.get(index);
}
public static final int METADATA_PARTS_FIELD_NUMBER = 2;
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> metadataParts_;
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> metadataParts_;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
*
@@ -328,7 +328,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getMetadataPartsList() {
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getMetadataPartsList() {
return metadataParts_;
}
/**
@@ -338,7 +338,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getMetadataPartsOrBuilderList() {
return metadataParts_;
}
@@ -359,7 +359,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index) {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index) {
return metadataParts_.get(index);
}
/**
@@ -369,7 +369,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
int index) {
return metadataParts_.get(index);
}
@@ -500,53 +500,53 @@ public final class DebugJvmPackageTable {
return super.writeReplace();
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
org.jetbrains.kotlin.protobuf.ByteString data)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
org.jetbrains.kotlin.protobuf.ByteString data,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(byte[] data)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(byte[] data)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
byte[] data,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(java.io.InputStream input)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
java.io.InputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseDelimitedFrom(java.io.InputStream input)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseDelimitedFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseDelimitedFrom(
java.io.InputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
org.jetbrains.kotlin.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parseFrom(
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
@@ -555,7 +555,7 @@ public final class DebugJvmPackageTable {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable prototype) {
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@@ -567,25 +567,25 @@ public final class DebugJvmPackageTable {
return builder;
}
/**
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.PackageTable}
* Protobuf type {@code org.jetbrains.kotlin.serialization.jvm.Module}
*/
public static final class Builder extends
org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.PackageTable)
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTableOrBuilder {
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.Module)
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.ModuleOrBuilder {
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
}
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.Builder.class);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.Builder.class);
}
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.newBuilder()
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
@@ -630,23 +630,23 @@ public final class DebugJvmPackageTable {
public org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable getDefaultInstanceForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.getDefaultInstance();
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module getDefaultInstanceForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.getDefaultInstance();
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable build() {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable result = buildPartial();
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module build() {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable buildPartial() {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable result = new org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable(this);
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module buildPartial() {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module result = new org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module(this);
int from_bitField0_ = bitField0_;
if (packagePartsBuilder_ == null) {
if (((bitField0_ & 0x00000001) == 0x00000001)) {
@@ -676,16 +676,16 @@ public final class DebugJvmPackageTable {
}
public Builder mergeFrom(org.jetbrains.kotlin.protobuf.Message other) {
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable) {
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable)other);
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module) {
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable other) {
if (other == org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable.getDefaultInstance()) return this;
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module other) {
if (other == org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module.getDefaultInstance()) return this;
if (packagePartsBuilder_ == null) {
if (!other.packageParts_.isEmpty()) {
if (packageParts_.isEmpty()) {
@@ -772,11 +772,11 @@ public final class DebugJvmPackageTable {
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable parsedMessage = null;
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageTable) e.getUnfinishedMessage();
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.Module) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
@@ -787,17 +787,17 @@ public final class DebugJvmPackageTable {
}
private int bitField0_;
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> packageParts_ =
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> packageParts_ =
java.util.Collections.emptyList();
private void ensurePackagePartsIsMutable() {
if (!((bitField0_ & 0x00000001) == 0x00000001)) {
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>(packageParts_);
packageParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>(packageParts_);
bitField0_ |= 0x00000001;
}
}
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder> packagePartsBuilder_;
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder> packagePartsBuilder_;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
@@ -806,7 +806,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getPackagePartsList() {
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getPackagePartsList() {
if (packagePartsBuilder_ == null) {
return java.util.Collections.unmodifiableList(packageParts_);
} else {
@@ -834,7 +834,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getPackageParts(int index) {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getPackageParts(int index) {
if (packagePartsBuilder_ == null) {
return packageParts_.get(index);
} else {
@@ -849,7 +849,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder setPackageParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (packagePartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -870,7 +870,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder setPackageParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (packagePartsBuilder_ == null) {
ensurePackagePartsIsMutable();
packageParts_.set(index, builderForValue.build());
@@ -887,7 +887,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public Builder addPackageParts(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
public Builder addPackageParts(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (packagePartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -908,7 +908,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addPackageParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (packagePartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -929,7 +929,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addPackageParts(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (packagePartsBuilder_ == null) {
ensurePackagePartsIsMutable();
packageParts_.add(builderForValue.build());
@@ -947,7 +947,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addPackageParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (packagePartsBuilder_ == null) {
ensurePackagePartsIsMutable();
packageParts_.add(index, builderForValue.build());
@@ -965,7 +965,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addAllPackageParts(
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> values) {
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> values) {
if (packagePartsBuilder_ == null) {
ensurePackagePartsIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
@@ -1017,7 +1017,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder getPackagePartsBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder getPackagePartsBuilder(
int index) {
return getPackagePartsFieldBuilder().getBuilder(index);
}
@@ -1028,7 +1028,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getPackagePartsOrBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getPackagePartsOrBuilder(
int index) {
if (packagePartsBuilder_ == null) {
return packageParts_.get(index); } else {
@@ -1042,7 +1042,7 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getPackagePartsOrBuilderList() {
if (packagePartsBuilder_ != null) {
return packagePartsBuilder_.getMessageOrBuilderList();
@@ -1057,9 +1057,9 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addPackagePartsBuilder() {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addPackagePartsBuilder() {
return getPackagePartsFieldBuilder().addBuilder(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
@@ -1068,10 +1068,10 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addPackagePartsBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addPackagePartsBuilder(
int index) {
return getPackagePartsFieldBuilder().addBuilder(
index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts package_parts = 1;</code>
@@ -1080,16 +1080,16 @@ public final class DebugJvmPackageTable {
* Names of .class files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder>
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder>
getPackagePartsBuilderList() {
return getPackagePartsFieldBuilder().getBuilderList();
}
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getPackagePartsFieldBuilder() {
if (packagePartsBuilder_ == null) {
packagePartsBuilder_ = new org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>(
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>(
packageParts_,
((bitField0_ & 0x00000001) == 0x00000001),
getParentForChildren(),
@@ -1099,17 +1099,17 @@ public final class DebugJvmPackageTable {
return packagePartsBuilder_;
}
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> metadataParts_ =
private java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> metadataParts_ =
java.util.Collections.emptyList();
private void ensureMetadataPartsIsMutable() {
if (!((bitField0_ & 0x00000002) == 0x00000002)) {
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts>(metadataParts_);
metadataParts_ = new java.util.ArrayList<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts>(metadataParts_);
bitField0_ |= 0x00000002;
}
}
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder> metadataPartsBuilder_;
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder> metadataPartsBuilder_;
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
@@ -1118,7 +1118,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> getMetadataPartsList() {
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> getMetadataPartsList() {
if (metadataPartsBuilder_ == null) {
return java.util.Collections.unmodifiableList(metadataParts_);
} else {
@@ -1146,7 +1146,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getMetadataParts(int index) {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getMetadataParts(int index) {
if (metadataPartsBuilder_ == null) {
return metadataParts_.get(index);
} else {
@@ -1161,7 +1161,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder setMetadataParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (metadataPartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -1182,7 +1182,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder setMetadataParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (metadataPartsBuilder_ == null) {
ensureMetadataPartsIsMutable();
metadataParts_.set(index, builderForValue.build());
@@ -1199,7 +1199,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public Builder addMetadataParts(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
public Builder addMetadataParts(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (metadataPartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -1220,7 +1220,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addMetadataParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts value) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts value) {
if (metadataPartsBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
@@ -1241,7 +1241,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addMetadataParts(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (metadataPartsBuilder_ == null) {
ensureMetadataPartsIsMutable();
metadataParts_.add(builderForValue.build());
@@ -1259,7 +1259,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addMetadataParts(
int index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder builderForValue) {
int index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder builderForValue) {
if (metadataPartsBuilder_ == null) {
ensureMetadataPartsIsMutable();
metadataParts_.add(index, builderForValue.build());
@@ -1277,7 +1277,7 @@ public final class DebugJvmPackageTable {
* </pre>
*/
public Builder addAllMetadataParts(
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts> values) {
java.lang.Iterable<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts> values) {
if (metadataPartsBuilder_ == null) {
ensureMetadataPartsIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
@@ -1329,7 +1329,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder getMetadataPartsBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder getMetadataPartsBuilder(
int index) {
return getMetadataPartsFieldBuilder().getBuilder(index);
}
@@ -1340,7 +1340,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder getMetadataPartsOrBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder getMetadataPartsOrBuilder(
int index) {
if (metadataPartsBuilder_ == null) {
return metadataParts_.get(index); } else {
@@ -1354,7 +1354,7 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
public java.util.List<? extends org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getMetadataPartsOrBuilderList() {
if (metadataPartsBuilder_ != null) {
return metadataPartsBuilder_.getMessageOrBuilderList();
@@ -1369,9 +1369,9 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addMetadataPartsBuilder() {
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addMetadataPartsBuilder() {
return getMetadataPartsFieldBuilder().addBuilder(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
@@ -1380,10 +1380,10 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder addMetadataPartsBuilder(
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder addMetadataPartsBuilder(
int index) {
return getMetadataPartsFieldBuilder().addBuilder(
index, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance());
index, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance());
}
/**
* <code>repeated .org.jetbrains.kotlin.serialization.jvm.PackageParts metadata_parts = 2;</code>
@@ -1392,16 +1392,16 @@ public final class DebugJvmPackageTable {
* Names of .kotlin_metadata files for each package
* </pre>
*/
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder>
public java.util.List<org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder>
getMetadataPartsBuilderList() {
return getMetadataPartsFieldBuilder().getBuilderList();
}
private org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>
getMetadataPartsFieldBuilder() {
if (metadataPartsBuilder_ == null) {
metadataPartsBuilder_ = new org.jetbrains.kotlin.protobuf.RepeatedFieldBuilder<
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder>(
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder>(
metadataParts_,
((bitField0_ & 0x00000002) == 0x00000002),
getParentForChildren(),
@@ -1549,15 +1549,15 @@ public final class DebugJvmPackageTable {
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.jvm.PackageTable)
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.jvm.Module)
}
static {
defaultInstance = new PackageTable(true);
defaultInstance = new Module(true);
defaultInstance.initFields();
}
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.jvm.PackageTable)
// @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.serialization.jvm.Module)
}
public interface PackagePartsOrBuilder extends
@@ -1919,14 +1919,14 @@ public final class DebugJvmPackageTable {
}
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
}
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder.class);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder.class);
}
public static org.jetbrains.kotlin.protobuf.Parser<PackageParts> PARSER =
@@ -2353,53 +2353,53 @@ public final class DebugJvmPackageTable {
return super.writeReplace();
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
org.jetbrains.kotlin.protobuf.ByteString data)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
org.jetbrains.kotlin.protobuf.ByteString data,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(byte[] data)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(byte[] data)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
byte[] data,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(java.io.InputStream input)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
java.io.InputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseDelimitedFrom(java.io.InputStream input)
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseDelimitedFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseDelimitedFrom(
java.io.InputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
org.jetbrains.kotlin.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
public static org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parseFrom(
public static org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parseFrom(
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
@@ -2408,7 +2408,7 @@ public final class DebugJvmPackageTable {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts prototype) {
public static Builder newBuilder(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@@ -2425,20 +2425,20 @@ public final class DebugJvmPackageTable {
public static final class Builder extends
org.jetbrains.kotlin.protobuf.GeneratedMessage.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.serialization.jvm.PackageParts)
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackagePartsOrBuilder {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackagePartsOrBuilder {
public static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
}
protected org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.Builder.class);
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.class, org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.Builder.class);
}
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.newBuilder()
// Construct using org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
@@ -2479,23 +2479,23 @@ public final class DebugJvmPackageTable {
public org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts getDefaultInstanceForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance();
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts getDefaultInstanceForType() {
return org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance();
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts build() {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts result = buildPartial();
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts build() {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts buildPartial() {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts result = new org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts(this);
public org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts buildPartial() {
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts result = new org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
@@ -2533,16 +2533,16 @@ public final class DebugJvmPackageTable {
}
public Builder mergeFrom(org.jetbrains.kotlin.protobuf.Message other) {
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts) {
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts)other);
if (other instanceof org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts) {
return mergeFrom((org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts other) {
if (other == org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts.getDefaultInstance()) return this;
public Builder mergeFrom(org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts other) {
if (other == org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts.getDefaultInstance()) return this;
if (other.hasPackageFqName()) {
bitField0_ |= 0x00000001;
packageFqName_ = other.packageFqName_;
@@ -2614,11 +2614,11 @@ public final class DebugJvmPackageTable {
org.jetbrains.kotlin.protobuf.CodedInputStream input,
org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts parsedMessage = null;
org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugJvmPackageTable.PackageParts) e.getUnfinishedMessage();
parsedMessage = (org.jetbrains.kotlin.serialization.jvm.DebugModuleProtoBuf.PackageParts) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
@@ -3361,10 +3361,10 @@ public final class DebugJvmPackageTable {
}
private static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor;
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor;
private static
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable;
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable;
private static final org.jetbrains.kotlin.protobuf.Descriptors.Descriptor
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor;
private static
@@ -3379,21 +3379,20 @@ public final class DebugJvmPackageTable {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n6core/descriptors.jvm/src/jvm_package_t" +
"able.debug.proto\022&org.jetbrains.kotlin.s" +
"erialization.jvm\"\303\001\n\014PackageTable\022K\n\rpac" +
"kage_parts\030\001 \003(\01324.org.jetbrains.kotlin." +
"serialization.jvm.PackageParts\022L\n\016metada" +
"ta_parts\030\002 \003(\01324.org.jetbrains.kotlin.se" +
"rialization.jvm.PackageParts\022\030\n\020jvm_pack" +
"age_name\030\003 \003(\t\"\366\001\n\014PackageParts\022\027\n\017packa" +
"ge_fq_name\030\001 \002(\t\022\030\n\020short_class_name\030\002 \003" +
"(\t\022*\n\036multifile_facade_short_name_id\030\003 \003",
"(\005B\002\020\001\022#\n\033multifile_facade_short_name\030\004 " +
"\003(\t\022.\n&class_with_jvm_package_name_short" +
"_name\030\005 \003(\t\0222\n&class_with_jvm_package_na" +
"me_package_id\030\006 \003(\005B\002\020\001B\026B\024DebugJvmPacka" +
"geTable"
"\n/core/descriptors.jvm/src/jvm_module.de" +
"bug.proto\022&org.jetbrains.kotlin.serializ" +
"ation.jvm\"\275\001\n\006Module\022K\n\rpackage_parts\030\001 " +
"\003(\01324.org.jetbrains.kotlin.serialization" +
".jvm.PackageParts\022L\n\016metadata_parts\030\002 \003(" +
"\01324.org.jetbrains.kotlin.serialization.j" +
"vm.PackageParts\022\030\n\020jvm_package_name\030\003 \003(" +
"\t\"\366\001\n\014PackageParts\022\027\n\017package_fq_name\030\001 " +
"\002(\t\022\030\n\020short_class_name\030\002 \003(\t\022*\n\036multifi" +
"le_facade_short_name_id\030\003 \003(\005B\002\020\001\022#\n\033mul",
"tifile_facade_short_name\030\004 \003(\t\022.\n&class_" +
"with_jvm_package_name_short_name\030\005 \003(\t\0222" +
"\n&class_with_jvm_package_name_package_id" +
"\030\006 \003(\005B\002\020\001B\025B\023DebugModuleProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -3407,11 +3406,11 @@ public final class DebugJvmPackageTable {
.internalBuildGeneratedFileFrom(descriptorData,
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor =
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_fieldAccessorTable = new
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageTable_descriptor,
internal_static_org_jetbrains_kotlin_serialization_jvm_Module_descriptor,
new java.lang.String[] { "PackageParts", "MetadataParts", "JvmPackageName", });
internal_static_org_jetbrains_kotlin_serialization_jvm_PackageParts_descriptor =
getDescriptor().getMessageTypes().get(1);

View File

@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
buildscript {
extra["defaultSnapshotVersion"] = "1.2-SNAPSHOT"
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.30-dev-441", onlySuccessBootstrap = false))
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.2.40-dev-165", onlySuccessBootstrap = false))
val repos = listOfNotNull(
bootstrapKotlinRepo,
@@ -115,7 +115,7 @@ extra["versions.ant"] = "1.8.2"
extra["versions.android"] = "2.3.1"
extra["ideaCoreSdkJars"] = arrayOf("annotations", "asm-all", "guava", "intellij-core", "jdom", "jna", "log4j", "picocontainer",
"snappy-in-java", "streamex", "trove4j", "xpp3-1.1.4-min", "xstream")
"snappy-in-java", "trove4j", "xpp3-1.1.4-min", "xstream")
extra["compilerModules"] = arrayOf(
":compiler:util",
@@ -162,6 +162,7 @@ val coreLibProjects = listOf(
":kotlin-test:kotlin-test-common",
":kotlin-test:kotlin-test-jvm",
":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-testng",
":kotlin-test:kotlin-test-js",
":kotlin-reflect"
)

View File

@@ -384,20 +384,19 @@
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/annotations.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/asm-all.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/guava-21.0.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/guava-19.0.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/intellij-core.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/jdom.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
<zipfileset src="${basedir}/ideaSDK/core/jna.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/log4j.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
<zipfileset src="${basedir}/ideaSDK/core/picocontainer.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/snappy-in-java-0.5.1.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/streamex-0.6.2.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/trove4j.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/xpp3-1.1.4-min.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/xstream-1.4.8.jar"/>
<zipfileset src="${idea.sdk}/lib/jna-platform.jar"/>
<zipfileset src="${idea.sdk}/lib/oromatcher.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar" excludes="META-INF/services/**"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
<zipfileset src="${dependencies}/jline3.jar"/>
<zipfileset src="${dependencies}/jansi.jar"/>
<zipfileset src="${dependencies}/javaslang-2.0.6.jar"/>

View File

@@ -20,7 +20,7 @@ dependencies {
testCompile(ideaSdkDeps("jps-model.jar", subdir = "jps"))
testCompile(ideaSdkDeps("groovy-all"))
testCompile(ideaSdkDeps("idea", "idea_rt"))
testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
//testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
testCompile(ideaSdkDeps("jps-builders"))
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
package org.jetbrains.kotlin.android.tests;
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase;
@@ -60,3 +60,4 @@ public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr");
}
}
*/

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
package org.jetbrains.kotlin.android.tests;
import com.google.common.io.Files;
@@ -74,3 +74,4 @@ public class AndroidRunner {
}
}
}
*/

View File

@@ -22,7 +22,9 @@ import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_1_2_20_FQ_NAME
import org.jetbrains.kotlin.resolve.calls.checkers.COROUTINE_CONTEXT_FQ_NAME
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.module
@@ -30,17 +32,14 @@ val SUSPEND_COROUTINE_OR_RETURN_NAME = Name.identifier("suspendCoroutineOrReturn
val INTERCEPTED_NAME = Name.identifier("intercepted")
val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")
val COROUTINES_INTRINSICS_PACKAGE_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("intrinsics"))
val COROUTINE_CONTEXT_FQ_NAME = COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
val SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME = Name.identifier("suspendCoroutineUninterceptedOrReturn")
fun FunctionDescriptor.isBuiltInIntercepted(): Boolean {
if (name != INTERCEPTED_NAME) return false
val original =
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(INTERCEPTED_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull() as CallableDescriptor
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(INTERCEPTED_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull() as CallableDescriptor
return DescriptorEquivalenceForOverrides.areEquivalent(original, this)
}
@@ -50,22 +49,19 @@ fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturn(): Boolean {
val originalDeclaration = getBuiltInSuspendCoroutineOrReturn() ?: return false
return DescriptorEquivalenceForOverrides.areEquivalent(
originalDeclaration, this
originalDeclaration, this
)
}
fun FunctionDescriptor.getBuiltInSuspendCoroutineOrReturn() =
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull()
fun FunctionDescriptor.isBuiltInCoroutineContext() =
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe == COROUTINE_CONTEXT_FQ_NAME
module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(SUSPEND_COROUTINE_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull()
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturn(): Boolean {
if (name != SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME) return false
val original = module.getPackage(COROUTINES_INTRINSICS_PACKAGE_FQ_NAME).memberScope
.getContributedFunctions(SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull() as CallableDescriptor
.getContributedFunctions(SUSPEND_COROUTINE_UNINTERCEPTED_OR_RETURN_NAME, NoLookupLocation.FROM_BACKEND)
.singleOrNull() as CallableDescriptor
return DescriptorEquivalenceForOverrides.areEquivalent(original, this)
}

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.codegen;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import kotlin.Pair;
import kotlin.collections.CollectionsKt;
import kotlin.io.FilesKt;
import org.jetbrains.annotations.NotNull;
@@ -26,14 +27,23 @@ import org.jetbrains.annotations.TestOnly;
import org.jetbrains.kotlin.backend.common.output.OutputFile;
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.config.AnalysisFlag;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DescriptorUtilKt;
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.kotlin.ModuleMapping;
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
import org.jetbrains.kotlin.load.kotlin.PackageParts;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable;
import org.jetbrains.kotlin.serialization.ProtoBuf;
import org.jetbrains.kotlin.serialization.StringTableImpl;
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf;
import org.jetbrains.org.objectweb.asm.Type;
import java.io.File;
@@ -95,19 +105,25 @@ public class ClassFileFactory implements OutputFileCollection {
}
private void writeModuleMappings() {
JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
JvmModuleProtoBuf.Module.Builder builder = JvmModuleProtoBuf.Module.newBuilder();
String outputFilePath = getMappingFileName(state.getModuleName());
for (PackageParts part : ClassFileUtilsKt.addCompiledPartsAndSort(partsGroupedByPackage.values(), state)) {
part.addTo(builder);
}
if (builder.getPackagePartsCount() == 0) return;
List<String> experimental = state.getLanguageVersionSettings().getFlag(AnalysisFlag.getExperimental());
if (!experimental.isEmpty()) {
writeExperimentalMarkers(state.getModule(), builder, experimental);
}
JvmModuleProtoBuf.Module moduleProto = builder.build();
if (moduleProto.getSerializedSize() == 0) return;
generators.put(outputFilePath, new OutAndSourceFileList(CollectionsKt.toList(packagePartSourceFiles)) {
@Override
public byte[] asBytes(ClassBuilderFactory factory) {
return ClassFileUtilsKt.serializeToByteArray(builder);
return ClassFileUtilsKt.serializeToByteArray(moduleProto);
}
@Override
@@ -122,6 +138,29 @@ public class ClassFileFactory implements OutputFileCollection {
});
}
private static void writeExperimentalMarkers(
@NotNull ModuleDescriptor module,
@NotNull JvmModuleProtoBuf.Module.Builder builder,
@NotNull List<String> experimental
) {
StringTableImpl stringTable = new StringTableImpl();
for (String fqName : experimental) {
ClassDescriptor descriptor =
DescriptorUtilKt.resolveClassByFqName(module, new FqName(fqName), NoLookupLocation.FOR_ALREADY_TRACKED);
if (descriptor != null) {
ProtoBuf.Annotation.Builder annotation = ProtoBuf.Annotation.newBuilder();
ClassId classId = DescriptorUtilsKt.getClassId(descriptor);
if (classId != null) {
annotation.setId(stringTable.getClassIdIndex(classId));
builder.addAnnotation(annotation);
}
}
}
Pair<ProtoBuf.StringTable, ProtoBuf.QualifiedNameTable> tables = stringTable.buildProto();
builder.setStringTable(tables.getFirst());
builder.setQualifiedNameTable(tables.getSecond());
}
@NotNull
@Override
public List<OutputFile> asList() {

View File

@@ -384,10 +384,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (context.closure != null)
genClosureFields(context.closure, v, typeMapper);
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
for (ExpressionCodegenExtension extension : ExpressionCodegenExtension.Companion.getInstances(state.getProject())) {
extension.generateClassSyntheticParts(this);
if (state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES
|| extension.getShouldGenerateClassSyntheticPartsInLightClassesMode()
) {
extension.generateClassSyntheticParts(this);
}
}
}

View File

@@ -95,23 +95,33 @@ public class CodegenBinding {
@NotNull
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull KtElement expression) {
Type result = asmTypeForAnonymousClassOrNull(bindingContext, expression);
if (result == null) {
throw new IllegalStateException("Type must not be null: " + expression.getText());
}
return result;
}
@Nullable
public static Type asmTypeForAnonymousClassOrNull(@NotNull BindingContext bindingContext, @NotNull KtElement expression) {
if (expression instanceof KtObjectLiteralExpression) {
expression = ((KtObjectLiteralExpression) expression).getObjectDeclaration();
}
ClassDescriptor descriptor = bindingContext.get(CLASS, expression);
if (descriptor != null) {
return getAsmType(bindingContext, descriptor);
return bindingContext.get(ASM_TYPE, descriptor);
}
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
if (functionDescriptor != null) {
return asmTypeForAnonymousClass(bindingContext, functionDescriptor);
return asmTypeForAnonymousClassOrNull(bindingContext, functionDescriptor);
}
VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression);
if (variableDescriptor != null) {
return asmTypeForAnonymousClass(bindingContext, variableDescriptor);
return asmTypeForAnonymousClassOrNull(bindingContext, variableDescriptor);
}
throw new KotlinExceptionWithAttachments("Couldn't compute ASM type for expression")
@@ -120,7 +130,17 @@ public class CodegenBinding {
@NotNull
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor descriptor) {
return getAsmType(bindingContext, anonymousClassForCallable(bindingContext, descriptor));
Type result = asmTypeForAnonymousClassOrNull(bindingContext, descriptor);
if (result == null) {
throw new IllegalStateException("Type must not be null: " + descriptor);
}
return result;
}
@Nullable
public static Type asmTypeForAnonymousClassOrNull(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor descriptor) {
return bindingContext.get(ASM_TYPE, anonymousClassForCallable(bindingContext, descriptor));
}
public static boolean canHaveOuter(@NotNull BindingContext bindingContext, @NotNull ClassDescriptor classDescriptor) {
@@ -216,7 +236,9 @@ public class CodegenBinding {
@NotNull
public static Type getAsmType(@NotNull BindingContext bindingContext, @NotNull ClassDescriptor klass) {
Type type = bindingContext.get(ASM_TYPE, klass);
assert type != null : "Type is not yet recorded for " + klass;
if (type == null) {
throw new IllegalStateException("Type is not yet recorded for " + klass);
}
return type;
}

View File

@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
import org.jetbrains.kotlin.load.kotlin.PackageParts
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf
import java.io.ByteArrayOutputStream
fun ClassFileFactory.getClassFiles(): Iterable<OutputFile> {
@@ -57,7 +57,7 @@ private fun Iterable<PackageParts>.addCompiledParts(state: GenerationState): Lis
}
}
fun JvmPackageTable.PackageTable.Builder.serializeToByteArray(): ByteArray {
fun JvmModuleProtoBuf.Module.serializeToByteArray(): ByteArray {
val moduleMapping = ByteArrayOutputStream(4096)
val out = DataOutputStream(moduleMapping)
val version = JvmMetadataVersion.INSTANCE.toArray()
@@ -65,7 +65,7 @@ fun JvmPackageTable.PackageTable.Builder.serializeToByteArray(): ByteArray {
for (number in version) {
out.writeInt(number)
}
build().writeTo(out)
writeTo(out)
out.flush()
return moduleMapping.toByteArray()
}

View File

@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.ClassBuilder
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.TransformationMethodVisitor
import org.jetbrains.kotlin.codegen.inline.MaxStackFrameSizeAndLocalsCalculator
import org.jetbrains.kotlin.codegen.inline.isAfterSuspendMarker
import org.jetbrains.kotlin.codegen.inline.isBeforeSuspendMarker
import org.jetbrains.kotlin.codegen.inline.isInlineMarker
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.optimization.DeadCodeEliminationMethodTransformer
import org.jetbrains.kotlin.codegen.optimization.common.*
import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer
@@ -81,6 +78,13 @@ class CoroutineTransformerMethodVisitor(
ReturnUnitMethodTransformer.transform(containingClassInternalName, methodNode)
if (allSuspensionPointsAreTailCalls(containingClassInternalName, methodNode, suspensionPoints)) {
continuationIndex =
if (isStatic(methodNode.access))
Type.getArgumentTypes(methodNode.desc).size - 1
else
Type.getArgumentTypes(methodNode.desc).size
replaceFakeContinuationsWithRealOnes(methodNode, continuationIndex)
dropSuspensionMarkers(methodNode, suspensionPoints)
return
}
@@ -99,6 +103,8 @@ class CoroutineTransformerMethodVisitor(
// Actual max stack might be increased during the previous phases
updateMaxStack(methodNode)
replaceFakeContinuationsWithRealOnes(methodNode, continuationIndex)
// Remove unreachable suspension points
// If we don't do this, then relevant frames will not be analyzed, that is unexpected from point of view of next steps (e.g. variable spilling)
removeUnreachableSuspensionPointsAndExitPoints(methodNode, suspensionPoints)
@@ -153,6 +159,14 @@ class CoroutineTransformerMethodVisitor(
methodNode.removeEmptyCatchBlocks()
}
private fun replaceFakeContinuationsWithRealOnes(methodNode: MethodNode, continuationIndex: Int) {
val fakeContinuations = methodNode.instructions.asSequence().filter(::isFakeContinuationMarker)
for (fakeContinuation in fakeContinuations) {
methodNode.instructions.removeAll(listOf(fakeContinuation.previous.previous, fakeContinuation.previous))
methodNode.instructions.set(fakeContinuation, VarInsnNode(Opcodes.ALOAD, continuationIndex))
}
}
private fun createInsnForReadingLabel() =
if (isForNamedFunction)
MethodInsnNode(

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.backend.common.*
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.codegen.topLevelClassAsmType
import org.jetbrains.kotlin.codegen.topLevelClassInternalName
@@ -32,6 +33,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
@@ -59,22 +61,23 @@ const val EXCEPTION_FIELD_NAME = "exception"
@JvmField
val COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME =
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("jvm")).child(Name.identifier("internal"))
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("jvm")).child(Name.identifier("internal"))
@JvmField
val CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME.topLevelClassAsmType()
@JvmField
val COROUTINE_CONTEXT_ASM_TYPE = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineContext")).topLevelClassAsmType()
val COROUTINE_CONTEXT_ASM_TYPE =
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineContext")).topLevelClassAsmType()
@JvmField
val COROUTINE_IMPL_ASM_TYPE = COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl")).topLevelClassAsmType()
private val COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME =
COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("IntrinsicsKt")).topLevelClassAsmType()
private val INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME =
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineIntrinsics")).topLevelClassInternalName()
private val NORMALIZE_CONTINUATION_METHOD_NAME = "normalizeContinuation"
private val GET_CONTEXT_METHOD_NAME = "getContext"
@@ -94,41 +97,42 @@ val INITIAL_SUSPEND_DESCRIPTOR_FOR_DO_RESUME = object : FunctionDescriptor.UserD
// So this function returns resolved call with descriptor looking like `fun <V> await(f: CompletableFuture<V>, machine: Continuation<V>): Unit`
// and fake `this` expression that used as argument for second parameter
fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
project: Project,
bindingContext: BindingContext
project: Project,
bindingContext: BindingContext
): ResolvedCallWithRealDescriptor? {
if (this is VariableAsFunctionResolvedCall) {
val replacedFunctionCall =
functionCall.replaceSuspensionFunctionWithRealDescriptor(project, bindingContext)
?: return null
functionCall.replaceSuspensionFunctionWithRealDescriptor(project, bindingContext)
?: return null
@Suppress("UNCHECKED_CAST")
return replacedFunctionCall.copy(
VariableAsFunctionResolvedCallImpl(
replacedFunctionCall.resolvedCall as MutableResolvedCall<FunctionDescriptor>,
variableCall.asMutableResolvedCall(bindingContext)
)
VariableAsFunctionResolvedCallImpl(
replacedFunctionCall.resolvedCall as MutableResolvedCall<FunctionDescriptor>,
variableCall.asMutableResolvedCall(bindingContext)
)
)
}
val function = candidateDescriptor as? FunctionDescriptor ?: return null
if (!function.isSuspend || function.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) return null
val newCandidateDescriptor =
when (function) {
is FunctionImportedFromObject ->
getOrCreateJvmSuspendFunctionView(function.callableFromObject, bindingContext).asImportedFromObject()
is SimpleFunctionDescriptor ->
getOrCreateJvmSuspendFunctionView(function, bindingContext)
else ->
throw AssertionError("Unexpected suspend function descriptor: $function")
}
when (function) {
is FunctionImportedFromObject ->
getOrCreateJvmSuspendFunctionView(function.callableFromObject, bindingContext).asImportedFromObject()
is SimpleFunctionDescriptor ->
getOrCreateJvmSuspendFunctionView(function, bindingContext)
else ->
throw AssertionError("Unexpected suspend function descriptor: $function")
}
val newCall = ResolvedCallImpl(
call,
newCandidateDescriptor,
dispatchReceiver, extensionReceiver, explicitReceiverKind,
null, DelegatingBindingTrace(BindingTraceContext().bindingContext, "Temporary trace for unwrapped suspension function"),
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY))
call,
newCandidateDescriptor,
dispatchReceiver, extensionReceiver, explicitReceiverKind,
null, DelegatingBindingTrace(BindingTraceContext().bindingContext, "Temporary trace for unwrapped suspension function"),
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
)
this.valueArguments.forEach {
newCall.recordValueArgument(newCandidateDescriptor.valueParameters[it.key.index], it.value)
@@ -138,15 +142,17 @@ fun ResolvedCall<*>.replaceSuspensionFunctionWithRealDescriptor(
val arguments = psiFactory.createCallArguments("(this)").arguments.single()
val thisExpression = arguments.getArgumentExpression()!!
newCall.recordValueArgument(
newCandidateDescriptor.valueParameters.last(),
ExpressionValueArgument(arguments))
newCandidateDescriptor.valueParameters.last(),
ExpressionValueArgument(arguments)
)
val newTypeArguments = newCandidateDescriptor.typeParameters.map {
Pair(it, typeArguments[candidateDescriptor.typeParameters[it.index]]!!.asTypeProjection())
}.toMap()
newCall.setResultingSubstitutor(
TypeConstructorSubstitution.createByParametersMap(newTypeArguments).buildSubstitutor())
TypeConstructorSubstitution.createByParametersMap(newTypeArguments).buildSubstitutor()
)
return ResolvedCallWithRealDescriptor(newCall, thisExpression)
}
@@ -161,19 +167,19 @@ private fun ResolvedCall<VariableDescriptor>.asMutableResolvedCall(bindingContex
private fun NewResolvedCallImpl<VariableDescriptor>.asDummyOldResolvedCall(bindingContext: BindingContext): ResolvedCallImpl<VariableDescriptor> {
return ResolvedCallImpl(
call,
candidateDescriptor,
dispatchReceiver, extensionReceiver, explicitReceiverKind,
null, DelegatingBindingTrace(bindingContext, "Trace for old call"),
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
call,
candidateDescriptor,
dispatchReceiver, extensionReceiver, explicitReceiverKind,
null, DelegatingBindingTrace(bindingContext, "Trace for old call"),
TracingStrategy.EMPTY, MutableDataFlowInfoForArguments.WithoutArgumentsCheck(DataFlowInfo.EMPTY)
)
}
fun ResolvedCall<*>.isSuspendNoInlineCall() =
resultingDescriptor.safeAs<FunctionDescriptor>()
?.let {
it.isSuspend && (!it.isInline || it.isBuiltInSuspendCoroutineOrReturnInJvm() || it.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm())
} == true
resultingDescriptor.safeAs<FunctionDescriptor>()
?.let {
it.isSuspend && (!it.isInline || it.isBuiltInSuspendCoroutineOrReturnInJvm() || it.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm())
} == true
fun CallableDescriptor.isSuspendFunctionNotSuspensionView(): Boolean {
if (this !is FunctionDescriptor) return false
@@ -193,14 +199,14 @@ fun <D : FunctionDescriptor> getOrCreateJvmSuspendFunctionView(function: D, bind
bindingContext?.get(CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, function)?.let { return it as D }
val continuationParameter = ValueParameterDescriptorImpl(
function, null, function.valueParameters.size, Annotations.EMPTY, Name.identifier("continuation"),
// Add j.l.Object to invoke(), because that is the type of parameters we have in FunctionN+1
if (function.containingDeclaration.safeAs<ClassDescriptor>()?.defaultType?.isBuiltinFunctionalType == true)
function.builtIns.nullableAnyType
else
function.getContinuationParameterTypeOfSuspendFunction(),
/* declaresDefaultValue = */ false, /* isCrossinline = */ false,
/* isNoinline = */ false, /* varargElementType = */ null, SourceElement.NO_SOURCE
function, null, function.valueParameters.size, Annotations.EMPTY, Name.identifier("continuation"),
// Add j.l.Object to invoke(), because that is the type of parameters we have in FunctionN+1
if (function.containingDeclaration.safeAs<ClassDescriptor>()?.defaultType?.isBuiltinFunctionalType == true)
function.builtIns.nullableAnyType
else
function.getContinuationParameterTypeOfSuspendFunction(),
/* declaresDefaultValue = */ false, /* isCrossinline = */ false,
/* isNoinline = */ false, /* varargElementType = */ null, SourceElement.NO_SOURCE
)
return function.createCustomCopy {
@@ -213,18 +219,18 @@ fun <D : FunctionDescriptor> getOrCreateJvmSuspendFunctionView(function: D, bind
}
typealias FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder =
FunctionDescriptor.CopyBuilder<out FunctionDescriptor>.(FunctionDescriptor)
FunctionDescriptor.CopyBuilder<out FunctionDescriptor>.(FunctionDescriptor)
-> FunctionDescriptor.CopyBuilder<out FunctionDescriptor>
fun <D : FunctionDescriptor> D.createCustomCopy(
copySettings: FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder
copySettings: FunctionDescriptorCopyBuilderToFunctionDescriptorCopyBuilder
): D {
val newOriginal =
if (original !== this)
original.createCustomCopy(copySettings)
else
null
if (original !== this)
original.createCustomCopy(copySettings)
else
null
val result = newCopyBuilder().copySettings(this).setOriginal(newOriginal).build()!!
@@ -235,52 +241,52 @@ fun <D : FunctionDescriptor> D.createCustomCopy(
}
private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction() =
module.getContinuationOfTypeOrAny(returnType!!)
module.getContinuationOfTypeOrAny(returnType!!)
fun ModuleDescriptor.getContinuationOfTypeOrAny(kotlinType: KotlinType) =
module.findContinuationClassDescriptorOrNull(NoLookupLocation.FROM_BACKEND)?.defaultType?.let {
KotlinTypeFactory.simpleType(
it,
arguments = listOf(kotlinType.asTypeProjection())
)
} ?: module.builtIns.nullableAnyType
module.findContinuationClassDescriptorOrNull(NoLookupLocation.FROM_BACKEND)?.defaultType?.let {
KotlinTypeFactory.simpleType(
it,
arguments = listOf(kotlinType.asTypeProjection())
)
} ?: module.builtIns.nullableAnyType
fun FunctionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm() =
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineOrReturn() == true
fun createMethodNodeForSuspendCoroutineOrReturn(
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
): MethodNode {
assert(functionDescriptor.isBuiltInSuspendCoroutineOrReturnInJvm()) {
"functionDescriptor must be kotlin.coroutines.intrinsics.suspendOrReturn"
}
val node =
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitVarInsn(Opcodes.ALOAD, 1)
node.visitMethodInsn(
Opcodes.INVOKESTATIC,
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
NORMALIZE_CONTINUATION_METHOD_NAME,
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
false
Opcodes.INVOKESTATIC,
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
NORMALIZE_CONTINUATION_METHOD_NAME,
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
false
)
node.visitMethodInsn(
Opcodes.INVOKEINTERFACE,
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
OperatorNameConventions.INVOKE.identifier,
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
true
Opcodes.INVOKEINTERFACE,
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
OperatorNameConventions.INVOKE.identifier,
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
true
)
node.visitInsn(Opcodes.ARETURN)
node.visitMaxs(2, 2)
@@ -289,32 +295,32 @@ fun createMethodNodeForSuspendCoroutineOrReturn(
}
fun FunctionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm() =
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineUninterceptedOrReturn() == true
getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)?.isBuiltInSuspendCoroutineUninterceptedOrReturn() == true
fun createMethodNodeForIntercepted(
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
): MethodNode {
assert(functionDescriptor.isBuiltInIntercepted()) {
"functionDescriptor must be kotlin.coroutines.intrinsics.intercepted"
}
val node =
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitMethodInsn(
Opcodes.INVOKESTATIC,
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
NORMALIZE_CONTINUATION_METHOD_NAME,
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
false
Opcodes.INVOKESTATIC,
INTERNAL_COROUTINE_INTRINSICS_OWNER_INTERNAL_NAME,
NORMALIZE_CONTINUATION_METHOD_NAME,
Type.getMethodDescriptor(CONTINUATION_ASM_TYPE, CONTINUATION_ASM_TYPE),
false
)
node.visitInsn(Opcodes.ARETURN)
node.visitMaxs(1, 1)
@@ -328,24 +334,25 @@ fun createMethodNodeForCoroutineContext(functionDescriptor: FunctionDescriptor):
}
val node =
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE, CONTINUATION_ASM_TYPE),
null, null
)
node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitMethodInsn(
Opcodes.INVOKEINTERFACE,
CONTINUATION_ASM_TYPE.internalName,
GET_CONTEXT_METHOD_NAME,
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE),
true
null, null
)
val v = InstructionAdapter(node)
addFakeContinuationMarker(v)
v.invokeinterface(
CONTINUATION_ASM_TYPE.internalName,
GET_CONTEXT_METHOD_NAME,
Type.getMethodDescriptor(COROUTINE_CONTEXT_ASM_TYPE)
)
node.visitInsn(Opcodes.ARETURN)
v.areturn(COROUTINE_CONTEXT_ASM_TYPE)
node.visitMaxs(1, 1)
return node
@@ -353,30 +360,30 @@ fun createMethodNodeForCoroutineContext(functionDescriptor: FunctionDescriptor):
fun createMethodNodeForSuspendCoroutineUninterceptedOrReturn(
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
functionDescriptor: FunctionDescriptor,
typeMapper: KotlinTypeMapper
): MethodNode {
assert(functionDescriptor.isBuiltInSuspendCoroutineUninterceptedOrReturnInJvm()) {
"functionDescriptor must be kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn"
}
val node =
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
MethodNode(
Opcodes.ASM5,
Opcodes.ACC_STATIC,
"fake",
typeMapper.mapAsmMethod(functionDescriptor).descriptor, null, null
)
node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitVarInsn(Opcodes.ALOAD, 1)
node.visitMethodInsn(
Opcodes.INVOKEINTERFACE,
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
OperatorNameConventions.INVOKE.identifier,
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
true
Opcodes.INVOKEINTERFACE,
typeMapper.mapType(functionDescriptor.valueParameters[0]).internalName,
OperatorNameConventions.INVOKE.identifier,
"(${AsmTypes.OBJECT_TYPE})${AsmTypes.OBJECT_TYPE}",
true
)
node.visitInsn(Opcodes.ARETURN)
node.visitMaxs(2, 2)
@@ -386,21 +393,21 @@ fun createMethodNodeForSuspendCoroutineUninterceptedOrReturn(
@Suppress("UNCHECKED_CAST")
fun <D : CallableDescriptor?> D.unwrapInitialDescriptorForSuspendFunction(): D =
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
this.safeAs<SimpleFunctionDescriptor>()?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) as D ?: this
fun FunctionDescriptor.getOriginalSuspendFunctionView(bindingContext: BindingContext): FunctionDescriptor =
if (isSuspend)
getOrCreateJvmSuspendFunctionView(unwrapInitialDescriptorForSuspendFunction().original, bindingContext)
else
this
if (isSuspend)
getOrCreateJvmSuspendFunctionView(unwrapInitialDescriptorForSuspendFunction().original, bindingContext)
else
this
fun InstructionAdapter.loadCoroutineSuspendedMarker() {
invokestatic(
COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME.internalName,
"get$COROUTINE_SUSPENDED_NAME",
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
false
COROUTINES_INTRINSICS_FILE_FACADE_INTERNAL_NAME.internalName,
"get$COROUTINE_SUSPENDED_NAME",
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
false
)
}
@@ -411,12 +418,12 @@ fun InstructionAdapter.invokeDoResumeWithUnit(thisName: String) {
aconst(null)
invokevirtual(
thisName,
DO_RESUME_METHOD_NAME,
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE, AsmTypes.OBJECT_TYPE, AsmTypes.JAVA_THROWABLE_TYPE),
false
thisName,
DO_RESUME_METHOD_NAME,
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE, AsmTypes.OBJECT_TYPE, AsmTypes.JAVA_THROWABLE_TYPE),
false
)
}
fun Method.getImplForOpenMethod(ownerInternalName: String) =
Method("$name\$suspendImpl", returnType, arrayOf(Type.getObjectType(ownerInternalName)) + argumentTypes)
Method("$name\$suspendImpl", returnType, arrayOf(Type.getObjectType(ownerInternalName)) + argumentTypes)

View File

@@ -47,4 +47,7 @@ interface ExpressionCodegenExtension {
fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null
fun generateClassSyntheticParts(codegen: ImplementationBodyCodegen) {}
val shouldGenerateClassSyntheticPartsInLightClassesMode: Boolean
get() = false
}

View File

@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.codegen.inline
import com.intellij.psi.PsiElement
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.backend.common.isBuiltInCoroutineContext
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
import org.jetbrains.kotlin.codegen.*
@@ -41,6 +40,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.inline.InlineUtil.isInlinableParameterExpression
@@ -265,9 +265,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
addInlineMarker(codegen.v, true)
}
if (functionDescriptor.isBuiltInCoroutineContext())
invocationParamBuilder.addNextValueParameter(CONTINUATION_ASM_TYPE, false, continuationValue(), 0)
val parameters = invocationParamBuilder.buildParameters()
val info = RootInliningContext(

View File

@@ -91,7 +91,8 @@ private const val INLINE_MARKER_FINALLY_START = "finallyStart"
private const val INLINE_MARKER_FINALLY_END = "finallyEnd"
private const val INLINE_MARKER_BEFORE_SUSPEND_ID = 0
private const val INLINE_MARKER_AFTER_SUSPEND_ID = 1
private const val INLINE_MARKET_RETURNS_UNIT = 2
private const val INLINE_MARKER_RETURNS_UNIT = 2
private const val INLINE_MARKER_FAKE_CONTINUATION = 3
private val INTRINSIC_ARRAY_CONSTRUCTOR_TYPE = AsmUtil.asmTypeByClassId(classId)
internal fun getMethodNode(
@@ -421,7 +422,7 @@ internal fun addSuspendMarker(v: InstructionAdapter, isStartNotEnd: Boolean) {
}
private fun addReturnsUnitMarker(v: InstructionAdapter) {
v.iconst(INLINE_MARKET_RETURNS_UNIT)
v.iconst(INLINE_MARKER_RETURNS_UNIT)
v.visitMethodInsn(
Opcodes.INVOKESTATIC, INLINE_MARKER_CLASS_NAME,
"mark",
@@ -429,9 +430,26 @@ private fun addReturnsUnitMarker(v: InstructionAdapter) {
)
}
/* There are contexts when the continuation does not yet exist, for example, in inline lambdas, which are going to
* be inlined into suspendable functions.
* In such cases we just generate the marker which is going to be replaced with real continuation on generating state machine.
* See [CoroutineTransformerMethodVisitor] for more info.
*/
internal fun addFakeContinuationMarker(v: InstructionAdapter) {
v.iconst(INLINE_MARKER_FAKE_CONTINUATION)
v.invokestatic(
INLINE_MARKER_CLASS_NAME,
"mark",
"(I)V", false
)
v.aconst(null)
}
internal fun isBeforeSuspendMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_BEFORE_SUSPEND_ID)
internal fun isAfterSuspendMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_AFTER_SUSPEND_ID)
internal fun isReturnsUnitMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKET_RETURNS_UNIT)
internal fun isReturnsUnitMarker(insn: AbstractInsnNode) = isSuspendMarker(insn, INLINE_MARKER_RETURNS_UNIT)
internal fun isFakeContinuationMarker(insn: AbstractInsnNode) =
insn.previous != null && isSuspendMarker(insn.previous, INLINE_MARKER_FAKE_CONTINUATION) && insn.opcode == Opcodes.ACONST_NULL
private fun isSuspendMarker(insn: AbstractInsnNode, id: Int) =
isInlineMarker(insn, "mark") && insn.previous.intConstant == id

View File

@@ -126,14 +126,6 @@ private fun ExpressionCodegen.createIntrinsifiedRangeValueOrNull(rangeCall: Reso
CollectionIndicesRangeValue(rangeCall)
isCharSequenceIndices(rangeCallee) ->
CharSequenceIndicesRangeValue(rangeCall)
isArrayOrPrimitiveArrayWithIndex(rangeCallee) ->
ArrayWithIndexRangeValue(rangeCall)
isIterableWithIndex(rangeCallee) ->
IterableWithIndexRangeValue(rangeCall)
isSequenceWithIndex(rangeCallee) ->
SequenceWithIndexRangeValue(rangeCall)
isCharSequenceWithIndex(rangeCallee) ->
CharSequenceWithIndexRangeValue(rangeCall)
isComparableRangeTo(rangeCallee) ->
ComparableRangeLiteralRangeValue(this, rangeCall)
isPrimitiveProgressionReverse(rangeCallee) ->

View File

@@ -1,236 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen.when;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.codegen.FrameMap;
import org.jetbrains.kotlin.psi.KtWhenEntry;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.NullValue;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.*;
abstract public class SwitchCodegen {
protected final KtWhenExpression expression;
protected final boolean isStatement;
protected final boolean isExhaustive;
protected final ExpressionCodegen codegen;
protected final BindingContext bindingContext;
protected final Type subjectType;
protected final Type resultType;
protected final InstructionAdapter v;
protected final NavigableMap<Integer, Label> transitionsTable = new TreeMap<>();
protected final List<Label> entryLabels = new ArrayList<>();
protected Label elseLabel = new Label();
protected Label endLabel = new Label();
protected Label defaultLabel;
protected final SwitchCodegenProvider switchCodegenProvider;
public SwitchCodegen(
@NotNull KtWhenExpression expression, boolean isStatement,
boolean isExhaustive, @NotNull ExpressionCodegen codegen,
@Nullable Type subjectType
) {
this.expression = expression;
this.isStatement = isStatement;
this.isExhaustive = isExhaustive;
this.codegen = codegen;
this.bindingContext = codegen.getBindingContext();
this.switchCodegenProvider = new SwitchCodegenProvider(codegen);
this.subjectType = subjectType != null ? subjectType : codegen.expressionType(expression.getSubjectExpression());
resultType = isStatement ? Type.VOID_TYPE : codegen.expressionType(expression);
v = codegen.v;
}
/**
* Generates bytecode for entire when expression
*/
public void generate() {
prepareConfiguration();
boolean hasElse = expression.getElseExpression() != null;
// if there is no else-entry and it's statement then default --- endLabel
defaultLabel = (hasElse || !isStatement || isExhaustive) ? elseLabel : endLabel;
generateSubject();
generateSwitchInstructionByTransitionsTable();
generateEntries();
// there is no else-entry but this is not statement, so we should return Unit
if (!hasElse && (!isStatement || isExhaustive)) {
v.visitLabel(elseLabel);
codegen.putUnitInstanceOntoStackForNonExhaustiveWhen(expression, isStatement);
}
codegen.markLineNumber(expression, isStatement);
v.mark(endLabel);
}
/**
* Sets up transitionsTable and maybe something else needed in a special case
* Behaviour may be changed by overriding processConstant
*/
private void prepareConfiguration() {
for (KtWhenEntry entry : expression.getEntries()) {
Label entryLabel = new Label();
for (ConstantValue<?> constant : switchCodegenProvider.getConstantsFromEntry(entry)) {
if (constant instanceof NullValue) continue;
processConstant(constant, entryLabel);
}
if (entry.isElse()) {
elseLabel = entryLabel;
}
entryLabels.add(entryLabel);
}
}
abstract protected void processConstant(
@NotNull ConstantValue<?> constant,
@NotNull Label entryLabel
);
protected void putTransitionOnce(int value, @NotNull Label entryLabel) {
if (!transitionsTable.containsKey(value)) {
transitionsTable.put(value, entryLabel);
}
}
/**
* Should generate int subject on top of the stack
* Default implementation just run codegen for actual subject of expression
* May also gen nullability check if needed
*/
protected void generateSubject() {
codegen.gen(expression.getSubjectExpression(), subjectType);
}
protected void generateNullCheckIfNeeded() {
assert expression.getSubjectExpression() != null : "subject expression can't be null";
KotlinType subjectJetType = bindingContext.getType(expression.getSubjectExpression());
assert subjectJetType != null : "subject type can't be null (i.e. void)";
if (TypeUtils.isNullableType(subjectJetType)) {
int nullEntryIndex = findNullEntryIndex(expression);
Label nullLabel = nullEntryIndex == -1 ? defaultLabel : entryLabels.get(nullEntryIndex);
Label notNullLabel = new Label();
v.dup();
v.ifnonnull(notNullLabel);
v.pop();
v.goTo(nullLabel);
v.visitLabel(notNullLabel);
}
}
private int findNullEntryIndex(@NotNull KtWhenExpression expression) {
int entryIndex = 0;
for (KtWhenEntry entry : expression.getEntries()) {
for (ConstantValue<?> constant : switchCodegenProvider.getConstantsFromEntry(entry)) {
if (constant instanceof NullValue) {
return entryIndex;
}
}
entryIndex++;
}
return -1;
}
private void generateSwitchInstructionByTransitionsTable() {
int[] keys = new int[transitionsTable.size()];
Label[] labels = new Label[transitionsTable.size()];
int i = 0;
for (Map.Entry<Integer, Label> transition : transitionsTable.entrySet()) {
keys[i] = transition.getKey();
labels[i] = transition.getValue();
i++;
}
int nlabels = keys.length;
int hi = keys[nlabels - 1];
int lo = keys[0];
/*
* Heuristic estimation if it's better to use tableswitch or lookupswitch.
* From OpenJDK sources
*/
long table_space_cost = 4 + ((long) hi - lo + 1); // words
long table_time_cost = 3; // comparisons
long lookup_space_cost = 3 + 2 * (long) nlabels;
//noinspection UnnecessaryLocalVariable
long lookup_time_cost = nlabels;
boolean useTableSwitch = nlabels > 0 &&
table_space_cost + 3 * table_time_cost <=
lookup_space_cost + 3 * lookup_time_cost;
if (!useTableSwitch) {
v.lookupswitch(defaultLabel, keys, labels);
return;
}
Label[] sparseLabels = new Label[hi - lo + 1];
Arrays.fill(sparseLabels, defaultLabel);
for (i = 0; i < keys.length; i++) {
sparseLabels[keys[i] - lo] = labels[i];
}
v.tableswitch(lo, hi, defaultLabel, sparseLabels);
}
protected void generateEntries() {
// resolving entries' entryLabels and generating entries' code
Iterator<Label> entryLabelsIterator = entryLabels.iterator();
for (KtWhenEntry entry : expression.getEntries()) {
v.visitLabel(entryLabelsIterator.next());
FrameMap.Mark mark = codegen.myFrameMap.mark();
codegen.gen(entry.getExpression(), resultType);
mark.dropTo();
if (!entry.isElse()) {
v.goTo(endLabel);
}
}
}
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen.`when`
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.psi.KtWhenExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.constants.ConstantValue
import org.jetbrains.kotlin.resolve.constants.NullValue
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import java.util.*
abstract class SwitchCodegen(
@JvmField
protected val expression: KtWhenExpression,
protected val isStatement: Boolean,
private val isExhaustive: Boolean,
@JvmField
protected val codegen: ExpressionCodegen,
subjectType: Type?
) {
protected val bindingContext: BindingContext = codegen.bindingContext
@JvmField
protected val subjectType = subjectType ?: codegen.expressionType(expression.subjectExpression)
protected val resultType: Type = if (isStatement) Type.VOID_TYPE else codegen.expressionType(expression)
@JvmField
protected val v: InstructionAdapter = codegen.v
@JvmField
protected val transitionsTable: NavigableMap<Int, Label> = TreeMap()
private val entryLabels: MutableList<Label> = ArrayList()
private var elseLabel = Label()
private var endLabel = Label()
protected lateinit var defaultLabel: Label
private val switchCodegenProvider = SwitchCodegenProvider(codegen)
/**
* Generates bytecode for entire when expression
*/
open fun generate() {
prepareConfiguration()
val hasElse = expression.elseExpression != null
// if there is no else-entry and it's statement then default --- endLabel
defaultLabel = if (hasElse || !isStatement || isExhaustive) elseLabel else endLabel
generateSubject()
generateSwitchInstructionByTransitionsTable()
generateEntries()
// there is no else-entry but this is not statement, so we should return Unit
if (!hasElse && (!isStatement || isExhaustive)) {
v.visitLabel(elseLabel)
codegen.putUnitInstanceOntoStackForNonExhaustiveWhen(expression, isStatement)
}
codegen.markLineNumber(expression, isStatement)
v.mark(endLabel)
}
/**
* Sets up transitionsTable and maybe something else needed in a special case
* Behaviour may be changed by overriding processConstant
*/
private fun prepareConfiguration() {
for (entry in expression.entries) {
val entryLabel = Label()
for (constant in switchCodegenProvider.getConstantsFromEntry(entry)) {
if (constant is NullValue || constant == null) continue
processConstant(constant, entryLabel)
}
if (entry.isElse) {
elseLabel = entryLabel
}
entryLabels.add(entryLabel)
}
}
protected abstract fun processConstant(
constant: ConstantValue<*>,
entryLabel: Label
)
protected fun putTransitionOnce(value: Int, entryLabel: Label) {
if (!transitionsTable.containsKey(value)) {
transitionsTable[value] = entryLabel
}
}
/**
* Should generate int subject on top of the stack
* Default implementation just run codegen for actual subject of expression
* May also gen nullability check if needed
*/
protected open fun generateSubject() {
codegen.gen(expression.subjectExpression, subjectType)
}
protected fun generateNullCheckIfNeeded() {
assert(expression.subjectExpression != null) { "subject expression can't be null" }
val subjectJetType = bindingContext.getType(expression.subjectExpression!!) ?: error("subject type can't be null (i.e. void)")
if (TypeUtils.isNullableType(subjectJetType)) {
val nullEntryIndex = findNullEntryIndex(expression)
val nullLabel = if (nullEntryIndex == -1) defaultLabel else entryLabels[nullEntryIndex]
val notNullLabel = Label()
with(v) {
dup()
ifnonnull(notNullLabel)
pop()
goTo(nullLabel)
visitLabel(notNullLabel)
}
}
}
private fun findNullEntryIndex(expression: KtWhenExpression) =
expression.entries.withIndex().firstOrNull { (_, entry) ->
switchCodegenProvider.getConstantsFromEntry(entry).any { it is NullValue }
}?.index ?: -1
private fun generateSwitchInstructionByTransitionsTable() {
val keys = transitionsTable.keys.toIntArray()
val labelsNumber = keys.size
val maxValue = keys.last()
val minValue = keys.first()
val rangeLength = maxValue.toLong() - minValue.toLong() + 1L
// In modern JVM implementations it shouldn't matter very much for runtime performance
// whether to choose lookupswitch or tableswitch.
// The only metric that really matters is bytecode size and here we can estimate:
// - lookupswitch: ~ 2 * labelsNumber
// - tableswitch: ~ rangeLength
if (rangeLength > 2L * labelsNumber || rangeLength > Int.MAX_VALUE) {
val labels = transitionsTable.values.toTypedArray()
v.lookupswitch(defaultLabel, keys, labels)
return
}
val sparseLabels = Array(rangeLength.toInt()) { index ->
transitionsTable[index + minValue] ?: defaultLabel
}
v.tableswitch(minValue, maxValue, defaultLabel, *sparseLabels)
}
protected open fun generateEntries() {
// resolving entries' entryLabels and generating entries' code
val entryLabelsIterator = entryLabels.iterator()
for (entry in expression.entries) {
v.visitLabel(entryLabelsIterator.next())
val mark = codegen.myFrameMap.mark()
codegen.gen(entry.expression, resultType)
mark.dropTo()
if (!entry.isElse) {
v.goTo(endLabel)
}
}
}
}

View File

@@ -60,6 +60,7 @@ dependencies {
testRuntime(projectDist(":kotlin-daemon-client"))
testRuntime(preloadedDeps("dx", subdir = "android-5.0/lib"))
testRuntime(ideaSdkCoreDeps("*.jar"))
testRuntime(ideaSdkDeps("resources"))
testRuntime(ideaSdkDeps("*.jar"))
testRuntime(files("${System.getProperty("java.home")}/../lib/tools.jar"))

View File

@@ -123,7 +123,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
value = "-Xlegacy-smart-cast-after-try",
description = "Allow var smart casts despite assignment in try block"
)
var legacySmartCastAfterTry by FreezableVar(false)
var legacySmartCastAfterTry: Boolean by FreezableVar(false)
@Argument(
value = "-Xeffect-system",
@@ -137,11 +137,27 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var readDeserializedContracts: Boolean by FreezableVar(false)
@Argument(
value = "-Xexperimental",
valueDescription = "<fq.name>",
description = "Enable and propagate usages of experimental API for marker annotation with the given fully qualified name"
)
var experimental: Array<String>? by FreezableVar(null)
@Argument(
value = "-Xuse-experimental",
valueDescription = "<fq.name>",
description = "Enable usages of COMPILATION-affecting experimental API for marker annotation with the given fully qualified name"
)
var useExperimental: Array<String>? by FreezableVar(null)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
put(AnalysisFlag.multiPlatformDoNotCheckActual, noCheckActual)
put(AnalysisFlag.allowKotlinPackage, allowKotlinPackage)
put(AnalysisFlag.experimental, experimental?.toList().orEmpty())
put(AnalysisFlag.useExperimental, useExperimental?.toList().orEmpty())
}
}

View File

@@ -22,6 +22,7 @@ import kotlin.reflect.KMutableProperty1
import kotlin.reflect.full.findAnnotation
import kotlin.reflect.full.memberProperties
@Target(AnnotationTarget.PROPERTY)
annotation class Argument(
val value: String,
val shortName: String = "",

View File

@@ -31,6 +31,10 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = AggregatedReplStageState(compiler.createState(lock), evaluator.createState(lock), lock)
override fun compileAndEval(state: IReplStageState<*>, codeLine: ReplCodeLine, scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult {
if (codeLine.code.trim().isEmpty()) {
return ReplEvalResult.UnitResult()
}
return state.lock.write {
val aggregatedState = state.asState(AggregatedReplStageState::class.java)
val compiled = compiler.compile(state, codeLine)

View File

@@ -1,6 +1,5 @@
<idea-plugin>
<id>org.jetbrains.kotlin</id>
<version>1.2</version>
<extensionPoints>
<extensionPoint qualifiedName="org.jetbrains.kotlin.diagnosticSuppressor"

View File

@@ -23,6 +23,7 @@ import com.intellij.psi.util.PsiFormatUtil
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTrackerImpl
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.sortedDiagnostics
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
@@ -33,12 +34,16 @@ import org.jetbrains.kotlin.resolve.AnalyzingUtils
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
class AnalyzerWithCompilerReport(private val messageCollector: MessageCollector) {
class AnalyzerWithCompilerReport(
private val messageCollector: MessageCollector,
private val languageVersionSettings: LanguageVersionSettings
) {
lateinit var analysisResult: AnalysisResult
private fun reportIncompleteHierarchies() {
@@ -94,6 +99,11 @@ class AnalyzerWithCompilerReport(private val messageCollector: MessageCollector)
fun analyzeAndReport(files: Collection<KtFile>, analyze: () -> AnalysisResult) {
analysisResult = analyze()
ExperimentalUsageChecker.checkCompilerArguments(
analysisResult.moduleDescriptor, languageVersionSettings,
reportError = { message -> messageCollector.report(ERROR, message) },
reportWarning = { message -> messageCollector.report(WARNING, message) }
)
reportSyntaxErrors(files)
reportDiagnostics(analysisResult.bindingContext.diagnostics, messageCollector)
reportIncompleteHierarchies()

View File

@@ -222,7 +222,9 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return COMPILATION_ERROR;
}
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(messageCollector);
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
messageCollector, CommonConfigurationKeysKt.getLanguageVersionSettings(configuration)
);
analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sourcesFiles, config));
if (analyzerWithCompilerReport.hasErrors()) {
return COMPILATION_ERROR;

View File

@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.light.LightJavaModule
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
@@ -91,22 +92,22 @@ class ClasspathRootsResolver(
for ((root, packagePrefix) in javaSourceRoots) {
val modularRoot = modularSourceRoot(root, hasOutputDirectoryInClasspath)
if (modularRoot != null) {
modules += modularRoot
}
else {
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
if (isValidJavaFqName(prefix)) FqName(prefix)
else null.also {
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
if (modularRoot != null) {
modules += modularRoot
}
})
}
}
else {
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
if (isValidJavaFqName(prefix)) FqName(prefix)
else null.also {
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
}
})
}
}
for (root in jvmClasspathRoots) {
result += JavaRoot(root, JavaRoot.RootType.BINARY)
}
result += JavaRoot(root, JavaRoot.RootType.BINARY)
}
val outputDirectoryAddedAsPartOfModule = modules.any { module -> module.moduleRoots.any { it.file == outputDirectory } }
@@ -116,16 +117,17 @@ class ClasspathRootsResolver(
if (outputDirectoryAddedAsPartOfModule && root == outputDirectory) continue
val module = modularBinaryRoot(root)
if (module != null) {
modules += module
}
}
if (module != null) {
modules += module
}
}
addModularRoots(modules, result)
return RootsAndModules(result, modules)
}
/*
private fun findSourceModuleInfo(root: VirtualFile): Pair<VirtualFile, PsiJavaModule>? {
val moduleInfoFile =
when {
@@ -139,8 +141,10 @@ class ClasspathRootsResolver(
return moduleInfoFile to psiJavaModule
}
*/
private fun modularSourceRoot(root: VirtualFile, hasOutputDirectoryInClasspath: Boolean): JavaModule.Explicit? {
/*
val (moduleInfoFile, psiJavaModule) = findSourceModuleInfo(root) ?: return null
val sourceRoot = JavaModule.Root(root, isBinary = false)
val roots =
@@ -148,12 +152,15 @@ class ClasspathRootsResolver(
listOf(sourceRoot, JavaModule.Root(outputDirectory!!, isBinary = true))
else listOf(sourceRoot)
return JavaModule.Explicit(JavaModuleInfo.create(psiJavaModule), roots, moduleInfoFile)
*/
return null
}
private fun modularBinaryRoot(root: VirtualFile): JavaModule? {
val isJar = root.fileSystem.protocol == StandardFileSystems.JAR_PROTOCOL
val manifest: Attributes? by lazy(NONE) { readManifestAttributes(root) }
/*
val moduleInfoFile =
root.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE)
?: root.takeIf { isJar }?.findFileByRelativePath(MULTI_RELEASE_MODULE_INFO_CLS_FILE)?.takeIf {
@@ -164,6 +171,7 @@ class ClasspathRootsResolver(
val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile)
}
*/
// Only .jar files can be automatic modules
if (isJar) {

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.js.resolve.getAnnotationsOnContainingJsModule
import org.jetbrains.kotlin.load.kotlin.getJvmModuleNameForDeserializedDescriptor
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
class CliModuleAnnotationsResolver : ModuleAnnotationsResolver {
private val packagePartProviders = mutableListOf<PackagePartProvider>()
fun addPackagePartProvider(packagePartProvider: PackagePartProvider) {
packagePartProviders += packagePartProvider
}
override fun getAnnotationsOnContainingModule(descriptor: DeclarationDescriptor): List<ClassId> {
getAnnotationsOnContainingJsModule(descriptor)?.let { return it }
val moduleName = getJvmModuleNameForDeserializedDescriptor(descriptor) ?: return emptyList()
return packagePartProviders.flatMap { it.getAnnotationsOnBinaryModule(moduleName) }
}
}

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
import org.jetbrains.kotlin.load.kotlin.PackageParts
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
import java.io.EOFException
@@ -31,7 +32,7 @@ class JvmPackagePartProvider(
languageVersionSettings: LanguageVersionSettings,
private val scope: GlobalSearchScope
) : PackagePartProvider {
private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping)
private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping, val name: String)
private val deserializationConfiguration = CompilerDeserializationConfiguration(languageVersionSettings)
@@ -68,6 +69,12 @@ class JvmPackagePartProvider(
return result
}
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
return loadedModules.mapNotNull { (_, mapping, name) ->
if (name == moduleName) mapping.moduleData.annotations else null
}.flatten()
}
fun addRoots(roots: List<JavaRoot>) {
for ((root, type) in roots) {
if (type != JavaRoot.RootType.BINARY) continue
@@ -83,7 +90,7 @@ class JvmPackagePartProvider(
catch (e: EOFException) {
throw RuntimeException("Error on reading package parts from $moduleFile in $root", e)
}
loadedModules.add(ModuleMappingInfo(root, mapping))
loadedModules.add(ModuleMappingInfo(root, mapping, moduleFile.nameWithoutExtension))
}
}
}

View File

@@ -245,10 +245,12 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
return result
}
/*
override fun findModules(moduleName: String, scope: GlobalSearchScope): Collection<PsiJavaModule> {
// TODO
return emptySet()
}
*/
override fun getNonTrivialPackagePrefixes(): Collection<String> = emptyList()

View File

@@ -28,9 +28,6 @@ import com.intellij.ide.highlighter.JavaFileType
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.lang.MetaLanguage
import com.intellij.lang.java.JavaParserDefinition
import com.intellij.lang.jvm.facade.JvmElementProvider
import com.intellij.lang.jvm.facade.JvmFacade
import com.intellij.lang.jvm.facade.JvmFacadeImpl
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.TransactionGuard
import com.intellij.openapi.application.TransactionGuardImpl
@@ -46,7 +43,6 @@ import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.psi.FileContextProvider
import com.intellij.psi.JavaModuleSystem
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.augment.PsiAugmentProvider
@@ -100,6 +96,7 @@ import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
@@ -276,6 +273,7 @@ class KotlinCoreEnvironment private constructor(
return JvmPackagePartProvider(configuration.languageVersionSettings, scope).apply {
addRoots(initialRoots)
packagePartProviders += this
(ModuleAnnotationsResolver.getInstance(project) as CliModuleAnnotationsResolver).addPackagePartProvider(this)
}
}
@@ -381,7 +379,7 @@ class KotlinCoreEnvironment private constructor(
}
companion object {
private val ideaCompatibleBuildNumber = "173.1"
private val ideaCompatibleBuildNumber = "172.9999"
init {
setCompatibleBuild()
@@ -504,8 +502,6 @@ class KotlinCoreEnvironment private constructor(
//
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier::class.java)
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), MetaLanguage.EP_NAME, MetaLanguage::class.java)
//
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), JavaModuleSystem.EP_NAME, JavaModuleSystem::class.java)
}
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
@@ -554,7 +550,6 @@ class KotlinCoreEnvironment private constructor(
private fun registerProjectExtensionPoints(area: ExtensionsArea) {
CoreApplicationEnvironment.registerExtensionPoint(area, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor::class.java)
CoreApplicationEnvironment.registerExtensionPoint(area, PsiElementFinder.EP_NAME, PsiElementFinder::class.java)
CoreApplicationEnvironment.registerExtensionPoint(area, JvmElementProvider.EP_NAME, JvmElementProvider::class.java)
}
// made public for Upsource
@@ -566,6 +561,7 @@ class KotlinCoreEnvironment private constructor(
registerService(ScriptDependenciesProvider::class.java, CliScriptDependenciesProvider(projectEnvironment.project, scriptDefinitionProvider))
registerService(KotlinJavaPsiFacade::class.java, KotlinJavaPsiFacade(this))
registerService(KtLightClassForFacade.FacadeStubCache::class.java, KtLightClassForFacade.FacadeStubCache(this))
registerService(ModuleAnnotationsResolver::class.java, CliModuleAnnotationsResolver())
if (messageCollector != null) {
registerService(ScriptReportSink::class.java, CliScriptReportSink(messageCollector))
}

View File

@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.PsiModificationTrackerImpl
import com.intellij.psi.search.DelegatingGlobalSearchScope
@@ -43,10 +42,7 @@ import org.jetbrains.kotlin.cli.jvm.config.*
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.addKotlinSourceRoots
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.javac.JavacWrapper
@@ -192,14 +188,14 @@ object KotlinToJVMBytecodeCompiler {
}
}
val isJava9Module = chunk.any { module ->
val isJava9Module = false /*chunk.any { module ->
module.getJavaSourceRoots().any { (path, packagePrefix) ->
val file = File(path)
packagePrefix == null &&
(file.name == PsiJavaModule.MODULE_INFO_FILE ||
(file.isDirectory && file.listFiles().any { it.name == PsiJavaModule.MODULE_INFO_FILE }))
}
}
}*/
for (module in chunk) {
for (classpathRoot in module.getClasspathRoots()) {
@@ -364,7 +360,7 @@ object KotlinToJVMBytecodeCompiler {
val collector = environment.messageCollector
val analysisStart = PerformanceCounter.currentTime()
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector)
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector, environment.configuration.languageVersionSettings)
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
val project = environment.project
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNullTo(hashSetOf()) { module ->

View File

@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.codeInsight.ExternalAnnotationsManager
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.*
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
@@ -41,8 +40,4 @@ class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
override fun editExternalAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String, value: Array<out PsiNameValuePair>?): Boolean {
throw UnsupportedOperationException("not implemented")
}
override fun hasAnnotationRootsForFile(file: VirtualFile): Boolean {
throw UnsupportedOperationException("not implemented")
}
}

View File

@@ -17,10 +17,8 @@
package org.jetbrains.kotlin.cli.jvm.modules
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleFinder
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
private val modulesRoot = jrtFileSystemRoot?.findChild("modules")
@@ -40,8 +38,11 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
modulesRoot?.findChild(name)?.let(this::findSystemModule) ?: userModules[name]
private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? {
/*
val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null
val moduleInfo = JavaModuleInfo.read(file) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file)
*/
return null
}
}

View File

@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.jvm.repl.messages.unescapeLineBreaks
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import java.io.File
import java.io.IOException
import java.io.PrintWriter
import java.util.*
import java.util.concurrent.Callable
@@ -140,8 +141,12 @@ class ReplFromTerminal(
}
else if (split.size >= 2 && split[0] == "load") {
val fileName = split[1]
val scriptText = FileUtil.loadFile(File(fileName))
eval(scriptText)
try {
val scriptText = FileUtil.loadFile(File(fileName))
eval(scriptText)
} catch (e: IOException) {
writer.outputCompileError("Can not load script: ${e.message}")
}
return true
}
else {

View File

@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragment.Companion.DOT_METADATA_FILE_EXTENSION
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable
import org.jetbrains.kotlin.serialization.jvm.JvmModuleProtoBuf
import java.io.ByteArrayOutputStream
import java.io.DataOutputStream
import java.io.File
@@ -62,7 +62,7 @@ open class MetadataSerializer(private val dependOnOldBuiltIns: Boolean) {
return
}
val analyzer = AnalyzerWithCompilerReport(messageCollector)
val analyzer = AnalyzerWithCompilerReport(messageCollector, configuration.languageVersionSettings)
analyzer.analyzeAndReport(files) {
CommonAnalyzerFacade.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { _, content ->
environment.createPackagePartProvider(content.moduleContentScope)
@@ -121,11 +121,11 @@ open class MetadataSerializer(private val dependOnOldBuiltIns: Boolean) {
}
val kotlinModuleFile = File(destDir, JvmCodegenUtil.getMappingFileName(JvmCodegenUtil.getModuleName(module)))
val packageTableBytes = JvmPackageTable.PackageTable.newBuilder().apply {
val packageTableBytes = JvmModuleProtoBuf.Module.newBuilder().apply {
for (table in packageTable.values) {
table.addTo(this)
}
}.serializeToByteArray()
}.build().serializeToByteArray()
kotlinModuleFile.parentFile.mkdirs()
kotlinModuleFile.writeBytes(packageTableBytes)

View File

@@ -61,7 +61,6 @@ messages/**)
-dontwarn net.jpountz.lz4.LZ4Factory
-dontwarn org.jetbrains.annotations.ReadOnly
-dontwarn org.jetbrains.annotations.Mutable
-dontwarn com.intellij.util.io.TarUtil
#-libraryjars '<rtjar>'
#-libraryjars '<jssejar>'

View File

@@ -137,6 +137,8 @@ class CompileServiceImpl(
private val sessions: MutableMap<Int, ClientOrSessionProxy<Any>> = hashMapOf()
private val sessionsIdCounter = AtomicInteger(0)
val lastSessionId get() = sessionsIdCounter.get()
fun<T: Any> leaseSession(session: ClientOrSessionProxy<T>): Int = lock.write {
val newId = getValidId(sessionsIdCounter) {
it != CompileService.NO_SESSION && !sessions.containsKey(it)
@@ -182,8 +184,13 @@ class CompileServiceImpl(
val aliveClientsCount: Int get() = clientProxies.size
private val _clientsCounter = AtomicInteger(0)
val clientsCounter get() = _clientsCounter.get()
fun addClient(aliveFlagPath: String?) {
clientsLock.write {
_clientsCounter.incrementAndGet()
clientProxies.add(ClientOrSessionProxy(aliveFlagPath))
}
}
@@ -352,70 +359,72 @@ class CompileServiceImpl(
servicesFacade: CompilerServicesFacadeBase,
compilationResults: CompilationResults?
): CompileService.CallResult<Int> = ifAlive {
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
val targetPlatform = compilationOptions.targetPlatform
log.info("Starting compilation with args: " + compilerArguments.joinToString(" "))
withValidClientOrSessionProxy(sessionId) {
val messageCollector = CompileServicesFacadeMessageCollector(servicesFacade, compilationOptions)
val daemonReporter = DaemonMessageReporter(servicesFacade, compilationOptions)
val targetPlatform = compilationOptions.targetPlatform
log.info("Starting compilation with args: " + compilerArguments.joinToString(" "))
@Suppress("UNCHECKED_CAST")
val compiler = when (targetPlatform) {
CompileService.TargetPlatform.JVM -> K2JVMCompiler()
CompileService.TargetPlatform.JS -> K2JSCompiler()
CompileService.TargetPlatform.METADATA -> K2MetadataCompiler()
} as CLICompiler<CommonCompilerArguments>
@Suppress("UNCHECKED_CAST")
val compiler = when (targetPlatform) {
CompileService.TargetPlatform.JVM -> K2JVMCompiler()
CompileService.TargetPlatform.JS -> K2JSCompiler()
CompileService.TargetPlatform.METADATA -> K2MetadataCompiler()
} as CLICompiler<CommonCompilerArguments>
val k2PlatformArgs = compiler.createArguments()
parseCommandLineArguments(compilerArguments.asList(), k2PlatformArgs)
val argumentParseError = validateArguments(k2PlatformArgs.errors)
if (argumentParseError != null) {
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
CompileService.CallResult.Good(ExitCode.COMPILATION_ERROR.code)
}
else when (compilationOptions.compilerMode) {
CompilerMode.JPS_COMPILER -> {
val jpsServicesFacade = servicesFacade as JpsCompilerServicesFacade
withIC(enabled = servicesFacade.hasIncrementalCaches()) {
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
compiler.exec(messageCollector, services, k2PlatformArgs)
}
}
val k2PlatformArgs = compiler.createArguments()
parseCommandLineArguments(compilerArguments.asList(), k2PlatformArgs)
val argumentParseError = validateArguments(k2PlatformArgs.errors)
if (argumentParseError != null) {
messageCollector.report(CompilerMessageSeverity.ERROR, argumentParseError)
CompileService.CallResult.Good(ExitCode.COMPILATION_ERROR.code)
}
CompilerMode.NON_INCREMENTAL_COMPILER -> {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
compiler.exec(messageCollector, Services.EMPTY, k2PlatformArgs)
}
}
CompilerMode.INCREMENTAL_COMPILER -> {
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
else when (compilationOptions.compilerMode) {
CompilerMode.JPS_COMPILER -> {
val jpsServicesFacade = servicesFacade as JpsCompilerServicesFacade
when (targetPlatform) {
CompileService.TargetPlatform.JVM -> {
val k2jvmArgs = k2PlatformArgs as K2JVMCompilerArguments
withIC {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
execIncrementalCompiler(k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
messageCollector, daemonReporter)
}
withIC(enabled = servicesFacade.hasIncrementalCaches()) {
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
val services = createCompileServices(jpsServicesFacade, eventManger, profiler)
compiler.exec(messageCollector, services, k2PlatformArgs)
}
}
CompileService.TargetPlatform.JS -> {
val k2jsArgs = k2PlatformArgs as K2JSCompilerArguments
}
CompilerMode.NON_INCREMENTAL_COMPILER -> {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
compiler.exec(messageCollector, Services.EMPTY, k2PlatformArgs)
}
}
CompilerMode.INCREMENTAL_COMPILER -> {
val gradleIncrementalArgs = compilationOptions as IncrementalCompilationOptions
val gradleIncrementalServicesFacade = servicesFacade as IncrementalCompilerServicesFacade
withJsIC {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
execJsIncrementalCompiler(k2jsArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!, messageCollector)
when (targetPlatform) {
CompileService.TargetPlatform.JVM -> {
val k2jvmArgs = k2PlatformArgs as K2JVMCompilerArguments
withIC {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
execIncrementalCompiler(k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
messageCollector, daemonReporter)
}
}
}
}
else -> throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
CompileService.TargetPlatform.JS -> {
val k2jsArgs = k2PlatformArgs as K2JSCompilerArguments
withJsIC {
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
execJsIncrementalCompiler(k2jsArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!, messageCollector)
}
}
}
else -> throw IllegalStateException("Incremental compilation is not supported for target platform: $targetPlatform")
}
}
else -> throw IllegalStateException("Unknown compilation mode ${compilationOptions.compilerMode}")
}
else -> throw IllegalStateException("Unknown compilation mode ${compilationOptions.compilerMode}")
}
}
@@ -801,18 +810,23 @@ class CompileServiceImpl(
private fun shutdownWithDelay() {
state.delayedShutdownQueued.set(true)
val currentClientsCount = state.clientsCounter
val currentSessionId = state.sessions.lastSessionId
val currentCompilationsCount = compilationsCounter.get()
log.info("Delayed shutdown in ${daemonOptions.shutdownDelayMilliseconds}ms")
timer.schedule(daemonOptions.shutdownDelayMilliseconds) {
state.delayedShutdownQueued.set(false)
if (currentCompilationsCount == compilationsCounter.get()) {
if (currentClientsCount == state.clientsCounter &&
currentCompilationsCount == compilationsCounter.get() &&
currentSessionId == state.sessions.lastSessionId)
{
ifAliveExclusiveUnit(minAliveness = Aliveness.LastSession) {
log.fine("Execute delayed shutdown")
shutdownNow()
}
}
else {
log.info("Cancel delayed shutdown due to new client")
log.info("Cancel delayed shutdown due to a new activity")
}
}
}

View File

@@ -26,8 +26,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
val bytecodeVersion: Int by lazy {
when (this) {
JVM_1_6 -> Opcodes.V1_6
JVM_1_8 ->
if (java.lang.Boolean.valueOf(System.getProperty("kotlin.test.substitute.bytecode.1.8.to.1.9"))) Opcodes.V1_9 else Opcodes.V1_8
JVM_1_8 -> Opcodes.V1_8
}
}
@@ -42,7 +41,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?:
when (bytecodeVersion) {
Opcodes.V1_7 -> "1.7"
Opcodes.V1_9 -> "1.9"
Opcodes.V1_8 + 1 -> "1.9"
else -> null
}

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.JvmMethodSignature
@@ -62,8 +63,8 @@ private fun inlineAccessorsJvmNames(properties: List<ProtoBuf.Property>, nameRes
}
val inlineAccessors = arrayListOf<JvmMethodSignature>()
propertiesWithInlineAccessors.forEach { proto ->
if (proto.hasExtension(JvmProtoBuf.propertySignature)) {
val signature = proto.getExtension(JvmProtoBuf.propertySignature)
val signature = proto.getExtensionOrNull(JvmProtoBuf.propertySignature)
if (signature != null) {
if (proto.hasGetterFlags() && Flags.IS_INLINE_ACCESSOR.get(proto.getterFlags)) {
inlineAccessors.add(signature.getter)
}

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.psi.psiUtil.contains
class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass), VirtualFileBoundJavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
init {
@@ -114,7 +115,7 @@ class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass)
override val virtualFile: VirtualFile?
get() = psi.containingFile?.virtualFile
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile.virtualFile in scope
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile in scope
override fun getAnnotationOwnerPsi() = psi.modifierList

View File

@@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.util.Computable
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
class KotlinBinaryClassCache : Disposable {
private class RequestCache {
@@ -56,8 +55,6 @@ class KotlinBinaryClassCache : Disposable {
fun getKotlinBinaryClass(file: VirtualFile, fileContent: ByteArray? = null): KotlinJvmBinaryClass? {
if (file.fileType !== JavaClassFileType.INSTANCE) return null
if (file.name == PsiJavaModule.MODULE_INFO_CLS_FILE) return null
val service = ServiceManager.getService(KotlinBinaryClassCache::class.java)
val requestCache = service.cache.get()

View File

@@ -90,7 +90,9 @@ class IncrementalPackageFragmentProvider(
DeserializedPackageMemberScope(
this, packageProto, nameResolver,
JvmPackagePartSource(partName, facadeName, knownJvmBinaryClass = jvmBinaryClass),
JvmPackagePartSource(
partName, facadeName, packageProto, nameResolver, knownJvmBinaryClass = jvmBinaryClass
),
deserializationComponents, classNames = { emptyList() }
)
}

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin.incremental
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
import org.jetbrains.kotlin.storage.StorageManager
@@ -42,4 +43,8 @@ class IncrementalPackagePartProvider(
// TODO
override fun findMetadataPackageParts(packageFqName: String): List<String> = TODO()
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
return parent.getAnnotationsOnBinaryModule(moduleName)
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
import org.jetbrains.kotlin.serialization.deserialization.getExtensionOrNull
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
fun getJvmModuleNameForDeserializedDescriptor(descriptor: DeclarationDescriptor): String? {
val parent = DescriptorUtils.getParentOfType(descriptor, ClassOrPackageFragmentDescriptor::class.java, false)
when {
parent is DeserializedClassDescriptor -> {
val classProto = parent.classProto
val nameResolver = parent.c.nameResolver
return classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)
?.let(nameResolver::getString)
?: JvmAbi.DEFAULT_MODULE_NAME
}
descriptor is DeserializedMemberDescriptor -> {
val source = descriptor.containerSource
if (source is JvmPackagePartSource) {
val packageProto = source.packageProto
val nameResolver = source.nameResolver
return packageProto.getExtensionOrNull(JvmProtoBuf.packageModuleName)
?.let(nameResolver::getString)
?: JvmAbi.DEFAULT_MODULE_NAME
}
}
}
return null
}

View File

@@ -70,7 +70,9 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
@Suppress("UNCHECKED_CAST")
val resolverForReferencedModule = referencedClassModule?.let { resolverForProject.tryGetResolverForModule(it as M) }
val resolverForModule = resolverForReferencedModule ?: run {
val resolverForModule = resolverForReferencedModule?.takeIf {
referencedClassModule.platform == JvmPlatform || referencedClassModule.platform == null
} ?: run {
// in case referenced class lies outside of our resolver, resolve the class as if it is inside our module
// this leads to java class being resolved several times
resolverForProject.resolverForModule(moduleInfo)

View File

@@ -17,15 +17,15 @@
package org.jetbrains.kotlin.resolve.jvm.modules
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
//import com.intellij.psi.PsiJavaModule
import com.intellij.psi.PsiModifier
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.utils.compact
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.ModuleVisitor
//import org.jetbrains.org.objectweb.asm.ModuleVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_TRANSITIVE
//import org.jetbrains.org.objectweb.asm.Opcodes.ACC_TRANSITIVE
import java.io.IOException
class JavaModuleInfo(
@@ -41,7 +41,7 @@ class JavaModuleInfo(
"Module $moduleName (${requires.size} requires, ${exports.size} exports)"
companion object {
fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
/*fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
return JavaModuleInfo(
psiJavaModule.name,
psiJavaModule.requires.mapNotNull { statement ->
@@ -55,9 +55,9 @@ class JavaModuleInfo(
}
}
)
}
}*/
fun read(file: VirtualFile): JavaModuleInfo? {
/*fun read(file: VirtualFile): JavaModuleInfo? {
val contents = try { file.contentsToByteArray() } catch (e: IOException) { return null }
var moduleName: String? = null
@@ -84,6 +84,6 @@ class JavaModuleInfo(
return if (moduleName != null)
JavaModuleInfo(moduleName!!, requires.compact(), exports.compact())
else null
}
}*/
}
}

View File

@@ -31,6 +31,9 @@ interface LegacyResolverWrapper
internal class LegacyPackageDependencyResolverWrapper(
val legacyResolver: ScriptDependenciesResolver
) : kotlin.script.experimental.dependencies.DependenciesResolver, LegacyResolverWrapper {
private var previousDependencies: org.jetbrains.kotlin.script.KotlinScriptExternalDependencies? = null
override fun resolve(
scriptContents: kotlin.script.dependencies.ScriptContents,
environment: Environment
@@ -45,7 +48,8 @@ internal class LegacyPackageDependencyResolverWrapper(
environment,
{ sev, msg, pos ->
reports.add(ScriptReport(msg, sev.convertSeverity(), pos?.convertPosition()))
}, null
},
previousDependencies
).get() ?: return DependenciesResolver.ResolveResult.Failure(reports)
val dependencies = ScriptDependencies(
@@ -55,6 +59,7 @@ internal class LegacyPackageDependencyResolverWrapper(
sources = legacyDeps.sources.toList(),
scripts = legacyDeps.scripts.toList()
)
previousDependencies = legacyDeps
return DependenciesResolver.ResolveResult.Success(dependencies, reports)
}
@@ -73,6 +78,9 @@ internal class ApiChangeDependencyResolverWrapper(
) : kotlin.script.experimental.dependencies.DependenciesResolver,
DependencyResolverWrapper<kotlin.script.dependencies.ScriptDependenciesResolver>,
LegacyResolverWrapper {
private var previousDependencies: kotlin.script.dependencies.KotlinScriptExternalDependencies? = null
override fun resolve(
scriptContents: kotlin.script.dependencies.ScriptContents,
environment: Environment
@@ -83,7 +91,8 @@ internal class ApiChangeDependencyResolverWrapper(
environment,
{ sev, msg, pos ->
reports.add(ScriptReport(msg, sev.convertSeverity(), pos?.convertPosition()))
}, null
},
previousDependencies
).get() ?: return DependenciesResolver.ResolveResult.Failure(reports)
val dependencies = ScriptDependencies(
@@ -93,6 +102,7 @@ internal class ApiChangeDependencyResolverWrapper(
sources = legacyDeps.sources.toList(),
scripts = legacyDeps.scripts.toList()
)
previousDependencies = legacyDeps
return DependenciesResolver.ResolveResult.Success(dependencies, reports)
}

View File

@@ -238,6 +238,18 @@ public interface Errors {
DiagnosticFactory1<PsiElement, FqName> ILLEGAL_KOTLIN_VERSION_STRING_VALUE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, String> NEWER_VERSION_IN_SINCE_KOTLIN = DiagnosticFactory1.create(WARNING);
DiagnosticFactory2<PsiElement, FqName, Boolean> EXPERIMENTAL_API_USAGE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<PsiElement, FqName, Boolean> EXPERIMENTAL_API_USAGE_ERROR = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<PsiElement, FqName, DeclarationDescriptor> EXPERIMENTAL_OVERRIDE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<PsiElement, FqName, DeclarationDescriptor> EXPERIMENTAL_OVERRIDE_ERROR = DiagnosticFactory2.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> USE_EXPERIMENTAL_WITHOUT_ARGUMENTS = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<KtAnnotationEntry, FqName> USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER = DiagnosticFactory1.create(WARNING);
DiagnosticFactory1<KtAnnotationEntry, FqName> USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<KtAnnotationEntry, String> EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET = DiagnosticFactory1.create(ERROR);
// Const
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
@@ -984,6 +996,9 @@ public interface Errors {
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_FUNCTION_CALL = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, CallableDescriptor> ILLEGAL_SUSPEND_PROPERTY_ACCESS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtReturnExpression> RETURN_FOR_BUILT_IN_SUSPEND = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_ERROR = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, RenderedDiagnostic<?>> PLUGIN_WARNING = DiagnosticFactory1.create(WARNING);

View File

@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.config.LanguageVersion;
import org.jetbrains.kotlin.diagnostics.Diagnostic;
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement;
import org.jetbrains.kotlin.types.KotlinTypeKt;
@@ -33,6 +34,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ServiceLoader;
@@ -149,6 +151,27 @@ public class DefaultErrorMessages {
MAP.put(ILLEGAL_KOTLIN_VERSION_STRING_VALUE, "Invalid @{0} annotation value (should be ''major.minor'' or ''major.minor.patch'')", TO_STRING);
MAP.put(NEWER_VERSION_IN_SINCE_KOTLIN, "The version is greater than the specified API version {0}", STRING);
RenderingContext.Key<FqName> getExperimentalFqName = new RenderingContext.Key<FqName>("getExperimentalFqName") {
@Override
public FqName compute(@NotNull Collection<?> objectsToRender) {
return (FqName) CollectionsKt.first(objectsToRender);
}
};
DiagnosticParameterRenderer<Boolean> renderUseExperimental = (useExperimentalAllowed, c) ->
useExperimentalAllowed ? " or ''@UseExperimental(" + c.get(getExperimentalFqName) + "::class)''" : "";
MAP.put(EXPERIMENTAL_API_USAGE, "This declaration is experimental and its usage should be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental);
MAP.put(EXPERIMENTAL_API_USAGE_ERROR, "This declaration is experimental and its usage must be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental);
MAP.put(EXPERIMENTAL_OVERRIDE, "This declaration overrides experimental member of supertype ''{1}'' and should be annotated with ''@{0}''", TO_STRING, NAME);
MAP.put(EXPERIMENTAL_OVERRIDE_ERROR, "This declaration overrides experimental member of supertype ''{1}'' and must be annotated with ''@{0}''", TO_STRING, NAME);
MAP.put(USE_EXPERIMENTAL_WITHOUT_ARGUMENTS, "@UseExperimental without any arguments has no effect");
MAP.put(USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER, "Annotation ''{0}'' is not an experimental API marker, therefore its usage in @UseExperimental is ignored", TO_STRING);
MAP.put(USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT,
"Experimental annotation ''{0}'' has impact other than COMPILATION, therefore its usage in @UseExperimental is forbidden", TO_STRING);
MAP.put(EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT, "Experimental annotation with changesMayBreak = [] is not allowed");
MAP.put(EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET, "Experimental annotation cannot be used on the following code elements: {0}. Please remove these targets", STRING);
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
MAP.put(REDUNDANT_OPEN_IN_INTERFACE, "Modifier 'open' is redundant for abstract interface members");
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
@@ -873,6 +896,9 @@ public class DefaultErrorMessages {
MAP.put(ILLEGAL_SUSPEND_FUNCTION_CALL, "Suspend function ''{0}'' should be called only from a coroutine or another suspend function", NAME);
MAP.put(ILLEGAL_SUSPEND_PROPERTY_ACCESS, "Suspend property ''{0}'' should be accessed only from a coroutine or suspend function", NAME);
MAP.put(ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL, "Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope");
MAP.put(NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND, "''suspend'' function can only be called in a form of modifier of a lambda: suspend { ... }");
MAP.put(RETURN_FOR_BUILT_IN_SUSPEND, "Using implicit label for this lambda is prohibited");
MAP.put(MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND, "Calls having a form of ''suspend {}'' are deprecated because ''suspend'' in the context will have a meaning of a modifier. Add empty argument list to the call: ''suspend() { ... }''");
MAP.put(PLUGIN_ERROR, "{0}", (d, c) -> d.getText());
MAP.put(PLUGIN_WARNING, "{0}", (d, c) -> d.getText());

View File

@@ -29,17 +29,12 @@ sealed class RenderingContext {
class Impl(private val objectsToRender: Collection<Any?>) : RenderingContext() {
private val data = linkedMapOf<Key<*>, Any?>()
@Suppress("UNCHECKED_CAST")
override fun <T> get(key: Key<T>): T {
if (!data.containsKey(key)) {
val result = key.compute(objectsToRender)
data[key] = result
return result
}
return data[key] as T
return data[key] as? T ?: key.compute(objectsToRender).also { data[key] = it }
}
}
object Empty : RenderingContext() {
override fun <T> get(key: Key<T>): T {
return key.compute(emptyList())
@@ -65,4 +60,4 @@ sealed class RenderingContext {
return Impl(parameters)
}
}
}
}

View File

@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbacksImpl
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
import org.jetbrains.kotlin.resolve.lazy.*
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
@@ -63,6 +64,10 @@ fun StorageComponentContainer.configureModule(
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
useImpl<SupertypeLoopCheckerImpl>()
useImpl<KotlinResolutionStatelessCallbacksImpl>()
useImpl<ExperimentalUsageChecker>()
useImpl<ExperimentalUsageChecker.Overrides>()
useImpl<ExperimentalUsageChecker.ClassifierUsage>()
}
fun StorageComponentContainer.configureModule(

View File

@@ -19,14 +19,12 @@ package org.jetbrains.kotlin.psi;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceService;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
public KtElementImpl(@NotNull ASTNode node) {
@@ -96,4 +94,10 @@ public class KtElementImpl extends ASTWrapperPsiElement implements KtElement {
public KtElement getPsiOrParent() {
return this;
}
@Override
public PsiElement getParent() {
PsiElement substitute = KtPsiUtilKt.getParentSubstitute(this);
return substitute != null ? substitute : super.getParent();
}
}

View File

@@ -26,6 +26,7 @@ import com.intellij.psi.stubs.StubElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementType;
import java.util.Arrays;
@@ -117,4 +118,10 @@ public class KtElementImplStub<T extends StubElement<?>> extends StubBasedPsiEle
public KtElement getPsiOrParent() {
return this;
}
@Override
public PsiElement getParent() {
PsiElement substitute = KtPsiUtilKt.getParentSubstitute(this);
return substitute != null ? substitute : super.getParent();
}
}

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.psi;
import com.google.common.collect.ImmutableSet;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.LocalSearchScope;
@@ -32,6 +33,9 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
import org.jetbrains.kotlin.psi.stubs.KotlinStubWithFqName;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import java.util.Set;
import static org.jetbrains.kotlin.psi.KtPsiFactoryKt.KtPsiFactory;
@@ -78,21 +82,32 @@ abstract class KtNamedDeclarationStub<T extends KotlinStubWithFqName<?>> extends
return findChildByType(KtTokens.IDENTIFIER);
}
private static final Set<String> FUNCTIONLIKE_CONVENTIONS = ImmutableSet.of(
OperatorNameConventions.INVOKE.asString(),
OperatorNameConventions.GET.asString()
);
private static boolean shouldDropOperatorKeyword(String oldName, String newName) {
return !OperatorConventions.isConventionName(Name.identifier(newName)) ||
FUNCTIONLIKE_CONVENTIONS.contains(oldName) != FUNCTIONLIKE_CONVENTIONS.contains(newName);
}
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
PsiElement identifier = getNameIdentifier();
if (identifier == null) return null;
KtModifierList modifierList = getModifierList();
if (modifierList != null &&
modifierList.hasModifier(KtTokens.OPERATOR_KEYWORD) &&
!OperatorConventions.isConventionName(Name.identifier(name))) {
removeModifier(KtTokens.OPERATOR_KEYWORD);
if (modifierList != null && modifierList.hasModifier(KtTokens.OPERATOR_KEYWORD)) {
if (shouldDropOperatorKeyword(getName(), name)) {
removeModifier(KtTokens.OPERATOR_KEYWORD);
}
}
PsiElement newIdentifier = KtPsiFactory(this).createNameIdentifierIfPossible(name);
PsiElement newIdentifier =
KtPsiFactory(this).createNameIdentifierIfPossible(KtPsiUtilKt.quoteIfNeeded(name));
if (newIdentifier != null) {
identifier.replace(newIdentifier);
KtPsiUtilKt.astReplace(identifier, newIdentifier);
}
else {
identifier.delete();
@@ -157,17 +172,4 @@ abstract class KtNamedDeclarationStub<T extends KotlinStubWithFqName<?>> extends
}
return KtNamedDeclarationUtil.getFQName(this);
}
@Override
public void delete() throws IncorrectOperationException {
KtClassOrObject classOrObject = KtPsiUtilKt.getContainingClassOrObject(this);
super.delete();
if (classOrObject instanceof KtObjectDeclaration
&& ((KtObjectDeclaration) classOrObject).isCompanion()
&& classOrObject.getDeclarations().isEmpty()) {
classOrObject.delete();
}
}
}

View File

@@ -179,7 +179,11 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
}
fun createCompanionObject(): KtObjectDeclaration {
return createClass("class A {\n companion object{\n}\n}").companionObjects.first()
return createCompanionObject("companion object {\n}")
}
fun createCompanionObject(text: String): KtObjectDeclaration {
return createClass("class A {\n $text\n}").companionObjects.first()
}
fun createFileAnnotation(annotationText: String): KtAnnotationEntry {
@@ -325,8 +329,6 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
return createProperty(text + " val x").modifierList!!
}
fun createEmptyModifierList() = createModifierList(KtTokens.PRIVATE_KEYWORD).apply { firstChild.delete() }
fun createModifier(modifier: KtModifierKeywordToken): PsiElement {
return createModifierList(modifier.value).getModifier(modifier)!!
}

View File

@@ -920,6 +920,11 @@ public class KtPsiUtil {
return null;
}
public static boolean isLabeledFunctionLiteral(@NotNull KtFunctionLiteral functionLiteral) {
// KtFunctionLiteral -> KtLambdaExpression -> KtLabeledExpression
return functionLiteral.getParent().getParent() instanceof KtLabeledExpression;
}
@Nullable
public static KtExpression getLastElementDeparenthesized(
@Nullable KtExpression expression,

View File

@@ -42,11 +42,11 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
}
public R visitSecondaryConstructor(@NotNull KtSecondaryConstructor constructor, D data) {
return visitDeclaration(constructor, data);
return visitNamedDeclaration(constructor, data);
}
public R visitPrimaryConstructor(@NotNull KtPrimaryConstructor constructor, D data) {
return visitDeclaration(constructor, data);
return visitNamedDeclaration(constructor, data);
}
public R visitNamedFunction(@NotNull KtNamedFunction function, D data) {

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.psi.psiUtil
import com.intellij.extapi.psi.StubBasedPsiElementBase
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiParameter
@@ -27,6 +28,7 @@ import com.intellij.psi.tree.TokenSet
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.lexer.KotlinLexer
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name
@@ -154,6 +156,9 @@ fun KtExpression.getQualifiedExpressionForReceiverOrThis(): KtExpression {
fun KtExpression.isDotReceiver(): Boolean =
(parent as? KtDotQualifiedExpression)?.receiverExpression == this
fun KtExpression.getPossiblyQualifiedCallExpression(): KtCallExpression? =
((this as? KtQualifiedExpression)?.selectorExpression ?: this) as? KtCallExpression
// ---------- Block expression -------------------------------------------------------------------------------------------------------------
fun KtElement.blockExpressionsOrSingle(): Sequence<KtElement> =
@@ -568,4 +573,20 @@ fun KtExpression.getLabeledParent(labelName: String): KtLabeledExpression? {
}
}
return null
}
}
fun PsiElement.astReplace(newElement: PsiElement) = parent.node.replaceChild(node, newElement.node)
var KtElement.parentSubstitute: PsiElement? by UserDataProperty(Key.create<PsiElement>("PARENT_SUBSTITUTE"))
fun String?.isIdentifier(): Boolean {
if (this == null || isEmpty()) return false
val lexer = KotlinLexer()
lexer.start(this, 0, length)
if (lexer.tokenType !== KtTokens.IDENTIFIER) return false
lexer.advance()
return lexer.tokenType == null
}
fun String.quoteIfNeeded(): String = if (this.isIdentifier()) this else "`$this`"

View File

@@ -95,7 +95,7 @@ fun PsiElement.nextLeaf(filter: (PsiElement) -> Boolean): PsiElement? {
}
fun <T : PsiElement> PsiElement.getParentOfTypesAndPredicate(
strict: Boolean = false, vararg parentClasses: Class<T>, predicate: (T) -> Boolean
strict: Boolean = false, vararg parentClasses: Class<out T>, predicate: (T) -> Boolean
): T? {
var element = if (strict) parent else this
while (element != null) {

View File

@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
import org.jetbrains.kotlin.resolve.constants.ArrayValue
@@ -193,6 +194,8 @@ class AnnotationChecker(
}
companion object {
private val TARGET_ALLOWED_TARGETS = Name.identifier("allowedTargets")
private fun applicableTargetSet(entry: KtAnnotationEntry, trace: BindingTrace): Set<KotlinTarget> {
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return KotlinTarget.DEFAULT_TARGET_SET
// For descriptor with error type, all targets are considered as possible
@@ -207,10 +210,12 @@ class AnnotationChecker(
}
fun applicableTargetSet(classDescriptor: ClassDescriptor): Set<KotlinTarget>? {
val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target)
?: return null
val valueArguments = targetEntryDescriptor.allValueArguments
val valueArgument = valueArguments.entries.firstOrNull()?.value as? ArrayValue ?: return null
val targetEntryDescriptor = classDescriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target) ?: return null
return loadAnnotationTargets(targetEntryDescriptor)
}
fun loadAnnotationTargets(targetEntryDescriptor: AnnotationDescriptor): Set<KotlinTarget>? {
val valueArgument = targetEntryDescriptor.allValueArguments[TARGET_ALLOWED_TARGETS] as? ArrayValue ?: return null
return valueArgument.value.filterIsInstance<EnumValue>().mapNotNull {
KotlinTarget.valueOrNull(it.enumEntryName.asString())
}.toSet()

View File

@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.constants.ConstantValue
import org.jetbrains.kotlin.resolve.constants.ErrorValue
val JVM_STATIC_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmStatic")
private val JVM_STATIC_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmStatic")
val JVM_FIELD_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmField")

View File

@@ -227,7 +227,7 @@ class LazyTopDownAnalyzer(
checkClassifierUsages(
declarations, classifierUsageCheckers,
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver)
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver, moduleDescriptor)
)
return c

View File

@@ -278,8 +278,9 @@ public class ModifiersChecker {
public void runDeclarationCheckers(@NotNull KtDeclaration declaration, @NotNull DeclarationDescriptor descriptor) {
DeclarationCheckerContext context =
new DeclarationCheckerContext(trace, languageVersionSettings, deprecationResolver, expectActualTracker);
DeclarationCheckerContext context = new DeclarationCheckerContext(
trace, languageVersionSettings, deprecationResolver, moduleDescriptor, expectActualTracker
);
for (DeclarationChecker checker : declarationCheckers) {
checker.check(declaration, descriptor, context);
}
@@ -301,19 +302,22 @@ public class ModifiersChecker {
private final LanguageVersionSettings languageVersionSettings;
private final ExpectActualTracker expectActualTracker;
private final DeprecationResolver deprecationResolver;
private final ModuleDescriptor moduleDescriptor;
public ModifiersChecker(
@NotNull AnnotationChecker annotationChecker,
@NotNull Iterable<DeclarationChecker> declarationCheckers,
@NotNull LanguageVersionSettings languageVersionSettings,
@NotNull ExpectActualTracker expectActualTracker,
@NotNull DeprecationResolver deprecationResolver
@NotNull DeprecationResolver deprecationResolver,
@NotNull ModuleDescriptor moduleDescriptor
) {
this.annotationChecker = annotationChecker;
this.declarationCheckers = declarationCheckers;
this.languageVersionSettings = languageVersionSettings;
this.expectActualTracker = expectActualTracker;
this.deprecationResolver = deprecationResolver;
this.moduleDescriptor = moduleDescriptor;
}
@NotNull

View File

@@ -0,0 +1,20 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.name.ClassId
interface ModuleAnnotationsResolver {
fun getAnnotationsOnContainingModule(descriptor: DeclarationDescriptor): List<ClassId>
companion object {
fun getInstance(project: Project): ModuleAnnotationsResolver =
ServiceManager.getService(project, ModuleAnnotationsResolver::class.java)
}
}

View File

@@ -100,12 +100,16 @@ private val DEFAULT_CALL_CHECKERS = listOf(
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker,
CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker, MissingDependencyClassChecker,
CallableReferenceCompatibilityChecker(), LateinitIntrinsicApplicabilityChecker,
UnderscoreUsageChecker, AssigningNamedArgumentToVarargChecker()
UnderscoreUsageChecker, AssigningNamedArgumentToVarargChecker(),
LambdaWithSuspendModifierCallChecker
)
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
DeprecatedClassifierUsageChecker(), ApiVersionClassifierUsageChecker, MissingDependencyClassChecker.ClassifierUsage
)
private val DEFAULT_ANNOTATION_CHECKERS = listOf<AdditionalAnnotationChecker>(
ExperimentalMarkerDeclarationAnnotationChecker
)
abstract class PlatformConfigurator(
@@ -114,7 +118,7 @@ abstract class PlatformConfigurator(
additionalCallCheckers: List<CallChecker>,
additionalTypeCheckers: List<AdditionalTypeChecker>,
additionalClassifierUsageCheckers: List<ClassifierUsageChecker>,
private val additionalAnnotationCheckers: List<AdditionalAnnotationChecker>,
additionalAnnotationCheckers: List<AdditionalAnnotationChecker>,
private val identifierChecker: IdentifierChecker,
private val overloadFilter: OverloadFilter,
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
@@ -127,6 +131,7 @@ abstract class PlatformConfigurator(
private val typeCheckers: List<AdditionalTypeChecker> = DEFAULT_TYPE_CHECKERS + additionalTypeCheckers
private val classifierUsageCheckers: List<ClassifierUsageChecker> =
DEFAULT_CLASSIFIER_USAGE_CHECKERS + additionalClassifierUsageCheckers
private val annotationCheckers: List<AdditionalAnnotationChecker> = DEFAULT_ANNOTATION_CHECKERS + additionalAnnotationCheckers
abstract fun configureModuleComponents(container: StorageComponentContainer)
@@ -136,7 +141,7 @@ abstract class PlatformConfigurator(
callCheckers.forEach { useInstance(it) }
typeCheckers.forEach { useInstance(it) }
classifierUsageCheckers.forEach { useInstance(it) }
additionalAnnotationCheckers.forEach { useInstance(it) }
annotationCheckers.forEach { useInstance(it) }
useInstance(identifierChecker)
useInstance(overloadFilter)
useInstance(platformToKotlinClassMap)

View File

@@ -16,13 +16,12 @@
package org.jetbrains.kotlin.resolve.calls
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
import org.jetbrains.kotlin.builtins.isFunctionType
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.contracts.EffectSystem
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContext.CONSTRAINT_SYSTEM_COMPLETER
@@ -48,7 +47,6 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
@@ -61,8 +59,7 @@ class CallCompleter(
private val candidateResolver: CandidateResolver,
private val dataFlowAnalyzer: DataFlowAnalyzer,
private val callCheckers: Iterable<CallChecker>,
private val builtIns: KotlinBuiltIns,
private val languageVersionSettings: LanguageVersionSettings,
private val moduleDescriptor: ModuleDescriptor,
private val deprecationResolver: DeprecationResolver,
private val effectSystem: EffectSystem
) {
@@ -90,7 +87,7 @@ class CallCompleter(
if (calleeExpression != null && !calleeExpression.isFakeElement) calleeExpression
else resolvedCall.call.callElement
val callCheckerContext = CallCheckerContext(context, languageVersionSettings, deprecationResolver)
val callCheckerContext = CallCheckerContext(context, deprecationResolver, moduleDescriptor)
for (callChecker in callCheckers) {
callChecker.check(resolvedCall, reportOn, callCheckerContext)
@@ -205,7 +202,7 @@ class CallCompleter(
updateSystemIfNeeded { builder ->
val returnTypeInSystem = builder.typeInSystem(returnType)
if (returnTypeInSystem != null) {
builder.addSubtypeConstraint(returnTypeInSystem, builtIns.unitType, EXPECTED_TYPE_POSITION.position())
builder.addSubtypeConstraint(returnTypeInSystem, moduleDescriptor.builtIns.unitType, EXPECTED_TYPE_POSITION.position())
val system = builder.build()
if (system.status.isSuccessful()) system else null
} else null

View File

@@ -185,11 +185,11 @@ class CallExpressionResolver(
}
fun getCallExpressionTypeInfo(
callExpression: KtCallExpression, receiver: ReceiverValue?,
callOperationNode: ASTNode?, context: ExpressionTypingContext
callExpression: KtCallExpression,
context: ExpressionTypingContext
): KotlinTypeInfo {
val typeInfo = getCallExpressionTypeInfoWithoutFinalTypeCheck(
callExpression, receiver, callOperationNode, context, context.dataFlowInfo
callExpression, null, null, context, context.dataFlowInfo
)
if (context.contextDependency == INDEPENDENT) {
dataFlowAnalyzer.checkType(typeInfo.type, callExpression, context)

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DeprecationResolver
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
@@ -36,11 +37,11 @@ interface CallChecker {
fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext)
}
class CallCheckerContext(
class CallCheckerContext @JvmOverloads constructor(
val resolutionContext: ResolutionContext<*>,
override val trace: BindingTrace,
override val languageVersionSettings: LanguageVersionSettings,
override val deprecationResolver: DeprecationResolver
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor,
override val trace: BindingTrace = resolutionContext.trace
) : CheckerContext {
val scope: LexicalScope
get() = resolutionContext.scope
@@ -51,11 +52,8 @@ class CallCheckerContext(
val isAnnotationContext: Boolean
get() = resolutionContext.isAnnotationContext
constructor(
c: ResolutionContext<*>,
languageVersionSettings: LanguageVersionSettings,
deprecationResolver: DeprecationResolver
) : this(c, c.trace, languageVersionSettings, deprecationResolver)
override val languageVersionSettings: LanguageVersionSettings
get() = resolutionContext.languageVersionSettings
}
// Use this utility to avoid premature computation of deferred return type of a resolved callable descriptor.

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
import org.jetbrains.kotlin.resolve.calls.callUtil.isCallableReference
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
object LambdaWithSuspendModifierCallChecker : CallChecker {
@JvmField
val KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME = FqName("kotlin.suspend")
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
val descriptor = resolvedCall.candidateDescriptor
val call = resolvedCall.call
val callName = call.referencedName()
if (callName != "suspend" && descriptor.name.asString() != "suspend") return
when (descriptor.fqNameOrNull()) {
KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME -> {
if (!call.hasFormOfSuspendModifierForLambda() || call.explicitReceiver != null) {
context.trace.report(Errors.NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND.on(reportOn))
}
}
else -> {
if (call.hasFormOfSuspendModifierForLambda()) {
context.trace.report(Errors.MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND.on(reportOn))
}
}
}
}
private fun Call.hasFormOfSuspendModifierForLambda() =
referencedName() == "suspend"
&& !isCallableReference()
&& typeArguments.isEmpty()
&& (hasNoArgumentListButDanglingLambdas() || isInfixWithRightLambda())
private fun Call.referencedName() =
calleeExpression?.safeAs<KtSimpleNameExpression>()?.getReferencedName()
private fun Call.hasNoArgumentListButDanglingLambdas() =
valueArgumentList?.leftParenthesis == null && functionLiteralArguments.isNotEmpty()
private fun Call.isInfixWithRightLambda() =
isInfixCall(this)
&& callElement.safeAs<KtBinaryExpression>()?.right is KtLambdaExpression
}

View File

@@ -23,12 +23,15 @@ import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspensionAnnotation
@@ -43,15 +46,28 @@ import org.jetbrains.kotlin.types.typeUtil.supertypes
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
val COROUTINE_CONTEXT_1_2_20_FQ_NAME = DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
val COROUTINE_CONTEXT_FQ_NAME = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("coroutineContext"))
fun FqName.isBuiltInCorouineContext() =
this == COROUTINE_CONTEXT_1_2_20_FQ_NAME || this == COROUTINE_CONTEXT_FQ_NAME
fun FunctionDescriptor.isBuiltInCoroutineContext() =
(this as? PropertyGetterDescriptor)?.correspondingProperty?.fqNameSafe?.isBuiltInCorouineContext() == true
fun PropertyDescriptor.isBuiltInCoroutineContext() = this.fqNameSafe.isBuiltInCorouineContext()
object CoroutineSuspendCallChecker : CallChecker {
private val ALLOWED_SCOPE_KINDS = setOf(LexicalScopeKind.FUNCTION_INNER_SCOPE, LexicalScopeKind.FUNCTION_HEADER_FOR_DESTRUCTURING)
private val COROUTINE_CONTEXT_FQ_NAME = FqName("kotlin.coroutines.experimental.intrinsics.coroutineContext")
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
val descriptor = resolvedCall.candidateDescriptor
when (descriptor) {
is FunctionDescriptor -> if (!descriptor.isSuspend) return
is PropertyDescriptor -> if (descriptor.fqNameSafe != COROUTINE_CONTEXT_FQ_NAME) return
is PropertyDescriptor -> when (descriptor.fqNameSafe) {
COROUTINE_CONTEXT_1_2_20_FQ_NAME, COROUTINE_CONTEXT_FQ_NAME -> {}
else -> return
}
else -> return
}

View File

@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.contracts.EffectSystem
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
@@ -59,10 +57,8 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.util.*
class KotlinToResolvedCallTransformer(
private val callCheckers: Iterable<CallChecker>,
private val languageFeatureSettings: LanguageVersionSettings,
private val dataFlowAnalyzer: DataFlowAnalyzer,
private val argumentTypeResolver: ArgumentTypeResolver,
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
@@ -70,9 +66,8 @@ class KotlinToResolvedCallTransformer(
private val expressionTypingServices: ExpressionTypingServices,
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
private val additionalDiagnosticReporter: AdditionalDiagnosticReporter,
private val effectSystem: EffectSystem
private val moduleDescriptor: ModuleDescriptor
) {
companion object {
private val REPORT_MISSING_NEW_INFERENCE_DIAGNOSTIC
get() = false
@@ -103,9 +98,8 @@ class KotlinToResolvedCallTransformer(
CallResolutionResult.Type.ERROR, CallResolutionResult.Type.COMPLETED -> {
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor()
val ktPrimitiveCompleter = ResolvedAtomCompleter(
resultSubstitutor, context.trace, context, this,
expressionTypingServices, argumentTypeResolver, doubleColonExpressionResolver,
languageFeatureSettings, deprecationResolver
resultSubstitutor, context.trace, context, this, expressionTypingServices, argumentTypeResolver,
doubleColonExpressionResolver, deprecationResolver, moduleDescriptor
)
for (subKtPrimitive in candidate.subResolvedAtoms) {

View File

@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.builtins.replaceReturnType
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.psi.KtElement
@@ -50,15 +50,14 @@ class ResolvedAtomCompleter(
private val resultSubstitutor: NewTypeSubstitutor,
private val trace: BindingTrace,
private val topLevelCallContext: BasicCallResolutionContext,
private val kotlinToResolvedCallTransformer: KotlinToResolvedCallTransformer,
private val expressionTypingServices: ExpressionTypingServices,
private val argumentTypeResolver: ArgumentTypeResolver,
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
languageVersionSettings: LanguageVersionSettings,
deprecationResolver: DeprecationResolver
deprecationResolver: DeprecationResolver,
moduleDescriptor: ModuleDescriptor
) {
private val callCheckerContext = CallCheckerContext(topLevelCallContext, languageVersionSettings, deprecationResolver)
private val callCheckerContext = CallCheckerContext(topLevelCallContext, deprecationResolver, moduleDescriptor)
private fun complete(resolvedAtom: ResolvedAtom) {
when (resolvedAtom) {

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DeprecationResolver
@@ -26,4 +27,6 @@ interface CheckerContext {
val languageVersionSettings: LanguageVersionSettings
val deprecationResolver: DeprecationResolver
val moduleDescriptor: ModuleDescriptor
}

View File

@@ -35,7 +35,8 @@ interface ClassifierUsageChecker {
class ClassifierUsageCheckerContext(
override val trace: BindingTrace,
override val languageVersionSettings: LanguageVersionSettings,
override val deprecationResolver: DeprecationResolver
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor
) : CheckerContext

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.resolve.BindingTrace
@@ -31,5 +32,6 @@ class DeclarationCheckerContext(
override val trace: BindingTrace,
override val languageVersionSettings: LanguageVersionSettings,
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor,
val expectActualTracker: ExpectActualTracker
) : CheckerContext

View File

@@ -222,7 +222,7 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
else -> true
}
private fun findExpectedForActual(
fun findExpectedForActual(
actual: MemberDescriptor,
commonModule: ModuleDescriptor
): Map<Compatibility, List<MemberDescriptor>>? {

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.resolve.AdditionalAnnotationChecker
import org.jetbrains.kotlin.resolve.AnnotationChecker
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.constants.ArrayValue
import org.jetbrains.kotlin.resolve.constants.ConstantValue
import org.jetbrains.kotlin.resolve.constants.KClassValue
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
object ExperimentalMarkerDeclarationAnnotationChecker : AdditionalAnnotationChecker {
private val WRONG_TARGETS_FOR_MARKER = setOf(KotlinTarget.EXPRESSION, KotlinTarget.FILE)
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
var isAnnotatedWithExperimental = false
for (entry in entries) {
val annotation = trace.bindingContext.get(BindingContext.ANNOTATION, entry)
when (annotation?.fqName) {
ExperimentalUsageChecker.USE_EXPERIMENTAL_FQ_NAME -> {
val annotationClasses =
(annotation.allValueArguments[ExperimentalUsageChecker.USE_EXPERIMENTAL_ANNOTATION_CLASS] as? ArrayValue)?.value.orEmpty()
checkUseExperimentalUsage(annotationClasses, trace, entry)
}
ExperimentalUsageChecker.EXPERIMENTAL_FQ_NAME -> {
val impact = (annotation.allValueArguments[ExperimentalUsageChecker.IMPACT] as? ArrayValue)?.value
checkExperimentalUsage(impact, trace, entry)
isAnnotatedWithExperimental = true
}
}
}
if (isAnnotatedWithExperimental) {
checkMarkerTargets(entries, trace)
}
}
private fun checkUseExperimentalUsage(annotationClasses: List<ConstantValue<*>>, trace: BindingTrace, entry: KtAnnotationEntry) {
if (annotationClasses.isEmpty()) {
trace.report(Errors.USE_EXPERIMENTAL_WITHOUT_ARGUMENTS.on(entry))
return
}
for (annotationClass in annotationClasses) {
val classDescriptor =
(annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor as? ClassDescriptor
?: continue
val experimentality = with(ExperimentalUsageChecker) {
classDescriptor.loadExperimentalityForMarkerAnnotation()
}
if (experimentality == null) {
trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER.on(entry, classDescriptor.fqNameSafe))
} else if (!experimentality.isCompilationOnly) {
trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT.on(entry, experimentality.annotationFqName))
}
}
}
private fun checkExperimentalUsage(impact: List<ConstantValue<*>>?, trace: BindingTrace, entry: KtAnnotationEntry) {
if (impact != null && impact.isEmpty()) {
trace.report(Errors.EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT.on(entry))
}
}
private fun checkMarkerTargets(entries: List<KtAnnotationEntry>, trace: BindingTrace) {
val targetEntry =
entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) }
.entries
.firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltIns.FQ_NAMES.target }
?: return
val (entry, descriptor) = targetEntry
val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return
val wrongTargets = allowedTargets.intersect(WRONG_TARGETS_FOR_MARKER)
if (wrongTargets.isNotEmpty()) {
trace.report(
Errors.EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET.on(entry, wrongTargets.joinToString(transform = KotlinTarget::description))
)
}
}
}

View File

@@ -0,0 +1,343 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.checkers
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.AnalysisFlag
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.constants.ArrayValue
import org.jetbrains.kotlin.resolve.constants.EnumValue
import org.jetbrains.kotlin.resolve.constants.KClassValue
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.utils.SmartSet
import org.jetbrains.kotlin.utils.addIfNotNull
class ExperimentalUsageChecker(project: Project) : CallChecker {
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
internal data class Experimentality(
val markerDescriptor: ClassDescriptor,
val annotationFqName: FqName,
val severity: Severity,
val impact: List<Impact>
) {
val isCompilationOnly: Boolean get() = impact.all(Impact.COMPILATION::equals)
enum class Severity { WARNING, ERROR }
enum class Impact { COMPILATION, LINKAGE_OR_RUNTIME }
companion object {
val DEFAULT_SEVERITY = Severity.ERROR
val DEFAULT_IMPACT = listOf(Impact.COMPILATION, Impact.LINKAGE_OR_RUNTIME)
}
}
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
checkExperimental(resolvedCall.resultingDescriptor, reportOn, context, moduleAnnotationsResolver)
}
companion object {
internal val EXPERIMENTAL_FQ_NAME = FqName("kotlin.Experimental")
internal val USE_EXPERIMENTAL_FQ_NAME = FqName("kotlin.UseExperimental")
internal val USE_EXPERIMENTAL_ANNOTATION_CLASS = Name.identifier("markerClass")
private val LEVEL = Name.identifier("level")
private val WARNING_LEVEL = Name.identifier("WARNING")
private val ERROR_LEVEL = Name.identifier("ERROR")
internal val IMPACT = Name.identifier("changesMayBreak")
private val COMPILATION_IMPACT = Name.identifier("COMPILATION")
private val LINKAGE_IMPACT = Name.identifier("LINKAGE")
private val RUNTIME_IMPACT = Name.identifier("RUNTIME")
private fun checkExperimental(
descriptor: DeclarationDescriptor,
element: PsiElement,
context: CheckerContext,
moduleAnnotationsResolver: ModuleAnnotationsResolver
) {
val experimentalities = descriptor.loadExperimentalities(moduleAnnotationsResolver)
if (experimentalities.isNotEmpty()) {
checkExperimental(
experimentalities, element, context.trace.bindingContext, context.languageVersionSettings,
context.moduleDescriptor
) { experimentality, isBodyUsageOfSourceOnlyExperimentality ->
val diagnostic = when (experimentality.severity) {
Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_API_USAGE
Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_API_USAGE_ERROR
}
context.trace.report(diagnostic.on(element, experimentality.annotationFqName, isBodyUsageOfSourceOnlyExperimentality))
}
}
}
private fun checkExperimental(
experimentalities: Collection<Experimentality>,
element: PsiElement,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings,
module: ModuleDescriptor,
report: (experimentality: Experimentality, isBodyUsageOfCompilationExperimentality: Boolean) -> Unit
) {
val isBodyUsageExceptPublicInline = element.isBodyUsage(bindingContext, allowPublicInline = false)
val isBodyUsage = isBodyUsageExceptPublicInline || element.isBodyUsage(bindingContext, allowPublicInline = true)
for (experimentality in experimentalities) {
val isBodyUsageOfCompilationExperimentality =
experimentality.isCompilationOnly && isBodyUsage
val isBodyUsageInSameModule =
experimentality.markerDescriptor.module == module && isBodyUsageExceptPublicInline
val annotationFqName = experimentality.annotationFqName
val isExperimentalityAccepted =
isBodyUsageInSameModule ||
(isBodyUsageOfCompilationExperimentality &&
element.hasContainerAnnotatedWithUseExperimental(annotationFqName, bindingContext, languageVersionSettings)) ||
element.propagates(annotationFqName, bindingContext, languageVersionSettings)
if (!isExperimentalityAccepted) {
report(experimentality, isBodyUsageOfCompilationExperimentality)
}
}
}
private fun DeclarationDescriptor.loadExperimentalities(
moduleAnnotationsResolver: ModuleAnnotationsResolver
): Set<Experimentality> {
val result = SmartSet.create<Experimentality>()
for (annotation in annotations) {
result.addIfNotNull(annotation.annotationClass?.loadExperimentalityForMarkerAnnotation())
}
val container = containingDeclaration
if (container is ClassDescriptor && this !is ConstructorDescriptor) {
result.addAll(container.loadExperimentalities(moduleAnnotationsResolver))
}
for (moduleAnnotationClassId in moduleAnnotationsResolver.getAnnotationsOnContainingModule(this)) {
val annotationClass = module.findClassAcrossModuleDependencies(moduleAnnotationClassId)
result.addIfNotNull(annotationClass?.loadExperimentalityForMarkerAnnotation())
}
return result
}
internal fun ClassDescriptor.loadExperimentalityForMarkerAnnotation(): Experimentality? {
val experimental = annotations.findAnnotation(EXPERIMENTAL_FQ_NAME) ?: return null
val severity = when ((experimental.allValueArguments[LEVEL] as? EnumValue)?.enumEntryName) {
WARNING_LEVEL -> Experimentality.Severity.WARNING
ERROR_LEVEL -> Experimentality.Severity.ERROR
else -> Experimentality.DEFAULT_SEVERITY
}
val impact = (experimental.allValueArguments[IMPACT] as? ArrayValue)?.value?.mapNotNull { impact ->
when ((impact as? EnumValue)?.enumEntryName) {
COMPILATION_IMPACT -> Experimentality.Impact.COMPILATION
LINKAGE_IMPACT, RUNTIME_IMPACT -> Experimentality.Impact.LINKAGE_OR_RUNTIME
else -> null
}
} ?: Experimentality.DEFAULT_IMPACT
return Experimentality(this, fqNameSafe, severity, impact)
}
// Returns true if this element appears in the body of some function and is not visible in any non-local declaration signature.
// If that's the case, one can opt-in to using the corresponding experimental API by annotating this element (or any of its
// enclosing declarations) with @UseExperimental(X::class), not requiring propagation of the experimental annotation to the call sites.
// (Note that this is allowed only if X's impact is [COMPILATION].)
private fun PsiElement.isBodyUsage(bindingContext: BindingContext, allowPublicInline: Boolean): Boolean {
return anyParentMatches { element, parent ->
element == (parent as? KtDeclarationWithBody)?.bodyExpression?.takeIf {
allowPublicInline || !parent.isPublicInline(bindingContext)
} ||
element == (parent as? KtDeclarationWithInitializer)?.initializer ||
element == (parent as? KtClassInitializer)?.body ||
element == (parent as? KtParameter)?.defaultValue ||
element == (parent as? KtSuperTypeCallEntry)?.valueArgumentList ||
element == (parent as? KtDelegatedSuperTypeEntry)?.delegateExpression ||
element == (parent as? KtPropertyDelegate)?.expression
}
}
private fun PsiElement.isPublicInline(bindingContext: BindingContext): Boolean {
val descriptor = when (this) {
is KtFunction -> bindingContext.get(BindingContext.FUNCTION, this)
is KtPropertyAccessor -> bindingContext.get(BindingContext.PROPERTY_ACCESSOR, this)
else -> null
}
return descriptor != null && descriptor.isInline && descriptor.effectiveVisibility().let {
it == EffectiveVisibility.Public ||
it == EffectiveVisibility.ProtectedBound ||
it is EffectiveVisibility.Protected
}
}
// Checks whether any of the non-local enclosing declarations is annotated with annotationFqName, effectively requiring
// propagation for the experimental annotation to the call sites
private fun PsiElement.propagates(
annotationFqName: FqName,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
): Boolean =
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlag.experimental) ||
anyParentMatches { element, _ ->
if (element is KtDeclaration) {
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
descriptor != null && !DescriptorUtils.isLocal(descriptor) &&
descriptor.annotations.hasAnnotation(annotationFqName)
} else false
}
// Checks whether there's an element lexically above the tree, that is annotated with `@UseExperimental(X::class)`
// where annotationFqName is the FQ name of X
private fun PsiElement.hasContainerAnnotatedWithUseExperimental(
annotationFqName: FqName,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
): Boolean =
annotationFqName.asString() in languageVersionSettings.getFlag(AnalysisFlag.useExperimental) ||
anyParentMatches { element, _ ->
element is KtAnnotated && element.annotationEntries.any { entry ->
bindingContext.get(BindingContext.ANNOTATION, entry)?.isUseExperimental(annotationFqName) == true
}
}
private inline fun PsiElement.anyParentMatches(predicate: (element: PsiElement, parent: PsiElement?) -> Boolean): Boolean {
var element = this
while (true) {
val parent = element.parent
if (predicate(element, parent)) return true
element = parent ?: return false
}
}
private fun AnnotationDescriptor.isUseExperimental(annotationFqName: FqName): Boolean {
if (fqName != USE_EXPERIMENTAL_FQ_NAME) return false
val annotationClasses = allValueArguments[USE_EXPERIMENTAL_ANNOTATION_CLASS]
return annotationClasses is ArrayValue && annotationClasses.value.any { annotationClass ->
(annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor?.fqNameSafe == annotationFqName
}
}
fun checkCompilerArguments(
module: ModuleDescriptor,
languageVersionSettings: LanguageVersionSettings,
reportError: (String) -> Unit,
reportWarning: (String) -> Unit
) {
// Ideally, we should run full resolution (with all classifier usage checkers) on classifiers used in "-Xexperimental" and
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
val deprecationResolver = DeprecationResolver(LockBasedStorageManager(), languageVersionSettings)
fun checkAnnotation(fqName: String, allowNonCompilationImpact: Boolean): Boolean {
val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_NON_TRACKED_SCOPE)
val experimentality = descriptor?.loadExperimentalityForMarkerAnnotation()
val message = when {
descriptor == null ->
"Experimental API marker $fqName is unresolved. " +
"Please make sure it's present in the module dependencies"
experimentality == null ->
"Class $fqName is not an experimental API marker annotation"
!allowNonCompilationImpact && !experimentality.impact.all(Experimentality.Impact.COMPILATION::equals) ->
"Experimental API marker $fqName has impact other than COMPILATION, " +
"therefore it can't be used with -Xuse-experimental"
else -> {
for (deprecation in deprecationResolver.getDeprecations(descriptor)) {
val report = when (deprecation.deprecationLevel) {
DeprecationLevelValue.WARNING -> reportWarning
DeprecationLevelValue.ERROR, DeprecationLevelValue.HIDDEN -> reportError
}
report("Experimental API marker $fqName is deprecated" + deprecation.message?.let { ". $it" }.orEmpty())
}
return true
}
}
reportError(message)
return false
}
val validExperimental =
languageVersionSettings.getFlag(AnalysisFlag.experimental)
.filter { checkAnnotation(it, allowNonCompilationImpact = true) }
val validUseExperimental =
languageVersionSettings.getFlag(AnalysisFlag.useExperimental)
.filter { checkAnnotation(it, allowNonCompilationImpact = false) }
for (fqName in validExperimental.intersect(validUseExperimental)) {
reportError("'-Xuse-experimental=$fqName' has no effect because '-Xexperimental=$fqName' is used")
}
}
}
class ClassifierUsage(project: Project) : ClassifierUsageChecker {
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
override fun check(targetDescriptor: ClassifierDescriptor, element: PsiElement, context: ClassifierUsageCheckerContext) {
checkExperimental(targetDescriptor, element, context, moduleAnnotationsResolver)
}
}
class Overrides(project: Project) : DeclarationChecker {
private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project)
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
if (descriptor !is CallableMemberDescriptor) return
val experimentalOverridden = descriptor.overriddenDescriptors.flatMap { member ->
member.loadExperimentalities(moduleAnnotationsResolver).map { experimentality -> experimentality to member }
}.toMap()
val module = descriptor.module
for ((experimentality, member) in experimentalOverridden) {
checkExperimental(
listOf(experimentality), declaration, context.trace.bindingContext, context.languageVersionSettings, module
) { _, _ ->
val diagnostic = when (experimentality.severity) {
Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_OVERRIDE
Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_OVERRIDE_ERROR
}
val reportOn = (declaration as? KtNamedDeclaration)?.nameIdentifier ?: declaration
context.trace.report(diagnostic.on(reportOn, experimentality.annotationFqName, member.containingDeclaration))
}
}
}
}
}

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
@@ -200,10 +201,8 @@ class DeprecationResolver(
descriptor.checkSinceKotlinVersionAccessibility(languageVersionSettings)
}
fun getDeprecations(
descriptor: DeclarationDescriptor
) = deprecations(descriptor.original)
fun getDeprecations(descriptor: DeclarationDescriptor): List<Deprecation> =
deprecations(descriptor.original)
fun isDeprecatedHidden(descriptor: DeclarationDescriptor): Boolean =
getDeprecations(descriptor).any { it.deprecationLevel == HIDDEN }
@@ -301,7 +300,7 @@ class DeprecationResolver(
ProtoBuf.VersionRequirement.VersionKind.API_VERSION ->
languageVersionSettings.apiVersion
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION ->
ApiVersion.LATEST_STABLE
KotlinCompilerVersion.getVersion()?.let((ApiVersion)::parse)
else -> null
}
if (currentVersion != null && currentVersion < requiredVersion) {

View File

@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.types;
@@ -24,11 +13,13 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
import org.jetbrains.kotlin.utils.DFS;
import java.util.*;
import java.util.stream.Collectors;
import static org.jetbrains.kotlin.types.Variance.IN_VARIANCE;
import static org.jetbrains.kotlin.types.Variance.OUT_VARIANCE;
@@ -147,7 +138,23 @@ public class CommonSupertypes {
}
commonSupertypes = computeCommonRawSupertypes(merge);
}
assert !commonSupertypes.isEmpty() : commonSupertypes + " <- " + types;
if (commonSupertypes.isEmpty()) {
StringBuilder info = new StringBuilder();
for (SimpleType type : types) {
String superTypes = type.getConstructor().getSupertypes().stream()
.map(CommonSupertypes::renderTypeFully)
.collect(Collectors.joining(", "));
info
.append("Info about ").append(renderTypeFully(type)).append(": ").append('\n')
.append("- Supertypes: ").append(superTypes).append('\n')
.append("- DeclarationDescriptor class: ").append(classOfDeclarationDescriptor(type)).append('\n')
.append("- TypeConstructor class: ").append(type.getConstructor().getClass()).append('\n')
.append('\n');
}
throw new IllegalStateException("There is no common supertype for: " + types + " \n" + info.toString());
}
// constructor of the supertype -> all of its instantiations occurring as supertypes
Map.Entry<TypeConstructor, Set<SimpleType>> entry = commonSupertypes.entrySet().iterator().next();
@@ -157,6 +164,21 @@ public class CommonSupertypes {
return TypeUtils.makeNullableIfNeeded(result, nullable);
}
@NotNull
private static String renderTypeFully(@NotNull KotlinType type) {
return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type);
}
@Nullable
private static Class<?> classOfDeclarationDescriptor(@NotNull KotlinType type) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (descriptor != null) {
return descriptor.getClass();
}
return null;
}
// Raw supertypes are superclasses w/o type arguments
// @return TypeConstructor -> all instantiations of this constructor occurring as supertypes
@NotNull

View File

@@ -713,7 +713,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
@Override
public KotlinTypeInfo visitCallExpression(@NotNull KtCallExpression expression, ExpressionTypingContext context) {
CallExpressionResolver callExpressionResolver = components.callExpressionResolver;
return callExpressionResolver.getCallExpressionTypeInfo(expression, null, null, context);
return callExpressionResolver.getCallExpressionTypeInfo(expression, context);
}
@Override
@@ -939,7 +939,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
// Call must be validated with the actual, not temporary trace in order to report operator diagnostic
// Only unary assignment expressions (++, --) and +=/... must be checked, normal assignments have the proper trace
CallCheckerContext callCheckerContext =
new CallCheckerContext(context, trace, components.languageVersionSettings, components.deprecationResolver);
new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor, trace);
for (CallChecker checker : components.callCheckers) {
checker.check(resolvedCall, expression, callCheckerContext);
}
@@ -1016,7 +1016,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
@NotNull
private CallCheckerContext createCallCheckerContext(@NotNull ExpressionTypingContext context) {
return new CallCheckerContext(context, components.languageVersionSettings, components.deprecationResolver);
return new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor);
}
@Override

View File

@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils;
import org.jetbrains.kotlin.resolve.ModifierCheckerCore;
import org.jetbrains.kotlin.resolve.ModifiersChecker;
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.checkers.LambdaWithSuspendModifierCallChecker;
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
@@ -55,6 +57,7 @@ import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import static org.jetbrains.kotlin.diagnostics.Errors.*;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
@@ -663,6 +666,22 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
}
else if (labelTargetElement instanceof KtFunctionLiteral
&& Objects.equals(expression.getLabelName(), "suspend")) {
KtExpression callExpression = KtPsiUtil.getParentCallIfPresent((KtFunction) labelTargetElement);
ResolvedCall<? extends CallableDescriptor> resolvedCall =
CallUtilKt.getResolvedCall(callExpression, context.trace.getBindingContext());
if (resolvedCall != null &&
!KtPsiUtil.isLabeledFunctionLiteral((KtFunctionLiteral) labelTargetElement) &&
Objects.equals(
DescriptorUtilsKt.fqNameOrNull(resolvedCall.getResultingDescriptor()),
LambdaWithSuspendModifierCallChecker.KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
)
) {
context.trace.report(RETURN_FOR_BUILT_IN_SUSPEND.on(expression));
}
}
}
}

View File

@@ -113,7 +113,7 @@ sealed class KtLightFieldImpl<D : PsiField>(
fun lazy(
dummyDelegate: PsiField,
origin: LightMemberOriginForDeclaration,
origin: LightMemberOriginForDeclaration?,
containingClass: KtLightClass,
computeRealDelegate: () -> PsiField
): KtLightField {

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
import org.jetbrains.kotlin.asJava.classes.cannotModify
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
@@ -36,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.TypeUtils
@@ -53,12 +55,6 @@ abstract class KtLightAbstractAnnotation(parent: PsiElement, computeDelegate: ()
override fun getParameterList() = clsDelegate.parameterList
override fun canNavigate(): Boolean = super<KtLightElementBase>.canNavigate()
override fun canNavigateToSource(): Boolean = super<KtLightElementBase>.canNavigateToSource()
override fun navigate(requestFocus: Boolean) = super<KtLightElementBase>.navigate(requestFocus)
open fun fqNameMatches(fqName: String): Boolean = qualifiedName == fqName
}
@@ -174,7 +170,7 @@ class KtLightAnnotationForSourceEntry(
override fun getType(): PsiType? = delegate.type
}
inner class LightStringLiteral(
inner class LightPsiLiteral(
delegate: PsiLiteralExpression,
parent: PsiElement,
valueOrigin: AnnotationValueOrigin
@@ -201,6 +197,9 @@ class KtLightAnnotationForSourceEntry(
wrapAnnotationValue(memberValue, this, {
originalExpression.let { ktOrigin ->
when {
ktOrigin is KtCallExpression
&& memberValue is PsiAnnotation
&& isAnnotationConstructorCall(ktOrigin, memberValue) -> ktOrigin
ktOrigin is KtValueArgumentList -> ktOrigin.arguments.getOrNull(i)?.getArgumentExpression()
ktOrigin is KtCallElement -> ktOrigin.valueArguments.getOrNull(i)?.getArgumentExpression()
ktOrigin is KtCollectionLiteralExpression -> ktOrigin.getInnerExpressions().getOrNull(i)
@@ -225,7 +224,7 @@ class KtLightAnnotationForSourceEntry(
private fun wrapAnnotationValue(value: PsiAnnotationMemberValue, parent: PsiElement, ktOrigin: AnnotationValueOrigin): PsiAnnotationMemberValue =
when {
value is PsiLiteralExpression && value.value is String -> LightStringLiteral(value, parent, ktOrigin)
value is PsiLiteralExpression -> LightPsiLiteral(value, parent, ktOrigin)
value is PsiClassObjectAccessExpression -> LightClassLiteral(value, parent, ktOrigin)
value is PsiExpression -> LightExpressionValue(value, parent, ktOrigin)
value is PsiArrayInitializerMemberValue -> LightArrayInitializerValue(value, parent, ktOrigin)
@@ -256,6 +255,25 @@ class KtLightAnnotationForSourceEntry(
override fun findDeclaredAttributeValue(name: String?) = clsDelegate.findDeclaredAttributeValue(name)?.let { wrapAnnotationValue(it) }
override fun getParameterList(): PsiAnnotationParameterList = KtLightAnnotationParameterList(super.getParameterList())
inner class KtLightAnnotationParameterList(private val list: PsiAnnotationParameterList) : KtLightElementBase(this),
PsiAnnotationParameterList {
override val kotlinOrigin get() = null
override fun getAttributes(): Array<PsiNameValuePair> = list.attributes.map { KtLightPsiNameValuePair(it) }.toTypedArray()
inner class KtLightPsiNameValuePair(private val psiNameValuePair: PsiNameValuePair) : KtLightElementBase(this),
PsiNameValuePair {
override fun setValue(newValue: PsiAnnotationMemberValue): PsiAnnotationMemberValue = psiNameValuePair.setValue(newValue)
override fun getNameIdentifier(): PsiIdentifier? = psiNameValuePair.nameIdentifier
override fun getLiteralValue(): String? = (value as? PsiLiteral)?.value?.toString()
override val kotlinOrigin: KtElement? = null
override fun getValue(): PsiAnnotationMemberValue? = psiNameValuePair.value?.let { wrapAnnotationValue(it) }
}
}
override fun delete() = kotlinOrigin.delete()
override fun toString() = "@$qualifiedName"
@@ -294,12 +312,6 @@ class KtLightNonExistentAnnotation(parent: KtLightElement<*, *>) : KtLightElemen
override fun findDeclaredAttributeValue(attributeName: String?) = null
override fun getMetaData() = null
override fun getParameterList() = KtLightEmptyAnnotationParameterList(this)
override fun canNavigate(): Boolean = super<KtLightElementBase>.canNavigate()
override fun canNavigateToSource(): Boolean = super<KtLightElementBase>.canNavigateToSource()
override fun navigate(requestFocus: Boolean) = super<KtLightElementBase>.navigate(requestFocus)
}
class KtLightEmptyAnnotationParameterList(parent: PsiElement) : KtLightElementBase(parent), PsiAnnotationParameterList {
@@ -338,6 +350,9 @@ private fun KtElement.getResolvedCall(): ResolvedCall<out CallableDescriptor>? {
return this.getResolvedCall(context)
}
private fun isAnnotationConstructorCall(callExpression: KtCallExpression, psiAnnotation: PsiAnnotation) =
(callExpression.getResolvedCall()?.resultingDescriptor as? ClassConstructorDescriptor)?.constructedClass?.fqNameUnsafe?.toString() == psiAnnotation.qualifiedName
private fun PsiElement.asKtCall(): KtCallElement? = (this as? KtElement)?.getResolvedCall()?.call?.callElement as? KtCallElement
private fun psiReport(psiElement: PsiElement?): String {

View File

@@ -164,15 +164,31 @@ private val DEFAULT_IMPLS_CLASS_NAME = Name.identifier(JvmAbi.DEFAULT_IMPLS_CLAS
fun FqName.defaultImplsChild() = child(DEFAULT_IMPLS_CLASS_NAME)
@Suppress("unused")
fun KtAnnotationEntry.toLightAnnotation(): PsiAnnotation? {
fun KtElement.toLightAnnotation(): PsiAnnotation? {
val ktDeclaration = getStrictParentOfType<KtModifierList>()?.parent as? KtDeclaration ?: return null
for (lightElement in ktDeclaration.toLightElements()) {
if (lightElement !is PsiModifierListOwner) continue
lightElement.modifierList?.annotations?.firstOrNull { it is KtLightAnnotationForSourceEntry && it.kotlinOrigin == this }?.let { return it }
for (rootAnnotation in lightElement.modifierList?.annotations ?: continue) {
for (annotation in rootAnnotation.withNestedAnnotations()) {
if (annotation is KtLightAnnotationForSourceEntry && annotation.kotlinOrigin == this)
return annotation
}
}
}
return null
}
private fun PsiAnnotation.withNestedAnnotations(): Sequence<PsiAnnotation> {
fun handleValue(memberValue: PsiAnnotationMemberValue?): Sequence<PsiAnnotation> =
when (memberValue) {
is PsiArrayInitializerMemberValue ->
memberValue.initializers.asSequence().flatMap { handleValue(it) }
is PsiAnnotation -> memberValue.withNestedAnnotations()
else -> emptySequence()
}
return sequenceOf(this) + parameterList.attributes.asSequence().flatMap { handleValue(it.value) }
}
fun propertyNameByAccessor(name: String, accessor: KtLightMethod): String? {
val toRename = accessor.kotlinOrigin ?: return null
if (toRename !is KtProperty && toRename !is KtParameter) return null

View File

@@ -94,7 +94,7 @@ class TowerResolver {
name: Name
): Collection<C> = scopeTower.run(processor, AllCandidatesCollector(), false, name)
fun <C : Candidate> ImplicitScopeTower.run(
private fun <C : Candidate> ImplicitScopeTower.run(
processor: ScopeTowerProcessor<C>,
resultCollector: ResultCollector<C>,
useOrder: Boolean,

View File

@@ -7,6 +7,7 @@ where advanced options include:
-Xcoroutines={enable|warn|error}
Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
-Xeffect-system Enable experimental language feature: effect system
-Xexperimental=<fq.name> Enable and propagate usages of experimental API for marker annotation with the given fully qualified name
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
-Xmulti-platform Enable experimental language support for multi-platform projects
@@ -18,6 +19,7 @@ where advanced options include:
-Xrepeat=<count> Repeat compilation (for performance analysis)
-Xreport-output-files Report source to output files mapping
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
-Xuse-experimental=<fq.name> Enable usages of COMPILATION-affecting experimental API for marker annotation with the given fully qualified name
Advanced options are non-standard and may be changed or removed without any notice.
OK

View File

@@ -0,0 +1,8 @@
$TESTDATA_DIR$/experimentalAndUseExperimentalWithSameAnnotation.kt
-d
$TEMP_DIR$
-Xskip-runtime-version-check
-language-version
1.3
-Xexperimental=org.test.ExperimentalAPI
-Xuse-experimental=org.test.ExperimentalAPI

View File

@@ -0,0 +1,4 @@
package org.test
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
annotation class ExperimentalAPI

View File

@@ -0,0 +1,3 @@
warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features
error: '-Xuse-experimental=org.test.ExperimentalAPI' has no effect because '-Xexperimental=org.test.ExperimentalAPI' is used
COMPILATION_ERROR

View File

@@ -0,0 +1,10 @@
$TESTDATA_DIR$/experimentalDeprecated.kt
-d
$TEMP_DIR$
-Xskip-runtime-version-check
-language-version
1.3
-Xexperimental=org.test.BinaryError
-Xexperimental=org.test.BinaryHidden
-Xuse-experimental=org.test.SourceError
-Xuse-experimental=org.test.SourceHidden

View File

@@ -0,0 +1,17 @@
package org.test
@Deprecated("BinaryError", level = DeprecationLevel.ERROR)
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
annotation class BinaryError
@Deprecated("BinaryHidden", level = DeprecationLevel.HIDDEN)
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME])
annotation class BinaryHidden
@Deprecated("SourceError", level = DeprecationLevel.ERROR)
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
annotation class SourceError
@Deprecated("SourceHidden", level = DeprecationLevel.HIDDEN)
@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION])
annotation class SourceHidden

Some files were not shown because too many files have changed in this diff Show More