Compare commits

...

891 Commits

Author SHA1 Message Date
Ilya Gorbunov
6456c5fb90 Export transitively underlying test framework modules
Otherwise "This class does not have a constructor" happens when using
an aliased annotation, e.g. kotlin.test.Test aliased to org.junit.test
2020-08-28 22:38:48 +03:00
Ilya Gorbunov
9007832245 Add exports for jvm package names used in kotlin.test annotations
KT-41320
2020-08-28 22:38:47 +03:00
Steven Schäfer
b02f0f0a25 JVM IR: Fix compilation of nested inner classes 2020-08-28 20:03:19 +02:00
Steven Schäfer
02e78bcd76 JVM IR: Use package visibility for fields of captured variables 2020-08-28 20:03:19 +02:00
Roman Artemev
443269af0a [IR] Drop irProviders from stub generator 2020-08-28 18:14:05 +03:00
Roman Artemev
39808789c3 [KLIB] Fix SOE in K/N
- fixes KT-41324
2020-08-28 18:14:04 +03:00
Mikhail Zarechenskiy
23f87d413a Use initial system for completion if common one is effectively empty
Otherwise we can get unsubstituted type variables as expected types and
 then write wrong information for assertions

 #KT-41470 Fixed
2020-08-28 17:47:08 +03:00
Nick
bb18203ae6 [FIR] Various checkers performance fixes 2020-08-28 17:07:35 +03:00
Sergey Igushkin
5c88eb722d Fix transitive deps on MPP with host-specific source sets (KT-41083)
A consumer could not resolve the host-specific metadata artifact
of the transitive dependency because the transitive dependency's parent
in the platform dependencies graph did not include the dependency on it
in the variant that is chosen for host-specific source sets metadata:
the dependencies of that variant were empty.

Export the dependencies of the Kotlin/Native target in the host-specific
metadata variant as well.

Issue #KT-41083 Fixed
2020-08-28 11:09:56 +00:00
Zalim Bashorov
9097d0918c [JS BE] Support passing an array as argument of vararg in named form
#KT-38059 fixed
2020-08-28 13:14:23 +03:00
Zalim Bashorov
606232a584 [JS IR] Don't generate "import" statements for external interfaces
#KT-40964 fixed
2020-08-28 13:14:22 +03:00
Zalim Bashorov
ba846830c9 [JS IR] Support nativeGetter, nativeSetter and nativeInvoke
#KT-41081 fixed
2020-08-28 13:04:18 +03:00
Ilya Kirillov
c804319e65 FIR IDE: fix compilation on AS 2020-08-28 12:51:55 +03:00
Ilya Kirillov
36cc73602e FIR IDE: fix testdata of AbstractFirLazyResolveTest 2020-08-28 12:51:55 +03:00
Ilya Kirillov
3cd445563e FIR IDE: implement KotlinExpressionTypeProvider for FIR 2020-08-28 12:51:55 +03:00
Ilya Kirillov
fcc7db5224 FIR IDE: introduce analyseInModalWindow function 2020-08-28 12:51:23 +03:00
Ilya Kirillov
81be230541 FIR IDE: add validity assertion on analysis session access 2020-08-28 12:15:19 +03:00
Ilya Kirillov
db48884a4e FIR IDE: add check canceled check between diagnostics 2020-08-28 12:15:18 +03:00
Ilya Kirillov
95a96f32bf FIR IDE: log errors on diagnostics, not throw them 2020-08-28 12:15:17 +03:00
Ilya Kirillov
ebafd0fb51 FIR IDE: resolve ambiguity & inapplicable references 2020-08-28 12:15:16 +03:00
Ilya Kirillov
4fa2dd85b4 FIR IDE: move lazy resolve to FirLazyDeclarationResolver 2020-08-28 12:15:15 +03:00
Ilya Kirillov
8faaff00fa FIR IDE: run lazy resolve on declaration when getting phased fir 2020-08-28 12:15:14 +03:00
Ilya Kirillov
78bb1f1076 FIR IDE: fix testdata in idea-frontend-fir 2020-08-28 12:15:13 +03:00
Ilya Kirillov
30ac80a506 FIR IDE: introduce property accessor symbols 2020-08-28 12:15:13 +03:00
Ilya Kirillov
aae56cadac FIR IDE: add ModuleInfo for ide sessions as they are used for getting resolve components 2020-08-28 12:15:12 +03:00
Ilya Kirillov
bc3e98b116 FIR IDE: allow PCE between resolve phases, forbid in other cases 2020-08-28 12:15:11 +03:00
Ilya Kirillov
8363c711e6 FIR IDE: fix lazy resolve for local declarations 2020-08-28 12:15:10 +03:00
Ilya Kirillov
9d237033ad FIR IDE: minor, rename FirIdeModuleLibraryDependenciesSession to FirIdeLibrariesSession 2020-08-28 12:15:09 +03:00
Ilya Kirillov
8b782d5954 FIR IDE: fix session provider implementation as it only provides only 2 sessions 2020-08-28 12:15:07 +03:00
Ilya Kirillov
a07d3f2425 FIR IDE: minor: rename FirIdeJavaModuleBasedSession to FirIdeSourcesSession 2020-08-28 12:15:07 +03:00
Ilya Kirillov
f76b5bbf1b FIR IDE: allow KtFirPackageScope to work without providers 2020-08-28 12:15:06 +03:00
Ilya Kirillov
f4c17dadb3 FIR IDE: remove unused FirIdeModuleLibraryDependenciesSymbolProvider 2020-08-28 12:15:05 +03:00
Ilya Kirillov
a156cca02a FIR: make class FirObjectImportedCallableScope to be name aware 2020-08-28 12:15:04 +03:00
Ilya Kirillov
333213bbb9 Wizard: add descriptions for some settings 2020-08-28 11:46:55 +03:00
Ilya Kirillov
37b869ebc5 Wizard: add descriptions for settings 2020-08-28 11:46:55 +03:00
Dmitriy Novozhilov
09ed0c3e82 [FIR-TEST] Update testdata 2020-08-28 10:59:54 +03:00
Dmitriy Novozhilov
e7b5a88cbd [FIR] Remove dependency on :compiler:frontend from :compiler:fir:resolve 2020-08-28 10:59:54 +03:00
Dmitriy Novozhilov
abeb42ca20 [FIR] Don't use ProjectExtensionDescriptor in FirExtensionRegistrar 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
f09e17a5ae [FIR] Remove unused import 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
e405a02e8e [FIR] Fix contract serialization 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
eaf8af919d [FIR] Use PersistentList instead of guava's ImmutableList in SupertypeResolution 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
148e8fe76e Move FlatSignature to :compiler:resolution.common 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
64766e125c Move common inference classes to :compiler:resolution.common 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov
068d21635e [NI] Get rid of KotlinType usages in MutableConstraintStorage.kt 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
af0df35623 [NI] Get rid of FE 1.0 types in ConstraintInjector 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
ad039a28bd [NI] Get rid of left FE 1.0 types in NewConstraintSystemImpl 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
6914aba5c2 [NI] Commonize detection of @OnlyInputTypes in NewConstraintSystemImpl 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
64f0ee21c1 Get rid of FE 1.0 classes usage in ConstraintIncorporator 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
1050f7f066 Extract PostponedResolvedAtomMarker to separate file 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
1cadabb099 Extract ResolutionCandidateApplicability to separate file 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
775df6dfc3 [NI] Get rid of FE 1.0 type usages in ResultTypeResolver 2020-08-28 10:59:52 +03:00
Dmitriy Novozhilov
aae1681b76 [NI] Get rid of ResolvedAtom usage in ConstraintSystemCompletionContext 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
11e8552861 [NI] Get rid of PostponedArgumentInputTypesResolver.Context 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
970a2581a1 [NI] Extract PostponedArgumentsAnalyzerContext from PostponedArgumentsAnalyzer 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
b15f847943 [NI] Extract common parts from KotlinConstraintSystemCompleter 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
12fbb93871 [NI] Extract FE 1.0 specific part from NewCommonSuperTypeCalculator 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
b21a0213df [NI] Get rid of FE 1.0 types in AbstractTypeApproximator 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
527c5a771d [NI] Get rid of FE 1.0 types in AbstractTypeCheckerContextForConstraintSystem 2020-08-28 10:59:51 +03:00
Dmitriy Novozhilov
686c17a234 [NI] Rename NewConstraintSystem.diagnostics to errors 2020-08-28 10:59:50 +03:00
Dmitriy Novozhilov
59b2cb6393 [NI] Split KotlinCallDiagnostics and inference errors to different hierarchies 2020-08-28 10:59:50 +03:00
Dmitriy Novozhilov
fae21d4db3 Introduce frontend independent constraint positions 2020-08-28 10:59:50 +03:00
Dmitriy Novozhilov
e5e3d7cab1 Extract FE 1.0 related parts from NewConstraintSystem 2020-08-28 10:59:50 +03:00
Dmitriy Novozhilov
be1033a4a7 [FIR] Implement ConeTypeContext.createTypeWithAlternativeForIntersectionResult 2020-08-28 10:59:50 +03:00
Dmitriy Novozhilov
f247cc3165 [NI] Properly detecting suitability of candidate for builder inference
#KT-41430 Fixed
2020-08-28 10:34:18 +03:00
Sergey Bogolepov
b2d9e5be91 [kotlinx-metadata-klib] Drop dependency on descriptors
It's unneeded since all used declarations moved to
:core:compiler.common.
2020-08-28 12:33:46 +07:00
Simon Ogorodnik
7170a23f63 [FIR] Use coroutine intrinsics in tower resolver manager
To remove SafeContinuation overhead
2020-08-28 00:12:17 +03:00
Simon Ogorodnik
7cb5c0a6d8 [FIR] Cleanup hides members condition 2020-08-28 00:12:17 +03:00
Simon Ogorodnik
bf2e17b133 [FIR] Extract invoke processing from TowerLevelHandler 2020-08-28 00:12:17 +03:00
Simon Ogorodnik
96f100381a Use proper manifest for kotlin-reflect in jps build 2020-08-28 00:12:17 +03:00
Simon Ogorodnik
34f5cfbf96 [FIR] Fix integer approximation on safe calls 2020-08-28 00:12:17 +03:00
Simon Ogorodnik
2a4e1a0b99 [FIR] Clarify testData for invokes 2020-08-28 00:12:16 +03:00
Alexander Udalov
74c6d2b951 Do not generate non-standard compareTo as primitive comparison in all backends
Previous changes related to this in the old JVM backend were in
582b1c5e66 and
0482f7e9c5, but they did not affect the
`ProperIeee754Comparisons` mode which became the default in 1.4.0. As a
result, we had a regression here.

Since the `PRIMITIVE_NUMERIC_COMPARISON_INFO` slice is used in psi2ir to
determine how to generate the comparison, this fixes the regression both
in the old JVM backend, and in all IR backends.

 #KT-41426 Fixed
2020-08-27 19:00:11 +02:00
Alexander Udalov
9d81e50128 IR: undeprecate IrUninitializedType
It's no longer a temporary hack, see the comment.
2020-08-27 18:02:04 +02:00
Dmitry Savvinov
5649cbc2e1 Wire KotlinTypeRefiner in areCallableDescriptorsEquivalent
See the issue for details

^KT-41218 Fixed
2020-08-27 18:50:42 +03:00
Dmitry Savvinov
421efaa565 Add test for overload resoultion ambiguity in HMPP
The behaviour is undesired, see the next commit for fix

^KT-41218 In Progress
2020-08-27 18:50:42 +03:00
Dmitry Savvinov
68d931969d Minor: explicitly opt-in for diagnostics messages in MultiplatformAnalysisTests 2020-08-27 18:50:42 +03:00
Dmitriy Novozhilov
9cde42e2bc [NI] Fix shouldRunCompletion for builder inference session
#KT-41308 Fixed
#KT-41363
2020-08-27 16:51:12 +03:00
Dmitriy Novozhilov
e98cbf81cf [NI] Don't always complete builder inference lambda in FULL mode
#KT-41164 Fixed
2020-08-27 16:51:11 +03:00
vldf
6a15e0410f [FIR] Fix CLI tests to prevent non-relevant errors from appearing 2020-08-27 16:07:04 +03:00
vldf
6c2ece9a6e Rename: FirSourceElement.getChildren() -> getChild() + minor fixes 2020-08-27 16:07:04 +03:00
vldf
bf363e8f1a [FIR] Update/add extended checker tests 2020-08-27 16:07:04 +03:00
Oleg Ivanov
acbb67f851 [FIR] Fix collectDataForNode backward traverse 2020-08-27 16:07:03 +03:00
vldf
f9c7cce11d [FIR] Add some helper functions for checkers 2020-08-27 16:07:03 +03:00
vldf
96f24a43be [FIR] Introduce unused variable extended checker 2020-08-27 16:07:03 +03:00
vldf
e718f60833 [FIR] Refactoring extended checkers 2020-08-27 16:07:03 +03:00
vldf
aefb7dc10f [FIR] Add checkerContext parameter to ControlFlowAnalyserCheckers 2020-08-27 16:07:03 +03:00
vldf
14eaa113e0 [FIR] Add new errors for extended checkers (around unused variable) 2020-08-27 16:07:03 +03:00
vldf
58c5d3a6ca [FIR] Fix destructuring declaration creation via light tree 2020-08-27 16:07:03 +03:00
vldf
3428a5434b [FIR] Add methods to access child/children of FirSourceElement 2020-08-27 16:07:02 +03:00
vldf
5e0dc53295 [FIR] Refactor CanBeValChecker 2020-08-27 16:07:02 +03:00
Andrei Klunnyi
5cf76aa950 KT-41425 Project can not be launched with Gradle runner
93a82060 introduced support of "delegate to Gradle" for Gradle-Kotlin.
This commit fixes an issue known as "Could not get unknown property
'sourceSets' for root project".
2020-08-27 14:50:40 +02:00
Nikolay Krasko
f57f920dc0 Mark IdeReplExecutionTest.testOnePlusOne as flaky
Was previously muted on TC.
2020-08-27 14:08:48 +03:00
Nikolay Krasko
866666f3ff Update test data for MultiModuleHighlightingTest.testLanguageVersionsViaFacets
Remove `Reference is not resolved to anything` markers
2020-08-27 14:08:48 +03:00
Nikolay Krasko
4b937f0929 Mute stable CompilerDaemonTest.testParallelDaemonStart
It was previously muted on TC.
2020-08-27 14:08:48 +03:00
Dmitry Gridin
0c0b394cc2 [formatter] fix performance issue
^KT-41314 Fixed
2020-08-27 11:04:34 +00:00
Ilya Goncharov
9818321b46 [JS, Wizard] Use react template in full stack
^KT-41417 fixed
2020-08-27 13:35:17 +03:00
Ilya Goncharov
cd0bdc190b [JS, Wizard] Use IR in gradle.properties and otherwise use as a param
^KT-41418 fixed
2020-08-27 13:34:46 +03:00
Ilya Goncharov
13bf15b403 [JS, Wizard] Set js compiler per module
^KT-41418 fixed
2020-08-27 13:34:46 +03:00
Ilya Kirillov
f824f03fa2 Wizard: fix filtering values in DropDownComponent 2020-08-27 13:34:46 +03:00
Ilya Goncharov
98f98d5856 [JS, Wizard] Add different compilers for JS wizard
^KT-41418 fixed
2020-08-27 13:34:46 +03:00
Ilya Goncharov
c797f3044e [JS, Wizard] Add react template plugin
^KT-41417 fixed
2020-08-27 13:34:45 +03:00
Ilya Goncharov
220ff6c648 [JS, Wizard] Add redux and react router
^KT-41417 fixed
2020-08-27 13:34:30 +03:00
Ilya Goncharov
d5340803bd [JS, Wizard] Add react application template
^KT-41417 fixed
2020-08-27 13:34:15 +03:00
Ilya Goncharov
01064a4e46 [JS, Wizard] Add react application template
^KT-41417 fixed
2020-08-27 13:33:50 +03:00
Ilya Goncharov
96e1b1c0e0 [JS, Wizard] Separate browser application without react
^KT-41417 fixed
2020-08-27 13:33:34 +03:00
Ilya Goncharov
491eb5e366 [JS, Wizard] Move subtarget settings in separate object
^KT-41417 fixed
2020-08-27 13:33:15 +03:00
Ilya Goncharov
94f8a78893 [JS, Wizard] Fix source set name for js wizard
^KT-41417 fixed
2020-08-27 13:30:37 +03:00
Mikhail Zarechenskiy
cba13c3c35 Take into account captured types with variables during fixation
#KT-41202 Fixed
2020-08-27 11:06:14 +03:00
Dmitry Gridin
5dbb6fdf50 [inspections] NamingConversion: add missing space in description
^KT-41395 Fixed
2020-08-27 14:58:33 +07:00
Yunir Salimzyanov
e12c35de5f Traverse all pages of muted tests on Teamcity (KTI-326)
incomplete list of remotely muted tests was causing re-muting of tests
that were not fetched
2020-08-26 19:37:11 +03:00
Mikhail Zarechenskiy
06a592c018 Fix SOE when recursive type argument is used with star projection
#KT-41043 Fixed
2020-08-26 19:23:21 +03:00
Mikhail Zarechenskiy
674e9e455f Fold lower constraints like (T!!..T) and (T..T?) into the latter one
#KT-41149 Fixed
2020-08-26 19:23:20 +03:00
Mikhail Zarechenskiy
e91b378b7d Don't perform unnecessary SAM conversions
#KT-41149 In Progress
2020-08-26 19:23:19 +03:00
Mikhail Zarechenskiy
6a7ed96be5 Consider T <: Nothing! as trivial during constraint incorporation
#KT-41149 In Progress
2020-08-26 19:23:18 +03:00
Mikhail Zarechenskiy
567e6ca9ca Fix OOM when there are several lambdas with extension function types
#KT-41335 Fixed
2020-08-26 19:23:18 +03:00
Jinseong Jeon
085e0dc1de FIR2IR: allow array expression as named argument for vararg 2020-08-26 18:01:21 +03:00
Vladimir Dolzhenko
54d3c5fb0a Pick up script language level from used stdlib in a gradle's classpath
^KT-41283 Fixed
2020-08-26 14:09:58 +00:00
Ilya Kirillov
949c67078d NJ2K: fix testdata of MultiFileTestGenerated.testNullabilityByDFa 2020-08-26 16:17:24 +03:00
Ilya Kirillov
c8ab827fa0 Wizard: fix invalid path in generated buildscript on windows 2020-08-26 16:17:24 +03:00
Nicolay Mitropolsky
c93ae64546 Uast: KotlinClassViaConstructorUSimpleReferenceExpression resolve to PsiClass (KT-41290) 2020-08-26 16:13:13 +03:00
Vladimir Dolzhenko
99924ea5e4 Fix Typo: equals() & hashCode(), toString() are written with the first uppercase letter
^KT-41390 Fixed
2020-08-26 14:59:31 +02:00
Jinseong Jeon
553ae68c96 FIR2IR: convert adapted callable reference with vararg 2020-08-26 14:26:19 +03:00
Igor Yakovlev
48034092e9 Fix SOE on library source based lightclass lookup
Fixed KT-41325
2020-08-26 12:10:09 +03:00
Jinseong Jeon
99286a6ce3 FIR2IR: introduce & use ClassId-based lookup for local class as IrParent 2020-08-26 10:08:16 +03:00
Aurimas Liutikas
777b16e0a3 Fix @Language injection when using named parameters
Start using names of arguments if they are available when fetching
the @Language injection information.

Fixes KT-35859
2020-08-25 23:02:53 +03:00
Alexander Udalov
a9ddf02556 Replace deprecated usages of max/min with maxOrNull/minOrNull 2020-08-25 20:33:59 +02:00
Nikolay Krasko
81dda96ece Mute flaky KotlinFindUsagesWithLibraryTestGenerated.KotlinLibrary 2020-08-25 21:31:11 +03:00
Nikolay Krasko
3a1158b4ef Minor: move mute KotlinFindUsagesWithLibraryTestGenerated to common 2020-08-25 21:31:11 +03:00
Nikolay Krasko
125819f9bf Mute flaky testUsingReadOnlyInterfaces test 2020-08-25 21:31:10 +03:00
Nikolay Krasko
1928390121 Prevent flaky behaviour from MakeOverriddenMemberOpenFix in tests
Several quick fix tests are flaky thanks to MakeOverrideMemberOpenFix
class. Flakiness is probably caused by `myQuickFixInfo: QuickFixInfo`
field. When there's no memory pressure, there's no resolve in dispatch
thread, but value may be invalidated because of soft reference usage
and re-evaluating might cause the test failure.

Caused by: org.jetbrains.kotlin.idea.caches.resolve.KotlinIdeaResolutionException: Kotlin resolution encountered a problem while analyzing KtNamedFunction
  at org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacadeWithDebugInfo.analyze(ResolutionFacadeWithDebugInfo.kt:44)
  at org.jetbrains.kotlin.idea.caches.resolve.ExtendedResolutionApiKt.analyze(extendedResolutionApi.kt:97)
  at org.jetbrains.kotlin.idea.caches.resolve.ExtendedResolutionApiKt.resolveToDescriptorIfAny(extendedResolutionApi.kt:39)
  at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.resolveToDescriptorIfAny(resolutionApi.kt:60)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix.computeInfo(MakeOverriddenMemberOpenFix.kt:54)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix.access$computeInfo(MakeOverriddenMemberOpenFix.kt:38)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix$myQuickFixInfo$2.invoke(MakeOverriddenMemberOpenFix.kt:41)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix$myQuickFixInfo$2.invoke(MakeOverriddenMemberOpenFix.kt:38)
  at org.jetbrains.kotlin.idea.core.util.CachedValueHelpersKt$sam$com_intellij_psi_util_CachedValueProvider$0.compute(CachedValueHelpers.kt)
  at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
  at com.intellij.util.CachedValueBase.lambda$getValueWithLock$0(CachedValueBase.java:228)
  at com.intellij.util.IdempotenceChecker.applyForRandomCheck(IdempotenceChecker.java:336)
  at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
  at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
  at org.jetbrains.kotlin.idea.core.util.CachedValueHelpersKt.getValue(CachedValueHelpers.kt:25)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix.getMyQuickFixInfo(MakeOverriddenMemberOpenFix.kt)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix.getContainingDeclarationsNames(MakeOverriddenMemberOpenFix.kt:45)
  at org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix.getText(MakeOverriddenMemberOpenFix.kt:89)
  at com.intellij.codeInsight.intention.impl.IntentionActionWithTextCaching$MyIntentionAction.getText(IntentionActionWithTextCaching.java:165)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$invokeIntention$52(CodeInsightTestFixtureImpl.java:1933)
  at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
  at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
  at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:322)
  at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
  at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:132)
  at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
  at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:188)
  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
  at java.awt.EventQueue.access$500(EventQueue.java:97)
  at java.awt.EventQueue$3.run(EventQueue.java:709)
  at java.awt.EventQueue$3.run(EventQueue.java:703)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
  at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:965)
  at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
  at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:449)
  at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:733)
  at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
  at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
  at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
  at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at com.intellij.util.ui.UIUtil.dispatchAllInvocationEvents(UIUtil.java:1738)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$invokeIntention$53(CodeInsightTestFixtureImpl.java:1939)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.withReadOnlyFile(CodeInsightTestFixtureImpl.java:1960)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.invokeIntention(CodeInsightTestFixtureImpl.java:1929)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$launchAction$14(CodeInsightTestFixtureImpl.java:680)
  at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
  at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
  at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:44)
  at com.intellij.testFramework.EdtTestUtil$Companion.runInEdtAndWait(EdtTestUtil.kt:18)
  at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.kt)
  at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.launchAction(CodeInsightTestFixtureImpl.java:680)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$applyAction$stubComparisonFailure$1.invoke(AbstractQuickFixTest.kt:176)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$applyAction$stubComparisonFailure$1.invoke(AbstractQuickFixTest.kt:34)
  at org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadManager.runWithForceCheckForResolveInDispatchThreadInTests$idea_core(ResolveInDispatchThreadManager.kt:115)
  at org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadManagerKt.forceCheckForResolveInDispatchThreadInTests(ResolveInDispatchThreadManager.kt:40)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest.applyAction(AbstractQuickFixTest.kt:175)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest.access$applyAction(AbstractQuickFixTest.kt:34)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$doKotlinQuickFixTest$1.run(AbstractQuickFixTest.kt:125)
  at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)
  at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:177)
  at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:167)
  at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:153)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest.doKotlinQuickFixTest(AbstractQuickFixTest.kt:96)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest.access$doKotlinQuickFixTest(AbstractQuickFixTest.kt:34)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$doTest$1.invoke(AbstractQuickFixTest.kt:60)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$doTest$1.invoke(AbstractQuickFixTest.kt:34)
  at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseKt.withCustomCompilerOptions(KotlinLightCodeInsightFixtureTestCase.kt:253)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest.doTest(AbstractQuickFixTest.kt:55)
  at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$testWithCustomIgnoreDirective$6(KotlinTestUtils.java:803)
  at org.jetbrains.kotlin.test.MuteWithFileKt$testWithMuteInFile$1.invoke(muteWithFile.kt:41)
  at org.jetbrains.kotlin.test.KotlinTestUtils.runTestImpl(KotlinTestUtils.java:773)
  at org.jetbrains.kotlin.test.KotlinTestUtils.runTest(KotlinTestUtils.java:716)
  at org.jetbrains.kotlin.idea.quickfix.QuickFixTestGenerated$Override.runTest(QuickFixTestGenerated.java:10025)
  at org.jetbrains.kotlin.idea.quickfix.QuickFixTestGenerated$Override.testOverridingDelegatedMethod(QuickFixTestGenerated.java:10074)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at junit.framework.TestCase.runTest(TestCase.java:176)
  at com.intellij.testFramework.UsefulTestCase.lambda$runTest$9(UsefulTestCase.java:327)
  at com.intellij.testFramework.UsefulTestCase.lambda$invokeTestRunnable$10(UsefulTestCase.java:364)
  at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:44)
  at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:363)
  at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:346)
  at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase.lambda$runTest$0(KotlinLightCodeInsightFixtureTestCaseBase.java:92)
  at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestWithThrowable$4(KotlinTestUtils.java:726)
  ... 36 more
Caused by: org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadException: Resolve is not allowed under the write action for `org.jetbrains.kotlin.idea.quickfix.MakeOverriddenMemberOpenFix`!
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$applyAction$writeActionResolveHandler$1.invoke(AbstractQuickFixTest.kt:170)
  at org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest$applyAction$writeActionResolveHandler$1.invoke(AbstractQuickFixTest.kt:34)
  at org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadManager.assertNoResolveInDispatchThread$idea_core(ResolveInDispatchThreadManager.kt:73)
  at org.jetbrains.kotlin.idea.caches.resolve.ModuleResolutionFacadeImpl.analyze(ModuleResolutionFacadeImpl.kt:60)
  at org.jetbrains.kotlin.idea.caches.resolve.ModuleResolutionFacadeImpl.analyze(ModuleResolutionFacadeImpl.kt:56)
  at org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacadeWithDebugInfo.analyze(ResolutionFacadeWithDebugInfo.kt:45)
  ... 126 more
2020-08-25 21:31:10 +03:00
Mikhail Glukhikh
5702fb3b22 FIR: fix CCE in AttributeArrayOwner 2020-08-25 19:29:59 +03:00
Mikhail Glukhikh
962059a878 Introduce FirProperty.hasBackingField & use it in FIR2IR 2020-08-25 19:29:58 +03:00
Mikhail Glukhikh
c6417696cf FirProperty: return back 'isReferredViaField' attribute 2020-08-25 19:29:58 +03:00
Jinseong Jeon
3e9ac75cfc FIR: record use of backing field symbol to indeed add a backing field 2020-08-25 19:29:58 +03:00
Vyacheslav Gerasimov
0cc3762f9a Build: Fix kotlinx-metadata-klib publication 2020-08-25 17:18:00 +03:00
vldf
36f2f1fcf7 [FIR] Add lightTree support to extended checkers + minor refactorings 2020-08-25 17:08:57 +03:00
vldf
da702992d9 [FIR] Fix null source on destructuring declaration 2020-08-25 16:33:49 +03:00
Ilya Matveev
30d24ed943 Tests, Gradle: Fix broken test for KT-40834 2020-08-25 13:06:40 +00:00
Ilya Matveev
920f1184bd Revert "Revert "CocoaPods: Skip synthetic task on non-mac hosts""
This reverts commit 6040491373.
2020-08-25 13:06:39 +00:00
Nick
fd9bfe44f1 [FIR] Visit class annotations without the class's scope 2020-08-25 15:59:33 +03:00
vldf
3cad88a58c [FIR] Fir Helpers hotfix 2020-08-25 14:49:56 +03:00
vldF
cb627952b2 [FIR] Checkers performance improvement
[FIR] Checkers performance improvement
2020-08-25 14:20:30 +03:00
Ilya Goncharov
d86c81cb38 [JS, Gradle] Fix test on overflow, now throw exception on overflow 2020-08-25 13:44:20 +03:00
Arsen Nagdalian
8b4e8a2c0c Diagnostics: add diagnostic for reporting contract description blocks in old frontend 2020-08-25 12:58:39 +03:00
Arsen Nagdalian
80d7f6b688 Ignore the "contract" keyword in code completion 2020-08-25 12:58:39 +03:00
Arsen Nagdalian
ede1c08a9b [FIR] Add resolution of contracts that are written using the new syntax 2020-08-25 12:58:39 +03:00
Arsen Nagdalian
b8b60864fd [FIR] Add contracts tests and place them in a separate directory 2020-08-25 12:58:39 +03:00
Arsen Nagdalian
86e07cd626 Parser tests: move the contract description blocks tests to a separate folder and add a test for property accessors' contracts 2020-08-25 12:58:38 +03:00
Arsen Nagdalian
66f7250380 [FIR] Add contract description blocks support to "lightTree2FIR" conversion 2020-08-25 12:58:38 +03:00
Arsen Nagdalian
9fd104eec8 [FIR] Add contract description blocks support to RawFirBuilder 2020-08-25 12:58:38 +03:00
Arsen Nagdalian
d53f3b9ba8 [PSI] Add some useful getters to psi nodes 2020-08-25 12:58:37 +03:00
Arsen Nagdalian
a936c6331a [Parser] Add getters' and setters' contracts parsing 2020-08-25 12:58:37 +03:00
Arsen Nagdalian
6c06008b4d [FIR] Add a class representing the old syntax contract description in order to use the previous class for the new syntax 2020-08-25 12:58:37 +03:00
Arsen Nagdalian
b83aa88eff [FIR] Add function for getting ConeEffectDeclaration from FirEffectDeclaration and use it where needed 2020-08-25 12:58:35 +03:00
Arsen Nagdalian
991b18fec4 [FIR] Add a Fir node that wraps a ConeEffectDeclaration 2020-08-25 12:58:35 +03:00
Arsen Nagdalian
32a64b888e [Parser] Add parsing of function's contract either before or after type constraints 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
1b57889773 Clean the code 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
f781a9993b Parser tests: add tests for contract description blocks 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
2e9a898f45 [Parser] Move function's contracts parsing in before type constraints parsing 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
0990434840 [Parser] Modify parser so that it could parse contract description blocks of functions 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
e3fe9c3314 [PSI] Add new Psi nodes representing contract effects list and each individual contract effect in the list 2020-08-25 12:58:34 +03:00
Arsen Nagdalian
4b7d34b537 Add "contract" keyword 2020-08-25 12:58:34 +03:00
Dmitriy Novozhilov
316e0e6609 [FIR] Update testdata 2020-08-25 12:07:59 +03:00
Dmitriy Novozhilov
3ccb72bb1a Shadow :core:compiler.common inside kotlinx.metadata 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
811a2206a5 Fix usages of KotlinBuiltIns after rebase 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
bc1b6d3588 Rename :core:descriptors.common to :core:compiler.common 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
864cf21f03 Merge :core:type-system into :core:descriptors.common 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
5fa80a2f8c Merge :core:deserialization:deserialization.common into :core:descriptors.common 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
bbac270b33 Move OperatorNameConventions to :core.descriptors.common 2020-08-25 10:41:34 +03:00
Dmitriy Novozhilov
2760a187a9 Move FunctionClassKind utils to :core.descriptors.common 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov
2285d3e3cf Move Variance and AnnotationUseSiteTarget to :core.descriptors.common 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov
167f18b738 Move SourceElement and SourceFile to :deserialization.common
Remove dependency on `:core:descriptors` from `:core:deserialization:deserialization.common`
2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov
a764732020 Rename KotlinBuiltInsNames to StandardNames 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov
d032fdfc44 [FIR] Cleanup dependencies in :compiler:fir:raw-fir modules 2020-08-25 10:41:33 +03:00
Dmitriy Novozhilov
b6fd6c3a84 [FIR] Remove dependency on descriptors from :compiler:fir:raw-fir.raw-fir.common module 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
71a517c686 [FIR] Rename :compiler:fir:raw-fir:fir-common to :compiler:fir:raw-fir:raw-fir.common 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
7d4349edc2 [FIR] Remove dependency on descriptors from :compiler:fir:tree module 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
95346f834b [FIR] Fix forgotten dependency to contracts of FE 1.0 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
73ace6d161 Remove dependency to descriptors from :compiler:config module 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
82a9b1492b Move RenderingUtils to :core:descriptors.common module 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
ba6b1c37d0 Move TargetPlatform to :core:descriptors.common module 2020-08-25 10:41:32 +03:00
Dmitriy Novozhilov
d6d2be8e58 Move incremental components to :core:descriptors.common module 2020-08-25 10:41:31 +03:00
Dmitriy Novozhilov
3a48265077 Move ModuleDescriptor.Capability to :core:descriptors.common module 2020-08-25 10:31:37 +03:00
Dmitriy Novozhilov
6f0cd14afa Move common classes to new :core:deserialization:deserialization.common module 2020-08-25 10:31:37 +03:00
Dmitriy Novozhilov
079a2dfe1e Move EventOccurrencesRange class to :core:descriptors.common module 2020-08-25 10:31:37 +03:00
Dmitriy Novozhilov
f7f489537b [FIR] Remove dependency on :core:descriptors from :compiler:fir:tree 2020-08-25 10:31:37 +03:00
Dmitriy Novozhilov
e92caae609 [FIR] Remove dependency on :core:descriptors from :compiler:fir:cones 2020-08-25 10:31:36 +03:00
Dmitriy Novozhilov
45cf221b97 Move util functions from KotlinBuiltIns to :core:descriptors.common module 2020-08-25 10:31:36 +03:00
Dmitriy Novozhilov
20a2ad8223 Move FunctionClassDescriptor.Kind to :core:descriptors.common module 2020-08-25 10:31:36 +03:00
Dmitriy Novozhilov
7a7fe77b8e Move static constants with builtin names to :core:descriptors.common module 2020-08-25 10:31:36 +03:00
Dmitriy Novozhilov
2e92fe9be9 [FIR2IR] Add fir2ir component for converting fir visibility to FE 1.0 2020-08-25 10:31:36 +03:00
Dmitriy Novozhilov
a02109d857 [FIR] Add FirVisibilityChecker session component
This is needed because we have different visibility rules for different
  platform visibilities (e.g. protected and package private on JVM), so
  we need ability to configure visibility checks for different platforms
2020-08-25 10:31:35 +03:00
Dmitriy Novozhilov
18ae593700 [FIR] Rename new visibilities to CamelCase
It's more convenient since they are objects now instead of
  const fields in FE 1.0
2020-08-25 10:31:35 +03:00
Dmitriy Novozhilov
43821b681c [FIR] Introduce new Visibility class which not depends on descriptors 2020-08-25 10:31:35 +03:00
Dmitriy Novozhilov
9d9f9c52c0 Extract some classes from descriptors module to :core:common
This is needed to remove dependencies from fir modules to
  `:core:descriptors` module

What was extracted:
- Modality
- ClassKind
- org.jetbrains.kotlin.name package
2020-08-25 10:31:35 +03:00
Dmitriy Novozhilov
41ba9b0a2d [FIR] Add flag to disable transformers required only for plugins 2020-08-25 10:31:34 +03:00
Mikhail Glukhikh
53ad502d2a [FIR2IR] Generate fake overrides earlier and bind them later
Before this commit, we generated fake overrides at last FIR2IR stage,
after having all functions and classes built. This could lead to a
situation when fake override was called before it was generated.
This commit fixes this situation.
2020-08-25 10:00:26 +03:00
Ilya Chernikov
ee9c597767 Build: Remove exclusion of kotlinx-coroutines-core in scripting-compiler
The previous fix was insufficient to fix gradle substitution in MPP
projects (https://github.com/gradle/gradle/issues/14017)
2020-08-24 19:13:16 +02:00
Nikolay Krasko
741f5de0f9 Clean PSI elements in KotlinExpressionMover
Fix report about leaked projects on build server:

via 'com.intellij.psi.impl.PsiManagerImpl.myProject'; Value: 'Project (name=light_temp, containerState=DISPOSE_COMPLETED, componentStore=/mnt/agent/temp/buildTmp/ideaProject_test_1285163057398451250/testRootGW1/unitTest_addPrimaryConstructorParameter/light_temp....' of class com.intellij.openapi.project.impl.ProjectImpl
      via 'com.intellij.psi.impl.source.PsiFileImpl.myManager'; Value: 'com.intellij.psi.impl.PsiManagerImpl@4ecdfe8' of class com.intellij.psi.impl.PsiManagerImpl
      via 'com.intellij.psi.impl.source.tree.CompositeElement.myWrapper'; Value: 'DummyHolder' of class com.intellij.psi.impl.source.JavaDummyHolder
      via 'com.intellij.psi.impl.source.tree.TreeElement.myParent'; Value: 'Element(DUMMY_HOLDER)' of class com.intellij.psi.impl.source.tree.FileElement
      via 'com.intellij.psi.impl.source.SubstrateRef$2.val$node'; Value: 'Element(VALUE_PARAMETER)' of class com.intellij.psi.impl.source.tree.CompositeElement
      via 'com.intellij.extapi.psi.StubBasedPsiElementBase.mySubstrateRef'; Value: 'com.intellij.psi.impl.source.SubstrateRef$2@5d02fa19' of class com.intellij.psi.impl.source.SubstrateRef$2
      via 'kotlin.Pair.first'; Value: 'VALUE_PARAMETER' of class org.jetbrains.kotlin.psi.KtParameter
      via 'org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover.parametersOrArgsToMove'; Value: '(VALUE_PARAMETER, VALUE_PARAMETER)' of class kotlin.Pair
      via '?'; Value: 'org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover@7a6f128e' of class org.jetbrains.kotlin.idea.codeInsight.upDownMover.KotlinExpressionMover
      via 'com.intellij.openapi.extensions.impl.ExtensionPointImpl.myExtensionsCacheAsArray'; Value: '[Lcom.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;@276493b6' of class [Lcom.intellij.codeInsight.editorActions.moveUpDown.StatementUpDownMover;
      via 'java.util.concurrent.ConcurrentHashMap$Node.val'; Value: 'com.intellij.statementUpDownMover' of class com.intellij.openapi.extensions.impl.InterfaceExtensionPoint
      via '?'; Value: 'com.intellij.statementUpDownMover=com.intellij.statementUpDownMover' of class java.util.concurrent.ConcurrentHashMap$Node
      via 'java.util.concurrent.ConcurrentHashMap.table'; Value: '[Ljava.util.concurrent.ConcurrentHashMap$Node;@724e0cae' of class [Ljava.util.concurrent.ConcurrentHashMap$Node;
      via 'com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.extensionPoints'; Value: '{com.intellij.embeddedTokenHighlighter=com.intellij.embeddedTokenHighlighter, org.intellij.groovy.expectedTypesContributor=org.intellij.groovy.expectedTypesContributor, org.jetbrains.kotlin.resolveSco...' of class java.util.concurrent.ConcurrentHashMap
      via 'com.intellij.serviceContainer.ComponentManagerImpl.extensionArea'; Value: 'Application (containerState=ACTIVE)  (Unit test) (Internal) (Headless) (Command line)' of class com.intellij.openapi.extensions.impl.ExtensionsAreaImpl
      via '?'; Value: 'Application (containerState=ACTIVE)  (Unit test) (Internal) (Headless) (Command line)' of class com.intellij.openapi.application.impl.ApplicationImpl
       (from ApplicationManager.getApplication())
2020-08-24 19:03:03 +03:00
Nikolay Krasko
18195b3296 Rewrite SmartCompletionMultifileHandlerTest to KotlinFixtureCompletionBaseTestCase
Use light projects as an attempt to fight leaking project errors
2020-08-24 19:03:03 +03:00
Nikolay Krasko
e95c3e2905 Rewrite CompletionMultiFileHandlerTest to KotlinFixtureCompletionBaseTestCase
Use light projects as an attempt to fight leaking project errors
2020-08-24 19:03:03 +03:00
Ilya Goncharov
f92083989a [JS, Wizard] Fix build integrity 2020-08-24 19:01:38 +03:00
Nikolay Krasko
6040491373 Revert "CocoaPods: Skip synthetic task on non-mac hosts"
This reverts commit ce029822
2020-08-24 18:31:32 +03:00
Ilya Goncharov
621c87ee84 Overflowed teamcity messages should failed build
^KT-41133 fixed
2020-08-24 18:22:22 +03:00
Nick
e7b12b9bb1 [FIR] Fix false positive SUPER_NOT_AVAILABLE 2020-08-24 17:23:32 +03:00
Dmitry Petrov
a2dabe11c5 JVM KT-41150: Fix backward compatibility for inline vals in inline class
In 1.3.x, for inline class member inline vals 'getFoo-impl' method was
generated in corresponding inline class.
Since 1.4.0, getters for properties returning inline class values are
mangled (so corresponding getters are named 'getFoo-<mangling_hash>'.
However, to maintain backward compatibility with libraries compiled with
1.3.x, inliner should be able to find 'getFoo-impl' method in the
bytecode.
2020-08-24 16:17:12 +03:00
Vladimir Ilmov
27a22fc1e9 Cleanup Coroutine panel in case connection gets disposed soon after
creation.
2020-08-24 15:09:14 +02:00
Vladimir Ilmov
cb2ab4676b (CoroutineDebugger) Top node added to prevent dumpCoroutine() call
Panel gather information from the agent on each breakpoint hit.
2020-08-24 15:09:13 +02:00
Alexander Udalov
fa45650fd0 JVM IR: specialize ExpressionCodegen.visitFunctionAccess for constructors
This makes the code a bit clearer, and gets rid of some extra type
mapper invocations when generating constructor calls.
2020-08-24 14:51:52 +02:00
Ilya Kirillov
f9bd935ac6 Wizard: fix missing module templates 2020-08-24 15:48:02 +03:00
Kirill Shmakov
5a91dd0439 Update main wizard tests 2020-08-24 15:43:08 +03:00
Kirill Shmakov
147a8c357d Wizard: switch androidx.core -> android.material 2020-08-24 15:43:08 +03:00
Kirill Shmakov
57e9e9a2a1 Wizard: add android.useAndroidX property 2020-08-24 15:43:07 +03:00
Kirill Shmakov
9e88d61be4 Wizard: switch android:allowBackup
Otherwise template could leak sensitive data.
2020-08-24 15:43:06 +03:00
Kirill Shmakov
94ae839d2c Wizard: update Android Appcompat version 2020-08-24 15:43:03 +03:00
Kirill Shmakov
06f9a4e228 Wizard: update Android Gradle plugin version 2020-08-24 15:43:02 +03:00
Roman Artemev
a095909d5c [Plugin API] Provide special context in EP for link-time resolve
- requires to customize declarations from synthetic declarations
2020-08-24 15:37:39 +03:00
Steven Schäfer
ea98062241 JVM IR: Fix compilation of inline functions in anonymous objects...
...in class members. The corresponding classes end up nested in the
class initializer of the surrounding class and we need to take this into
account when creating instances of ClassCodegen.

This fixes KT-40332 on the JVM IR backend.
2020-08-24 14:10:36 +02:00
Ilya Matveev
ce02982226 CocoaPods: Skip synthetic task on non-mac hosts
This patch performs the following changes:

1. Create synthetic tasks even if synthetic projects are
not supported on the current host. This change simplifies
configuring dependencies between these tasks and custom user
tasks at the user side.

2. Disable synthetic tasks if synthetic projects are not supported
on the current host

Issue #KT-40834 Fixed
2020-08-24 12:04:50 +00:00
Alexander Udalov
b10cc6657e Fix loading of builtins resources in kotlin-reflect in Java modular mode
The main change here is that when kotlin-reflect is being run under Java
9+, we use another implementation of BuiltInsResourceLoader (see
libraries/reflect/api/src/java9) which loads .kotlin_builtins files from
the java.lang.Module instance of kotlin-stdlib, instead of the class
loader of kotlin-reflect, which may not have access to those resources.

If the application is being run in the old (classpath) mode, that Module
represents the unnamed module, which contains everything on the
classpath, and everything works as before. But if it's being run in the
modular mode, that Module instance is an encapsulated module for
kotlin-stdlib classes and resources, exactly where .kotlin_builtins
files are located.

This fixes a regression in 1.4.0. Prior to 1.4, kotlin-reflect and
kotlin-stdlib were not named modules (see KT-21266) and were loaded as
_automatic_ modules even if the application was run in the modular mode.
Apparently, they shared the same class loader in that case and looking
up .kotlin_builtins resources worked.

This change was supposed to go alongside
828cc6dbf3, but was overlooked because
adding module-info to standard libraries was postponed at that point.

Also slightly refactor Java9ModulesIntegrationTest to simplify running
compiled code, and add a smoke test on using kotlin-reflect in modular
mode.

 #KT-40842 Fixed
2020-08-24 13:30:00 +02:00
Alexander Udalov
201fa849b8 Workaround problem with log4j warnings in CLI tests
#KTI-166
2020-08-24 13:30:00 +02:00
Nick
05cfb654ba [FIR] Fix removeAtInt test 2020-08-24 13:38:43 +03:00
Nikolay Krasko
2b983b1c20 Mute flaky JavaAgainstKotlinBinariesCheckerTestGenerated.testEnumStaticImportInJava 2020-08-24 13:20:31 +03:00
Ilya Goncharov
2d8643b6ef [Gradle, JS] Add nowarn flag for kotlin2js
^KT-41340 fixed
2020-08-24 13:05:22 +03:00
Nick
aeae898b94 [FIR] Fix issues with properties' fake sources 2020-08-24 11:06:45 +03:00
Nick
61e21dadec [FIR] Add 3 type mismatch diagnostics 2020-08-24 11:06:12 +03:00
Nick
c8f8908a01 [FIR] Add NO_THIS & INSTANCE_ACCESS_BEFORE_SUPER_CALL 2020-08-24 11:06:10 +03:00
Nick
7e1c2cfd36 [FIR] Add diagnostic INAPPLICABLE_LATEINIT_MODIFIER + some builtin types 2020-08-24 11:06:06 +03:00
Nick
091e12c093 [FIR] Add diagnostic CONFLICTING_PROJECTION 2020-08-24 11:06:04 +03:00
Dmitriy Dolovov
d40bca4143 [Commonizer] Short-circuiting of type aliases
^KT-41220
2020-08-24 12:21:12 +07:00
Vyacheslav Gerasimov
8a84af8a6f Build: Fix idea-gradle test task dependency on dist 2020-08-22 14:11:34 +03:00
Mark Punzalan
a9359eb530 RangeContainsLowering: Handle unsigned ranges. 2020-08-21 21:15:27 +02:00
Mark Punzalan
ceba9f231d RangeContainsLowering: Fix bug in additional condition order for
`until` ranges.
2020-08-21 21:15:27 +02:00
Mark Punzalan
60a2f7d03f RangeContainsLowering: Handle Comparable ranges. 2020-08-21 21:15:27 +02:00
Mark Punzalan
1c1b1b4b0f Initial version of RangeContainsLowering, which optimizes calls to
contains() on ClosedRanges.
2020-08-21 21:15:27 +02:00
Jinseong Jeon
ca541337d1 FIR: skip return insertion for lambda w/ Unit return type 2020-08-21 19:16:43 +03:00
Alexander Udalov
f1ce668ede IR: minor, don't store unnecessary fields 2020-08-21 17:52:10 +02:00
Alexander Udalov
26eb51a9f9 Minor, fix generateBuiltins test 2020-08-21 17:51:23 +02:00
Nikolay Krasko
d170f46bfc Mute flaky fun usages tests 2020-08-21 18:28:21 +03:00
Nikolay Krasko
6293842d81 Mute XCoroutinesStackTraceTestGenerated flaky test 2020-08-21 18:28:21 +03:00
Nikolay Krasko
9d300f56cc Mark SubpluginsIT.testKotlinVersionDowngradeInSupbrojectKt39809 as flaky 2020-08-21 18:28:21 +03:00
Nikolay Krasko
8f785f6bb2 Mute flaky tests in ContinuationStackTraceTestGenerated 2020-08-21 18:28:21 +03:00
Nikolay Krasko
fd036c2658 Mute flaky tests in JavaAgainstKotlinBinariesCheckerTestGenerated 2020-08-21 18:28:21 +03:00
Roman Artemev
fcca2c6fa3 [JS IR] fix failing test 2020-08-21 17:44:07 +03:00
pyos
5722f889d8 FIR2IR: scan the entire interface tree for delegatable members 2020-08-21 16:50:23 +03:00
Mikhail Glukhikh
99d2fd7c4d [FIR] Handle open in interface correctly during status resolve 2020-08-21 16:50:23 +03:00
Mikhail Glukhikh
8e2c5bf4fe [FIR] Fix exposed visibility checking for enum entries 2020-08-21 16:50:22 +03:00
Mikhail Glukhikh
e15e87fded [FIR] Expand aliased type before checking for exposure 2020-08-21 16:50:22 +03:00
Denis Zharkov
cb6fbc329a FIR: Simplify FirQualifiedAccess hiearchy
Mostly, it's getting rid of FirQualifiedAccessWithoutCallee and FirModifiableQualifiedAccess
The latter was only used during FIR building to set explicit receiver
that might be done by replace call on explicit receiver

The problem with replaceExplicitReceiver is that for FirComponentCall
explicitReceiver should be not null, so it's needed to perform those tricks
at the generatot
2020-08-21 16:34:46 +03:00
Dmitriy Novozhilov
e6837a5b8c [FIR] Unify implementations of toSymbol and getSymbolByLookupTag 2020-08-21 15:28:34 +03:00
Dmitriy Novozhilov
d1f6e45b08 [FIR] Cleanup signature of getNestedClassifierScope 2020-08-21 15:27:55 +03:00
Dmitriy Novozhilov
ffdc68b68d [FIR] Get rid of AbstractFirSymbolProviderWithCache 2020-08-21 15:27:55 +03:00
Dmitriy Novozhilov
111b8c0169 [FIR] Cleanup caching symbol in ConeClassLikeLookupTagImpl
Type of `boundSymbol` replaced to OneElementWeakMap
`FirSymbolProvider.getSymbolByLookupTag` moved to extensions
2020-08-21 15:27:55 +03:00
Dmitriy Novozhilov
9032234e1d [FIR] Get rid of FirSymbolProvider.getNestedClassifierScope 2020-08-21 15:27:55 +03:00
Dmitriy Novozhilov
77f52a9ddb [FIR] Add special inline class for caches which are used in symbol providers 2020-08-21 15:27:55 +03:00
Dmitriy Novozhilov
4b6193159c [FIR] Get rid of JavaSymbolProvider.getJavaTopLevelClasses 2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
d7cfb2fb13 [FIR] Get rid of FirSymbolProvider.getClassNamesInPackage
There was one non-removable usage of those function in FirJavaElementFinder
  and three non-trivial implementation
- `FirProvider.SymbolProvider`
- `KotlinDeserializedJvmSymbolsProvider`
- `FirBuiltinSymbolProvider`

First implementation was moved to `FirProvider` and other two was
  deleted, because in FirJavaElementFinder we need lookup only in
  classes from source code, so such methods in library providers are
  useless

#KT-41048
2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
b31f80aee3 [FIR] Get rid of FirSymbolProvider.getAllCallableNamesInPackage
#KT-41048
2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
f32a0fe7ad [FIR-TEST] Unify AbstractFirLoadCompiledKotlin and BuiltInsDeserializationForFirTestCase 2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
913ea9b56d [FIR-TEST] Get rid of deprecated methods usage in AbstractFirLoadCompiledKotlin
Now complied declaration names are collected via ModuleDescriptor,
  so tests pass more correctly. Before this change tests didn't render
  compiled typealiases and properties.
Also some testdata was changed because of new order of declaration
2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
41aa90ad71 [FIR-TEST] Add flag to take memory dumps in modularized test 2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
cb0b25ea39 [FIR] Replace Deprecated with PrivateForInline in ScopeSession 2020-08-21 15:27:54 +03:00
Dmitriy Novozhilov
b4dc7955b4 [FIR] Avoid collections copying in FirSymbolProvider 2020-08-21 15:27:53 +03:00
Dmitriy Novozhilov
ce36ae64a1 [FIR] Deprecate questionable methods of FirSymbolProvider 2020-08-21 15:27:53 +03:00
Dmitriy Novozhilov
d5bb87cd1f [FIR] Replace inheritance with delegation for FirProvider and FirSymbolProvider 2020-08-21 15:27:53 +03:00
Dmitriy Novozhilov
ad9e41b828 [FIR] Mark JavaSymbolProvider.getJavaTopLevelClasses as @TestOnly 2020-08-21 15:27:53 +03:00
Dmitriy Novozhilov
1d26ce4a4e [FIR] Get rid of useless methods in FirSymbolProvider 2020-08-21 15:27:53 +03:00
Dmitriy Novozhilov
f0d05a321d [FIR-IDE] Use symbolProvider instead of firProvider in KtFirPackageScope 2020-08-21 15:27:53 +03:00
vldf
0d6b363179 [FIR] Refactoring for extended checkers 2020-08-21 15:09:05 +03:00
vldf
e2016499f3 [FIR] Fixed CFA bug 2020-08-21 15:08:37 +03:00
vldf
ac07438489 [FIR] Speed up CFA-checkers 2020-08-21 15:08:37 +03:00
vldf
638a0d3b82 [FIR] Checkers performance improvement and some refactoring 2020-08-21 15:08:36 +03:00
Kirill Shmakov
5a45cc7290 Update wizard tests 2020-08-21 13:06:56 +03:00
Denis Zharkov
cee72023fa Remove TypeSystemContext::mayBeTypeVariable optimization
It doesn't work now since anyway it's required to obtain type
constructor
At the same time, now it's not very expensive to obtain the constructor
since it's just a lookup tag
2020-08-21 12:50:33 +03:00
Denis Zharkov
9ac5dd2bce FIR: Use lookup tags for as type constructors instead of symbols
It may help to avoid redundant symbols lookups
2020-08-21 12:50:33 +03:00
Vladimir Ilmov
34b55dbeb3 (CoroutineDebugger) Disable agent for MPP projects
#KT-39412 fixed
2020-08-21 10:35:39 +02:00
Vladimir Dolzhenko
1e96088cc6 Check unique symbols in Goto*Tests 2020-08-21 10:04:36 +02:00
Dmitry Gridin
5f584691a6 [inspections] disable "Redundant inner modifier" inspection
^KT-41264 Fixed
2020-08-21 09:28:37 +07:00
Vladimir Dolzhenko
ec253862c6 Check unique symbols in Goto*Tests 2020-08-20 23:50:26 +02:00
Kirill Shmakov
62be688eb7 Wizard: add missing test dependency 2020-08-20 22:33:14 +03:00
Roman Artemev
e7f22bcfbc [JS IR] Add test for cross module export 2020-08-20 22:16:20 +03:00
Anton Bannykh
136d86e552 [JS IR] Fix cross-module import/export in case per-module splitting 2020-08-20 22:13:39 +03:00
Roman Artemev
8d61e9ba21 [KLIB] Load @JsExport annotated declarations explicitly 2020-08-20 22:13:39 +03:00
Roman Artemev
1a0e3a1d83 [KLIB] Refactor file serializer a bit
- Support explicitly exported on files and properties
2020-08-20 22:13:38 +03:00
Alexander Udalov
12e900ef3c Minor, do not capitalize words in generated Gradle options docs
To make this output correspond to the actual table at
https://github.com/JetBrains/kotlin-web-site/blob/master/pages/docs/reference/using-gradle.md
2020-08-20 20:30:55 +02:00
Alexander Udalov
0ef4b22cf3 Remove deprecated usages of ContainerUtil 2020-08-20 20:30:34 +02:00
Alexander Udalov
2428c180c2 Suppress warning on usage of old MPP in kotlin-stdlib 2020-08-20 20:30:34 +02:00
Alexander Udalov
da6d904c6e Suppress code warnings in kotlin-stdlib 2020-08-20 20:30:34 +02:00
Nikolay Krasko
5ef4f7df5a Mute more tests 2020-08-20 16:06:11 +03:00
Nikolay Krasko
44a95a4105 Stop running failed AndroidRunner tests 2020-08-20 16:06:11 +03:00
Nikolay Krasko
7f91ed6997 Support mute tests in kotlin-gradle-plugin-integration-tests (KTI-234)
#KTI-234 Fixed
2020-08-20 16:06:11 +03:00
Mikhail Glukhikh
07bddbe4d0 [FIR CLI] Don't run generation if some errors are found 2020-08-20 16:04:07 +03:00
Mikhail Glukhikh
85c1505689 [FIR2IR] Copy type parameters for trivial fake overrides 2020-08-20 16:04:02 +03:00
Alexander Udalov
bf0bb9e946 JVM IR: remove obsolete code for duplicate signature diagnostics 2020-08-20 14:58:36 +02:00
Alexander Udalov
425b192a5f Fix warnings in build-common/daemon code 2020-08-20 14:58:11 +02:00
Alexander Udalov
1d15a5547d Suppress deprecation warnings related to scripting 2020-08-20 14:58:11 +02:00
Alexander Udalov
549ee84687 Fix some compiler warnings in FIR modules 2020-08-20 14:57:54 +02:00
Mikhail Zarechenskiy
ced151f3af Add test for KT-41254
It was fixed along with #KT-41005
2020-08-20 15:45:32 +03:00
Mads Ager
a6f301e84a [JVM_IR] Rebase constructor stepping tests that are working as intended.
JVM_IR has consistent stepping behavior for secondary constructors
and init blocks. This change fixes the expectations for tests that
expect the less consistent JVM backend behavior.
2020-08-20 13:12:22 +02:00
Mads Ager
2c6b5c8847 [JVM_IR] Give temporary variable loads meaningful offsets.
Temporary variable loads in when expressions had the offsets
of the variable declaration. That leads to hacks during codegen
for line number generation.

Instead of those hacks, give the variable loads the offsets of
the context in which they occur. That avoids the codegen hacks
and fixes stepping behavior for more when expressions.
2020-08-20 13:12:22 +02:00
Sergey Igushkin
413d02621b Add a link to docs in MPP stability warning; add a flag that hides it 2020-08-20 10:44:59 +00:00
Mikhail Glukhikh
02e5f140f4 Fir2IrLazyProperty: generate overridden symbols via FirTypeScope 2020-08-20 11:47:35 +03:00
Mikhail Glukhikh
25efad2fd7 [FIR2IR] Extract generateOverriddenAccessorSymbols 2020-08-20 11:47:35 +03:00
Roman Golyshev
539d2bc01f FIR Completion: Fix completion with error type as receiver
- When type is error, the completion should not show anything; instead,
it was showing as if the explicit receiver was not there
2020-08-20 11:33:23 +03:00
Roman Golyshev
bca9754a7b FIR Completion: Move completion from available scopes to separate class 2020-08-20 11:33:23 +03:00
Denis Zharkov
7f3f0faa1a FIR: Rework overridden members processing in FirTypeScope
Now, FirTypeScope returns only direct overridden and a base scope
where a client might look for deeper overridden

It's necessary to make the API fast and simple
when only direct overridden are needed

At the same time, while this API looks a bit complicated for most of the clients
there are simple extension helpers that obtain just the direct or all overridden
2020-08-20 11:18:59 +03:00
Toshiaki Kameyama
8ce9b2d061 KT-34572 Convert to block body action improperly works with suppress annotations (#2969)
* Convert to block body: place @Suppress annotation before return expression

#KT-34572 Fixed

* Convert to block body: place annotations before return expression
2020-08-20 11:15:00 +03:00
Ilya Kirillov
9e0bb4ce8e FIR: save resolvePhase of declaration when creating it fake override copy 2020-08-20 11:07:09 +03:00
Ilya Kirillov
b1d3ab04c2 FIR [IDE]: provide correct node phase when necessary 2020-08-20 09:48:33 +03:00
Mads Ager
119302b016 [JVM_IR] Run KotlinSteppingTests with the JVM_IR backend.
Implement support for supressing failures by backend.
2020-08-20 05:48:54 +02:00
Nikolay Krasko
01f7da66c6 Mute ProjectTemplateNewWizardProjectImportTestGenerated.**.testMultiplatformApplication 2020-08-19 23:35:23 +03:00
Nikolay Krasko
9d18279ec9 Mute ReferenceResolveTestGenerated.DelegatedPropertyAccessors.InStandardLibrary.testNotNull 2020-08-19 23:01:09 +03:00
Nikolay Krasko
d87d42348b Mute flaky GotoWithMultipleLibrariesTest
Tests are flaky after e2a12602a3
2020-08-19 23:01:09 +03:00
Nikolay Krasko
179bd1cc3d Mute KotlinUastTypesTest.testEa101715 2020-08-19 23:01:09 +03:00
Nikolay Krasko
950b139804 Mute CreateFunction.Invoke.testLambdaArgument 2020-08-19 23:01:09 +03:00
Nikolay Krasko
496ede7587 Mute KotlinUastTypesTest.testEa101715 2020-08-19 23:01:08 +03:00
Nikolay Krasko
4135240cc0 Mute testFunctionBreakpointInStdlib in AS41 2020-08-19 23:01:08 +03:00
Nikolay Krasko
7982283007 Copy mutes for AS41 from 201 2020-08-19 23:01:08 +03:00
Nikolay Krasko
a3c8427cb2 Mute GradleScriptListenerTest tests 2020-08-19 23:01:08 +03:00
Nikolay Krasko
7de5368b4d Fix AbstractGradleBuildRootsLocatorTest tests 2020-08-19 23:01:08 +03:00
Nikolay Krasko
0b2fcd2c4d Remove mutes for navigation tests 2020-08-19 23:01:08 +03:00
Yunir Salimzyanov
ebe0489a74 Fix joined lines in .bunch 2020-08-19 19:51:51 +03:00
Yunir Salimzyanov
70cda1b113 Refactor and fix files previously affected by 192 patchset (KTI-315) 2020-08-19 19:40:02 +03:00
Yunir Salimzyanov
42da9e62db Cleanup 192 patchset files (KTI-315) 2020-08-19 19:40:02 +03:00
Yunir Salimzyanov
73aa21aab6 Refactor and fix files previously affected by as36 patchset (KTI-315) 2020-08-19 19:40:00 +03:00
Yunir Salimzyanov
27b2e16141 Cleanup as36 patchset files (KTI-315) 2020-08-19 19:40:00 +03:00
Ilya Chernikov
0a9089bc72 Set correct base classloader for REPL evaluation
the contributed partial fix of KT-35925 set it to the system classloader
which brought in many cases the compiler CP into the evaluation and lead
to the problems like KT-40898. This fix set it to the extension/platform
classloader, which preserves (partial) fix of the KT-35925 and do not
bring the compiler jar into the REPL evaluation classpath.

#KT-40898 fixed
2020-08-19 15:17:07 +02:00
Ilya Chernikov
f713e8ad36 Set context classloader before REPL evaluation
#KT-35925 fixed
2020-08-19 15:17:06 +02:00
Vladimir Dolzhenko
d0366d3bcb Failed test clean up
Relates to ^KT-40960
2020-08-19 15:06:53 +02:00
alexjuca
4794297640 used string template instead of concatenation 2020-08-19 13:58:58 +02:00
Kirill Shmakov
f88e492d11 Support hmpp in template
Explained in KMM-332
2020-08-19 14:46:49 +03:00
Toshiaki Kameyama
11044a3ab5 Surround with null check: fix incorrect check for 'in' expression
#KT-31749 Fixed
2020-08-19 14:37:24 +03:00
Toshiaki Kameyama
1188f4617a Change file's package to match directory: add space after package keyword if needed
#KT-39604 Fixed
2020-08-19 14:04:18 +03:00
Kirill Shmakov
1ce39222e3 Build KMM plugin for AS 4.2 2020-08-19 13:02:39 +03:00
Mikhail Zarechenskiy
6ed13ef1b6 Fix unresolved reference to catch parameter from lambda expression
#KT-41140 Fixed
2020-08-19 12:52:16 +03:00
Mikhail Zarechenskiy
f2fba8a469 Fix delegated property resolve when provideDelegate has this as argument
#KT-41135 Fixed
2020-08-19 12:52:16 +03:00
Toshiaki Kameyama
f3be3f449a Scope function conversion: do not suggest when invoked without receiver
#KT-35525 Fixed
2020-08-19 12:27:41 +03:00
Toshiaki Kameyama
8ba5548a0f "Eliminate argument of 'when'": do not suggest if 'when' is used as expression and it has no 'else' branch (#2898)
#KT-35526 Fixed
2020-08-19 12:24:58 +03:00
Toshiaki Kameyama
d965ad0a98 IfThenToSafeAccessInspection: do not report if condition is SENSELESS_COMPARISON/USELESS_IS_CHECK (#3007)
#KT-36051 Fixed
2020-08-19 12:22:10 +03:00
Toshiaki Kameyama
122bba9102 UnnecessaryVariableInspection: don't report for overriding property
#KT-39263 Fixed
2020-08-19 12:16:37 +03:00
Igor Yakovlev
c29dbee65e Cover move method refactoring with registry key (disabled by default) 2020-08-19 12:11:53 +03:00
aleksandrina-streltsova
ed67517fb9 Move: make minor refactorings and add GUI form for MoveKotlinMethodDialog 2020-08-19 12:11:53 +03:00
aleksandrina-streltsova
5515465760 Move: Support method moving 2020-08-19 12:11:53 +03:00
Alex Chmyr
a5368e443c KT-20421 fixing code generation for the case when "object" extends "class". It should look like: "object: class()". 2020-08-19 11:46:29 +03:00
Anton Yalyshev
26ca205f7e Fix a broken hyperlink to Whatsnew at the plugin change-notes 2020-08-19 11:41:13 +03:00
Ilya Kirillov
ccf285a284 FIR IDE: do not recreate analysis session for tests now 2020-08-19 11:35:42 +03:00
Ilya Kirillov
c191373a6b FIR IDE: always pass ValidityToken to KtAnalysisSessionComponent 2020-08-19 11:35:41 +03:00
Ilya Kirillov
2290d2fcc0 FIR IDE: make FirScopeRegistry belong to a KtFirScopeProvider 2020-08-19 11:35:40 +03:00
Roman Golyshev
7d58588f06 FIR IDE: Fix KtFirPropertySymbol::receiverType 2020-08-19 11:23:56 +03:00
Dmitry Petrov
8f0aecce58 JVM_IR: KT-40330 Unify field names for captured 'this' with JVM
NB some cases such as captured extension receiver for an extension
lambda are not supported yet; to be discussed, to what extent should we
actually follow JVM code shape here.
2020-08-19 11:07:41 +03:00
Dmitriy Dolovov
24bfc155af IDE perf tests for K/N: Use Gradle 6.6 2020-08-19 12:45:16 +07:00
Dmitriy Dolovov
6a95317f73 IDE perf tests for K/N: Switch to 1.4.0 2020-08-19 12:45:09 +07:00
Mikhail Glukhikh
f7cb165fb9 Introduce Fir2IrBuiltIns & move extension function type inside 2020-08-18 21:54:05 +03:00
Simon Ogorodnik
97b10b5ab3 [FIR2IR] Hack-in setting of extension function type annotation 2020-08-18 21:53:55 +03:00
Mikhail Glukhikh
b1c36feef4 Minor: regenerate FIR diagnostic tests 2020-08-18 21:53:35 +03:00
Jinseong Jeon
7e22de1e24 FIR2IR: insert coerce-to-unit expressions in statement containers 2020-08-18 21:53:08 +03:00
pyos
1b3ab53e16 FIR2IR: set superQualifierSymbol for setters too 2020-08-18 21:53:08 +03:00
Jinseong Jeon
e9659d9c8a FIR2IR: make the scope of body of do-while loop transparent 2020-08-18 21:53:07 +03:00
Jinseong Jeon
1b6c4329d2 FIR2IR: handle unbound reference with adapted arguments 2020-08-18 21:53:07 +03:00
vldf
a26eeb6ee8 [FIR] Add CLI flag for running extended checkers 2020-08-18 21:53:07 +03:00
vldf
2bf1d3fee8 [FIR] Add messages for extended checkers' warnings 2020-08-18 21:53:06 +03:00
Ilya Kirillov
08e2dd3dea NJ2K: fix implicit type cast in binary expressions
#KT-37298 fixed
2020-08-18 17:38:07 +03:00
Ilya Kirillov
d5d57f84e0 NJ2K: preserve annotations while converting class to object
#KT-38879 fixed
2020-08-18 17:38:07 +03:00
Ilya Kirillov
3d517c3656 NJ2K: fix retrieving resolutionFacade on empty context elements list 2020-08-18 17:38:07 +03:00
Ilya Kirillov
de0c216cfa NJ2K: fix NPE in JavaObjectEqualsToEqOperatorProcessing 2020-08-18 17:38:06 +03:00
Simon Ogorodnik
38477be484 [FIR] Make test fail if profiling requested, but misconfigured 2020-08-18 16:21:48 +03:00
Simon Ogorodnik
15d4333e81 [FIR] Add per-pass profiling support to modularized test 2020-08-18 16:21:48 +03:00
Simon Ogorodnik
83ded9badf [FIR] Add pass argument to beforePass of modularized test 2020-08-18 16:21:48 +03:00
Roman Artemev
716c3668d6 [IR] Properly resolve type parameters in case of property accessor
- fix KT-41006
2020-08-18 11:48:06 +03:00
Alexander Udalov
a810dbb41b IR: fix compiler warnings 2020-08-18 10:33:25 +02:00
Vladimir Dolzhenko
be53467bee Flaky and muted navigation tests clean up
Relates to #KT-40960
2020-08-18 08:23:02 +00:00
Vladimir Dolzhenko
e2a12602a3 Fixed getPsiMethodWrappers for KtLightMethodForDecompiledDeclaration
#KT-40960 Fixed
2020-08-18 08:23:01 +00:00
Vladimir Dolzhenko
ee0250bd35 Reformat file
Relates to #KT-40960
2020-08-18 08:23:00 +00:00
Vladimir Dolzhenko
5c7054a5ab Fixed src path for mock library
Relates to #KT-40960
2020-08-18 08:23:00 +00:00
Natalia Selezneva
7b80be5c9d Temporary workaround for gradle issue: wrong navigation for included plugin source code
https://github.com/gradle/gradle/issues/13783
^KT-39522
2020-08-17 23:12:51 +03:00
Alexander Udalov
7dd687cf00 IR: minor, use lazy instead of lazyVar for readonly value 2020-08-17 21:19:53 +02:00
Alexander Udalov
a21f273570 Fix compiler warnings in compiler code 2020-08-17 21:18:20 +02:00
Alexander Udalov
9b94e073af Fix warnings related to OptIn/UseExperimental 2020-08-17 21:18:19 +02:00
Alexander Udalov
256f4449ce IR: annotate obsolete API in IrPluginContext with ObsoleteDescriptorBasedAPI 2020-08-17 21:18:19 +02:00
Alexander Udalov
9961bd1fe1 IR: remove unneeded casts after making IrCall's symbol a simple function 2020-08-17 21:18:17 +02:00
Alexander Udalov
3bdbfc1e73 Output total codegen statistics after IR translation/generation 2020-08-17 19:29:58 +02:00
Alexander Udalov
c3cbcf6d7f Slightly improve performance measurements rendering
Report the input module name and size once before any measurements
instead of duplicating it in all of them. Also, render measurements in a
table to improve readability.

Before:

info: PERF: INIT: Compiler initialized in 467 ms
info: PERF: ANALYZE: 1 files (2 lines) target main-java-production in 277 ms - 7.220 loc/s
info: PERF: IR: Translation 1 files (2 lines) target main-java-production in 291 ms - 6.873 loc/s
info: PERF: GENERATE: 1 files (2 lines) target main-java-production in 513 ms - 3.899 loc/s
info: PERF: IR: Generation 1 files (2 lines) target main-java-production in 142 ms - 14.085 loc/s

After:

info: PERF: main-java-production, 1 files (2 lines)
info: PERF: INIT: Compiler initialized in 421 ms
info: PERF:         ANALYZE     342 ms       5.848 loc/s
info: PERF:  IR TRANSLATION     296 ms       6.757 loc/s
info: PERF:        GENERATE     453 ms       4.415 loc/s
info: PERF:   IR GENERATION     137 ms      14.599 loc/s
2020-08-17 19:29:57 +02:00
Simon Ogorodnik
0045b501d5 FIR IDE: Fix memory leak in thread locals 2020-08-17 20:05:52 +03:00
Ilya Kirillov
76b078b561 FIR IDE: resolve KtFirLocalVariableSymbol only to IMPLICIT_TYPES_BODY_RESOLVE 2020-08-17 20:05:52 +03:00
Ilya Kirillov
b8920114f8 FIR: set resolvePhase to BODY_RESOLVE in deserialized Kotlin declarations 2020-08-17 20:05:52 +03:00
Simon Ogorodnik
c7d6a79c25 FIR IDE: Fix completion in case of function with parameters 2020-08-17 20:05:52 +03:00
Nikolay Krasko
863de52f7a Minor: better name for file walking with excludes 2020-08-17 20:02:47 +03:00
Nikolay Krasko
c30910130e Remove minor optimization in CodeConformanceTest 2020-08-17 20:02:46 +03:00
Nikolay Krasko
01f3bdfc69 Exclude kotlin-ultimate/ide/common-cidr-native from author check 2020-08-17 20:02:46 +03:00
Nikolay Krasko
31ed803ada More excludes 2020-08-17 19:40:49 +03:00
Nikolay Krasko
713dbc225e Other repositories monitoring 2020-08-17 19:40:48 +03:00
Nikolay Krasko
fad15b6627 Rewrite testThirdPartyCopyrights test 2020-08-17 19:40:48 +03:00
Nikolay Krasko
bb0ea56d63 Extract traversing through directories to the common code 2020-08-17 19:40:48 +03:00
Nikolay Krasko
8db588c7f0 Optimize testNoBadSubstringsInProjectCode test
Don't visit ignored directories
2020-08-17 19:40:48 +03:00
Nikolay Krasko
2655d9dab3 Optimize testForgottenBunchDirectivesAndFiles test
Don't step through the ignored directories.
2020-08-17 19:40:48 +03:00
Nikolay Krasko
3eb89d6dfd Use own allow list for each repository 2020-08-17 19:40:48 +03:00
Nikolay Krasko
8445c8f4a5 Update copyright conformance excludes 2020-08-17 19:40:47 +03:00
Nikolay Krasko
04a1e572a8 Monitor new usages of kotlin-eap repository 2020-08-17 19:40:47 +03:00
Nikolay Krasko
d2bf5587d6 Monitor new usages of kotlin-dev repository 2020-08-17 19:40:47 +03:00
Nikolay Krasko
50d85b92da Remove more kotlin-dev usages 2020-08-17 19:40:47 +03:00
Nikolay Krasko
be2badc6ed Remove kotlin-dev from gradle migrate test 2020-08-17 19:40:47 +03:00
Nikolay Krasko
0c27e87eb9 Remove kotlin-dev from gradle configurator tests 2020-08-17 19:40:46 +03:00
Dmitriy Dolovov
3dc3c19c02 [Commonizer] Fix ImportAndCheckNavigation IT 2020-08-17 21:52:40 +07:00
Georgy Bronnikov
df8b819a55 JVM_IR: restore dumping for IrLowering phase 2020-08-17 15:57:12 +03:00
Ilya Goncharov
c70759673c [Gradle, JS] Update npm versions
^KT-41125 fixed
2020-08-17 15:22:30 +03:00
Steven Schäfer
6100166185 JVM IR: Fix special bridge generation with external Kotlin dependencies 2020-08-17 13:42:32 +02:00
Ilya Kirillov
730e07c52a Wizard: fix ExpectedFileTest.kt 2020-08-17 12:22:38 +03:00
Toshiaki Kameyama
35459d2ca7 "Add not-null asserted (!!) call": add '!!' to receiver of function reference
#KT-37841 Fixed
2020-08-17 12:05:45 +03:00
Ilya Kirillov
5e5e19f482 FIR IDE: temporary disable AddFunctionReturnTypeIntention 2020-08-17 11:38:05 +03:00
Ilya Kirillov
b79deafbc7 FIR IDE: fix testdata 2020-08-17 11:38:04 +03:00
Ilya Kirillov
27c045d035 FIR IDE: move all all symbol markers to markers package 2020-08-17 11:38:02 +03:00
Ilya Kirillov
052e8e5069 FIR IDE: make a symbol hierarchy a sealed one 2020-08-17 11:38:01 +03:00
Ilya Kirillov
018dd673b3 FIR IDE: simplify containing declaration provider 2020-08-17 11:38:00 +03:00
Ilya Kirillov
37ac654444 FIR IDE: rework high level API
Make analysis session to always be a receiver parameter
2020-08-17 11:37:58 +03:00
Ilya Kirillov
cadf99ca1e FIR IDE: introduce containingDeclarationProvider for symbols 2020-08-17 11:37:57 +03:00
Ilya Kirillov
b5a4e4c409 FIR IDE: introduce applicable computation & -based inspection 2020-08-17 11:37:56 +03:00
Ilya Kirillov
c8ab0766c9 FIR IDE: Implement symbol restoring for member symbols 2020-08-17 11:37:55 +03:00
Ilya Kirillov
e4995175a4 FIR IDE: fix idea-frontend-fir testdata 2020-08-17 11:37:53 +03:00
Ilya Kirillov
5f20910c79 FIR IDE: always try to find symbol origin in overridden symbols 2020-08-17 11:37:52 +03:00
Ilya Kirillov
a700d1fccb FIR IDE: resolve kt symbols only to the phase they actually need 2020-08-17 11:37:51 +03:00
Dmitriy Dolovov
75be9cf31f [Commonizer] Tests on rewriting callables names to succeed commonization
^KT-34602
2020-08-17 09:31:28 +07:00
Dmitriy Dolovov
de0b6e06cf [Commonizer] Keep parameters names hash in approximation keys for ObjC callables
^KT-34602
2020-08-17 09:31:21 +07:00
Dmitriy Dolovov
3b901a28d5 [Commonizer] More compact approximation keys
^KT-34602
2020-08-17 09:31:12 +07:00
Dmitriy Dolovov
4418dc85ca [Commonizer] Allow rewriting callables names to succeed commonization
^KT-34602
2020-08-17 09:31:03 +07:00
Dmitriy Dolovov
8904f5652b [Commonizer] Allow extended lookup for classifiers in test mode
Only for commonizer tests!

Allow to look up classifiers from the standard Kotlin packages (kotlin, kotlinx)
both in the default built-ins module and in test data sources. This is necessary
to write tests that refer to C-interop classifiers that are not available without
Kotlin/Native distribution.

^KT-34602
2020-08-17 09:30:57 +07:00
Dmitriy Dolovov
3b398ed57f [Commonizer] Small clean-up in IllegalCommonizerStateException 2020-08-17 09:30:47 +07:00
Dmitriy Dolovov
494fb39399 [Commonizer] CLI: Report duration even if it's 0ms long 2020-08-17 09:30:42 +07:00
Dmitriy Dolovov
9ef727747b [Commonizer] Use Array instead of List in AbstractListCommonizer 2020-08-17 09:30:36 +07:00
Igor Chevdar
e468a347b5 [box-tests] Tests on field init optimization
Added tests on all primitive types and a test when the field's type is an inline class
2020-08-15 12:16:33 +05:00
Steven Schäfer
0328fcaf5d JVM IR: Avoid IMPLICIT_NOTNULL checks on special bridge methods
...with dynamic type checks, except for the `@PlatformDependent`
methods, for which the JVM backend adds null checks.
2020-08-14 21:59:33 +02:00
Steven Schäfer
9026f89ba5 JVM IR: Avoid CHECKCASTs on type operators (KT-39520)
The type information coming from Java or Kotlin generics may be wrong
due to type erasure and a CHECKCAST instruction could throw an
exception.
2020-08-14 21:58:47 +02:00
Alexander Udalov
469b164555 IR: minor optimizations to IR validation 2020-08-14 21:55:37 +02:00
Alexander Udalov
7468518f35 JVM IR: minor, optimize forceSingleValueParameterBoxing
In JVM IR, both `valueParameters` and `isFromJavaOrBuiltins` take
noticeable time (1% of all compilation) because the logic for these in
IrBasedDescriptors is not trivial.
2020-08-14 21:55:37 +02:00
Alexander Udalov
35cace2540 JVM IR: collect potentialBridgeTargets in a list, then create bridges for all of them
This takes BridgeLowering time percentage from 1.3% to 1.0% of all
compiler time on a sample project, perhaps due to better data locality.
In addition, it simplifies stack traces by effectively merging all
bridge generation call sites into one, helping in future performance
investigations.
2020-08-14 21:55:37 +02:00
Alexander Udalov
9607414cf1 IR: make allOverridden return Set instead of Sequence, move to IrUtils
This doesn't hurt performance, but improves stack traces, in particular
in JVM's BridgeLowering.
2020-08-14 21:55:37 +02:00
Alexander Udalov
adcfbdec24 JVM IR: optimize special method / signature computation in BridgeLowering
First of all, put method signature caches of BridgeLowering into
JvmBackendContext. Since method hierarchies can span several files, and
a new instance of BridgeLowering is created to lower each file, keeping
them cached for the whole module makes BridgeLowering faster.

Also, do not attempt to compute special bridges if the method is
irrelevant, which can be deduced by its name. With this optimization,
the special method cache is no longer needed.

This brings BridgeLowering time from 3.8% down to 1.5% of all compiler
time on a sample project.
2020-08-14 21:55:37 +02:00
Alexander Udalov
0727e9055b JVM IR: use a simpler way to check if class is local 2020-08-14 21:55:37 +02:00
Alexander Udalov
6db5ad7310 IR: remove cast to IrStatement in IrDeclarationBase.transform
Default implementation of `IrStatement.transform` contained a cast to
`IrStatement`. Since almost all IR elements inherit from IrStatement,
this implementation was used in many subclasses. However, checkcast to
interface is slow and this place was indeed noticeable in the profiler
snapshot. Since not that many places really expected to get IrStatement
out of IrStatement.transform, introduce a new method
`transformStatement` that does this cast, and use it in all those
places. Meanwhile, most implementations will use the IrElement's
implementation of `transform` which merely invokes `accept` without
casts.
2020-08-14 21:55:37 +02:00
Alexander Udalov
fb8e39a621 IR: optimize transformation of declarations/statements lists in-place
Also, inherit IrDeclarationBase from IrElementBase to be able to use a
cast to IrElementBase, which is faster than a cast to IrElement or
IrDeclaration.
2020-08-14 21:55:36 +02:00
Alexander Udalov
4f0585950e IR: inline some transformChildren calls in IrElementTransformer{,Void}
IrElementTransformer.visitDeclaration/visitExpression are very prominent
hotspots, and it seems that HotSpot doesn't optimize the inlined Kotlin
bytecode there well enough. Reduce the bytecode in these and similar
methods by inlining calls to also/apply/transformChildrenVoid.
2020-08-14 21:55:36 +02:00
Nikolay Krasko
3a883e1236 Replace bintray bootstrap with space bootstrap repo 2020-08-14 17:31:13 +03:00
Nikolay Krasko
f484ceec80 Use GPG agent for signing in PublishedKotlinModule (KTI-314) 2020-08-14 17:31:13 +03:00
Nikolay Krasko
bbf8b12c65 Sign with GnuPG agent (KTI-314) 2020-08-14 17:31:13 +03:00
Nikolay Krasko
635ffcd53b Update maven signing for working with gpg 2 (KTI-314)
Update to maven-gpg-plugin 1.6 and add workaround for https://issues.apache.org/jira/browse/MGPG-59
2020-08-14 17:31:13 +03:00
Ilya Matveev
a121ec1e39 Update Kotlin/Native: 1.4.20-dev-16314 2020-08-14 09:41:47 +00:00
Roman Artemev
fa2c49a311 [Plugin API] Add extension point to contribute synthetic properties
- needs to fix KT_41006
2020-08-14 11:59:37 +03:00
Denis Zharkov
5ede37d6ab Report warnings on safe call + nullable extension operator
^KT-41034 In Progress
2020-08-14 11:12:34 +03:00
Roman Golyshev
852d22470e Revert "FIR Completion: Add idea-fir dependency to run completion tests"
This reverts commit 7d883f18
2020-08-13 23:12:34 +03:00
Toshiaki Kameyama
89cc5777ce Put parameters on line: don't suggest if parameters has end-of-line comments
#KT-35214 Fixed
2020-08-13 19:53:46 +03:00
Toshiaki Kameyama
efa981db36 "Create class from usage": add visibility to primary constructor if needed
#KT-29844 Fixed
2020-08-13 19:51:01 +03:00
Toshiaki Kameyama
b1e8238ea2 "Convert reference to lambda" intention: handle extension function reference with extension function call
#KT-35558 Fixed
2020-08-13 19:48:07 +03:00
Toshiaki Kameyama
9ff7539ff0 "Merge 'if's" intention: do not remove nested comments
#KT-33258 Fixed
#KT-39552 Fixed
2020-08-13 19:43:39 +03:00
Toshiaki Kameyama
f6e70cfed8 Wrap with let: fix it works correctly for invoking function type
#KT-39182 Fixed
2020-08-13 19:30:34 +03:00
Ilya Goncharov
babdeacdaf [Gradle, JS] Add resolution configuration method
^KT-41054 fixed
2020-08-13 18:04:44 +03:00
Ilya Goncharov
85f23d8c6e [Gradle, JS] Fix test with new API
^KT-41054 fixed
2020-08-13 18:04:44 +03:00
Ilya Goncharov
5eda8e95bf [Gradle, JS] Revert kotlinTargets
^KT-41054 fixed
2020-08-13 18:04:44 +03:00
Ilya Goncharov
855554ac38 [Gradle, JS] Move yarn resolutions from dependency constraints
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
fecda8548b [Gradle, JS] Override maven and ivy publishing aware context
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
58284c8b08 [Gradle, JS] Add yarn resolution gradle integration test
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
9df604cb3d [Gradle, JS] Migrate on set for npm ranges
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
1dd92f011c [Gradle, JS] Compare range lists as sets
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
50ccb522b9 [Gradle, JS] Add intersect tests
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
bd01ac52af [Gradle, JS] Add union test with fixed issue in union method
^KT-41054 fixed
2020-08-13 18:04:43 +03:00
Ilya Goncharov
7aaa1cf556 [Gradle, JS] Add invert test
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
9b8a64ef7b [Gradle, JS] Add hasIntersection test
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
814c0b73e3 [Gradle, JS] Add doc into NpmRange
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
dc7d7135f8 [Gradle, JS] Add min start, max end, min end tests
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
c25bcb4028 [Gradle, JS] Add max start test
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
42090e4839 [Gradle, JS] Add failing test
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
d4524e4050 [Gradle, JS] Small refactoring
^KT-41054 fixed
2020-08-13 18:04:42 +03:00
Ilya Goncharov
b95eb66032 [Gradle, JS] RejectAll => reject wildcard
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
d4c0d62eeb [Gradle, JS] Require version use caret
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
3ed42d394b [Gradle, JS] Support hyphenated range
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
a4de85da13 [Gradle, JS] Right wildcard range
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
f848b7cbeb [Gradle, JS] Right equals and hashCode for npm range
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
68880e6f47 [Gradle, JS] NpmRangeVisitor without nulls
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
7f3a2ac953 [Gradle, JS] Renames
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
fec8c6c0ae [Gradle, JS] Min and max are not nullable
^KT-41054 fixed
2020-08-13 18:04:41 +03:00
Ilya Goncharov
966c9dae68 [Gradle, JS] Use not inverted visitor but straightforward visitor
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
9bb49ac370 [Gradle, JS] Union of Npm Ranges
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
14fac83e2b [Gradle, JS] Intersect of NpmRange
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
90bee78dda [Gradle, JS] None range instead of none version
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
f1b8c62231 [Gradle, JS] Use rejected versions
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
d232e2ceb3 [Gradle, JS] Add ANTLR visitor for inverting of npm versions
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
768b9a0340 [Gradle, JS] Use NpmVersionConstraint
^KT-41054 fixed
2020-08-13 18:04:40 +03:00
Ilya Goncharov
bb569f36b1 [Gradle, JS] Implement reason and other methods beside version
^KT-41054 fixed
2020-08-13 18:04:39 +03:00
Ilya Goncharov
30f78847b1 [Gradle, JS] Not publish npm dependency constraints in metadata
^KT-41054 fixed
2020-08-13 18:04:39 +03:00
Ilya Goncharov
0473648b0e [Gradle, JS] Use gradle dependency constraints for yarn resolutions
^KT-41054 fixed
2020-08-13 18:04:39 +03:00
Roman Golyshev
7d883f1806 FIR Completion: Add idea-fir dependency to run completion tests
- Without this dependency, FIR plugin completion tests fail because the
fir completion contributor is not available
2020-08-13 17:29:45 +03:00
Ilmir Usmanov
31e4ddafd1 Minor. Add test with boolean parameter 2020-08-13 15:52:53 +02:00
Ilmir Usmanov
bcbb050326 Use fields for spilled variables for lambda parameters as well
In other words, do not generate p$ fields if we can use L$ fields,
which are being cleaned up.
 #KT-16222 Fixed
2020-08-13 15:52:51 +02:00
Ilya Goncharov
f5ab3a445f [Gradle, JS] Fix abstract task on default
^KT-40865 fixed
2020-08-13 15:39:02 +03:00
Yunir Salimzyanov
9ecf416a8a Parse multiple buildTypeIds for one bunch and synchronize muted tests
Cause: split Ide plugin tests in 4 parts
2020-08-13 12:57:09 +03:00
Mikhail Zarechenskiy
aafe41cf7a Do not force coercion to Unit for nullable lambda return type
#KT-41005 Fixed
2020-08-13 10:40:51 +03:00
Vyacheslav Gerasimov
d9bac4d5e4 Build: Warn about empty directories in sources 2020-08-12 21:40:04 +03:00
Vyacheslav Gerasimov
27578e6056 Build: Upgrade gradle to 6.6 2020-08-12 20:24:12 +03:00
Roman Golyshev
166b6db764 Make keyword lookup objects correctly comparable
- This is done to fix the problem with duplicated keyword items in
CodeWithMe plugin (see https://youtrack.jetbrains.com/issue/CWM-438)
2020-08-12 14:41:59 +00:00
Georgy Bronnikov
18ae665d41 IR: make IrCall take IrSimpleFunctionSymbol 2020-08-12 16:31:31 +03:00
Toshiaki Kameyama
4901cdb11f ConvertCallChainIntoSequence: support functions added in Kotlin 1.4
#KT-40448 Fixed
2020-08-12 16:28:29 +03:00
Toshiaki Kameyama
5e91ffb156 Move to class body: don't suggest on data class
#KT-40558 Fixed
2020-08-12 16:10:33 +03:00
Nick
28700ed64c [FIR] Supertype and inheritance checkers group 2020-08-12 15:38:29 +03:00
Oleg Ivanov
252eb1ad23 [FIR] Fix typo in FirDataFlowAnalyzer 2020-08-12 15:00:54 +03:00
Anton Yalyshev
e3bbc54e85 Add change-notes for 1.4 2020-08-12 14:36:47 +03:00
Oleg Ivanov
21b8679799 [FIR] Add ReturnsImplies effect analyzer 2020-08-12 11:06:07 +03:00
Oleg Ivanov
3454ae7ca4 [FIR] Add VariableStorage and flow on nodes into CFG reference 2020-08-12 11:06:07 +03:00
Oleg Ivanov
15598b62c9 [FIR] Add replaceControlFlowGraphReference function for FirFunction 2020-08-12 11:06:07 +03:00
Oleg Ivanov
7da94cc299 [FIR] Fix wrong ConstantReference for returnsNotNull in EffectExtractor 2020-08-12 11:06:07 +03:00
Anton Yalyshev
f6f3787b51 Disable FUS for Code Completion in 1.4.20 2020-08-12 10:22:29 +03:00
Andrey Uskov
20371b874a Configuration caching - register listener only once per project
To many listeners cause performance issues in Gradle.
2020-08-12 00:40:18 +03:00
Georgy Bronnikov
d2fda2a07c Fir2Ir: bug fix 2020-08-12 00:31:33 +03:00
Ilmir Usmanov
8a098545e6 Minor. Add test 2020-08-11 22:10:51 +02:00
Ilmir Usmanov
00bf07fc41 Force boxing kotlin.Result return type of suspend functions
#KT-40843 Fixed
2020-08-11 22:10:47 +02:00
Ilmir Usmanov
b06218c456 Minor. Update test data 2020-08-11 20:27:00 +02:00
Georgy Bronnikov
f21d8a4c5b JVM_IR, minor: use vals instead of objects 2020-08-11 18:44:47 +03:00
Vladimir Dolzhenko
6e016ce041 ktFile has to return script declaration from stub as well 2020-08-11 14:31:18 +00:00
Oleg Ivanov
4367d6631f [FIR] Add CallsInPlace contract analyzer 2020-08-11 16:17:01 +03:00
Oleg Ivanov
cc9c5b9e3c [FIR] Add CFG nodes, add multiple subGraphs for CFGOwner 2020-08-11 16:17:01 +03:00
Oleg Ivanov
128075e780 [FIR] Add fir source saving in resolved contract description 2020-08-11 16:17:01 +03:00
Oleg Ivanov
f467dccc68 [FIR] Rename confusing variable in CFGTraverser 2020-08-11 16:17:00 +03:00
Alexander Udalov
bcf1ee3907 Minor, fix test data for kotlinx.serialization bytecode text test 2020-08-11 15:14:06 +02:00
Steven Schäfer
53fe30eb45 JVM IR: Don't produce CHECKCASTs on null constants (KT-36650) 2020-08-11 15:13:40 +02:00
Alexander Udalov
7503f134c2 IR: use IdSignature to compare classes in FqNameEqualityChecker
This is both simpler and a lot more performant.
2020-08-11 14:41:57 +02:00
Alexander Udalov
36a1a65d98 IR: make IrBranch/IrCatch/IrSpreadElement/IrModuleFragment/IrPackageFragment classes 2020-08-11 14:41:57 +02:00
Alexander Udalov
08a35f0674 IR: make IrBody and subtypes classes 2020-08-11 14:41:57 +02:00
Alexander Udalov
4351f5235b IR: make IrExpression and subtypes classes 2020-08-11 14:41:56 +02:00
Alexander Udalov
ba7ff36274 IR: make IrDeclarationReference and subtypes classes 2020-08-11 14:41:56 +02:00
Alexander Udalov
ee904a975a IR: make IrMemberAccessExpression and subtypes classes
Merge IrMemberAccessExpressionBase into IrMemberAccessExpression, and
IrCallWithIndexedArgumentsBase into IrFunctionAccessExpression (extract
the latter into a separate file).
2020-08-11 14:41:56 +02:00
Alexander Udalov
fde7314aaf IR: do not inherit IrExpressionWithCopy from IrExpression 2020-08-11 14:41:55 +02:00
Alexander Udalov
9aa7da44e2 IR: remove IrTerminalExpressionBase, Ir{Terminal,}DeclarationReferenceBase
Implement no-op acceptChildren/transformChildren in the base class
IrExpressionBase instead. This doesn't change behavior because all other
implementations of acceptChildren/transformChildren are not affected.
2020-08-11 14:41:55 +02:00
Alexander Udalov
868018f51f IR: do not inherit IrFunctionReferenceImpl from IrCallWithIndexedArgumentsBase 2020-08-11 14:41:55 +02:00
Alexander Udalov
e3dfd5fb49 IR: push down implementations of startOffset/endOffset/type/...
Do not store these as properties in IrElementBase, IrExpressionBase and
similar classes. This helps to reduce boilerplate in implementations
(just "override val" in the constructor, instead of taking a parameter
and passing it to the superclass), and also slightly optimizes memory in
cases where the value is trivial (UNDEFINED_OFFSET, 0, etc) and thus
does not need to be stored.
2020-08-11 14:41:54 +02:00
Roman Golyshev
03f804b1c5 FIR Completion: Move completion files to idea-fir module 2020-08-11 15:38:07 +03:00
Ilmir Usmanov
d861373c6d Hack attributes for continuation of suspend function in SAM-adapter 2020-08-11 11:58:20 +02:00
Mikhail Zarechenskiy
2e131b870a Add tests for obsolete issues
#KT-38804 Obsolete
 #KT-38801 Obsolete
 #KT-38835 Obsolete
 #KT-38737 Obsolete
 #KT-38664 Obsolete
 #KT-38549 Obsolete
 #KT-38766 Obsolete
 #KT-38714 Obsolete
2020-08-11 12:34:02 +03:00
Georgy Bronnikov
7f4df19dd1 JVM_IR: reorganize throw... functions in Symbols 2020-08-11 10:54:29 +03:00
Denis Zharkov
6a16d6a246 FIR: Simplify delegating constructors call resolution 2020-08-11 10:14:02 +03:00
Denis Zharkov
8b71f5e558 FIR: Do not leave cyclic upper bounds of type parameters 2020-08-11 10:14:02 +03:00
Denis Zharkov
a5a93d00a7 FIR: Rework delegation constructor calls resolution
Make it work independently of being called for inner class (as in FE 1.0)
2020-08-11 10:14:02 +03:00
Denis Zharkov
db93b9052b FIR: Fix incorrect optimization for integer literals 2020-08-11 10:14:02 +03:00
Vyacheslav Gerasimov
ad8709b2dc Build: Remove exclusion of kotlinx-coroutines-core in scripting-common
It breaks available-at feature used in MPP
2020-08-11 00:39:04 +03:00
Vladimir Dolzhenko
8540f47c15 Fixed FindUsages case on look up implementation getter/setters via property names
#KT-40788 Fixed
#KT-24616 Fixed

back-port from kotlin-ide commit aa5580bb5a7e96b209cdaa1c82f4e485ee001ae8
2020-08-10 22:04:06 +02:00
Mikhail Zarechenskiy
e49cdf0ca2 Prohibit using suspend functions as SAM in fun interfaces
#KT-40978 Fixed
2020-08-10 22:04:16 +03:00
Mikhael Bogdanov
607f99ed3c Don't generate implicit overrides delegating to Java defaults
#KT-40920 Fixed
2020-08-10 20:03:23 +02:00
Sergey Igushkin
07aee8831e Fix stdlib-by-default with non-compiled source sets (KT-40559)
When a `variantFilter { ... }` is used in Android projects, AGP does not
creates some variants but still creates the source sets which would be
related to those variants.

For source sets that are not included into any compilation, the stdlib
module added by default was kotlin-stdlib-common, and it was added to
the `api` scope.

But AGP checks the `androidTest*Api` configurations and
if it detects any dependencies in them, it reports deprecation warnings.

However, we have plans to prohibit unused source sets at all as they
have no reasonable use cases. So the fix is not to add the stdlib by
default to source sets that participate in no compilations.

Issue #KT-40559 Fixed
2020-08-10 20:08:22 +04:00
Roman Golyshev
6e2887e083 FIR Completion: Add insertion handling for functions with lambdas
- The support is not complete
2020-08-10 18:25:34 +03:00
Roman Golyshev
b3a674abee FIR IDE: Add parameter's and type's properties required for completion 2020-08-10 18:25:34 +03:00
Roman Golyshev
67ed33367f FIR Completion: Add function insert handler
- It is a specialized copy from `KotlinFunctionInsertHandler.Normal`
2020-08-10 18:25:34 +03:00
Roman Golyshev
b547feb00d FIR Completion: Render vararg modifier in lookups 2020-08-10 18:25:33 +03:00
Roman Golyshev
582b00f5b2 FIR Completion: Add UniqueLookupElement to the lookup elements
- It is done to differentiate overloads of the same function
2020-08-10 18:25:33 +03:00
Roman Golyshev
b6ee478190 FIR Completion: Add psi element to the lookups
- May be a performance problem later
2020-08-10 18:25:33 +03:00
Roman Golyshev
53180e707e FIR Completion: Fix invalid isAbstract condition 2020-08-10 18:25:33 +03:00
Roman Golyshev
ef461260b0 FIR Completion: Add simple insertion handler to lookup elements
- The `QuotedNamesAwareInsertionHandler` is just a copy of
`BaseDeclarationInsertHandler`
2020-08-10 18:25:33 +03:00
Roman Golyshev
10598ee98e FIR Completion: Add simple lookup decorating with icon and parameters 2020-08-10 18:25:32 +03:00
Roman Golyshev
64187b40c9 FIR Completion: Prevent immediate completion in number literals
- This is copied from the original KotlinCompletionContributor
2020-08-10 18:25:32 +03:00
Alexey Trilis
d86c14243e Add @SinceKotlin to kotlinx.browser and kotlinx.dom packages
Add @DeprecatedSinceKotlin to kotlin.browser and kotlin.dom packages
2020-08-10 18:08:19 +03:00
Dmitriy Novozhilov
0e53d11dd4 Disable AllowResultInReturnType feature
#KT-40843
2020-08-10 17:57:53 +03:00
Valeriy.Vyrva
30ff886754 Improve docs for createTempDir/createTempFile
#KT-35218
2020-08-10 17:29:25 +03:00
Vladimir Ilmov
4fe6880489 Cyrillic 'c' fix in inspectionLikeProcessings.kt 2020-08-10 14:42:46 +02:00
Nick
0a2f113a24 [FIR] Fix slow string conversions in FirEffectiveVisibilityResolver 2020-08-10 13:46:15 +03:00
Alexander Dudinsky
e67518c349 Update gradle plugin version in GradleFacetImportTest
Also drop legacy tests for 1_1_2
2020-08-10 13:14:01 +03:00
Pavel Kirpichenkov
f431da2a66 Reapply "Introduce @FrontendInternals annotation""
This reverts commit 9ca4717d11.
^KT-39643 Fixed
2020-08-10 12:22:55 +03:00
Yan Zhulanow
5e8e60a399 Move back the 'KotlinStructureViewElement.isPublic' property used externally
Reasoning: Method com.gmail.blueboxware.extsee.kotlin.ExtSeeKotlinStructureViewModel.Companion.PublicElementsFilter.isVisible(com.intellij.ide.util.treeView.smartTree.TreeElement treeNode) : boolean contains an *invokevirtual* instruction referencing an unresolved method org.jetbrains.kotlin.idea.structureView.KotlinStructureViewElement.isPublic()
2020-08-10 18:18:37 +09:00
Alexander Dudinsky
aec87744f2 Run ImportAndCheckNavigation tests only vs the master version of plugin
Also error "Could not find org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable"
was fixed by adding ":native:kotlin-klib-commonizer-embeddable:install"
in dependencies for the kotlin-plugin install
2020-08-10 12:13:21 +03:00
Alexander Dudinsky
2042db598a Mute GradleNativeLibrariesInIDENamingTest.testLibrariesNaming in 192, 193
After updating version of gradle-plugin this tests started to fail on
the old version of IDE. After discussion we decided just mute it in
the old bunches
2020-08-10 12:04:51 +03:00
Sergey Igushkin
988480d649 Fix source JARs missing in Kotlin/Native targets with HMPP (KT-39051)
With HMPP, a separate implementation of `kotlinComponents` is used which
accidentally ignored the parent's logic for source artifacts.

As a simple fix, copy the parent's logic for source artifacts.

Issue #KT-39051 Fixed
2020-08-10 13:02:17 +04:00
Nataliya Valtman
a766369e72 KT-33908 Make Kotlin Gradle plugin compatible with configuration cache
#KT-33908 Fixed
2020-08-10 11:17:30 +03:00
Georgy Bronnikov
ea57b4cccb IR: add and unmute tests 2020-08-10 10:16:24 +03:00
Georgy Bronnikov
85ba170217 JVM_IR: use IrBasedDescriptors across codegen 2020-08-10 10:16:23 +03:00
Georgy Bronnikov
0b4c43083d IR: add IrBasedDescriptors 2020-08-10 10:16:23 +03:00
Georgy Bronnikov
dafcdc527d IR: propagate original declaration info via attributeOwnerId
For IrProperty, IrSimpleFunction we need to pass information about
original declaration to JVM_IR codegen. Instead of descriptors, use
the attributeOwnerId field.
2020-08-10 10:16:23 +03:00
Georgy Bronnikov
04d93dfbce IR: move containerSource from descriptor to IrFunction, IrProperty 2020-08-10 10:16:23 +03:00
Nick
4669e019d1 [FIR] Add diagnostic CONFLICTING_OVERLOADS & REDECLARATION 2020-08-10 10:09:37 +03:00
kvirolainen
36984009e9 Add samples for flatten, unzip functions 2020-08-10 03:40:13 +03:00
Elijah Verdoorn
41d5615608 Add samples for mapNotNull, find, getOrNull functions 2020-08-10 03:39:49 +03:00
Ilya Kirillov
62df2b3195 FIR IDE: run SUPER_TYPES & BODY_RESOLVE phases under global lock 2020-08-09 12:05:20 +03:00
Ilya Kirillov
7fb408ecd7 FIR IDE: enable new project wizard to FIR IDE 2020-08-09 12:05:13 +03:00
Ilya Kirillov
db7119f04d FIR IDE: fix ability to create new Kotlin files 2020-08-09 12:05:11 +03:00
Ilya Kirillov
054d196ec5 FIR IDE: temporary ignore failing tests 2020-08-09 12:05:02 +03:00
Ilya Kirillov
683ec2beff FIR IDE: make KtScopeProvider thread local 2020-08-09 12:04:53 +03:00
Ilya Kirillov
f62204fff1 FIR: move getCallableNames/getClassifierNames from scope to FirContainingNamesAwareScope 2020-08-09 12:04:52 +03:00
Ilya Kirillov
36a161080f FIR IDE: introduce KtType rendering 2020-08-09 12:04:44 +03:00
Ilya Kirillov
9f33d0147c FIR IDE: add info about nullability to KtType 2020-08-09 12:04:43 +03:00
Ilya Kirillov
16d22ae7e3 FIR IDE: correctly build FIR for qualified expressions 2020-08-09 12:04:43 +03:00
Ilya Kirillov
66f6fe18d6 FIR IDE: replace javax threadsafe annotations with custom ones
javax.annotation.concurrent may not be present for some JDKs
2020-08-09 12:04:35 +03:00
Ilya Kirillov
4595ee2cc0 FIR IDE: create read only copy of symbol builder only for completion 2020-08-09 12:04:34 +03:00
Ilya Kirillov
ccf232eaab FIR IDE: forbid analysis session to be stored in a variable 2020-08-09 12:04:34 +03:00
Ilya Kirillov
b41a5f9f34 FIR: make TypeRegistry thread safe 2020-08-09 12:04:26 +03:00
Ilya Kirillov
5f424ed1ec FIR IDE: rewrite low level API
- Cache ModuleResolveState for module till the world changes
- Resolve every file under a lock
- All creation of raw fir files and resolve of them happens in FirFileBuilder
- Lazy resolve of fir elements happens in FirElementBuilder

Caching works like the following:
- FirModuleResolveState holds PsiToFirCache & DiagnosticsCollector & FileCacheForModuleProvider
- FileCacheForModuleProvider holds a mapping from ModuleInfo to ModuleFileCache
- ModuleFileCache caches
    - KtFile -> FirFile mapping
    - ClassId -> FirClassLikeDeclaration, CallableId -> FirCallableSymbol
        which used in corresponding FirProvider
    - mapping from declaration to it's file
        which used in corresponding FirProvider
    - locks for fir file resolving
- PsiToFirCache provides mapping from KtElement to  FirElement
- DiagnosticsCollector collects diagnostics for file and caches them
2020-08-09 12:04:11 +03:00
Ilya Kirillov
1957be8757 FIR IDE: fix testdata of tests which now pass 2020-08-09 12:04:03 +03:00
Ilya Kirillov
34aa848b15 FIR: do not allow getting PSI text in RawFirBuilder in stub mode 2020-08-09 12:04:03 +03:00
Ilya Kirillov
cfc46b0cc8 FIR IDE: introduce FirIdeAllSourceDependenciesSymbolProvider
Co-authored-by: Simon Ogorodnik <simon.ogorodnik@jetbrains.com>
2020-08-09 12:03:56 +03:00
Ilya Kirillov
7d8ef5c7a2 FIR IDE: introduce KtFirConstructorDelegationReference 2020-08-09 12:03:54 +03:00
Ilya Kirillov
0870ded054 FIR IDE: introduce KtFirArrayAccessReference 2020-08-09 12:03:47 +03:00
Ilya Kirillov
22054c8507 FIR IDE: use non-fake override fir elements when finding psi for fir 2020-08-09 12:03:40 +03:00
Ilya Kirillov
d10e3f91fa FIR IDE: store FirScope strong references only in KtFirAnalysisSession 2020-08-09 12:03:33 +03:00
Ilya Kirillov
7033be588c FIR IDE: regenerate member scope test 2020-08-09 12:03:27 +03:00
Ilya Kirillov
ea3b2d8310 KT IDE: fix fully-qualified type resolving 2020-08-09 12:03:26 +03:00
Ilya Kirillov
50951fdfc3 KT IDE: use proper package symbol PSI to fix invalidated access exception 2020-08-09 12:03:14 +03:00
Ilya Kirillov
9f9ce6ba61 Fix compilation of KtFirDelegatingScope 2020-08-09 12:03:07 +03:00
Ilya Kirillov
1c195ea2bb FIR IDE: add kdoc for KtAnalysisSession 2020-08-09 12:03:07 +03:00
Ilya Kirillov
b8caefa0c4 FIR IDE: always recreate analysis session in tests to avoid breaking its contract 2020-08-09 12:03:06 +03:00
Ilya Kirillov
19efd19c6c FIR IDE: fix AbstractSymbolByFqNameTest after rebase 2020-08-09 12:03:01 +03:00
Ilya Kirillov
94b62e2ac6 FIR IDE: make context-dependent analysis session to use original cache on read-only mode 2020-08-09 12:03:00 +03:00
Ilya Kirillov
c0f5c90231 FIR IDE: separate ValidityOwner to ValidityTokenOwner & ValidityToken 2020-08-09 12:02:49 +03:00
Ilya Kirillov
6a6580dd97 FIR IDE: introduce KtConstructorSymbol.ownerClassId
Will be needed for completion
2020-08-09 12:02:48 +03:00
Ilya Kirillov
4653cdf794 FIR IDE: make KtFirDelegatingScope caching a thread safe 2020-08-09 12:02:42 +03:00
Roman Golyshev
ebf20c9706 Add multi-file tests for primitive completion
- This is required to test/debug correct completion from imports
2020-08-09 12:02:40 +03:00
Roman Golyshev
1b3a1a662f Add simple completion of class-like symbols 2020-08-09 12:02:34 +03:00
Roman Golyshev
20c627ea47 Implement collecting class-like names in KtFirStarImportingScope 2020-08-09 12:02:28 +03:00
Roman Golyshev
29ee233bb9 Remove repeating scopes collected by buildCompletionContextForFunction
- This is certainly a bug, we would have to fix it later
2020-08-09 12:02:27 +03:00
Roman Golyshev
e3778d62e3 Simplify canBeCalledWith function 2020-08-09 12:02:21 +03:00
Roman Golyshev
b90503decb Move PackageIndexHelper to KtFirStarImportingScope.kt 2020-08-09 12:02:16 +03:00
Roman Golyshev
d2fbd8e338 Remove KotlinFirCompletionProvider
- We should strive to use only high-level API for completion from now on
2020-08-09 12:02:16 +03:00
Ilya Kirillov
dee58e1d86 FIR IDE: handle importing scopes in completion in HL API
Co-authored-by: Roman Golyshev <roman.golyshev@jetbrains.com>
2020-08-09 12:02:11 +03:00
Ilya Kirillov
7aa26944d7 FIR IDE: rename utils.kt to psiUtils.kt
Co-authored-by: Roman Golyshev <roman.golyshev@jetbrains.com>
2020-08-09 12:02:00 +03:00
Ilya Kirillov
902b42ae1d FIR IDE: fix typo in completion testdata
Co-authored-by: Roman Golyshev <roman.golyshev@jetbrains.com>
2020-08-09 12:01:59 +03:00
Roman Golyshev
c3a3ab9e89 Implement the completion using high-level API only
- The indecies are not yet used

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:59 +03:00
Roman Golyshev
a6dd84a7e4 FIR IDE: Modify KtFirAnalysisSession for completion
- This is WIP solution for having a specialized `KtFirAnalysisSession`
for the completion

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:54 +03:00
Roman Golyshev
54946a793a Fix FirCompletionContext for safe access elements
- `towerDataContextForStatement` may contain safe access (?.) fir
elements as keys; however, `state.getCachedMapping(current)` would
never return those since they are considered as sugar fir elements

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:49 +03:00
Roman Golyshev
a2cf01162e Fix bug with member extensions with explicit receiver
Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:48 +03:00
Roman Golyshev
df03e31b86 FIR IDE: Add KtCallableSymbol abstraction
- It should incapsulate callable symbols like functions, properties
and constructors

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:44 +03:00
Roman Golyshev
a4a2d92c08 FIR IDE: Make KtFirReference implement KtSymbolBasedReference
Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2020-08-09 12:01:35 +03:00
Roman Golyshev
2eb439899e Use index to get symbols from importing scopes 2020-08-09 12:01:25 +03:00
Dmitriy Novozhilov
cefecdef25 fixup! Iterate on symbols, not on scopes 2020-08-09 12:01:23 +03:00
Roman Golyshev
e7f5594ffe Use more correct check for the constructor symbol
- add test for extension function receiver
2020-08-09 12:01:23 +03:00
Roman Golyshev
a3da1ea1a0 Iterate on symbols, not on scopes
- This way it is easier to get the correct results
2020-08-09 12:01:15 +03:00
Roman Golyshev
708c54f4d2 Refactor the collecting of callable symbols from scopes 2020-08-09 12:01:07 +03:00
Roman Golyshev
81f60bf252 Add test for smartcast 2020-08-09 12:01:07 +03:00
Roman Golyshev
ffb907150a Use information about receivers in completion
- Found few problems during resolving a single functon; disabled
assertions and marked them with TODO
- Add simple completion tests to simplify development
2020-08-09 12:01:00 +03:00
Roman Golyshev
0f5fc1fa99 Add FirSymbolProvider::getAllCallableNamesInPackage function
- Also, fix implementation of `getCallableNames` in few cases
2020-08-09 12:00:59 +03:00
Denis Zharkov
97d4918ed3 Expose local scopes to use in completion 2020-08-09 12:00:52 +03:00
Roman Golyshev
6129f4bcef Partial raw FIR building 2020-08-09 12:00:45 +03:00
Roman Golyshev
a1b621d987 Completion with FIR (prototype, work-in-progress) 2020-08-09 12:00:44 +03:00
Ilya Kirillov
2a495c1135 FIR IDE: introduce composite scopes 2020-08-09 12:00:38 +03:00
Ilya Kirillov
9092b33755 FIR IDE: Introduce module resolve state for completion 2020-08-09 12:00:31 +03:00
Ilya Kirillov
1d92fbaa7f FIR IDE: correctly set symbol origin for fake overridden ones 2020-08-09 12:00:24 +03:00
Ilya Kirillov
88548d988a FIR IDE: implement getCallableNames/getClassifierNames in more scopes 2020-08-09 12:00:18 +03:00
Ilya Kirillov
138f11ee27 FIR IDE: introduce member scope tests 2020-08-09 12:00:11 +03:00
Ilya Kirillov
f709e6acf3 FIR IDE: introduce scopes for HL API 2020-08-09 12:00:05 +03:00
Dmitriy Novozhilov
6596dc359b fixup! Completion with FIR (prototype, work-in-progress) 2020-08-09 12:00:04 +03:00
Ilya Kirillov
d62500531b FIR: add getClassifierNames for FirScope 2020-08-09 11:59:57 +03:00
Roman Golyshev
656086f90a Add FirScope::getCallableNames function 2020-08-09 11:59:50 +03:00
Ilya Kirillov
1f3add49f4 FIR IDE: move trailing comma related registry keys to ide-frontend-independent.xml 2020-08-09 11:59:49 +03:00
Ilya Kirillov
055b975699 FIR IDE: add tests which failing with exceptions inside FIR 2020-08-09 11:59:49 +03:00
Ilya Kirillov
9cf4fdfb71 FIR IDE: add reference info on reference resolve 2020-08-09 11:59:44 +03:00
Ilya Kirillov
5c6d636d02 Minor: reformat fir ide part of GenerateTests.kt 2020-08-09 11:59:38 +03:00
Ilya Kirillov
45e01a8b3d FIR IDE: precalculate DuplicatedFirSourceElementsException error message
It may be called from non-read action
2020-08-09 11:59:33 +03:00
Ilya Kirillov
964becf138 FIR IDE: allow the same entity to be accessed from different threads 2020-08-09 11:59:23 +03:00
Ilya Kirillov
4c08dfb238 Add invoke reference resolve test without errors in test data 2020-08-09 11:59:17 +03:00
Ilya Kirillov
15ecfd84b4 FIR IDE: cache KtAnalysisSession for modules 2020-08-09 11:59:15 +03:00
Ilya Kirillov
8c0197e081 FIR IDE: introduce KtAnalysisSessionProvider & helping functions for working with analysis session 2020-08-09 11:59:10 +03:00
Ilya Kirillov
acb8546583 FIR IDE: fix ReadOnlyWeakRef error message 2020-08-09 11:59:05 +03:00
Ilya Kirillov
b09358fe17 FIR IDE: rename KtFieldSymbol -> KtFirJavaFieldSymbol 2020-08-09 11:59:04 +03:00
Ilya Kirillov
f98ff2c25e FIR IDE: always pass resolve state as parameter when getting fir by psi 2020-08-09 11:59:04 +03:00
Mikhail Zarechenskiy
0c13a7f89a Fix accessibility check for experimental declarations from default scope
#KT-40919 Fixed
2020-08-07 17:49:15 +03:00
Ilmir Usmanov
b403b63f48 Ease field initialization check
Since there is already VAL_REASSIGNMENT diagnostics, we can safely only
for direct assignments.
 #KT-40893 Fixed
2020-08-07 14:22:18 +02:00
Nick
6c0abe7e48 [FIR] Fix CliTestGenerated$Jvm.testFirError 2020-08-07 13:27:29 +03:00
Pavel Kirpichenkov
9ca4717d11 Revert "Introduce @FrontendInternals annotation"
Revert due to Mobile IDE Trunk IJ TC configuration
This reverts commits:
ffc3d8bdfc
c0e713980b

^KT-39643 In Progress
2020-08-07 12:10:03 +03:00
Mads Ager
7f2efabe6a [JVM_IR]: Improve stepping for when.
Additionally, use the line number of the class for default interface
dispatch methods.
2020-08-07 09:16:01 +02:00
Dat Trieu
1009a240f2 KT-20357: Add samples for filter functions 2020-08-06 23:41:12 +03:00
Steven Schäfer
ca6e430e89 JVM IR: Handle nested classes in DelegatedPropertyOptimizer 2020-08-06 21:01:59 +02:00
Steven Schäfer
da9bff40f0 JVM IR: Don't remove stores to visible locals in DelegatedPropertyOptimizer 2020-08-06 21:01:59 +02:00
Ilya Kirillov
983c84d6a6 Wizard: fix default template compilation when using JS IR
#KT-39904 fixed
2020-08-06 21:46:50 +03:00
Alexander Udalov
e4cd7cdbcf IR: remove unused code, cleanup 2020-08-06 17:08:04 +02:00
Alexander Udalov
b30b2e0179 IR: minor, render duplicate IR node in checker 2020-08-06 17:08:04 +02:00
Alexander Udalov
8db1c3611b IR: introduce abstract class IrDeclarationBase
The main purpose of this class is to improve performance of IR visitors
and transformers. `IrElementVisitor.visitDeclaration` now takes
IrDeclarationBase as a parameter, and therefore the call to `accept`
there is now a virtual class call, instead of an interface call.
2020-08-06 17:08:04 +02:00
Alexander Udalov
771e7574f4 IR: make subtypes of IrDeclaration classes 2020-08-06 17:08:03 +02:00
Alexander Udalov
3cecf81176 IR: transform base classes of lazy IR to interfaces 2020-08-06 17:08:02 +02:00
Alexander Udalov
b02653a524 IR: remove base classes IrDeclarationBase and IrFunctionBase
They introduce a diamond class hierarchy which prevents IR element
hierarchy from being transformed to classes.
2020-08-06 16:46:26 +02:00
Alexander Udalov
9152df4702 PIR: transform base implementation classes to interfaces
Unfortunately this requires a lot of boilerplate, but is a requirement
for transforming the main IR element hierarchy interfaces
(IrDeclaration, IrClass, ...) to classes.
2020-08-06 16:46:26 +02:00
Ilya Goncharov
13766d5075 [Gradle, JS] Update test data
^KT-40884 fixed
2020-08-06 15:33:21 +03:00
Ilya Goncharov
52110a08d9 [Gradle, JS] Update versions
^KT-40884 fixed
2020-08-06 15:33:06 +03:00
Sergey Igushkin
f6356199d3 Fix typealias usage nullability and annotations lost in deserialization
Issue #KT-40824 Fixed
2020-08-06 15:46:54 +04:00
Alexander Dudinsky
4063aba677 Remade launch of NativeRunConfigurationTest against master version of gradle plugin 2020-08-06 14:06:05 +03:00
Konstantin Tskhovrebov
69ce6bd952 Add tests for setup native run gutters. 2020-08-06 14:06:04 +03:00
Sergey Igushkin
b5d4e4c44c Enable compatibility metadata variant by default in HMPP
This by default ensures that libraries published with HMPP are
compatible with non-HMPP consumers (which is the default in 1.4.0).
2020-08-06 14:08:51 +04:00
Mikhail Zarechenskiy
2eb17df962 Do not compute SamType too eagerly as it can force member resolution
Internally, during creation of `SamType` the compiler checks if a
 parameter is really can be used as a SAM, so this check involves
 lookup for abstract members, which can force additional computation of
 member scopes. This is totally fine for BE but it can be dangerous
 for light classes computation when not all scopes are processed.

 Note that this issue appeared quite recently after 16f175612e

 #KT-40869 Fixed
2020-08-06 09:20:56 +03:00
Vladimir Dolzhenko
6ec0e9546b Fix 192 compilation for UI for standalone gradle scripts
Relates to #KT-39790
2020-08-05 23:39:34 +02:00
Konstantin Tskhovrebov
66c1bd8c89 Revert "Update KMM plugin user texts."
This reverts commit 5edbc75d
2020-08-05 21:54:01 +03:00
Pavel Kirpichenkov
c0e713980b Add helpers for getting commonly used services without an opt-in
These services are LanguageVersionSettings, DataFlowValueFactory
#KT-39643 Fixed
2020-08-05 21:44:47 +03:00
Pavel Kirpichenkov
ffc3d8bdfc Introduce @FrontendInternals annotation
#KT-39643
2020-08-05 21:44:47 +03:00
Sergey Igushkin
eff5839369 "Kotlin Multiplatform Projects are an ~experimental~ Alpha feature." 2020-08-05 22:01:12 +04:00
Ilmir Usmanov
6c475e614a Minor. Update debugger tests 2020-08-05 19:47:55 +02:00
Ilmir Usmanov
68342a1f72 Initialize fake inliner variables on resume path
Otherwise, this will cause R8 to complain.
2020-08-05 19:47:55 +02:00
Ilmir Usmanov
bb5a99ec18 Do not put $completion to LVT if is dead 2020-08-05 19:47:54 +02:00
Florian Kistner
9925866293 203: Fix compilation 2020-08-05 19:36:43 +02:00
Florian Kistner
c792092410 Bump fastutil version to match 203 2020-08-05 19:36:42 +02:00
Nikita Bobko
c5398e8317 Move 'radixPrefix' from compiler modules to IDE modules
`radixPrefix` is used only in IDE now. So let's put it into IDE modules.

This commit is done in order to be able to use code dependent on
`radixPrefix` in `kotlin-ide` repo, because `kotlin-ide` depends on
1.4.0 artifacts of compiler. And `radixPrefix` isn't presented in
those artifacts
2020-08-05 20:17:17 +03:00
Sergey Igushkin
093d4b3108 Revert "Fix typealias usage nullability and annotations lost in deserialization"
This reverts commit 070848a1
2020-08-05 20:17:49 +04:00
Konstantin Tskhovrebov
5edbc75d7b Update KMM plugin user texts.
#Fixed KMM-324
2020-08-05 18:37:27 +03:00
Jinseong Jeon
b57794d96e IR util: IrExpression.isSafeToUseWithoutCopying 2020-08-05 17:07:27 +03:00
Jinseong Jeon
7ef1c74bbf FIR2IR: apply adapted reference conversion to coercion-to-unit 2020-08-05 17:07:27 +03:00
Mikhail Glukhikh
5f80bfd5d4 [FIR] Don't report UNINITIALIZED_VARIABLE on lateinit local variable 2020-08-05 16:47:51 +03:00
Natalia Selezneva
54d96a2dd7 UI for standalone gradle scripts
^KT-39790 Fixed
2020-08-05 15:22:22 +02:00
Mikhail Glukhikh
fc874e72b1 [FIR2IR] Initialize components a bit earlier to prevent lateinit errors 2020-08-05 12:11:34 +03:00
Mikhail Glukhikh
17b289fa00 [FIR] Code cleanup: get rid of FirClass.buildUseSiteMemberScope() 2020-08-05 12:11:34 +03:00
Mikhail Glukhikh
8bb5488a26 [FIR] look at intersectionOverride during override processing
This commit fixes some BB tests broken by previous commit
2020-08-05 12:11:34 +03:00
Mikhail Glukhikh
f1356a809e Fir2IrLazySimpleFunction: generate overridden symbols via FirTypeScope 2020-08-05 12:11:33 +03:00
Alexander Dudinsky
52c01abb83 Increase Xmx size after investigation OOM problem in KMM-316 2020-08-05 10:45:16 +03:00
Alexander Dudinsky
d012cd3272 Add kotlin-test-junit:install in dependencies for the kotlin-plugin install 2020-08-05 10:45:16 +03:00
Alexander Dudinsky
ea0099aa39 Fix testPlatformToCommonExpByInComposite.
In 9d362875da build started fail if mpp
or js targets not configured.
The test testPlatformToCommonExpByInComposite was fixed due it.
2020-08-05 10:45:16 +03:00
Alexander Dudinsky
05d6217f78 Changed gradle-plugin version in Gradle tests.
When 6.5.1 Gradle version was added, more tests have began to fail
because of legacy gradle-plugin versions (1.1., 1.2.) which are not
compatible with the new version of Gradle. This commit updates the used
version of the Gradle plugin to the latest stable (1.3.72) and makes it
configurable from tests.
2020-08-05 10:45:15 +03:00
Alexander Dudinsky
6652a7072c Fix testData due to KT-40551.
Starting from version 1.3.60, unnecessary dependencies with runtime
scopes have been added for modules jvmTest and jsTest. After updating
the plugin version in tests from 1.3.50 to 1.3.72 and master,
tests began to fail because of this. In order not to stop other checks
in tests, they were redone for the current behavior with unnecessary
dependencies.
After fixing bug KT-40551, the old behavior in tests will be returned.
2020-08-05 10:45:15 +03:00
Alexander Dudinsky
0298795b18 Add gradle.properties with kotlin.stdlib.default.dependency=false for tests
In the master version of plugin dependencies on stdlibs are enabled
by default. It is not expected for some tests.
Flag kotlin.stdlib.default.dependency=false fixed it.
2020-08-05 10:45:15 +03:00
Alexander Dudinsky
bc623e97ec Add Gradle version 6.5.1 for tests. 2020-08-05 10:45:15 +03:00
Alexander Dudinsky
1da05c54be Change gradle-plugin versions for tests from 1.3.50 to 1.3.72 2020-08-05 10:45:14 +03:00
Nick
f15f5bccc8 [FIR] Add more diagnostic messages 2020-08-05 10:41:06 +03:00
Victor Petukhov
f45de9d8fb NI: approximate not top-level captured types during code generation
^KT-40693 Fixed
2020-08-05 10:36:36 +03:00
Ilya Matveev
f6d7e7c52a CocoaPods: Fix setting custom framework name
The main scheme of a synthetic project generated for
pod import has the same name as the podspec generated
for the kotlin module (== Gradle project name). But
when starting an Xcode build, we specify the -scheme
argument to a framework name instead of project.name.

By default they are the same, but if a custom framework
name is specified, xcodebuild fails.

Issue #KT-40801 fixed
2020-08-05 06:46:53 +00:00
Mikhail Zarechenskiy
a45f73867a Add compatibility resolve when SAM conversion was applied partially
#KT-40646 Fixed
2020-08-05 00:03:33 +03:00
Sergey Igushkin
070848a1c1 Fix typealias usage nullability and annotations lost in deserialization
This fixes a regression introduced by the commit 4b0da0688a which made
deserializer expand typealiases but didn't take nullability and use site
annotations into account.

Issue #KT-40824 Fixed
2020-08-05 00:19:52 +04:00
Nick
ec4f04095c [FIR] Rearrange FirErrors.kt 2020-08-04 22:40:09 +03:00
Nick
207027b84c [FIR] Fix light tree's supertype FirDelegatedConstructorCall source 2020-08-04 22:37:43 +03:00
Nick
a59cedcd39 [FIR] Fix non-fake sources for constructor delegates 2020-08-04 22:37:42 +03:00
Nick
f74eb07203 [FIR] Fix incorrect diagnostic behaviour + several enum diagnostics 2020-08-04 22:28:49 +03:00
Nick
b76f757d47 [FIR] Add diagnostic for missing primary constructor 2020-08-04 22:28:49 +03:00
Nick
0f213e58db [FIR] Add diagnostic for primary constructor not called 2020-08-04 22:28:48 +03:00
Nick
bb0e1b7390 [FIR] Add diagnostic for constructor delegation cycles 2020-08-04 22:28:48 +03:00
Mikhail Glukhikh
e841b3a77b [FIR] Add diagnostic collection to KotlinToJVMBytecodeCompiler 2020-08-04 22:27:18 +03:00
Mikhail Glukhikh
9c3b8484b9 [FIR TEST] Add CLI test with should-be-error (not yet) 2020-08-04 22:27:18 +03:00
Ilmir Usmanov
824991a9dd Minor. Add tests. 2020-08-04 15:42:38 +02:00
Ilmir Usmanov
bbd4c21595 Cleanup spilled variables
#KT-16222
2020-08-04 15:42:37 +02:00
Ilmir Usmanov
999b41068b Minor. Refactor variables spilling
Split information collection and method node mutation.
2020-08-04 15:42:37 +02:00
Ilmir Usmanov
405c9743ef Do not spill dispatch receiver of suspend functions if it is not used
#KT-20571
2020-08-04 15:42:36 +02:00
Jinseong Jeon
5db7957230 FIR2IR: use type arguments from fully expanded type 2020-08-04 14:44:38 +03:00
Ilya Kirillov
606dc2f723 Fix binary compatibility problems in ImportInsertHelper & ShortenReferences 2020-08-04 12:46:13 +03:00
Victor Petukhov
af48f08f9c NI: take into account flexible types during capturing arguments from expression
^KT-40544 Fixed
2020-08-04 12:38:04 +03:00
vldf
65ebd02a39 [FIR] Fix for CanBeReplacedWithOperatorAssignment Checker 2020-08-04 11:20:42 +03:00
Mikhail Glukhikh
6f3df6faf4 [FIR] Regenerate extended checker tests 2020-08-04 09:35:36 +03:00
Mikhail Glukhikh
181a8bb79e [FIR TEST] Mute failing BB test with Byte/Short.and usage 2020-08-04 08:59:16 +03:00
Jinseong Jeon
47c47be3d3 FIR serializer: serialize annotations on FirTypeRef, not ConeKotlinType 2020-08-04 08:59:16 +03:00
Ivan Kylchik
0a28e5e031 Add argument unwrapping for case when argument is named 2020-08-04 08:59:15 +03:00
Mikhail Glukhikh
2e2099afae [FIR] Introduce NOT_AN_ANNOTATION_CLASS diagnostic 2020-08-04 08:59:15 +03:00
Mikhail Glukhikh
8fd087a964 [FIR] Don't report duplicated UNRESOLVED_REFERENCE on annotation entries 2020-08-04 08:59:15 +03:00
Mikhail Glukhikh
a6e811a67a [FIR] Add status to Java annotation constructor (fix after rebase) 2020-08-04 08:59:15 +03:00
Mikhail Glukhikh
8379b3794a [FIR2IR] Return fallback mode for annotation resolved placeholder 2020-08-04 08:59:15 +03:00
Dmitriy Novozhilov
b63257345b [FIR] Map Class to KClass in java annotations 2020-08-04 08:59:15 +03:00
Mikhail Glukhikh
282a295d43 [FIR] Enable arrayOf transformer in completion (inside annotations) 2020-08-04 08:59:14 +03:00
Dmitriy Novozhilov
721b9b4d8c [FIR] Resolve annotations as calls 2020-08-04 08:59:14 +03:00
Dmitriy Novozhilov
bc1fa8ed7f [FIR] Add constructor for java annotations 2020-08-04 08:59:14 +03:00
Dmitriy Novozhilov
644e9843f9 [FIR] Add initialization of calleeReference for FirAnnotationCall 2020-08-04 08:59:14 +03:00
Dmitriy Novozhilov
614291b2cc [FIR] Make FirAnnotationCall resolvable 2020-08-04 08:59:14 +03:00
Dmitriy Novozhilov
ffd30566be [FIR] Add FirErrorResolvedQualifier for qualifiers with resolve diagnostic 2020-08-04 08:59:14 +03:00
Dmitry Gridin
a5e9401a0a [configuration] change updater number to 1.4.* and 1.5.*
#KT-40639 Fixed
2020-08-04 11:13:30 +07:00
Julian Kotrba
88f508446a Make repeat example more expressive
This commit adds the zero-based index of current iteration from the passed HOF "action" of the repeat function to its associated code sample.

KT-20357
2020-08-04 00:48:06 +03:00
Ilya Gorbunov
a5178bb826 Minor: fix toJavaDuration docs 2020-08-04 00:34:15 +03:00
Ilya Gorbunov
99eb7f391b Fix doc wording around covariance/invariance 2020-08-04 00:33:05 +03:00
Roman Artemev
4f73e08704 [KLIB] Make fake override resolver garbage free as much as possible
- reduce memory pollution during FO resolve
2020-08-03 19:22:07 +03:00
Roman Artemev
876ee265f2 [KLIB] Fix memory leak in fake override resolver 2020-08-03 19:22:07 +03:00
Roman Artemev
e189cb1895 [KLIB] Fix memory leak in linker through haveSeen set 2020-08-03 19:22:06 +03:00
Roman Artemev
19b5fda750 [KLIB] Do not duplicate origin mapping per file 2020-08-03 19:22:06 +03:00
Roman Artemev
c253042948 [KLIB] Reduce amount of descriptors loaded during desc-idSig resolution 2020-08-03 19:22:06 +03:00
Roman Artemev
851c287105 [KLIB] Use SoftReference to hold proto memory
- fix metadata memory leak for KT-40345
2020-08-03 19:22:06 +03:00
Roman Artemev
add0ad6733 [KLIB] Change KLIB IO API
- Use ReadBuffer instead of native java buffer
 - Use Weak buffers for File IO
 - fix klib memory leak for KT-40345
2020-08-03 19:22:06 +03:00
Jinseong Jeon
0e54f98b79 FIR: support adapted callable reference with vararg 2020-08-03 16:37:36 +03:00
Mikhail Glukhikh
4332e95b8a [FIR] Don't transform setter parameter type if it's given explicitly 2020-08-03 16:37:30 +03:00
vldf
8813ebd950 [FIR] Add RedundantSetterParameterType Checker 2020-08-03 16:37:24 +03:00
vldf
a6c9d869fb [FIR] Move RedundantCallOfConversionMethod to extended checkers 2020-08-03 16:31:49 +03:00
vldf
3349739d1e [FIR] Fixes for RedundantReturnUnitType checker 2020-08-03 11:42:19 +03:00
vladislavf7@gmail.com
2384afdd93 [FIR] refactoring for running extended checkers 2020-08-03 11:42:19 +03:00
vldf
cfc09048c6 [FIR] Add RedundantCallOfConversionMethod checker 2020-08-03 10:41:19 +03:00
Mikhail Glukhikh
39d4b79324 [FIR TEST] Fix FE 1.0 / FIR test data for nested / local type alias case 2020-08-02 18:19:47 +03:00
Mikhail Glukhikh
7724d060ff [FIR] Don't compare SYNTAX diagnostics in light tree diagnostic test 2020-08-02 18:19:47 +03:00
Mikhail Glukhikh
4e4fe9f719 [FIR] Support some kinds of fake sources in light builder 2020-08-02 18:19:47 +03:00
Mikhail Glukhikh
951aa8185e [FIR] Avoid duplicate diagnostics on expression.typeRef 2020-08-02 18:19:47 +03:00
Mikhail Glukhikh
dc46d51d9a [FIR TEST] Update diagnostic spec test data 2020-08-02 18:19:47 +03:00
Mikhail Glukhikh
6eab6f2f87 [FIR TEST] Replace OTHER_ERROR with UNRESOLVED_REFERENCE in test data 2020-08-02 18:19:47 +03:00
Nick
c55cdf1935 [FIR] Fix missing ErrorTypeRef for QA and clean DiagnosticCollector 2020-08-02 18:19:46 +03:00
Nick
7086b0cbf3 [FIR] Don't report duplicated errors in component calls typeRefs 2020-08-02 18:19:46 +03:00
Nick
4ceae8dc5e [FIR] Don't report duplicated errors in function calls typeRefs 2020-08-02 18:19:46 +03:00
Nick
6f85a07290 [FIR] Don't report duplicated errors in property declarations 2020-08-02 18:19:46 +03:00
Nick
889324e972 [FIR] Ignore failing test, improve DiagnosticKind, fix UPPER_BOUND 2020-08-02 18:19:45 +03:00
Mikhail Glukhikh
9335e09149 [FIR] Don't report duplicated errors in implicit properties / parameters 2020-08-02 18:19:45 +03:00
Mikhail Glukhikh
ceaffb1e8b [FIR] Don't report duplicated errors in implicit primary constructors 2020-08-02 18:19:45 +03:00
Mikhail Glukhikh
749346b73b [FIR] Don't report duplicated errors on default accessor error type refs 2020-08-02 18:19:45 +03:00
Mikhail Glukhikh
e0d25876b0 [FIR] Don't report simple diagnostics on fake sources 2020-08-02 18:19:44 +03:00
Mikhail Glukhikh
551bdd267d [FIR] Introduce WRONG_NUMBER_OF_TYPE_ARGUMENTS diagnostic 2020-08-02 18:19:44 +03:00
Mikhail Glukhikh
0804c6a0f3 [FIR] Introduce TYPE_ARGUMENTS_NOT_ALLOWED & some other type errors
This commit introduces several different things, in particular:
- check type arguments in expressions
- new TypeArgumentList node to deal with diagnostic source
- ConeDiagnostic was moved to fir:cones
- ConeIntermediateDiagnostic to use in inference (?) without reporting
- detailed diagnostics on error type
2020-08-02 18:19:44 +03:00
Jinseong Jeon
c744dfba9c FIR: distinguish anonymous object as enum entry when scoping
so that `this` reference with the enum entry name as label can be
resolved
2020-08-02 18:06:15 +03:00
Jinseong Jeon
52631b7abd FIR2IR: make local storage track scopes, including anonymous init 2020-08-02 18:05:09 +03:00
Nick
26e3a111d6 [FIR] Add diagnostics for object related problems 2020-07-31 19:34:55 +03:00
Nick
694d3cad4e [FIR] Exposed visibility checker: optimize checks for local visibility 2020-07-31 19:28:10 +03:00
Nick
60462bea1c FirEffectiveVisibilityResolver: search parent in containingDeclarations
When determining effective visibility of 'something',
we use containing declarations from the context to find 'something'
parent, to avoid calling getClassSymbolByFqName for all cases.
2020-07-31 19:28:04 +03:00
Nick
7145caca40 [FIR] Refactor effective visibility calculation
Before this commit, we had effective visibility as a part of FIR status,
so it was integrated into the full pipeline. In this commit,
we introduced "effective visibility as a service" which is now used
only by exposed visibility checker. This allows us to make the thing
universal for all FIR nodes, including nodes for Java / deserialized.
2020-07-31 19:27:58 +03:00
Steven Schäfer
b15e32936e JVM IR: Optimize delegated properties (KT-36814) 2020-07-31 19:00:27 +03:00
vldf
8724efbe8a [FIR] Add empty range checker 2020-07-31 16:28:37 +03:00
vldf
b10defdbab [FIR] Add redundant single string expression template checker 2020-07-31 16:28:37 +03:00
vldf
95e0ba3d5c [FIR] Add ArrayEqualityOpCanBeReplacedWithEquals checker 2020-07-31 16:28:37 +03:00
Ilmir Usmanov
4d21a496fe Minor. Update tests 2020-07-31 14:33:52 +02:00
Dmitry Petrov
e11c90f26c JVM_IR: KT-40293 Box return type for DefaultImpls methods if required 2020-07-31 14:48:12 +03:00
Ilya Chernikov
034d5a948c Add JvmDefault to the new EP method for compatibility with older impls 2020-07-31 12:07:10 +02:00
Ilmir Usmanov
fa8c6deb18 Support restricted suspend lambdas in JVM_IR
#KT-40135 Fixed
2020-07-30 20:40:37 +02:00
Ilmir Usmanov
2c205410fa Check whether the field is indeed being initialized
in checkFieldInExactlyOnceLambdaInitialization
 #KT-40691 Fixed
2020-07-30 19:04:54 +02:00
Nikolay Krasko
d8b76f5b26 Register additional repository id 2020-07-30 19:33:58 +03:00
Vladimir Ilmov
7eca13569b (CoroutineDebugger) Enable agent for versions 1.3.8.*
Gradle artifact name gets changed from 'kotlinx-coroutines-core' to
'kotlinx-coroutines-core-jvm'. So it should support both.
2020-07-30 17:54:35 +02:00
Toshiaki Kameyama
c91858d470 Convert member to extension: do not suggest for delegated properties
#KT-35128 Fixed
2020-07-30 17:32:31 +03:00
Dmitry Petrov
46fccae7d1 PSI2IR: KT-40499 Fix delegated property desugaring
No type arguments were provided for property reference inside delegated
property accessors.
2020-07-30 13:18:36 +03:00
Jinseong Jeon
bff36e0199 FIR2IR: convert annotations on FirTypeRef 2020-07-30 11:25:36 +03:00
Georgy Bronnikov
4ca98041cd IR: update test data 2020-07-30 11:24:08 +03:00
Georgy Bronnikov
a27d63f58f JVM_IR: flexible nullability as annotation
We carry information about flexible nullability of IrType as an
annotation, so there is no need to look at its underlying KotlinType.
2020-07-30 11:24:07 +03:00
Georgy Bronnikov
a2e9521ad5 Make DescriptorlessExternalPackageFragmentSymbol public 2020-07-30 11:24:07 +03:00
Georgy Bronnikov
c2ead0303b IR: remove more descriptor usage 2020-07-30 11:24:07 +03:00
Alexander Gorshenev
9a717e9ecf Don't copy default value parameters for fake overrides 2020-07-29 22:15:10 +03:00
Mark Punzalan
2cfd776092 ForLoopsLowering: Assume step == 1 for *Range (e.g., IntRange) and
handle accordingly (e.g., do not read `step` property).
2020-07-29 20:44:51 +02:00
Dmitry Petrov
09e47fff7b Fix KotlinGradleIT.testCustomCompilerFile
Referencing org.jetbrains.annotations.{Nullable, NotNull} classes in
static initializer causes ClassNotFoundError in testCustomCompilerFile.
2020-07-29 20:33:17 +03:00
Dmitry Petrov
dae358c792 JVM: KT-40664 disable optimization for 'ULong in range of UInt' case 2020-07-29 20:33:17 +03:00
Dmitry Petrov
f2493d0950 JVM: KT-40665 more exact check for intrinsified range 'contains' 2020-07-29 20:33:17 +03:00
Roman Artemev
0559e192ee [JS IR] Support external delegation in case of JS in psi2ir
- fix FE delegation resolver
 - fix critical KT-40650
2020-07-29 19:57:05 +03:00
Nicolay Mitropolsky
c254651ed3 Uast: handling annotations on the property receiver (KT-40539) 2020-07-29 19:42:22 +03:00
Yaroslav Chernyshev
325ad56dcd Populate Kotlin source set roots with KotlinSourceRootTypes
By default Kotlin source root is populated with JavaSourceRootType and
changed during import only if real source folder exists.
Now Kotlin source roots has valid source type right after creation

#KT-37106 Fixed
2020-07-29 19:24:44 +03:00
Ilmir Usmanov
fec845365a Minor. No longer ignore obsolete PRE_RELEASE_CLASS diagnostic
in coroutine tests.
2020-07-29 17:52:01 +02:00
Simon Ogorodnik
ebfcd7e074 J2K: Improve presentation of conversions 2020-07-29 17:56:03 +03:00
Simon Ogorodnik
5c745facf4 J2K: Improve error message in case of incorrect detach 2020-07-29 17:56:02 +03:00
Simon Ogorodnik
dc963e4ff6 Improve J2K progress reporting 2020-07-29 17:56:02 +03:00
Simon Ogorodnik
8bcf1000f6 J2K: Fix java 9 try-with-resources 2020-07-29 17:56:02 +03:00
Simon Ogorodnik
c5005f8695 J2K: Speed-up add imports 2020-07-29 17:56:01 +03:00
Simon Ogorodnik
cd0c644654 J2K: Fix incorrect early detaching of elements in for conversion 2020-07-29 17:56:00 +03:00
Simon Ogorodnik
8c2dd876b5 J2K: Fix incorrect argument remapping when introducing defaults 2020-07-29 17:56:00 +03:00
Simon Ogorodnik
cd7ac55091 J2K: Show converted/total file counts 2020-07-29 17:55:59 +03:00
Simon Ogorodnik
468af0bb85 J2K: Fix type parameters in LHS of callable reference 2020-07-29 17:50:10 +03:00
Leonid Startsev
96d0b1c47a Update serialization runtime and fix test data
Revert "Mute/ignore 'PROVIDED_RUNTIME_TOO_LOW' in tests"
2020-07-29 14:20:33 +03:00
Nikolay Krasko
a6a22d1cde Revert "Populate Kotlin source set roots with KotlinSourceRootTypes"
This reverts commit e2634190
2020-07-29 12:05:42 +03:00
Yaroslav Chernyshev
e263419088 Populate Kotlin source set roots with KotlinSourceRootTypes
By default Kotlin source root is populated with JavaSourceRootType and
changed during import only if real source folder exists.
Now Kotlin source roots has valid source type right after creation

#KT-37106 Fixed
2020-07-29 10:26:42 +03:00
Ilmir Usmanov
4fb5f8603a Keep $continuation in LVT
in case of suspend functions and `this` is case of lambdas, since they
are used in async stack trace generation.
Update tests.
 #KT-40661 Open
2020-07-29 00:01:12 +02:00
Ilmir Usmanov
db40808186 Minor. Remove unused SourceFrames 2020-07-29 00:01:11 +02:00
Ilmir Usmanov
70e91bd5db Shrink and split LVT records of variables according to their liveness
Otherwise, debugger will show uninitialized values of dead variables
after resume.
 #KT-16222
 #KT-28016 Fixed
 #KT-20571 Fixed
2020-07-29 00:01:10 +02:00
Ilmir Usmanov
e5995f0c12 Update R8
Because old version throws assertion error if parameter's LVT record
does no span the whole function.
2020-07-29 00:01:10 +02:00
Ilmir Usmanov
60875f96b4 Do not take LVT into account when calculating liveness of variables 2020-07-29 00:01:09 +02:00
Alexander Udalov
687d13a320 IR: cleanup expression implementations
Remove unused constructors with descriptors, minimize usages of
secondary constructors and make some properties non-lateinit, fix some
inspections.
2020-07-28 20:05:58 +02:00
Alexander Udalov
e36d3ba4f6 IR: remove IrNoArgumentsCallableReferenceBase
To simplify transformation of IR element hierarchy to classes.
2020-07-28 20:05:57 +02:00
Dmitriy Novozhilov
f270cd8d6e [FIR] Update testdata due to lack of callee reference in FirResolvedQualifier 2020-07-28 20:47:07 +03:00
Dmitriy Novozhilov
f283f2db43 [FIR] Improve diagnostic reporting & don't use error symbol for candidate if possible
Also introduce few new diagnostics:
- NONE_APPLICABLE more many inapplicable candidates
- HIDDEN for visible candidates
2020-07-28 20:46:56 +03:00
anastasiia.spaseeva
5c0528b61e [Spec tests] Add tests for primary constructors declaration 2020-07-28 20:26:33 +03:00
anastasiia.spaseeva
0488dc985f [Spec tests] Add tests for intersection and OR 2020-07-28 20:26:32 +03:00
anastasiia.spaseeva
46774fb6d6 [Spec tests] Add call without an explicit receiver tests for top-level non-extension functions 2020-07-28 20:26:32 +03:00
anastasiia.spaseeva
bef59055cd [Spec tests] Fix test cases structure 2020-07-28 20:26:31 +03:00
anastasiia.spaseeva
4ad3847224 [Spec tests] Add tests for subtyping rules for simple classifier type 2020-07-28 20:26:30 +03:00
anastasiia.spaseeva
1801344c76 [Spec tests] Add tests for inner-and-nested-type-contexts section 2020-07-28 20:26:29 +03:00
anastasiia.spaseeva
d5ddb26180 [Spec tests] Add overload resolution tests for plus assign operator call 2020-07-28 20:26:28 +03:00
anastasiia.spaseeva
1d83c59e80 [Spec tests] Actualize test for callable reference section 2020-07-28 20:26:27 +03:00
anastasiia.spaseeva
4db209648d [Spec tests] Update spec version 2020-07-28 20:26:26 +03:00
anastasiia.spaseeva
3f862830f2 [Spec tests] Add tests for resolving callable references and some co-tests 2020-07-28 20:26:24 +03:00
anastasiia.spaseeva
cfbfec77a5 [Spec tests] Add tests for Algorithm of MSC selection 2020-07-28 20:26:23 +03:00
anastasiia.spaseeva
73850e97d7 [Spec tests] Add test for Coercion to Unit error diagnostics absence 2020-07-28 20:26:22 +03:00
anastasiia.spaseeva
26ac87d9be [Spec tests] Update spec testData 2020-07-28 20:26:21 +03:00
Alexander Udalov
f240d51d2c IR: do not inherit IrFakeOverride* from IrFunction/IrProperty
This will help to reduce boilerplate after making the latter classes.

Without this change, IrFunctionCommonImpl would not be able to be a
class because it would introduce a diamond class hierarchy, and thus
that would require copying all its contents to IrFunctionImpl and
IrFakeOverrideFunctionImpl.
2020-07-28 19:05:12 +02:00
Alexander Udalov
4892737cc9 Use IrFactory in kotlin-serialization-compiler 2020-07-28 19:04:44 +02:00
Alexander Udalov
0909894a96 PIR: make most implementations and carriers internal 2020-07-28 19:04:44 +02:00
Alexander Udalov
cce55f1609 IR: add module ir.tree.impl, move main IR implementation there 2020-07-28 19:04:44 +02:00
Alexander Udalov
77247deb23 IR: add module ir.tree.persistent, copy PIR implementation there
Use PersistentIrFactory in JS IR compiler entry points.
2020-07-28 19:04:43 +02:00
Alexander Udalov
9aed92d2dd Partially revert "Persistent IR implementation"
This partially reverts commit f437da8ee5.
Changes related to carriers and others are still there. They will be
moved out to a separate module in a subsequent commit.
2020-07-28 19:04:43 +02:00
Dmitry Petrov
980b91d082 JVM: generate 'Deprecated' on method as runtime-visible annotation
We generate @java.lang.Deprecated annotation on methods of $DefaultImpls
classes in compatibility mode. This annotation has RUNTIME retention and
should be visible.

Also, get rid of representing annotations as Class'es (yes we know that
these annotations are in compiler CLASSPATH, but we should not rely on
such classes and associated information).
2020-07-28 18:19:20 +03:00
Dmitry Petrov
4fdccb3b35 JVM_IR: don't generate repeated ElementType values in @Target 2020-07-28 18:19:20 +03:00
Ilya Goncharov
c065210b56 [Gradle, JS] Reuse task requirements
^KT-39825 fixed
2020-07-28 18:17:05 +03:00
Ilya Goncharov
9a3ae4f4fa [Gradle, JS] Common webpack configuration
^KT-39825 fixed
2020-07-28 18:16:51 +03:00
vldf
a2b26c00a1 Uncommented ControlFlowAnalysisBenchmark 2020-07-28 17:10:02 +03:00
vldf
fca0b7fedd [FIR] Add CFA benchmark 2020-07-28 14:30:40 +03:00
vldf
d7b3a86f5e [FIR] Add "can be val" extended checker 2020-07-28 14:17:38 +03:00
Jinseong Jeon
da6e96f4f1 FIR2IR: don't declare dispatch receiver for local functions 2020-07-28 13:43:10 +03:00
Jinseong Jeon
5a3367e09c FIR: initial support of suspend conversion for function reference 2020-07-28 13:37:05 +03:00
Alexander Udalov
b9243aad24 Minor, fix test data in bytecodeListing/specialBridges 2020-07-28 12:12:39 +02:00
Alexander Udalov
df324d5a08 IR: pull up common accept/transform implementations to interfaces
To avoid duplicating them among the main, persisting, lazy, and
fir2ir-lazy implementations.

Also reformat a bit, and avoid storing descriptor in a field in some
places.
2020-07-28 12:05:24 +02:00
Alexander Udalov
12d2a02d22 JS IR: drop JsIrDeclarationBuilder
Move buildValueParameter back to JsIrBuilder, and use common IR builders
directly where buildFunction was called.
2020-07-28 12:05:24 +02:00
Alexander Udalov
0d605a6b7f IR: create IrBlockBody via IrFactory 2020-07-28 12:05:24 +02:00
Alexander Udalov
9ad4a754ce IR: create IrExpressionBody via IrFactory 2020-07-28 12:05:24 +02:00
Alexander Udalov
d1dc938a5d IR: use IrFactory in IR builders 2020-07-28 12:05:24 +02:00
Alexander Udalov
898dd20a9e IR: use IrFactory in misc utils 2020-07-28 12:05:23 +02:00
Alexander Udalov
f359f36ed9 IR: add IrFactory to IrDeclaration, use in deep copy 2020-07-28 12:05:23 +02:00
Alexander Udalov
305288aa82 IR: use IrFactory in psi2ir 2020-07-28 12:05:23 +02:00
Alexander Udalov
8c41ba8ee4 IR: use IrFactory in fir2ir 2020-07-28 12:05:23 +02:00
Alexander Udalov
9356f87f28 IR: use IrFactory in linker 2020-07-28 12:05:23 +02:00
Alexander Udalov
db4cbe7103 IR: use IrFactory in SymbolTable 2020-07-28 12:05:23 +02:00
Alexander Udalov
c6a127e87e IR: introduce IrFactory
This is needed to refactor IrPersistingElementBase-based implementations
into another module, to use it in JS IR.
2020-07-28 12:05:23 +02:00
Kirill Shmakov
96968cd9c9 Fix build after rebasing 2020-07-28 12:55:38 +03:00
Kirill Shmakov
96160cbb55 Adapt AS wizard to changes in main wizard 2020-07-28 12:26:19 +03:00
Kirill Shmakov
5c8833f608 Wizard: improve mobile app template 2020-07-28 12:26:19 +03:00
Ilya Kirillov
63fa6674a3 Wizard: temporary add ios shortcut target
Temporary as it will not be needed when HMPP wizard will be ready
2020-07-28 12:26:19 +03:00
Ilya Kirillov
f330cd3697 Wizard: relocate AndroidManifest.xml for MPP module 2020-07-28 12:26:19 +03:00
Ilya Kirillov
b3d48cda8c Wizard: add common tests for iOS/Android template 2020-07-28 12:26:19 +03:00
Ilya Kirillov
5ffcaf6508 Wizard: add shared code for iOS/Android template
fix android
2020-07-28 12:26:19 +03:00
Ilya Kirillov
66c756ad0f Wizard: add ability for wizard to generate expected/actual declarations in MPP module 2020-07-28 12:26:18 +03:00
Ilya Kirillov
7d1036ee7e Wizard: use property for storing module dependency 2020-07-28 12:26:18 +03:00
Ilya Kirillov
dbc43b66bf Wizard: introduce ModuleConfiguratorProperty 2020-07-28 12:26:18 +03:00
Ilya Kirillov
74d6919c7c Wizard: wrap property into PluginProperty for plugin properties 2020-07-28 12:26:18 +03:00
Ilya Kirillov
3c3ba361e8 Wizard: specify path for plugin entities in one place 2020-07-28 12:26:18 +03:00
Ilya Kirillov
c05c72387e Wizard: fix node js templates 2020-07-28 12:26:18 +03:00
aleksandrina-streltsova
63e2d771b3 Get rid of reflection in new project wizard core: manually specify properties in plugins 2020-07-28 12:26:17 +03:00
Ilya Kirillov
cc35529b9a Wizard: get rid of reflection: specify plugin path by hand 2020-07-28 12:23:57 +03:00
Ilya Kirillov
3ed11c0491 Wizard: get rid of reflection: force plugins to specify settings & tasks directly 2020-07-28 12:23:57 +03:00
vldf
eadd3f00f2 [FIR] Add CanBeReplacedWithOperatorAssignmentChecker 2020-07-28 10:13:28 +03:00
Kevin Bierhoff
fa8c6e7fb6 Uast: KT-40578: resolve Kotlin property writes to setters (#3597)
* KT-40578: resolve Kotlin property writes to setters

* limit to non-constructor properties

* Uast: `KotlinIDERenderLogTest.testConstructors` fix

Co-authored-by: Nicolay Mitropolsky <nicolay.mitropolsky@jetbrains.com>
2020-07-28 10:03:22 +03:00
5230 changed files with 99942 additions and 45707 deletions

5
.bunch
View File

@@ -2,7 +2,6 @@
202
203_202
193
192_193
as36_192_193
as40_193
as41
as41
as42_as41

View File

@@ -8,10 +8,8 @@ buildscript {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-dev")
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
}
}
dependencies {
@@ -30,10 +28,8 @@ repositories {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-dev")
} else {
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
}
}
@@ -74,6 +70,7 @@ benchmark {
param("size", 1000)
include("CommonCallsBenchmark")
include("ControlFlowAnalysisBenchmark")
//include("InferenceBaselineCallsBenchmark")
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.benchmarks
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole
import java.util.concurrent.TimeUnit
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
open class ControlFlowAnalysisBenchmark : AbstractSimpleFileBenchmark() {
@Param("1000")
private var size: Int = 0
@Benchmark
fun benchmark(bh: Blackhole) {
analyzeGreenFile(bh)
}
override fun buildText() =
buildString {
appendLine("fun test() {")
for (i in 0 until size) {
appendLine("for (i$i in 0..10) { ")
}
for (i in 0 until size) {
appendLine("}")
}
appendLine("}")
}
}

View File

@@ -75,7 +75,7 @@ open class IncrementalJsCache(
override fun markDirty(removedAndCompiledSources: Collection<File>) {
removedAndCompiledSources.forEach { sourceFile ->
// The common prefix of all FQN parents has to be the file package
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minBy { it.length }?.let {
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minByOrNull { it.length }?.let {
packageMetadata.remove(it)
}
}

View File

@@ -168,6 +168,8 @@ open class IncrementalJvmCache(
constantsMap.process(kotlinClass, changesCollector)
inlineFunctionsMap.process(kotlinClass, changesCollector)
}
KotlinClassHeader.Kind.UNKNOWN, KotlinClassHeader.Kind.SYNTHETIC_CLASS -> {
}
}
}

View File

@@ -80,7 +80,7 @@ open class LookupStorage(
for (lookupSymbol in lookups.keySet().sorted()) {
val key = LookupSymbolKey(lookupSymbol.name, lookupSymbol.scope)
val paths = lookups[lookupSymbol]!!
val paths = lookups[lookupSymbol]
val fileIds = paths.mapTo(TreeSet()) { pathToId[it]!! }
fileIds.addAll(lookupMap[key] ?: emptySet())
lookupMap[key] = fileIds

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("UNUSED_PARAMETER")
package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf

View File

@@ -178,7 +178,7 @@ extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.1.2"
extra["versions.r8"] = "1.5.70"
extra["versions.r8"] = "2.0.88"
val immutablesVersion = "0.3.1"
extra["versions.kotlinx-collections-immutable"] = immutablesVersion
extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
@@ -187,7 +187,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.4-M3-dev-15627"
extra["versions.kotlin-native"] = "1.4.20-dev-16314"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -221,6 +221,7 @@ extra["compilerModules"] = arrayOf(
":compiler:config",
":compiler:config.jvm",
":compiler:container",
":compiler:resolution.common",
":compiler:resolution",
":compiler:serialization",
":compiler:psi",
@@ -229,6 +230,8 @@ extra["compilerModules"] = arrayOf(
":compiler:frontend.java",
":compiler:cli-common",
":compiler:ir.tree",
":compiler:ir.tree.impl",
":compiler:ir.tree.persistent",
":compiler:ir.psi2ir",
":compiler:ir.backend.common",
":compiler:backend.jvm",
@@ -263,17 +266,17 @@ extra["compilerModules"] = arrayOf(
":kotlin-build-common",
":core:metadata",
":core:metadata.jvm",
":core:compiler.common",
":core:descriptors",
":core:descriptors.jvm",
":core:descriptors.runtime",
":core:deserialization",
":core:util.runtime",
":core:type-system",
":compiler:fir:cones",
":compiler:fir:resolve",
":compiler:fir:fir-serialization",
":compiler:fir:tree",
":compiler:fir:raw-fir:fir-common",
":compiler:fir:raw-fir:raw-fir.common",
":compiler:fir:raw-fir:psi2fir",
":compiler:fir:raw-fir:light-tree2fir",
":compiler:fir:fir2ir",
@@ -285,7 +288,6 @@ extra["compilerModules"] = arrayOf(
)
extra["compilerModulesForJps"] = listOf(
":core:type-system",
":kotlin-build-common",
":kotlin-util-io",
":kotlin-util-klib",
@@ -294,6 +296,7 @@ extra["compilerModulesForJps"] = listOf(
":kotlin-compiler-runner",
":daemon-common",
":daemon-common-new",
":core:compiler.common",
":core:descriptors",
":core:descriptors.jvm",
":idea:idea-jps-common",
@@ -455,6 +458,16 @@ allprojects {
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KT-37089") { true }
}
tasks.withType<SourceTask>().configureEach {
doFirst {
source.visit {
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath)
}
}
}
}
normalization {
runtimeClasspath {
ignore("META-INF/MANIFEST.MF")

View File

@@ -53,7 +53,8 @@ enum class Ide(val platform: Platform) : CompatibilityPredicate {
AS35(Platform.P183),
AS36(Platform.P192),
AS40(Platform.P193),
AS41(Platform.P201);
AS41(Platform.P201),
AS42(Platform.P201);
val kind = Kind.values().first { it.shortName == name.take(2) }
val version = name.dropWhile { !it.isDigit() }.toInt()

View File

@@ -52,6 +52,7 @@ open class PublishedKotlinModule : Plugin<Project> {
configure<SigningExtension> {
isRequired = signingRequired
sign(configurations["archives"])
useGpgCmd()
}
tasks.named<Sign>("signArchives").configure {

View File

@@ -54,6 +54,7 @@ fun Task.dependsOnKotlinPluginInstall() {
":kotlin-test:kotlin-test-annotations-common:install",
":kotlin-test:kotlin-test-jvm:install",
":kotlin-test:kotlin-test-js:install",
":kotlin-test:kotlin-test-junit:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-common:install",
":kotlin-stdlib:install",
@@ -65,7 +66,8 @@ fun Task.dependsOnKotlinPluginInstall() {
":kotlin-scripting-jvm:install",
":kotlin-scripting-compiler-embeddable:install",
":kotlin-scripting-compiler-impl-embeddable:install",
":kotlin-test-js-runner:install"
":kotlin-test-js-runner:install",
":native:kotlin-klib-commonizer-embeddable:install"
)
}

View File

@@ -25,7 +25,7 @@ import org.junit.runners.AllTests;
import java.io.File;
@RunWith(AllTests.class)
//@RunWith(AllTests.class)
public class AndroidRunner {
private static PathManager pathManager;

View File

@@ -120,7 +120,7 @@ public abstract class AnnotationCodegen {
@Nullable Type returnType,
@Nullable KotlinType typeForTypeAnnotations,
@Nullable DeclarationDescriptorWithVisibility parameterContainer,
@NotNull List<Class<?>> additionalAnnotations
@NotNull List<String> additionalVisibleAnnotations
) {
if (annotated == null) return;
@@ -155,9 +155,9 @@ public abstract class AnnotationCodegen {
}
}
for (Class<?> annotation : additionalAnnotations) {
String descriptor = generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotation);
annotationDescriptorsAlreadyPresent.add(descriptor);
for (String annotation : additionalVisibleAnnotations) {
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotation, true);
annotationDescriptorsAlreadyPresent.add(annotation);
}
generateAdditionalAnnotations(annotated, returnType, annotationDescriptorsAlreadyPresent, parameterContainer);
@@ -248,17 +248,17 @@ public abstract class AnnotationCodegen {
if (!TypeUtils.isNullableType(flexibleType.getLowerBound()) && TypeUtils.isNullableType(flexibleType.getUpperBound())) {
AnnotationDescriptor notNull = type.getAnnotations().findAnnotation(JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION);
if (notNull != null) {
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, NotNull.class);
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, Type.getType(NotNull.class).getDescriptor(), false);
}
return;
}
}
boolean isNullableType = TypeUtils.isNullableType(type);
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass);
generateAnnotationIfNotPresent(
annotationDescriptorsAlreadyPresent,
TypeUtils.isNullableType(type) ? Type.getType(Nullable.class).getDescriptor() : Type.getType(NotNull.class).getDescriptor(),
false
);
}
private static final Map<JvmTarget, Map<KotlinTarget, ElementType>> annotationTargetMaps = new EnumMap<>(JvmTarget.class);
@@ -338,13 +338,14 @@ public abstract class AnnotationCodegen {
visitor.visitEnd();
}
@NotNull
private String generateAnnotationIfNotPresent(Set<String> annotationDescriptorsAlreadyPresent, Class<?> annotationClass) {
String descriptor = Type.getType(annotationClass).getDescriptor();
if (!annotationDescriptorsAlreadyPresent.contains(descriptor)) {
visitAnnotation(descriptor, false).visitEnd();
private void generateAnnotationIfNotPresent(
Set<String> annotationDescriptorsAlreadyPresent,
String annotationDescriptor,
boolean visible
) {
if (!annotationDescriptorsAlreadyPresent.contains(annotationDescriptor)) {
visitAnnotation(annotationDescriptor, visible).visitEnd();
}
return descriptor;
}
private static boolean isBareTypeParameterWithNullableUpperBound(@NotNull KotlinType type) {

View File

@@ -38,6 +38,7 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedS
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL;
import static org.jetbrains.kotlin.util.DeclarationUtilKt.findImplementationFromInterface;
import static org.jetbrains.kotlin.util.DeclarationUtilKt.findInterfaceImplementation;
public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject> {
@@ -236,9 +237,12 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
@NotNull GenerationState state,
boolean isErasedInlineClass
) {
CallableMemberDescriptor actualImplementation =
interfaceFun.getKind().isReal() ? interfaceFun : findImplementationFromInterface(interfaceFun);
assert actualImplementation != null : "Can't find actual implementation for " + interfaceFun;
// Skip Java 8 default methods
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) ||
JvmAnnotationUtilKt.checkIsImplementationCompiledToJvmDefault(interfaceFun, state.getJvmDefaultMode())) {
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(actualImplementation) ||
JvmAnnotationUtilKt.isCallableMemberCompiledToJvmDefault(actualImplementation, state.getJvmDefaultMode())) {
return;
}

View File

@@ -173,7 +173,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return null;
}
static class BlockStackElement {
public static class BlockStackElement {
}
static class LoopBlockStackElement extends BlockStackElement {
@@ -2224,8 +2224,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!skipPropertyAccessors) {
if (isBackingFieldMovedFromCompanion && context.getContextDescriptor() instanceof AccessorForPropertyBackingField) {
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getParentContext()
.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
CodegenContext<?> parentContext = backingFieldContext.getParentContext();
propertyDescriptor =
parentContext.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
}
else {
propertyDescriptor =
@@ -2835,7 +2836,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
TypeApproximator approximator = new TypeApproximator(state.getModule().getBuiltIns());
KotlinType approximatedType =
CapturedTypeConstructorKt.isCaptured(type) ?
TypeUtils.contains(type, (containedType) -> CapturedTypeConstructorKt.isCaptured(containedType)) ?
(KotlinType) approximator.approximateToSuperType(
type, TypeApproximatorConfiguration.InternalTypesApproximation.INSTANCE
) : null;
@@ -4103,15 +4104,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
TypeAndNullability right754Type = calcTypeForIeee754ArithmeticIfNeeded(right, getRightOperandType(primitiveNumericComparisonInfo));
boolean isSame754ArithmeticTypes = left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type);
boolean properIeee754Comparisons = shouldUseProperIeee754Comparisons();
boolean isStandardCompareTo = primitiveNumericComparisonInfo != null;
if (properIeee754Comparisons && left754Type != null && right754Type != null) {
if (properIeee754Comparisons && isStandardCompareTo && left754Type != null && right754Type != null) {
type = comparisonOperandType(left754Type.type, right754Type.type);
//type = comparisonOperandType(leftType, rightType);
leftValue = gen(left);
rightValue = gen(right);
}
else if (!properIeee754Comparisons &&
state.getIntrinsics().getIntrinsic((FunctionDescriptor) resolvedCall.getResultingDescriptor()) instanceof CompareTo &&
else if (!properIeee754Comparisons && isStandardCompareTo &&
((isPrimitive(leftType) && isPrimitive(rightType)) || isSame754ArithmeticTypes)) {
type = isSame754ArithmeticTypes ? left754Type.type : comparisonOperandType(leftType, rightType);
leftValue = gen(left);

View File

@@ -73,7 +73,7 @@ import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBinding
import static org.jetbrains.kotlin.codegen.state.KotlinTypeMapper.isAccessor;
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION;
import static org.jetbrains.kotlin.descriptors.ModalityKt.isOverridable;
import static org.jetbrains.kotlin.descriptors.ModalityUtilsKt.isOverridable;
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
@@ -83,6 +83,8 @@ import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.*;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class FunctionCodegen {
private static final String JAVA_LANG_DEPRECATED = Type.getType(Deprecated.class).getDescriptor();
public final GenerationState state;
private final KotlinTypeMapper typeMapper;
private final BindingContext bindingContext;
@@ -221,7 +223,7 @@ public class FunctionCodegen {
InlineClassDescriptorResolver.isSpecializedEqualsMethod(functionDescriptor);
generateMethodAnnotationsIfRequired(
functionDescriptor, asmMethod, jvmSignature, mv,
isCompatibilityStubInDefaultImpls ? Collections.singletonList(Deprecated.class) : Collections.emptyList(),
isCompatibilityStubInDefaultImpls ? Collections.singletonList(JAVA_LANG_DEPRECATED) : Collections.emptyList(),
skipNullabilityAnnotations
);
GenerateJava8ParameterNamesKt.generateParameterNames(functionDescriptor, mv, jvmSignature, state, (flags & ACC_SYNTHETIC) != 0);
@@ -285,7 +287,7 @@ public class FunctionCodegen {
@NotNull Method asmMethod,
@NotNull JvmMethodGenericSignature jvmSignature,
@NotNull MethodVisitor mv,
@NotNull List<Class<?>> additionalNoArgAnnotations,
@NotNull List<String> additionalVisibleAnnotations,
boolean skipNullabilityAnnotations
) {
FunctionDescriptor annotationsOwner;
@@ -302,7 +304,7 @@ public class FunctionCodegen {
}
AnnotationCodegen.forMethod(mv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(annotationsOwner, asmMethod.getReturnType(), functionDescriptor.getReturnType(), null, additionalNoArgAnnotations);
.genAnnotations(annotationsOwner, asmMethod.getReturnType(), functionDescriptor.getReturnType(), null, additionalVisibleAnnotations);
generateParameterAnnotations(
annotationsOwner, mv, jvmSignature,

View File

@@ -62,6 +62,8 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.*;
import static org.jetbrains.kotlin.builtins.StandardNames.ENUM_VALUES;
import static org.jetbrains.kotlin.builtins.StandardNames.ENUM_VALUE_OF;
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isGenericToArray;
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isNonGenericToArray;

View File

@@ -12,6 +12,7 @@ import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.builtins.StandardNames;
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
@@ -404,7 +405,7 @@ public class JvmCodegenUtil {
// The Result class is the only inline class in the standard library without special rules for equality.
// We only call Result.equals-impl0 if we are compiling for Kotlin 1.4 or later. Otherwise, the code
// might well be running against an older version of the standard library.
if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(DescriptorUtils.RESULT_FQ_NAME)) {
if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(StandardNames.RESULT_FQ_NAME)) {
return state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_4) >= 0;
} else {
return ((DeserializedClassDescriptor) descriptor).getMetadataVersion().isAtLeast(1, 1, 16);

View File

@@ -1543,7 +1543,7 @@ public abstract class StackValue {
//TODO: try to don't generate defaults at all in CollectionElementReceiver
List<ResolvedValueArgument> getterArguments = new ArrayList(collectionElementReceiver.valueArguments);
List<ResolvedValueArgument> getterArguments = new ArrayList<>(collectionElementReceiver.valueArguments);
List<ResolvedValueArgument> getterDefaults = CollectionsKt.takeLastWhile(getterArguments,
argument -> argument instanceof DefaultValueArgument);

View File

@@ -821,20 +821,17 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
Map<ValueParameterDescriptor, ResolvedValueArgument> arguments = newResolvedCall.getValueArguments();
for (ValueParameterDescriptor valueParameter : arguments.keySet()) {
SamType samType = SamType.createByValueParameter(valueParameter);
if (samType == null) continue;
ResolvedValueArgument argument = arguments.get(valueParameter);
if (argument instanceof ExpressionValueArgument) {
ValueArgument valueArgument = ((ExpressionValueArgument) argument).getValueArgument();
if (valueArgument != null && newResolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument) != null) {
recordSamTypeOnArgumentExpression(samType, valueArgument);
recordSamTypeOnArgumentExpression(valueParameter, valueArgument);
}
} else if (argument instanceof VarargValueArgument) {
VarargValueArgument varargValueArgument = (VarargValueArgument) argument;
for (ValueArgument valueArgument : varargValueArgument.getArguments()) {
if (valueArgument != null && newResolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument) != null) {
recordSamTypeOnArgumentExpression(samType, valueArgument);
recordSamTypeOnArgumentExpression(valueParameter, valueArgument);
}
}
}
@@ -872,6 +869,13 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
}
}
private void recordSamTypeOnArgumentExpression(ValueParameterDescriptor valueParameter, ValueArgument valueArgument) {
SamType samType = SamType.createByValueParameter(valueParameter);
if (samType == null) return;
recordSamTypeOnArgumentExpression(samType, valueArgument);
}
private void recordSamTypeOnArgumentExpression(SamType samType, ValueArgument valueArgument) {
KtExpression argumentExpression = valueArgument.getArgumentExpression();
assert argumentExpression != null : valueArgument.asElement().getText();

View File

@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.jetbrains.kotlin.utils.sure
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.MethodVisitor
@@ -104,9 +103,9 @@ abstract class AbstractCoroutineCodegen(
ValueParameterDescriptorImpl(
this, null, index, Annotations.EMPTY, name,
type,
false, false,
false,
null, SourceElement.NO_SOURCE
declaresDefaultValue = false, isCrossinline = false,
isNoinline = false,
varargElementType = null, source = SourceElement.NO_SOURCE
)
override fun generateConstructor(): Method {
@@ -157,7 +156,7 @@ abstract class AbstractCoroutineCodegen(
return constructor
}
abstract protected val passArityToSuperClass: Boolean
protected abstract val passArityToSuperClass: Boolean
}
class CoroutineCodegenForLambda private constructor(
@@ -187,6 +186,23 @@ class CoroutineCodegenForLambda private constructor(
private val endLabel = Label()
private val varsCountByType = hashMapOf<Type, Int>()
private val fieldsForParameters: Map<ParameterDescriptor, FieldInfo> = createFieldsForParameters()
private fun createFieldsForParameters(): Map<ParameterDescriptor, FieldInfo> {
val result = hashMapOf<ParameterDescriptor, FieldInfo>()
for (parameter in allFunctionParameters()) {
if (parameter.isUnused()) continue
val type = state.typeMapper.mapType(parameter.type)
val normalizedType = type.normalize()
val index = varsCountByType[normalizedType]?.plus(1) ?: 0
varsCountByType[normalizedType] = index
result[parameter] = createHiddenFieldInfo(parameter.type, "${normalizedType.descriptor[0]}$$index")
}
return result
}
private fun getCreateFunction(): SimpleFunctionDescriptor = SimpleFunctionDescriptorImpl.create(
funDescriptor.containingDeclaration,
Annotations.EMPTY,
@@ -232,8 +248,7 @@ class CoroutineCodegenForLambda private constructor(
override fun generateClosureBody() {
for (parameter in allFunctionParameters()) {
if (parameter.isUnused()) continue
val fieldInfo = parameter.getFieldInfoForCoroutineLambdaParameter()
val fieldInfo = fieldsForParameters[parameter] ?: continue
v.newField(
OtherOrigin(parameter),
Opcodes.ACC_PRIVATE + Opcodes.ACC_SYNTHETIC,
@@ -257,7 +272,7 @@ class CoroutineCodegenForLambda private constructor(
super.generateBody()
if (doNotGenerateInvokeBridge) {
v.serializationBindings.put<FunctionDescriptor, Method>(
v.serializationBindings.put(
METHOD_FOR_FUNCTION,
originalSuspendFunctionDescriptor,
typeMapper.mapAsmMethod(erasedInvokeFunction)
@@ -320,7 +335,7 @@ class CoroutineCodegenForLambda private constructor(
newarray(AsmTypes.OBJECT_TYPE)
// 0 - this
// 1..22 - parameters
// 23 - first empy slot
// 23 - first empty slot
val arraySlot = 23
store(arraySlot, AsmTypes.OBJECT_TYPE)
for ((varIndex, type) in parameterTypes.withVariableIndices()) {
@@ -405,8 +420,8 @@ class CoroutineCodegenForLambda private constructor(
// Pass lambda parameters to 'invoke' call on newly constructed object
var index = 1
for (parameter in allFunctionParameters()) {
val fieldInfoForCoroutineLambdaParameter = parameter.getFieldInfoForCoroutineLambdaParameter()
if (!parameter.isUnused()) {
val fieldInfoForCoroutineLambdaParameter = fieldsForParameters[parameter]
if (fieldInfoForCoroutineLambdaParameter != null) {
if (isBigArity) {
load(cloneIndex, fieldInfoForCoroutineLambdaParameter.ownerType)
load(1, AsmTypes.OBJECT_TYPE)
@@ -442,7 +457,7 @@ class CoroutineCodegenForLambda private constructor(
)
}
}
index += if (isBigArity || generateErasedCreate) 1 else fieldInfoForCoroutineLambdaParameter.fieldType.size
index += if (isBigArity || generateErasedCreate) 1 else state.typeMapper.mapType(parameter.type).size
}
load(cloneIndex, AsmTypes.OBJECT_TYPE)
@@ -452,17 +467,22 @@ class CoroutineCodegenForLambda private constructor(
private fun ExpressionCodegen.initializeCoroutineParameters() {
for (parameter in allFunctionParameters()) {
if (parameter.isUnused()) continue
val fieldStackValue =
StackValue.field(
parameter.getFieldInfoForCoroutineLambdaParameter(), generateThisOrOuter(context.thisDescriptor, false)
)
val fieldForParameter = fieldsForParameters[parameter] ?: continue
val fieldStackValue = StackValue.field(fieldForParameter, generateThisOrOuter(context.thisDescriptor, false))
val mappedType = typeMapper.mapType(parameter.type)
fieldStackValue.put(mappedType, v)
val originalType = typeMapper.mapType(parameter.type)
// If a parameter has reference type, it has prefix L$,
// however, when the type is primitive, its prefix is ${type.descriptor}$.
// In other words, it the type is Boolean, the prefix is Z$.
// This is different from spilled variables, where all int-like primitives have prefix I$.
// This is not a problem, since we do not clean spilled primitives up
// and we do not coerce Int to Boolean, which takes quite a bit of bytecode (see coerceInt).
val normalizedType = originalType.normalize()
fieldStackValue.put(normalizedType, v)
val newIndex = myFrameMap.enter(parameter, mappedType)
v.store(newIndex, mappedType)
val newIndex = myFrameMap.enter(parameter, originalType)
StackValue.coerce(normalizedType, originalType, v)
v.store(newIndex, originalType)
val name =
if (parameter is ReceiverParameterDescriptor)
@@ -471,7 +491,7 @@ class CoroutineCodegenForLambda private constructor(
(getNameForDestructuredParameterOrNull(parameter as ValueParameterDescriptor) ?: parameter.name.asString())
val label = Label()
v.mark(label)
v.visitLocalVariable(name, mappedType.descriptor, null, label, endLabel, newIndex)
v.visitLocalVariable(name, originalType.descriptor, null, label, endLabel, newIndex)
}
initializeVariablesForDestructuredLambdaParameters(
@@ -485,13 +505,10 @@ class CoroutineCodegenForLambda private constructor(
originalSuspendFunctionDescriptor.extensionReceiverParameter.let(::listOfNotNull) +
originalSuspendFunctionDescriptor.valueParameters
private fun ParameterDescriptor.getFieldInfoForCoroutineLambdaParameter() =
createHiddenFieldInfo(type, COROUTINE_LAMBDA_PARAMETER_PREFIX + (this.safeAs<ValueParameterDescriptor>()?.index ?: ""))
private fun createHiddenFieldInfo(type: KotlinType, name: String) =
FieldInfo.createForHiddenField(
typeMapper.mapClass(closureContext.thisDescriptor),
typeMapper.mapType(type),
typeMapper.mapType(type).normalize(),
type,
name
)
@@ -514,7 +531,8 @@ class CoroutineCodegenForLambda private constructor(
isForNamedFunction = false,
languageVersionSettings = languageVersionSettings,
disableTailCallOptimizationForFunctionReturningUnit = false,
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS),
initialVarsCountByType = varsCountByType
)
val maybeWithForInline = if (forInline)
SuspendForInlineCopyingMethodVisitor(stateMachineBuilder, access, name, desc, functionCodegen::newMethod)
@@ -758,16 +776,11 @@ class CoroutineCodegenForNamedFunction private constructor(
declaration: KtFunction
): CoroutineCodegenForNamedFunction {
val bindingContext = expressionCodegen.state.bindingContext
val closure =
bindingContext[
CodegenBinding.CLOSURE,
bindingContext[CodegenBinding.CLASS_FOR_CALLABLE, originalSuspendDescriptor]
].sure { "There must be a closure defined for $originalSuspendDescriptor" }
val closure = bindingContext[CLOSURE, bindingContext[CodegenBinding.CLASS_FOR_CALLABLE, originalSuspendDescriptor]]
.sure { "There must be a closure defined for $originalSuspendDescriptor" }
val suspendFunctionView =
bindingContext[
CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, originalSuspendDescriptor
].sure { "There must be a jvm view defined for $originalSuspendDescriptor" }
val suspendFunctionView = bindingContext[CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, originalSuspendDescriptor]
.sure { "There must be a jvm view defined for $originalSuspendDescriptor" }
if (suspendFunctionView.dispatchReceiverParameter != null) {
closure.setNeedsCaptureOuterClass()
@@ -785,10 +798,8 @@ class CoroutineCodegenForNamedFunction private constructor(
}
}
private const val COROUTINE_LAMBDA_PARAMETER_PREFIX = "p$"
private object FailingFunctionGenerationStrategy : FunctionGenerationStrategy() {
override fun skipNotNullAssertionsForParameters(): kotlin.Boolean {
override fun skipNotNullAssertionsForParameters(): Boolean {
error("This functions must not be called")
}

View File

@@ -20,6 +20,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
import kotlin.math.max
private const val COROUTINES_DEBUG_METADATA_VERSION = 1
@@ -63,7 +64,9 @@ class CoroutineTransformerMethodVisitor(
// JVM_IR backend generates $completion, while old backend does not
private val putContinuationParameterToLvt: Boolean = true,
// New SourceInterpreter-less analyser can be somewhat unstable, disable it
private val useOldSpilledVarTypeAnalysis: Boolean = false
private val useOldSpilledVarTypeAnalysis: Boolean = false,
// Parameters of suspend lambda are put to the same fields as spilled variables
private val initialVarsCountByType: Map<Type, Int> = emptyMap()
) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) {
private val classBuilderForCoroutineState: ClassBuilder by lazy(obtainClassBuilderForCoroutineState)
@@ -132,15 +135,19 @@ class CoroutineTransformerMethodVisitor(
UninitializedStoresProcessor(methodNode, shouldPreserveClassInitialization).run()
updateLvtAccordingToLiveness(methodNode, isForNamedFunction)
val spilledToVariableMapping = spillVariables(suspensionPoints, methodNode)
val suspendMarkerVarIndex = methodNode.maxLocals++
val suspensionPointLineNumbers = suspensionPoints.map { findSuspensionPointLineNumber(it) }
val continuationLabels = suspensionPoints.withIndex().map {
transformCallAndReturnContinuationLabel(
it.index + 1, it.value, methodNode, suspendMarkerVarIndex, suspensionPointLineNumbers[it.index])
// Create states in state-machine, to which state-machine can jump
val stateLabels = suspensionPoints.withIndex().map {
transformCallAndReturnStateLabel(
it.index + 1, it.value, methodNode, suspendMarkerVarIndex, suspensionPointLineNumbers[it.index]
)
}
methodNode.instructions.apply {
@@ -163,7 +170,7 @@ class CoroutineTransformerMethodVisitor(
0,
suspensionPoints.size,
defaultLabel,
firstStateLabel, *continuationLabels.toTypedArray()
firstStateLabel, *stateLabels.toTypedArray()
),
firstStateLabel
)
@@ -180,25 +187,38 @@ class CoroutineTransformerMethodVisitor(
})
}
initializeFakeInlinerVariables(methodNode, stateLabels)
dropSuspensionMarkers(methodNode)
methodNode.removeEmptyCatchBlocks()
// The parameters (and 'this') shall live throughout the method, otherwise, d8 emits warning about invalid debug info
val startLabel = LabelNode()
val endLabel = LabelNode()
methodNode.instructions.insertBefore(methodNode.instructions.first, startLabel)
methodNode.instructions.insert(methodNode.instructions.last, endLabel)
fixLvtForParameters(methodNode, startLabel, endLabel)
if (languageVersionSettings.isReleaseCoroutines()) {
writeDebugMetadata(methodNode, suspensionPointLineNumbers, spilledToVariableMapping)
}
}
// When suspension point is inlined, it is in range of fake inliner variables.
// Path from TABLESWITCH into unspilling goes to latter part of the range.
// In this case the variables are uninitialized, initialize them
private fun initializeFakeInlinerVariables(methodNode: MethodNode, stateLabels: List<LabelNode>) {
for (stateLabel in stateLabels) {
for (record in methodNode.localVariables) {
if (isFakeLocalVariableForInline(record.name) &&
methodNode.instructions.indexOf(record.start) < methodNode.instructions.indexOf(stateLabel) &&
methodNode.instructions.indexOf(stateLabel) < methodNode.instructions.indexOf(record.end)
) {
methodNode.instructions.insert(stateLabel, withInstructionAdapter {
iconst(0)
store(record.index, Type.INT_TYPE)
})
}
}
}
}
private fun addCompletionParameterToLVT(methodNode: MethodNode) {
val index =
/* all args */ Type.getMethodType(methodNode.desc).argumentTypes.fold(0) { a, b -> a + b.size } +
/* all args */ Type.getMethodType(methodNode.desc).argumentTypes.fold(0) { a, b -> a + b.size } +
/* this */ (if (isStatic(methodNode.access)) 0 else 1) -
/* only last */ 1
val startLabel = with(methodNode.instructions) {
@@ -311,31 +331,10 @@ class CoroutineTransformerMethodVisitor(
}
}
private fun fixLvtForParameters(methodNode: MethodNode, startLabel: LabelNode, endLabel: LabelNode) {
val paramsNum =
/* this */ (if (isStatic(methodNode.access)) 0 else 1) +
/* real params */ Type.getArgumentTypes(methodNode.desc).fold(0) { a, b -> a + b.size }
for (i in 0 until paramsNum) {
fixRangeOfLvtRecord(methodNode, i, startLabel, endLabel)
}
}
private fun fixRangeOfLvtRecord(methodNode: MethodNode, index: Int, startLabel: LabelNode, endLabel: LabelNode) {
val vars = methodNode.localVariables.filter { it.index == index }
assert(vars.size <= 1) {
"Someone else occupies parameter's slot at $index"
}
vars.firstOrNull()?.let {
it.start = startLabel
it.end = endLabel
}
}
private fun writeDebugMetadata(
methodNode: MethodNode,
suspensionPointLineNumbers: List<LineNumberNode?>,
spilledToLocalMapping: List<List<SpilledVariableDescriptor>>
spilledToLocalMapping: List<List<SpilledVariableAndField>>
) {
val lines = suspensionPointLineNumbers.map { it?.line ?: -1 }
val metadata = classBuilderForCoroutineState.newAnnotation(DEBUG_METADATA_ANNOTATION_ASM_TYPE.descriptor, true)
@@ -590,7 +589,7 @@ class CoroutineTransformerMethodVisitor(
}
}
private fun spillVariables(suspensionPoints: List<SuspensionPoint>, methodNode: MethodNode): List<List<SpilledVariableDescriptor>> {
private fun spillVariables(suspensionPoints: List<SuspensionPoint>, methodNode: MethodNode): List<List<SpilledVariableAndField>> {
val instructions = methodNode.instructions
val frames =
if (useOldSpilledVarTypeAnalysis) performRefinedTypeAnalysis(methodNode, containingClassInternalName)
@@ -598,11 +597,23 @@ class CoroutineTransformerMethodVisitor(
fun AbstractInsnNode.index() = instructions.indexOf(this)
// We postpone these actions because they change instruction indices that we use when obtaining frames
val postponedActions = mutableListOf<() -> Unit>()
val maxVarsCountByType = mutableMapOf<Type, Int>()
var initialSpilledVariablesCount = 0
for ((type, count) in initialVarsCountByType) {
if (type == AsmTypes.OBJECT_TYPE) {
initialSpilledVariablesCount = count
}
maxVarsCountByType[type] = count
}
val livenessFrames = analyzeLiveness(methodNode)
val spilledToVariableMapping = arrayListOf<List<SpilledVariableDescriptor>>()
// References shall be cleaned up after uspill (during spill in next suspension point) to prevent memory leaks,
val referencesToSpillBySuspensionPointIndex = arrayListOf<List<ReferenceToSpill>>()
// while primitives shall not
val primitivesToSpillBySuspensionPointIndex = arrayListOf<List<PrimitiveToSpill>>()
// Collect information about spillable variables, that we use to determine which variables we need to cleanup
for (suspension in suspensionPoints) {
val suspensionCallBegin = suspension.suspensionCallBegin
@@ -629,7 +640,8 @@ class CoroutineTransformerMethodVisitor(
// NB: it's also rather useful for sake of optimization
val livenessFrame = livenessFrames[suspensionCallBegin.index()]
val spilledToVariable = arrayListOf<SpilledVariableDescriptor>()
val referencesToSpill = arrayListOf<ReferenceToSpill>()
val primitivesToSpill = arrayListOf<PrimitiveToSpill>()
// 0 - this
// 1 - parameter
@@ -637,77 +649,181 @@ class CoroutineTransformerMethodVisitor(
// k - continuation
// k + 1 - data
// k + 2 - exception
val variablesToSpill =
(0 until localsCount)
.filterNot { it in setOf(continuationIndex, dataIndex, exceptionIndex) }
.map { Pair(it, frame.getLocal(it)) }
.filter { (index, value) ->
(index == 0 && needDispatchReceiver && isForNamedFunction) ||
(value.type != null && livenessFrame.isAlive(index))
}
for (slot in 0 until localsCount) {
if (slot == continuationIndex || slot == dataIndex || slot == exceptionIndex) continue
val value = frame.getLocal(slot)
if (value.type == null || !livenessFrame.isAlive(slot)) continue
for ((index, basicValue) in variablesToSpill) {
if (basicValue == StrictBasicValue.NULL_VALUE) {
postponedActions.add {
with(instructions) {
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
aconst(null)
store(index, AsmTypes.OBJECT_TYPE)
})
}
}
if (value == StrictBasicValue.NULL_VALUE) {
referencesToSpill += slot to null
continue
}
val type = basicValue.type!!
val type = value.type!!
val normalizedType = type.normalize()
val indexBySort = varsCountByType[normalizedType]?.plus(1) ?: 0
varsCountByType[normalizedType] = indexBySort
val fieldName = normalizedType.fieldNameForVar(indexBySort)
localVariableName(methodNode, index, suspension.suspensionCallEnd.next.index())
?.let { spilledToVariable.add(SpilledVariableDescriptor(fieldName, it)) }
postponedActions.add {
with(instructions) {
// store variable before suspension call
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
load(index, type)
StackValue.coerce(type, normalizedType, this)
putfield(classBuilderForCoroutineState.thisName, fieldName, normalizedType.descriptor)
})
// restore variable after suspension call
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
getfield(classBuilderForCoroutineState.thisName, fieldName, normalizedType.descriptor)
StackValue.coerce(normalizedType, type, this)
store(index, type)
})
}
if (normalizedType == AsmTypes.OBJECT_TYPE) {
referencesToSpill += slot to SpillableVariable(value, type, normalizedType, fieldName)
} else {
primitivesToSpill += slot to SpillableVariable(value, type, normalizedType, fieldName)
}
}
spilledToVariableMapping.add(spilledToVariable)
referencesToSpillBySuspensionPointIndex += referencesToSpill
primitivesToSpillBySuspensionPointIndex += primitivesToSpill
varsCountByType.forEach {
maxVarsCountByType[it.key] = max(maxVarsCountByType[it.key] ?: 0, it.value)
for ((type, index) in varsCountByType) {
maxVarsCountByType[type] = max(maxVarsCountByType[type] ?: 0, index)
}
}
postponedActions.forEach(Function0<Unit>::invoke)
// Calculate variables to cleanup
maxVarsCountByType.forEach { entry ->
// Use CFG to calculate amount of spilled variables in previous suspension point (P) and current one (C).
// All fields from L$C to L$P should be cleaned. I.e. we should spill ACONST_NULL to them.
val cfg = ControlFlowGraph.build(methodNode)
// Collect all immediately preceding suspension points. I.e. suspension points, from which there is a path
// into current one, that does not cross other suspension points.
val suspensionPointEnds = suspensionPoints.associateBy { it.suspensionCallEnd }
fun findSuspensionPointPredecessors(suspension: SuspensionPoint): List<SuspensionPoint> {
val visited = mutableSetOf<AbstractInsnNode>()
fun dfs(current: AbstractInsnNode): List<SuspensionPoint> {
if (!visited.add(current)) return emptyList()
suspensionPointEnds[current]?.let { return listOf(it) }
return cfg.getPredecessorsIndices(current).flatMap { dfs(instructions[it]) }
}
return dfs(suspension.suspensionCallBegin)
}
val predSuspensionPoints = suspensionPoints.associateWith { findSuspensionPointPredecessors(it) }
// Calculate all pairs SuspensionPoint -> C and P, where P is minimum of all preds' Cs
fun countVariablesToSpill(index: Int): Int =
referencesToSpillBySuspensionPointIndex[index].count { (_, variable) -> variable != null }
val referencesToCleanBySuspensionPointIndex = arrayListOf<Pair<Int, Int>>() // current to pred
for (suspensionPointIndex in suspensionPoints.indices) {
val suspensionPoint = suspensionPoints[suspensionPointIndex]
val currentSpilledReferencesCount = countVariablesToSpill(suspensionPointIndex)
val preds = predSuspensionPoints[suspensionPoint]
val predSpilledReferencesCount =
if (preds.isNullOrEmpty()) initialSpilledVariablesCount
else preds.maxOf { countVariablesToSpill(suspensionPoints.indexOf(it)) }
referencesToCleanBySuspensionPointIndex += currentSpilledReferencesCount to predSpilledReferencesCount
}
// Mutate method node
fun generateSpillAndUnspill(suspension: SuspensionPoint, slot: Int, spillableVariable: SpillableVariable?) {
if (spillableVariable == null) {
with(instructions) {
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
aconst(null)
store(slot, AsmTypes.OBJECT_TYPE)
})
}
return
}
with(instructions) {
// store variable before suspension call
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
load(slot, spillableVariable.type)
StackValue.coerce(spillableVariable.type, spillableVariable.normalizedType, this)
putfield(
classBuilderForCoroutineState.thisName,
spillableVariable.fieldName,
spillableVariable.normalizedType.descriptor
)
})
// restore variable after suspension call
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
getfield(
classBuilderForCoroutineState.thisName,
spillableVariable.fieldName,
spillableVariable.normalizedType.descriptor
)
StackValue.coerce(spillableVariable.normalizedType, spillableVariable.type, this)
store(slot, spillableVariable.type)
})
}
}
fun cleanUpField(suspension: SuspensionPoint, fieldIndex: Int) {
with(instructions) {
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
aconst(null)
putfield(
classBuilderForCoroutineState.thisName,
"L\$$fieldIndex",
AsmTypes.OBJECT_TYPE.descriptor
)
})
}
}
for (suspensionPointIndex in suspensionPoints.indices) {
val suspension = suspensionPoints[suspensionPointIndex]
for ((slot, referenceToSpill) in referencesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
generateSpillAndUnspill(suspension, slot, referenceToSpill)
}
val (currentSpilledCount, predSpilledCount) = referencesToCleanBySuspensionPointIndex[suspensionPointIndex]
if (predSpilledCount > currentSpilledCount) {
for (fieldIndex in currentSpilledCount until predSpilledCount) {
cleanUpField(suspension, fieldIndex)
}
}
for ((slot, primitiveToSpill) in primitivesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
generateSpillAndUnspill(suspension, slot, primitiveToSpill)
}
}
for (entry in maxVarsCountByType) {
val (type, maxIndex) = entry
for (index in 0..maxIndex) {
for (index in (initialVarsCountByType[type]?.plus(1) ?: 0)..maxIndex) {
classBuilderForCoroutineState.newField(
JvmDeclarationOrigin.NO_ORIGIN, AsmUtil.NO_FLAG_PACKAGE_PRIVATE,
type.fieldNameForVar(index), type.descriptor, null, null
)
}
}
// Calculate debug metadata mapping
fun calculateSpilledVariableAndField(
suspension: SuspensionPoint,
slot: Int,
spillableVariable: SpillableVariable?
): SpilledVariableAndField? {
if (spillableVariable == null) return null
val name = localVariableName(methodNode, slot, suspension.suspensionCallEnd.next.index()) ?: return null
return SpilledVariableAndField(spillableVariable.fieldName, name)
}
val spilledToVariableMapping = arrayListOf<List<SpilledVariableAndField>>()
for (suspensionPointIndex in suspensionPoints.indices) {
val suspension = suspensionPoints[suspensionPointIndex]
val spilledToVariable = arrayListOf<SpilledVariableAndField>()
referencesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
primitivesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
}
spilledToVariableMapping += spilledToVariable
}
return spilledToVariableMapping
}
@@ -729,21 +845,21 @@ class CoroutineTransformerMethodVisitor(
private val SuspensionPoint.tryCatchBlockEndLabelAfterSuspensionCall: LabelNode
get() {
assert(suspensionCallEnd.next is LabelNode) {
"Next instruction after ${this} should be a label, but " +
"Next instruction after $this should be a label, but " +
"${suspensionCallEnd.next::class.java}/${suspensionCallEnd.next.opcode} was found"
}
return suspensionCallEnd.next as LabelNode
}
private fun transformCallAndReturnContinuationLabel(
private fun transformCallAndReturnStateLabel(
id: Int,
suspension: SuspensionPoint,
methodNode: MethodNode,
suspendMarkerVarIndex: Int,
suspendPointLineNumber: LineNumberNode?
): LabelNode {
val continuationLabel = LabelNode().linkWithLabel()
val stateLabel = LabelNode().linkWithLabel()
val continuationLabelAfterLoadedResult = LabelNode()
val suspendElementLineNumber = lineNumber
var nextLineNumberNode = nextDefinitelyHitLineNumber(suspension)
@@ -771,7 +887,7 @@ class CoroutineTransformerMethodVisitor(
load(suspendMarkerVarIndex, AsmTypes.OBJECT_TYPE)
areturn(AsmTypes.OBJECT_TYPE)
// Mark place for continuation
visitLabel(continuationLabel.label)
visitLabel(stateLabel.label)
})
// After suspension point there is always three nodes: L1, NOP, L2
@@ -822,7 +938,7 @@ class CoroutineTransformerMethodVisitor(
}
}
return continuationLabel
return stateLabel
}
// Find the next line number instruction that is defintely hit. That is, a line number
@@ -830,9 +946,11 @@ class CoroutineTransformerMethodVisitor(
private fun nextDefinitelyHitLineNumber(suspension: SuspensionPoint): LineNumberNode? {
var next = suspension.suspensionCallEnd.next
while (next != null) {
if (next.isBranchOrCall) return null
else if (next is LineNumberNode) return next
else next = next.next
when {
next.isBranchOrCall -> return null
next is LineNumberNode -> return next
else -> next = next.next
}
}
return next
}
@@ -888,9 +1006,19 @@ class CoroutineTransformerMethodVisitor(
return
}
private data class SpilledVariableDescriptor(val fieldName: String, val variableName: String)
private data class SpilledVariableAndField(val fieldName: String, val variableName: String)
}
private class SpillableVariable(
val value: BasicValue,
val type: Type,
val normalizedType: Type,
val fieldName: String
)
private typealias ReferenceToSpill = Pair<Int, SpillableVariable?>
private typealias PrimitiveToSpill = Pair<Int, SpillableVariable>
internal fun InstructionAdapter.generateContinuationConstructorCall(
objectTypeForState: Type?,
methodNode: MethodNode,
@@ -956,7 +1084,7 @@ inline fun withInstructionAdapter(block: InstructionAdapter.() -> Unit): InsnLis
return tmpMethodNode.instructions
}
private fun Type.normalize() =
internal fun Type.normalize() =
when (sort) {
Type.ARRAY, Type.OBJECT -> AsmTypes.OBJECT_TYPE
else -> this
@@ -1027,3 +1155,72 @@ internal fun replaceFakeContinuationsWithRealOnes(methodNode: MethodNode, contin
methodNode.instructions.set(fakeContinuation, VarInsnNode(Opcodes.ALOAD, continuationIndex))
}
}
/* We do not want to spill dead variables, thus, we shrink its LVT record to region, where the variable is alive,
* so, the variable will not be visible in debugger. User can still prolong life span of the variable by using it.
*
* This means, that function parameters do not longer span the whole function, including `this`.
* This might and will break some bytecode processors, including old versions of R8. See KT-24510.
*/
private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction: Boolean) {
val liveness = analyzeLiveness(method)
fun List<LocalVariableNode>.findRecord(insnIndex: Int, variableIndex: Int): LocalVariableNode? {
for (variable in this) {
if (variable.index == variableIndex &&
method.instructions.indexOf(variable.start) <= insnIndex &&
insnIndex < method.instructions.indexOf(variable.end)
) return variable
}
return null
}
fun isAlive(insnIndex: Int, variableIndex: Int): Boolean =
liveness[insnIndex].isAlive(variableIndex)
val oldLvt = arrayListOf<LocalVariableNode>()
for (record in method.localVariables) {
oldLvt += record
}
method.localVariables.clear()
// Skip `this` for suspend lamdba
val start = if (isForNamedFunction) 0 else 1
for (variableIndex in start until method.maxLocals) {
if (oldLvt.none { it.index == variableIndex }) continue
var startLabel: LabelNode? = null
for (insnIndex in 0 until (method.instructions.size() - 1)) {
val insn = method.instructions[insnIndex]
if (!isAlive(insnIndex, variableIndex) && isAlive(insnIndex + 1, variableIndex)) {
startLabel = insn as? LabelNode ?: insn.findNextOrNull { it is LabelNode } as? LabelNode
}
if (isAlive(insnIndex, variableIndex) && !isAlive(insnIndex + 1, variableIndex)) {
// No variable in LVT -> do not add one
val lvtRecord = oldLvt.findRecord(insnIndex, variableIndex) ?: continue
if (lvtRecord.name == CONTINUATION_VARIABLE_NAME) continue
val endLabel = insn as? LabelNode ?: insn.findNextOrNull { it is LabelNode } as? LabelNode ?: continue
// startLabel can be null in case of parameters
@Suppress("NAME_SHADOWING") val startLabel = startLabel ?: lvtRecord.start
// No LINENUMBER in range -> no way to put a breakpoint -> do not bother adding a record
if (InsnSequence(startLabel, endLabel).none { it is LineNumberNode }) continue
method.localVariables.add(
LocalVariableNode(lvtRecord.name, lvtRecord.desc, lvtRecord.signature, startLabel, endLabel, lvtRecord.index)
)
}
}
}
for (variable in oldLvt) {
// $continuation and $result are dead, but they are used by debugger, as well as fake inliner variables
// For example, $continuation is used to create async stack trace
if (variable.name == CONTINUATION_VARIABLE_NAME ||
variable.name == SUSPEND_CALL_RESULT_NAME ||
isFakeLocalVariableForInline(variable.name)
) {
method.localVariables.add(variable)
}
// this acts like $continuation for lambdas. For example, it is used by debugger to create async stack trace. Keep it.
if (variable.name == "this" && !isForNamedFunction) {
method.localVariables.add(variable)
}
}
}

View File

@@ -1,11 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.coroutines
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
typealias SourceFrames = Array<Frame<SourceValue>?>

View File

@@ -1,11 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.coroutines
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
typealias SourceFrames = Array<Frame<SourceValue>>

View File

@@ -26,7 +26,6 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
// TODO Use this in variable liveness analysis
internal class MethodNodeExaminer(
val languageVersionSettings: LanguageVersionSettings,
containingClassInternalName: String,

View File

@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.codegen.coroutines
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalClassDescriptor
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
@@ -312,7 +312,7 @@ private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isR
fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
module.resolveTopLevelClass(
DescriptorUtils.RESULT_FQ_NAME,
StandardNames.RESULT_FQ_NAME,
NoLookupLocation.FROM_BACKEND
)?.defaultType?.let {
KotlinTypeFactory.simpleType(
@@ -501,7 +501,7 @@ fun FunctionDescriptor.isSuspendLambdaOrLocalFunction() = this.isSuspend && when
fun FunctionDescriptor.isLocalSuspendFunctionNotSuspendLambda() = isSuspendLambdaOrLocalFunction() && this !is AnonymousFunctionDescriptor
@JvmField
val EXPERIMENTAL_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType()
val EXPERIMENTAL_CONTINUATION_ASM_TYPE = StandardNames.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType()
@JvmField
val RELEASE_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType()
val RELEASE_CONTINUATION_ASM_TYPE = StandardNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType()

View File

@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.codegen.inline
import com.intellij.psi.PsiElement
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
import org.jetbrains.kotlin.codegen.context.ClosureContext
@@ -658,6 +658,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
if (nameWithoutManglingSuffix != null) {
methodNode = getMethodNode(bytes, nameWithoutManglingSuffix, asmMethod.descriptor, classType)
}
if (methodNode == null) {
val nameWithImplSuffix = "$nameWithoutManglingSuffix-impl"
methodNode = getMethodNode(bytes, nameWithImplSuffix, asmMethod.descriptor, classType)
}
}
return methodNode
}
@@ -671,7 +675,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
if (callableDescriptor is FictitiousArrayConstructor) return true
val name = callableDescriptor.name.asString()
return (name == "arrayOf" || name == "emptyArray") && callableDescriptor.containingDeclaration.let { container ->
container is PackageFragmentDescriptor && container.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
container is PackageFragmentDescriptor && container.fqName == StandardNames.BUILT_INS_PACKAGE_FQ_NAME
}
}

View File

@@ -171,7 +171,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
checkClusterInvariant(clustersFromInnermost);
int originalDepthIndex = 0;
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList();
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList<>();
while (tryCatchBlockIterator.hasNext()) {
TryBlockCluster<TryCatchBlockNodeInfo> clusterToFindFinally = tryCatchBlockIterator.next();
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();

View File

@@ -91,7 +91,7 @@ class ParametersBuilder private constructor() {
}
fun buildParameters(): Parameters {
var nextDeclarationIndex = (params.maxBy { it.declarationIndex }?.declarationIndex ?: -1) + 1
var nextDeclarationIndex = (params.maxOfOrNull { it.declarationIndex } ?: -1) + 1
return Parameters(params.map { param ->
if (param is CapturedParamInfo) {

View File

@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted
@@ -54,7 +55,7 @@ internal fun generateInlineIntrinsic(
private fun isSpecialEnumMethod(descriptor: FunctionDescriptor): Boolean {
val containingDeclaration = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false
if (containingDeclaration.fqName != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) {
if (containingDeclaration.fqName != StandardNames.BUILT_INS_PACKAGE_FQ_NAME) {
return false
}
if (descriptor.typeParameters.size != 1) {

View File

@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.builtins.StandardNames;
import org.jetbrains.kotlin.builtins.PrimitiveType;
import org.jetbrains.kotlin.codegen.AsmUtil;
import org.jetbrains.kotlin.config.JvmTarget;
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.*;
import static org.jetbrains.kotlin.builtins.StandardNames.*;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class IntrinsicMethods {
@@ -70,15 +70,15 @@ public class IntrinsicMethods {
public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) {
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, RECEIVER_PARAMETER_FQ_NAME, "javaClass", -1, JavaClassProperty.INSTANCE);
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "java", -1, new KClassJavaProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.FQ_NAMES.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "java", -1, new KClassJavaProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
intrinsicsMap.registerIntrinsic(StandardNames.FqNames.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorEnter", 1, MonitorInstruction.MONITOR_ENTER);
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorExit", 1, MonitorInstruction.MONITOR_EXIT);
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.array, "isArrayOf", 0, new IsArrayOf());
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.array, "isArrayOf", 0, new IsArrayOf());
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOf", 1, new ArrayOf());
@@ -87,7 +87,7 @@ public class IntrinsicMethods {
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
for (Name method : primitiveCastMethods) {
String methodName = method.asString();
declareIntrinsicFunction(FQ_NAMES.number, methodName, 0, NUMBER_CAST);
declareIntrinsicFunction(StandardNames.FqNames.number, methodName, 0, NUMBER_CAST);
for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) {
declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST);
}
@@ -139,20 +139,20 @@ public class IntrinsicMethods {
declareBinaryOp("or", IOR);
declareBinaryOp("xor", IXOR);
declareIntrinsicFunction(FQ_NAMES._boolean, "not", 0, new Not());
declareIntrinsicFunction(StandardNames.FqNames._boolean, "not", 0, new Not());
declareIntrinsicFunction(FQ_NAMES.string, "plus", 1, new Concat());
declareIntrinsicFunction(FQ_NAMES.string, "get", 1, new StringGetChar());
declareIntrinsicFunction(StandardNames.FqNames.string, "plus", 1, new Concat());
declareIntrinsicFunction(StandardNames.FqNames.string, "get", 1, new StringGetChar());
if (canReplaceStdlibRuntimeApiBehavior) {
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimMargin", 1, new TrimMargin());
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimIndent", 0, new TrimIndent());
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "trimMargin", 1, new TrimMargin());
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "trimIndent", 0, new TrimIndent());
}
declareIntrinsicFunction(FQ_NAMES.cloneable, "clone", 0, CLONE);
declareIntrinsicFunction(StandardNames.FqNames.cloneable, "clone", 0, CLONE);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "toString", 0, TO_STRING);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.string, "plus", 1, STRING_PLUS);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.any, "toString", 0, TO_STRING);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "plus", 1, STRING_PLUS);
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray());
for (PrimitiveType type : PrimitiveType.values()) {
@@ -197,7 +197,7 @@ public class IntrinsicMethods {
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName());
}
declareArrayMethods(FQ_NAMES.array.toSafe());
declareArrayMethods(FqNames.array.toSafe());
}
private void declareArrayMethods(@NotNull FqName arrayTypeFqName) {

View File

@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.builtins.StandardNames.COLLECTIONS_PACKAGE_FQ_NAME
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod

View File

@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
@@ -16,7 +16,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.*
import kotlin.text.Regex
object TypeIntrinsics {
@JvmStatic
@@ -134,20 +133,20 @@ object TypeIntrinsics {
private val MUTABLE_COLLECTION_TYPE_FQ_NAMES = setOf(
FQ_NAMES.mutableIterator,
FQ_NAMES.mutableIterable,
FQ_NAMES.mutableCollection,
FQ_NAMES.mutableList,
FQ_NAMES.mutableListIterator,
FQ_NAMES.mutableMap,
FQ_NAMES.mutableSet,
FQ_NAMES.mutableMapEntry
FqNames.mutableIterator,
FqNames.mutableIterable,
FqNames.mutableCollection,
FqNames.mutableList,
FqNames.mutableListIterator,
FqNames.mutableMap,
FqNames.mutableSet,
FqNames.mutableMapEntry
)
private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? {
val fqName = getClassFqName(jetType)
if (fqName == null || fqName !in MUTABLE_COLLECTION_TYPE_FQ_NAMES) return null
val baseName = if (fqName == FQ_NAMES.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
val baseName = if (fqName == FqNames.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
return prefix + baseName
}
@@ -200,4 +199,4 @@ object TypeIntrinsics {
private val BEFORE_CHECKCAST_TO_FUNCTION_OF_ARITY_DESCRIPTOR =
Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE, Type.INT_TYPE)
}
}

View File

@@ -5,16 +5,10 @@
package org.jetbrains.kotlin.codegen.optimization.common
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import org.jetbrains.org.objectweb.asm.tree.IincInsnNode
import org.jetbrains.org.objectweb.asm.tree.MethodNode
import org.jetbrains.org.objectweb.asm.tree.VarInsnNode
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
import java.util.*
@@ -29,10 +23,6 @@ class VariableLivenessFrame(val maxLocals: Int) : VarFrame<VariableLivenessFrame
bitSet.set(varIndex, true)
}
fun markAllAlive(bitSet: BitSet) {
this.bitSet.or(bitSet)
}
fun markDead(varIndex: Int) {
bitSet.set(varIndex, false)
}
@@ -45,34 +35,17 @@ class VariableLivenessFrame(val maxLocals: Int) : VarFrame<VariableLivenessFrame
}
override fun hashCode() = bitSet.hashCode()
override fun toString(): String = (0 until maxLocals).map { if (bitSet[it]) '@' else '_' }.joinToString(separator = "")
}
fun analyzeLiveness(node: MethodNode): List<VariableLivenessFrame> {
val typeAnnotatedFrames = MethodTransformer.analyze("fake", node, OptimizationBasicInterpreter())
val visibleByDebuggerVariables = analyzeVisibleByDebuggerVariables(node, typeAnnotatedFrames)
return analyze(node, object : BackwardAnalysisInterpreter<VariableLivenessFrame> {
fun analyzeLiveness(method: MethodNode): List<VariableLivenessFrame> =
analyze(method, object : BackwardAnalysisInterpreter<VariableLivenessFrame> {
override fun newFrame(maxLocals: Int) = VariableLivenessFrame(maxLocals)
override fun def(frame: VariableLivenessFrame, insn: AbstractInsnNode) = defVar(frame, insn)
override fun use(frame: VariableLivenessFrame, insn: AbstractInsnNode) =
useVar(frame, insn, node, visibleByDebuggerVariables[node.instructions.indexOf(insn)])
useVar(frame, insn)
})
}
private fun analyzeVisibleByDebuggerVariables(
node: MethodNode,
typeAnnotatedFrames: TypeAnnotatedFrames
): Array<BitSet> {
val res = Array(node.instructions.size()) { BitSet(node.maxLocals) }
for (local in node.localVariables) {
if (local.name.isInvisibleDebuggerVariable()) continue
for (index in node.instructions.indexOf(local.start) until node.instructions.indexOf(local.end)) {
if (Type.getType(local.desc).sort == typeAnnotatedFrames[index]?.getLocal(local.index)?.type?.sort) {
res[index].set(local.index)
}
}
}
return res
}
private fun defVar(frame: VariableLivenessFrame, insn: AbstractInsnNode) {
if (insn is VarInsnNode && insn.isStoreOperation()) {
@@ -80,22 +53,10 @@ private fun defVar(frame: VariableLivenessFrame, insn: AbstractInsnNode) {
}
}
private fun useVar(
frame: VariableLivenessFrame,
insn: AbstractInsnNode,
node: MethodNode,
visibleByDebuggerVariables: BitSet
) {
frame.markAllAlive(visibleByDebuggerVariables)
private fun useVar(frame: VariableLivenessFrame, insn: AbstractInsnNode) {
if (insn is VarInsnNode && insn.isLoadOperation()) {
frame.markAlive(insn.`var`)
} else if (insn is IincInsnNode) {
frame.markAlive(insn.`var`)
}
}
private fun String.isInvisibleDebuggerVariable(): Boolean =
startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_ARGUMENT) ||
startsWith(JvmAbi.LOCAL_VARIABLE_NAME_PREFIX_INLINE_FUNCTION) ||
this == SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
}

View File

@@ -69,9 +69,10 @@ abstract class PrimitiveNumberRangeIntrinsicRangeValue(
?: throw AssertionError("Floating point intrinsic range value should be a range literal")
InFloatingPointRangeLiteralExpressionGenerator(operatorReference, rangeLiteral, comparisonGenerator, codegen.frameMap)
}
else -> InIntegralContinuousRangeExpressionGenerator(
operatorReference, rangeContainsTypeInfo, getBoundedValue(codegen), comparisonGenerator, codegen.frameMap
)
else ->
InIntegralContinuousRangeExpressionGenerator(
operatorReference, rangeContainsTypeInfo, getBoundedValue(codegen), comparisonGenerator, codegen.frameMap
)
}
}

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.codegen.range
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
import org.jetbrains.kotlin.descriptors.*
@@ -83,10 +84,10 @@ fun getRangeOrProgressionElementType(rangeType: KotlinType): KotlinType? {
COMPARABLE_RANGE_FQN -> rangeType.arguments.singleOrNull()?.type
UINT_RANGE_FQN, UINT_PROGRESSION_FQN ->
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uIntFqName)
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(StandardNames.FqNames.uIntFqName)
ULONG_RANGE_FQN, ULONG_PROGRESSION_FQN ->
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uLongFqName)
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(StandardNames.FqNames.uLongFqName)
else -> null
}
@@ -208,17 +209,25 @@ fun isPrimitiveRangeContains(descriptor: CallableDescriptor): Boolean {
}
fun isUnsignedIntegerRangeContains(descriptor: CallableDescriptor): Boolean {
if (descriptor.name.asString() != "contains") return false
val dispatchReceiverType = descriptor.dispatchReceiverParameter?.type
val extensionReceiverType = descriptor.extensionReceiverParameter?.type
return (dispatchReceiverType != null && isUnsignedRange(dispatchReceiverType)) ||
(extensionReceiverType != null && isUnsignedRange(extensionReceiverType))
when {
dispatchReceiverType != null && extensionReceiverType == null -> {
if (descriptor.name.asString() != "contains") return false
return isUnsignedRange(dispatchReceiverType)
}
extensionReceiverType != null && dispatchReceiverType == null -> {
if (!descriptor.isTopLevelInPackage("contains", "kotlin.ranges")) return false
return isUnsignedRange(extensionReceiverType)
}
else ->
return false
}
}
fun isPrimitiveNumberRangeExtensionContainsPrimitiveNumber(descriptor: CallableDescriptor): Boolean {
if (descriptor.name.asString() != "contains") return false
if (!descriptor.isTopLevelInPackage("contains", "kotlin.ranges")) return false
val extensionReceiverType = descriptor.extensionReceiverParameter?.type ?: return false

View File

@@ -87,7 +87,10 @@ fun getComparisonGeneratorForRangeContainsCall(
getComparisonGeneratorForKotlinType(elementType)
KotlinBuiltIns.isUInt(elementType) ->
UIntComparisonGenerator
if (KotlinBuiltIns.isULong(valueParameterType))
null
else
UIntComparisonGenerator
KotlinBuiltIns.isULong(elementType) ->
ULongComparisonGenerator

View File

@@ -51,14 +51,12 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
moduleName: String,
languageVersionSettings: LanguageVersionSettings,
shouldGenerate: (JvmDeclarationOrigin) -> Boolean,
mapAsmMethod: ((FunctionDescriptor) -> Method)?
) : SignatureCollectingClassBuilderFactory(builderFactory, shouldGenerate) {
private val mapAsmMethod = mapAsmMethod
?: KotlinTypeMapper(
// Avoid errors when some classes are not loaded for some reason
bindingContext, ClassBuilderMode.LIGHT_CLASSES, moduleName, languageVersionSettings, isIrBackend = false
)::mapAsmMethod
private val mapAsmMethod: (FunctionDescriptor) -> Method = KotlinTypeMapper(
// Avoid errors when some classes are not loaded for some reason
bindingContext, ClassBuilderMode.LIGHT_CLASSES, moduleName, languageVersionSettings, isIrBackend = false
)::mapAsmMethod
private val reportDiagnosticsTasks = ArrayList<() -> Unit>()

View File

@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
@@ -48,7 +47,6 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeApproximator
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.Method
import java.io.File
class GenerationState private constructor(
@@ -283,7 +281,6 @@ class GenerationState private constructor(
val isIrWithStableAbi = configuration.getBoolean(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI)
val globalSerializationBindings = JvmSerializationBindings()
lateinit var irBasedMapAsmMethod: (FunctionDescriptor) -> Method
var mapInlineClass: (ClassDescriptor) -> Type = { descriptor -> typeMapper.mapType(descriptor.defaultType) }
val typeApproximator: TypeApproximator? =
@@ -310,7 +307,6 @@ class GenerationState private constructor(
BuilderFactoryForDuplicateSignatureDiagnostics(
it, this.bindingContext, diagnostics, this.moduleName, this.languageVersionSettings,
shouldGenerate = { origin -> !shouldOnlyCollectSignatures(origin) },
mapAsmMethod = if (isIrBackend) { descriptor: FunctionDescriptor -> irBasedMapAsmMethod(descriptor) } else null
).apply { duplicateSignatureFactory = this }
},
{ BuilderFactoryForDuplicateClassNameDiagnostics(it, diagnostics) },

View File

@@ -8,7 +8,9 @@ package org.jetbrains.kotlin.codegen.state
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames.RESULT_FQ_NAME
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
import org.jetbrains.kotlin.builtins.functions.FunctionClassKind
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.AsmUtil.isStaticMethod
@@ -52,10 +54,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.descriptorUtil.*
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.DEFAULT_CONSTRUCTOR_MARKER
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
@@ -330,8 +329,8 @@ class KotlinTypeMapper @JvmOverloads constructor(
if (classDescriptor is FunctionClassDescriptor) {
if (classDescriptor.hasBigArity ||
classDescriptor.functionKind == FunctionClassDescriptor.Kind.KFunction ||
classDescriptor.functionKind == FunctionClassDescriptor.Kind.KSuspendFunction
classDescriptor.functionKind == FunctionClassKind.KFunction ||
classDescriptor.functionKind == FunctionClassKind.KSuspendFunction
) {
// kotlin.reflect.KFunction{n}<P1, ..., Pn, R> is mapped to kotlin.reflect.KFunction<R> (for all n), and
// kotlin.Function{n}<P1, ..., Pn, R> is mapped to kotlin.jvm.functions.FunctionN<R> (for n > 22).
@@ -385,6 +384,11 @@ class KotlinTypeMapper @JvmOverloads constructor(
return functionDescriptor.builtIns.nullableAnyType
}
// Force boxing for Result type, otherwise, the coroutines machinery will break
if (originalReturnType.constructor.declarationDescriptor?.fqNameSafe == RESULT_FQ_NAME) {
return functionDescriptor.builtIns.nullableAnyType
}
// Don't box other inline classes
return originalReturnType
}

View File

@@ -18,6 +18,7 @@
package org.jetbrains.kotlin.codegen.state
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
@@ -37,7 +38,6 @@ import org.jetbrains.kotlin.types.checker.convertVariance
import org.jetbrains.kotlin.types.getEffectiveVariance
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
import org.jetbrains.kotlin.types.model.TypeParameterMarker
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES
// TODO: probably class upper bound should be used
@Suppress("UNUSED_PARAMETER")
@@ -81,9 +81,9 @@ val FqName?.isMethodWithDeclarationSiteWildcardsFqName: Boolean
private fun FqName.child(name: String): FqName = child(Name.identifier(name))
private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf(
BUILTIN_NAMES.mutableCollection.child("addAll"),
BUILTIN_NAMES.mutableList.child("addAll"),
BUILTIN_NAMES.mutableMap.child("putAll")
FqNames.mutableCollection.child("addAll"),
FqNames.mutableList.child("addAll"),
FqNames.mutableMap.child("putAll")
)
fun TypeMappingMode.updateArgumentModeFromAnnotations(

View File

@@ -35,7 +35,7 @@ private class State<T>(val path: MutableList<String>) {
path.add(step)
}
fun removeStep(step: String) {
fun removeStep() {
path.removeAt(path.lastIndex)
}
@@ -93,7 +93,7 @@ abstract class TypeAnnotationCollector<T>(val context: TypeSystemCommonBackendCo
fun KotlinTypeMarker.process(step: String) {
state.addStep(step)
this.gatherTypeAnnotations()
state.removeStep(step)
state.removeStep()
}

View File

@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.serialization.builtins
import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInClassDescriptorFactory
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
@@ -100,9 +100,9 @@ class BuiltInsSerializer(dependOnOldBuiltIns: Boolean) : MetadataSerializer(Buil
// Since Kotlin 1.1, we always discard this class during deserialization (see ClassDeserializer.kt).
private fun createCloneable(module: ModuleDescriptor): ClassDescriptor {
val factory = JvmBuiltInClassDescriptorFactory(LockBasedStorageManager.NO_LOCKS, module) {
EmptyPackageFragmentDescriptor(module, KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME)
EmptyPackageFragmentDescriptor(module, StandardNames.BUILT_INS_PACKAGE_FQ_NAME)
}
return factory.createClass(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe()))
return factory.createClass(ClassId.topLevel(StandardNames.FqNames.cloneable.toSafe()))
?: error("Could not create kotlin.Cloneable in $module")
}
}

View File

@@ -31,6 +31,9 @@ dependencies {
compile(project(":kotlin-util-io"))
compile(project(":compiler:ir.serialization.common"))
// TODO: as soon as cli-jvm is extracted out of this module, move this dependency there
compileOnly(project(":compiler:ir.tree.impl"))
compileOnly(toolsJarApi())
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }

View File

@@ -317,6 +317,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var useFir: Boolean by FreezableVar(false)
@Argument(
value = "-Xuse-fir-extended-checkers",
description = "Use extended analysis mode based on Front-end IR. Warning: this feature is far from being production-ready"
)
var useFirExtendedCheckers: Boolean by FreezableVar(false)
@Argument(
value = "-Xuse-mixed-named-arguments",
description = "Enable Support named arguments in their own position even if the result appears as mixed"

View File

@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.cli.common.messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -25,6 +24,7 @@ import java.io.File;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
public class OutputMessageUtil {
@@ -69,7 +69,7 @@ public class OutputMessageUtil {
}
private static Collection<File> parseSourceFiles(String[] strings, int start) {
Collection<File> sourceFiles = ContainerUtil.newArrayList();
Collection<File> sourceFiles = new ArrayList<>();
for (int i = start; i < strings.length; i++) {
sourceFiles.add(new File(strings[i]));
}

View File

@@ -89,6 +89,9 @@ open class GenericReplEvaluator(
historyActor.addPlaceholder(compileResult.lineId, EvalClassWithInstanceAndLoader(scriptClass.kotlin, null, classLoader, invokeWrapper))
val savedClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = classLoader
val scriptInstance =
try {
if (invokeWrapper != null) invokeWrapper.invoke { scriptInstanceConstructor.newInstance(*constructorArgs) }
@@ -104,6 +107,7 @@ open class GenericReplEvaluator(
}
finally {
historyActor.removePlaceholder(compileResult.lineId)
Thread.currentThread().contextClassLoader = savedClassLoader
}
historyActor.addFinal(compileResult.lineId, EvalClassWithInstanceAndLoader(scriptClass.kotlin, scriptInstance, classLoader, invokeWrapper))

View File

@@ -34,12 +34,12 @@ fun String.replUnescapeLineBreaks() = StringUtil.replace(this, XML_REPLACEMENTS,
fun String.replEscapeLineBreaks() = StringUtil.replace(this, SOURCE_CHARS, XML_REPLACEMENTS)
fun String.replOutputAsXml(escapeType: ReplEscapeType): String {
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
return "$XML_PREAMBLE<output type=\"$escapeType\">$escapedXml</output>"
}
fun String.replInputAsXml(): String {
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
return "$XML_PREAMBLE<input>$escapedXml</input>"
}
@@ -86,4 +86,4 @@ internal fun URLClassLoader.listLocalUrlsAsFiles(): List<File> {
internal fun <T : Any> List<T>.ensureNotEmpty(error: String): List<T> {
if (this.isEmpty()) throw IllegalStateException(error)
return this
}
}

View File

@@ -6,6 +6,7 @@ plugins {
dependencies {
compile(project(":compiler:cli"))
compile(project(":compiler:ir.serialization.js"))
compileOnly(project(":compiler:ir.tree.persistent"))
runtimeOnly(project(":kotlin-reflect"))
if (Platform[193].orLower()) {
compile(intellijDep()) { includeJars("picocontainer", rootProject = rootProject) }

View File

@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.cli.common.messages.*
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.psi.KtFile
@@ -87,6 +88,7 @@ fun buildKLib(
configuration = configuration,
allDependencies = allDependencies,
friendDependencies = emptyList(),
irFactory = PersistentIrFactory,
outputKlibPath = outputPath,
nopack = true
)

View File

@@ -24,13 +24,17 @@ import org.jetbrains.kotlin.cli.common.messages.MessageUtil
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
import org.jetbrains.kotlin.incremental.js.IncrementalNextRoundChecker
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
import org.jetbrains.kotlin.js.config.EcmaVersion
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
@@ -193,6 +197,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
configuration = config.configuration,
allDependencies = resolvedLibraries,
friendDependencies = friendDependencies,
irFactory = PersistentIrFactory,
outputKlibPath = outputKlibPath,
nopack = arguments.irProduceKlibDir
)

View File

@@ -127,10 +127,10 @@ object Main {
classpath.addPath(".")
}
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-stdlib.jar")
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
if (!noReflect) {
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-reflect.jar")
classpath.addPath("$KOTLIN_HOME/lib/kotlin-reflect.jar")
}
if (expression != null) {

View File

@@ -89,8 +89,10 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
performanceManager.notifyCompilationFinished()
if (arguments.reportPerf) {
performanceManager.getMeasurementResults()
.forEach { it -> configuration.get(MESSAGE_COLLECTOR_KEY)!!.report(INFO, "PERF: " + it.render(), null) }
collector.report(INFO, "PERF: " + performanceManager.getTargetInfo())
for (measurement in performanceManager.getMeasurementResults()) {
collector.report(INFO, "PERF: " + measurement.render(), null)
}
}
if (arguments.dumpPerf != null) {

View File

@@ -24,6 +24,13 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
private var irTranslationStart: Long = 0
private var irGenerationStart: Long = 0
private var targetDescription: String? = null
protected var files: Int? = null
protected var lines: Int? = null
fun getTargetInfo(): String =
"$targetDescription, $files files ($lines lines)"
fun getMeasurementResults(): List<PerformanceMeasurement> = measurements
fun enableCollectingPerformanceStatistics() {
@@ -34,9 +41,13 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
private fun deltaTime(start: Long): Long = PerformanceCounter.currentTime() - start
open fun notifyCompilerInitialized() {
open fun notifyCompilerInitialized(files: Int, lines: Int, targetDescription: String) {
if (!isEnabled) return
recordInitializationTime()
this.files = files
this.lines = lines
this.targetDescription = targetDescription
}
open fun notifyCompilationFinished() {
@@ -50,32 +61,30 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
analysisStart = PerformanceCounter.currentTime()
}
open fun notifyAnalysisFinished(files: Int, lines: Int, additionalDescription: String?) {
open fun notifyAnalysisFinished() {
val time = PerformanceCounter.currentTime() - analysisStart
measurements += CodeAnalysisMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
measurements += CodeAnalysisMeasurement(lines, TimeUnit.NANOSECONDS.toMillis(time))
}
open fun notifyGenerationStarted() {
generationStart = PerformanceCounter.currentTime()
}
open fun notifyGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
open fun notifyGenerationFinished() {
val time = PerformanceCounter.currentTime() - generationStart
measurements += CodeGenerationMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
measurements += CodeGenerationMeasurement(lines, TimeUnit.NANOSECONDS.toMillis(time))
}
open fun notifyIRTranslationStarted() {
irTranslationStart = PerformanceCounter.currentTime()
}
open fun notifyIRTranslationFinished(files: Int, lines: Int, additionalDescription: String?) {
open fun notifyIRTranslationFinished() {
val time = deltaTime(irTranslationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Translation
IRMeasurement.Kind.TRANSLATION
)
}
@@ -83,14 +92,12 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
irGenerationStart = PerformanceCounter.currentTime()
}
open fun notifyIRGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
open fun notifyIRGenerationFinished() {
val time = deltaTime(irGenerationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Generation
IRMeasurement.Kind.GENERATION
)
}

View File

@@ -102,6 +102,6 @@ public class Usage {
private static void appendln(@NotNull StringBuilder sb, @NotNull String string) {
sb.append(string);
StringsKt.appendln(sb);
sb.append('\n');
}
}

View File

@@ -23,6 +23,7 @@ fun <A : CommonCompilerArguments> CompilerConfiguration.setupCommonArguments(
) {
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
put(CommonConfigurationKeys.USE_FIR, arguments.useFir)
put(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS, arguments.useFirExtendedCheckers)
put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker)
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)

View File

@@ -9,54 +9,41 @@ interface PerformanceMeasurement {
fun render(): String
}
class JitCompilationMeasurement(private val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = "JIT time is $milliseconds ms"
}
class CompilerInitializationMeasurement(private val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = "INIT: Compiler initialized in $milliseconds ms"
}
class CodeAnalysisMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?) :
PerformanceMeasurement {
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
class CodeAnalysisMeasurement(private val lines: Int?, val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = formatMeasurement("ANALYZE", milliseconds, lines)
}
class CodeGenerationMeasurement(private val files: Int, val lines: Int, private val milliseconds: Long, private val description: String?) :
PerformanceMeasurement {
private val speed: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"GENERATE: $files files ($lines lines) ${description}in $milliseconds ms - ${"%.3f".format(speed)} loc/s"
class CodeGenerationMeasurement(private val lines: Int?, private val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = formatMeasurement("GENERATE", milliseconds, lines)
}
class GarbageCollectionMeasurement(val garbageCollectionKind: String, val milliseconds: Long, val count: Long) : PerformanceMeasurement {
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms, $count collections"
}
class PerformanceCounterMeasurement(private val counterReport: String) : PerformanceMeasurement {
override fun render(): String = counterReport
}
class IRMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?, val kind: Kind) :
PerformanceMeasurement {
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"IR: $kind $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
class IRMeasurement(val lines: Int?, val milliseconds: Long, val kind: Kind) : PerformanceMeasurement {
override fun render(): String = formatMeasurement("IR $kind", milliseconds, lines)
enum class Kind {
Generation, Translation
TRANSLATION, GENERATION
}
}
private fun formatMeasurement(name: String, time: Long, lines: Int?): String =
"%15s%8s ms".format(name, time) +
(lines?.let {
val lps = it.toDouble() * 1000 / time
"%12.3f loc/s".format(lps)
} ?: "")

View File

@@ -147,9 +147,14 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
ModuleChunk(listOf(module))
}
KotlinToJVMBytecodeCompiler.configureSourceRoots(configuration, moduleChunk.modules, buildFile)
val environment = createCoreEnvironment(rootDisposable, configuration, messageCollector)
?: return COMPILATION_ERROR
val chunk = moduleChunk.modules
KotlinToJVMBytecodeCompiler.configureSourceRoots(configuration, chunk, buildFile)
val environment = createCoreEnvironment(
rootDisposable, configuration, messageCollector,
chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
names.singleOrNull() ?: names.joinToString()
}
) ?: return COMPILATION_ERROR
environment.registerJavacIfNeeded(arguments).let {
if (!it) return COMPILATION_ERROR
}
@@ -161,7 +166,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
return COMPILATION_ERROR
}
KotlinToJVMBytecodeCompiler.compileModules(environment, buildFile, moduleChunk.modules)
KotlinToJVMBytecodeCompiler.compileModules(environment, buildFile, chunk)
return OK
} catch (e: CompilationException) {
messageCollector.report(
@@ -213,13 +218,17 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
private fun createCoreEnvironment(
rootDisposable: Disposable,
configuration: CompilerConfiguration,
messageCollector: MessageCollector
messageCollector: MessageCollector,
targetDescription: String
): KotlinCoreEnvironment? {
if (messageCollector.hasErrors()) return null
val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
configuration[CLIConfigurationKeys.PERF_MANAGER]?.notifyCompilerInitialized()
val sourceFiles = environment.getSourceFiles()
configuration[CLIConfigurationKeys.PERF_MANAGER]?.notifyCompilerInitialized(
sourceFiles.size, environment.countLinesOfCode(sourceFiles), targetDescription
)
return if (messageCollector.hasErrors()) null else environment
}

View File

@@ -38,7 +38,7 @@ class CliKotlinAsJavaSupport(
override fun getFacadeClassesInPackage(packageFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
return findFacadeFilesInPackage(packageFqName, scope)
.groupBy { it.javaFileFacadeFqName }
.mapNotNull { (facadeClassFqName, files) ->
.mapNotNull { (facadeClassFqName, _) ->
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope)
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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 com.intellij.codeInsight.ContainerProvider;
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
import com.intellij.core.CoreApplicationEnvironment;
import com.intellij.core.JavaCoreApplicationEnvironment;
import com.intellij.lang.MetaLanguage;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.FileContextProvider;
import com.intellij.psi.augment.PsiAugmentProvider;
import com.intellij.psi.augment.TypeAnnotationModifier;
import com.intellij.psi.compiled.ClassFileDecompilers;
import com.intellij.psi.meta.MetaDataContributor;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
// Mostly a placeholder for the functionality added to the bunch 193
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
Extensions.cleanRootArea(parentDisposable);
registerExtensionPoints();
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
}
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
super(parentDisposable, unitTestMode);
}
private static void registerExtensionPoints() {
ExtensionsArea area = Extensions.getRootArea();
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
}
@Nullable
@Override
protected VirtualFileSystem createJrtFileSystem() {
return new CoreJrtFileSystem();
}
}

View File

@@ -608,7 +608,10 @@ class KotlinCoreEnvironment private constructor(
// made public for Upsource
@JvmStatic
@Deprecated("Use registerProjectServices(project) instead.", ReplaceWith("registerProjectServices(projectEnvironment.project)"))
fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment, messageCollector: MessageCollector?) {
fun registerProjectServices(
projectEnvironment: JavaCoreProjectEnvironment,
@Suppress("UNUSED_PARAMETER") messageCollector: MessageCollector?
) {
registerProjectServices(projectEnvironment.project)
}

View File

@@ -52,12 +52,18 @@ import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.fir.FirPsiSourceElement
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
import org.jetbrains.kotlin.fir.analysis.registerExtendedCheckersComponent
import org.jetbrains.kotlin.fir.backend.Fir2IrConverter
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmClassCodegen
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmKotlinMangler
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmVisibilityConverter
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
import org.jetbrains.kotlin.fir.extensions.BunchOfRegisteredExtensions
import org.jetbrains.kotlin.fir.extensions.extensionService
@@ -71,6 +77,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveProcessor
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.ir.backend.jvm.jvmResolveLibraries
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmManglerDesc
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
import org.jetbrains.kotlin.modules.Module
@@ -82,6 +89,7 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
import org.jetbrains.kotlin.resolve.diagnostics.SimpleDiagnostics
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
@@ -192,12 +200,11 @@ object KotlinToJVMBytecodeCompiler {
val projectConfiguration = environment.configuration
if (projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
return compileModulesUsingFrontendIR(environment, buildFile, chunk)
val extendedAnalysisMode = projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS)
return compileModulesUsingFrontendIR(environment, buildFile, chunk, extendedAnalysisMode)
}
val targetDescription = "in targets [" + chunk.joinToString { input -> input.getModuleName() + "-" + input.getModuleType() } + "]"
val result = repeatAnalysisIfNeeded(analyze(environment, targetDescription), environment, targetDescription)
val result = repeatAnalysisIfNeeded(analyze(environment), environment)
if (result == null || !result.shouldGenerateCode) return false
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
@@ -302,7 +309,12 @@ object KotlinToJVMBytecodeCompiler {
configuration.addAll(JVMConfigurationKeys.MODULES, chunk)
}
private fun compileModulesUsingFrontendIR(environment: KotlinCoreEnvironment, buildFile: File?, chunk: List<Module>): Boolean {
private fun compileModulesUsingFrontendIR(
environment: KotlinCoreEnvironment,
buildFile: File?,
chunk: List<Module>,
extendedAnalysisMode: Boolean
): Boolean {
val project = environment.project
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
@@ -351,25 +363,40 @@ object KotlinToJVMBytecodeCompiler {
project, environment.createPackagePartProvider(librariesScope)
)
it.extensionService.registerExtensions(BunchOfRegisteredExtensions.empty())
if (extendedAnalysisMode) {
it.registerExtendedCheckersComponent()
}
}
val firProvider = (session.firProvider as FirProviderImpl)
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
val resolveTransformer = FirTotalResolveProcessor(session)
val collector = FirDiagnosticsCollector.create(session)
val firDiagnostics = mutableListOf<FirDiagnostic<*>>()
val firFiles = ktFiles.map {
val firFile = builder.buildFirFile(it)
firProvider.recordFile(firFile)
firFile
}.also {
}.also { firFiles ->
try {
resolveTransformer.process(it)
resolveTransformer.process(firFiles)
firFiles.forEach {
firDiagnostics += collector.collectDiagnostics(it)
}
} catch (e: Exception) {
throw e
}
}
AnalyzerWithCompilerReport.reportDiagnostics(
SimpleDiagnostics(
firDiagnostics.map { it.toRegularDiagnostic() }
),
environment.messageCollector
)
performanceManager?.notifyAnalysisFinished()
val debugTargetDescription = "target " + module.getModuleName() + "-" + module.getModuleType() + " "
val codeLines = environment.countLinesOfCode(ktFiles)
performanceManager?.notifyAnalysisFinished(ktFiles.size, codeLines, debugTargetDescription)
if (firDiagnostics.any { it.severity == Severity.ERROR }) {
return false
}
performanceManager?.notifyGenerationStarted()
val signaturer = IdSignatureDescriptor(JvmManglerDesc())
@@ -378,12 +405,12 @@ object KotlinToJVMBytecodeCompiler {
val (moduleFragment, symbolTable, sourceManager, components) =
Fir2IrConverter.createModuleFragment(
session, resolveTransformer.scopeSession, firFiles,
moduleConfiguration.languageVersionSettings, signaturer = signaturer,
generatorExtensions = JvmGeneratorExtensions(),
mangler = FirJvmKotlinMangler(session)
moduleConfiguration.languageVersionSettings, signaturer,
JvmGeneratorExtensions(), FirJvmKotlinMangler(session), IrFactoryImpl,
FirJvmVisibilityConverter
)
performanceManager?.notifyIRTranslationFinished(ktFiles.size, codeLines, debugTargetDescription)
performanceManager?.notifyIRTranslationFinished()
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
@@ -415,11 +442,6 @@ object KotlinToJVMBytecodeCompiler {
}
CodegenFactory.doCheckCancelled(generationState)
generationState.factory.done()
performanceManager?.notifyGenerationFinished(
ktFiles.size,
codeLines,
additionalDescription = debugTargetDescription
)
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
@@ -435,13 +457,37 @@ object KotlinToJVMBytecodeCompiler {
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished(ktFiles.size, codeLines, additionalDescription = debugTargetDescription)
performanceManager?.notifyIRGenerationFinished()
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
}
return writeOutputs(environment, projectConfiguration, chunk, outputs)
}
private fun FirDiagnostic<*>.toRegularDiagnostic(): Diagnostic {
val psiSource = element as FirPsiSourceElement<*>
@Suppress("TYPE_MISMATCH")
when (this) {
is FirSimpleDiagnostic ->
return SimpleDiagnostic(
psiSource.psi, factory.psiDiagnosticFactory, severity
)
is FirDiagnosticWithParameters1<*, *> ->
return DiagnosticWithParameters1(
psiSource.psi, this.a, factory.psiDiagnosticFactory, severity
)
is FirDiagnosticWithParameters2<*, *, *> ->
return DiagnosticWithParameters2(
psiSource.psi, this.a, this.b, factory.psiDiagnosticFactory, severity
)
is FirDiagnosticWithParameters3<*, *, *, *> ->
return DiagnosticWithParameters3(
psiSource.psi, this.a, this.b, this.c, factory.psiDiagnosticFactory, severity
)
}
}
private fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
if (buildFile == null) sourceFilePaths
else sourceFilePaths.map { path ->
@@ -484,11 +530,7 @@ object KotlinToJVMBytecodeCompiler {
}
}
private fun repeatAnalysisIfNeeded(
result: AnalysisResult?,
environment: KotlinCoreEnvironment,
targetDescription: String?
): AnalysisResult? {
private fun repeatAnalysisIfNeeded(result: AnalysisResult?, environment: KotlinCoreEnvironment): AnalysisResult? {
if (result is AnalysisResult.RetryWithAdditionalRoots) {
val configuration = environment.configuration
@@ -511,7 +553,7 @@ object KotlinToJVMBytecodeCompiler {
configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]?.clear()
// Repeat analysis with additional Java roots (kapt generated sources)
return analyze(environment, targetDescription)
return analyze(environment)
}
return result
@@ -519,7 +561,7 @@ object KotlinToJVMBytecodeCompiler {
@Suppress("MemberVisibilityCanBePrivate") // Used in ExecuteKotlinScriptMojo
fun analyzeAndGenerate(environment: KotlinCoreEnvironment): GenerationState? {
val result = repeatAnalysisIfNeeded(analyze(environment, null), environment, null) ?: return null
val result = repeatAnalysisIfNeeded(analyze(environment), environment) ?: return null
if (!result.shouldGenerateCode) return null
@@ -528,7 +570,7 @@ object KotlinToJVMBytecodeCompiler {
return generate(environment, environment.configuration, result, environment.getSourceFiles(), null)
}
fun analyze(environment: KotlinCoreEnvironment, targetDescription: String?): AnalysisResult? {
fun analyze(environment: KotlinCoreEnvironment): AnalysisResult? {
val sourceFiles = environment.getSourceFiles()
val collector = environment.messageCollector
@@ -561,7 +603,7 @@ object KotlinToJVMBytecodeCompiler {
)
}
performanceManager?.notifyAnalysisFinished(sourceFiles.size, environment.countLinesOfCode(sourceFiles), targetDescription)
performanceManager?.notifyAnalysisFinished()
val analysisResult = analyzerWithCompilerReport.analysisResult
@@ -642,11 +684,7 @@ object KotlinToJVMBytecodeCompiler {
KotlinCodegenFacade.compileCorrectFiles(generationState)
performanceManager?.notifyGenerationFinished(
sourceFiles.size,
environment.countLinesOfCode(sourceFiles),
additionalDescription = if (module != null) "target " + module.getModuleName() + "-" + module.getModuleType() + " " else ""
)
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()

View File

@@ -49,7 +49,7 @@ object KotlinCompilerRunnerUtils {
additionalJvmParams: Array<String> = arrayOf()
): CompileServiceSession? {
val daemonJVMOptions = configureDaemonJVMOptions(
additionalParams = *additionalJvmParams,
additionalParams = additionalJvmParams,
inheritMemoryLimits = true,
inheritOtherJvmOptions = false,
inheritAdditionalProperties = true

View File

@@ -4,7 +4,8 @@ plugins {
}
dependencies {
api(project(":core:deserialization"))
api(project(":core:metadata"))
api(project(":core:compiler.common"))
api(project(":compiler:util"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
}

View File

@@ -50,6 +50,9 @@ object CommonConfigurationKeys {
@JvmField
val DESERIALIZE_FAKE_OVERRIDES = CompilerConfigurationKey.create<Boolean>("Deserialize fake overrides")
@JvmField
val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create<Boolean>("fir extended checkers")
}
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings

View File

@@ -5,9 +5,9 @@
package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
fun LanguageVersionSettings.coroutinesPackageFqName(): FqName {
return coroutinesPackageFqName(isReleaseCoroutines())
@@ -17,9 +17,9 @@ fun LanguageVersionSettings.isReleaseCoroutines() = supportsFeature(LanguageFeat
private fun coroutinesPackageFqName(isReleaseCoroutines: Boolean): FqName {
return if (isReleaseCoroutines)
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
StandardNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
else
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
StandardNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
}
fun LanguageVersionSettings.coroutinesIntrinsicsPackageFqName() =
@@ -33,7 +33,7 @@ fun LanguageVersionSettings.restrictsSuspensionFqName() =
fun FqName.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) =
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines))
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
this == StandardNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
else
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
this == DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
this == StandardNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
this == StandardNames.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))

View File

@@ -79,6 +79,7 @@ internal class ComponentRegistry {
By mimicking the usual descriptors we get lazy evaluation and consistency checks for free.
*/
for (resolver in clashResolvers) {
@Suppress("UNCHECKED_CAST")
val clashedComponents = registrationMap[resolver.applicableTo] as? Collection<ComponentDescriptor> ?: continue
if (clashedComponents.size <= 1) continue
@@ -86,4 +87,4 @@ internal class ComponentRegistry {
registrationMap[resolver.applicableTo] = substituteDescriptor
}
}
}
}

View File

@@ -153,6 +153,7 @@ internal class ClashResolutionDescriptor<E : PlatformSpecificExtension<E>>(
override fun createInstance(context: ValueResolveContext): Any {
state = ComponentState.Initializing
@Suppress("UNCHECKED_CAST")
val extensions = computeArguments(clashedComponents) as List<E>
val resolution = resolver.resolveExtensionsClash(extensions)
state = ComponentState.Initialized

View File

@@ -1,5 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Kotlin Daemon Client New"
plugins {
@@ -49,6 +47,12 @@ dependencies {
}
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
apiVersion = "1.3"
}
}
sourceSets {
"main" { projectDefault() }
"test" {}

View File

@@ -297,13 +297,13 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
log.info("Executing daemon compilation with args: " + filteredArgs.joinToString(" "))
val servicesFacade =
CompilerCallbackServicesFacadeServerServerSide()
val serverRun = servicesFacade.runServer()
servicesFacade.runServer()
try {
val memBefore = daemon.getUsedMemory().get() / 1024
val startTime = System.nanoTime()
val compResults = createCompResults()
val compResultsServerRun = compResults.runServer()
compResults.runServer()
val res = daemon.compile(
CompileService.NO_SESSION,
filteredArgs.toList().toTypedArray(),
@@ -373,7 +373,6 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
// --- Implementation ---------------------------------------
@Synchronized
private inline fun <R> connectLoop(reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?): R? {
try {
var attempts = 1
@@ -544,6 +543,7 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
// assuming that all important output is already done, the rest should be routed to the log by the daemon itself
if (stdoutThread.isAlive) {
// TODO: find better method to stop the thread, but seems it will require asynchronous consuming of the stream
@Suppress("DEPRECATION")
stdoutThread.stop()
}
reportingTargets.out?.flush()

View File

@@ -38,6 +38,13 @@ dependencies {
}
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
// This module is being run from within Gradle, older versions of which only have kotlin-stdlib 1.3 in the runtime classpath.
apiVersion = "1.3"
}
}
sourceSets {
"main" { projectDefault() }
"test" {}

View File

@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.utils.isProcessCanceledException
import java.io.File
import java.rmi.server.UnicastRemoteObject
open class CompilerCallbackServicesFacadeServer(
val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
val lookupTracker: LookupTracker? = null,
@@ -40,7 +39,7 @@ open class CompilerCallbackServicesFacadeServer(
val incrementalResultsConsumer: IncrementalResultsConsumer? = null,
val incrementalDataProvider: IncrementalDataProvider? = null,
port: Int = SOCKET_ANY_FREE_PORT
) : CompilerCallbackServicesFacade,
) : @Suppress("DEPRECATION") CompilerCallbackServicesFacade,
UnicastRemoteObject(
port,
LoopbackNetworkInterface.clientLoopbackSocketFactory,

View File

@@ -63,7 +63,7 @@ object KotlinCompilerClient {
daemonOptions: DaemonOptions,
reportingTargets: DaemonReportingTargets,
autostart: Boolean = true,
checkId: Boolean = true
@Suppress("UNUSED_PARAMETER") checkId: Boolean = true
): CompileService? {
val flagFile = getOrCreateClientFlagFile(daemonOptions)
return connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, reportingTargets, autostart)
@@ -142,6 +142,7 @@ object KotlinCompilerClient {
compilerService.releaseCompileSession(sessionId)
}
@Suppress("DEPRECATION")
@Deprecated("Use other compile method", ReplaceWith("compile"))
fun compile(compilerService: CompileService,
sessionId: Int,
@@ -156,6 +157,7 @@ object KotlinCompilerClient {
}
@Suppress("DEPRECATION")
@Deprecated("Use non-deprecated compile method", ReplaceWith("compile"))
fun incrementalCompile(compileService: CompileService,
sessionId: Int,
@@ -277,6 +279,7 @@ object KotlinCompilerClient {
val memBefore = daemon.getUsedMemory().get() / 1024
val startTime = System.nanoTime()
@Suppress("DEPRECATION")
val res = daemon.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, filteredArgs.toList().toTypedArray(), servicesFacade, outStrm, CompileService.OutputFormat.PLAIN, outStrm, null)
val endTime = System.nanoTime()
@@ -308,8 +311,9 @@ object KotlinCompilerClient {
// --- Implementation ---------------------------------------
@Synchronized
private inline fun <R> connectLoop(reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?): R? {
private inline fun <R> connectLoop(
reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?
): R? = synchronized(this) {
try {
var attempts = 1
while (true) {

View File

@@ -43,11 +43,12 @@ class CompileServiceClientSideImpl(
} ?: false
override suspend fun clientHandshake(input: ByteReadChannelWrapper, output: ByteWriteChannelWrapper, log: Logger): Boolean {
return trySendHandshakeMessage(output, log) && tryAcquireHandshakeMessage(input, log)
return trySendHandshakeMessage(output) && tryAcquireHandshakeMessage(input)
}
override fun startKeepAlives() {
val keepAliveMessage = Server.KeepAliveMessage<CompileServiceServerSide>()
@OptIn(ObsoleteCoroutinesApi::class)
GlobalScope.async(newSingleThreadContext("keepAliveThread")) {
delay(KEEPALIVE_PERIOD * 4)
while (true) {
@@ -185,7 +186,7 @@ class CompileServiceClientSideImpl(
}
override suspend fun clearJarCache() {
val id = sendMessage(ClearJarCacheMessage())
sendMessage(ClearJarCacheMessage())
}
override suspend fun releaseReplSession(sessionId: Int): CompileService.CallResult<Nothing> {

View File

@@ -8,10 +8,8 @@ package org.jetbrains.kotlin.daemon.common.experimental
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.Client
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.DefaultClientRMIWrapper
import org.jetbrains.kotlin.daemon.common.*
import java.io.File
import java.io.Serializable
import java.rmi.NoSuchObjectException
@@ -74,6 +72,7 @@ class CompileServiceRMIWrapper(val server: CompileServiceServerSide, daemonOptio
server.scheduleShutdown(graceful)
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -85,6 +84,7 @@ class CompileServiceRMIWrapper(val server: CompileServiceServerSide, daemonOptio
operationsTracer: RemoteOperationsTracer?
) = deprecated()
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteIncrementalCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -123,6 +123,7 @@ class CompileServiceRMIWrapper(val server: CompileServiceServerSide, daemonOptio
server.clearJarCache()
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun leaseReplSession(
aliveFlagPath: String?,
targetPlatform: CompileService.TargetPlatform,

View File

@@ -5,24 +5,25 @@
package org.jetbrains.kotlin.daemon.common.experimental
import io.ktor.network.selector.ActorSelectorManager
import io.ktor.network.sockets.aSocket
import kotlinx.coroutines.*
import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.util.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.ServerSocketWrapper
import org.jetbrains.kotlin.daemon.common.*
import java.io.IOException
import java.io.Serializable
import java.net.*
import java.rmi.server.RMIClientSocketFactory
import java.rmi.server.RMIServerSocketFactory
import java.net.InetAddress
import java.net.InetSocketAddress
import java.util.*
object LoopbackNetworkInterfaceKtor {
val serverLoopbackSocketFactoryKtor by lazy { ServerLoopbackSocketFactoryKtor() }
val clientLoopbackSocketFactoryKtor by lazy { ClientLoopbackSocketFactoryKtor() }
@KtorExperimentalAPI
val selectorMgr = ActorSelectorManager(Dispatchers.IO)
class ServerLoopbackSocketFactoryKtor : Serializable {
@@ -30,6 +31,7 @@ object LoopbackNetworkInterfaceKtor {
override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class)
@OptIn(KtorExperimentalAPI::class)
fun createServerSocket(port: Int) =
aSocket(selectorMgr)
.tcp()
@@ -37,6 +39,7 @@ object LoopbackNetworkInterfaceKtor {
}
class ClientLoopbackSocketFactoryKtor : LoopbackNetworkInterface.AbstractClientLoopbackSocketFactory<io.ktor.network.sockets.Socket>() {
@OptIn(KtorExperimentalAPI::class)
override fun socketCreate(host: String, port: Int): io.ktor.network.sockets.Socket =
runBlocking { aSocket(selectorMgr).tcp().connect(InetSocketAddress(host, port)) }
}
@@ -63,4 +66,4 @@ fun findPortForSocket(attempts: Int, portRangeStart: Int, portRangeEnd: Int): Se
}
}
throw IllegalStateException("Cannot find free socketPort in $attempts attempts", lastException)
}
}

View File

@@ -1,3 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.Socket
@@ -114,6 +119,7 @@ abstract class DefaultAuthorizableClient<ServerType : ServerBase>(
return actualResult as T
}
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
override suspend fun connectToServer() {
writeActor = GlobalScope.actor(capacity = Channel.UNLIMITED) {
@@ -242,7 +248,7 @@ class DefaultClient<ServerType : ServerBase>(
serverHost: String = LoopbackNetworkInterface.loopbackInetAddressName
) : DefaultAuthorizableClient<ServerType>(serverPort, serverHost) {
override suspend fun clientHandshake(input: ByteReadChannelWrapper, output: ByteWriteChannelWrapper, log: Logger) = true
override suspend fun authorizeOnServer(output: ByteWriteChannelWrapper): Boolean = true
override suspend fun authorizeOnServer(serverOutputChannel: ByteWriteChannelWrapper): Boolean = true
override fun startKeepAlives() {}
override fun delayKeepAlives() {}
}

View File

@@ -1,3 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.ServerSocket
@@ -188,7 +193,7 @@ suspend fun <T> runWithTimeout(
): T? = withTimeoutOrNull(unit.toMillis(timeout)) { block() }
//@Throws(ConnectionResetException::class)
suspend fun tryAcquireHandshakeMessage(input: ByteReadChannelWrapper, log: Logger): Boolean {
suspend fun tryAcquireHandshakeMessage(input: ByteReadChannelWrapper): Boolean {
val bytes = runWithTimeout {
input.nextBytes()
} ?: return false
@@ -200,7 +205,7 @@ suspend fun tryAcquireHandshakeMessage(input: ByteReadChannelWrapper, log: Logge
//@Throws(ConnectionResetException::class)
suspend fun trySendHandshakeMessage(output: ByteWriteChannelWrapper, log: Logger): Boolean {
suspend fun trySendHandshakeMessage(output: ByteWriteChannelWrapper): Boolean {
runWithTimeout {
output.writeBytesAndLength(FIRST_HANDSHAKE_BYTE_TOKEN.size, FIRST_HANDSHAKE_BYTE_TOKEN)
} ?: return false

View File

@@ -1,9 +1,15 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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.daemon.common.experimental.socketInfrastructure
import io.ktor.network.sockets.Socket
import io.ktor.network.sockets.openReadChannel
import io.ktor.network.sockets.openWriteChannel
import kotlinx.coroutines.*
import io.ktor.network.sockets.*
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
@@ -45,6 +51,7 @@ class ByteReadChannelWrapper(readChannel: ByteReadChannel, private val log: Logg
}
// TODO : replace GlobalScope with something more explicit here and below.
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
private val readActor = GlobalScope.actor<ReadQuery>(capacity = Channel.UNLIMITED) {
consumeEach { message ->
if (!readChannel.isClosedForRead) {
@@ -145,6 +152,7 @@ class ByteWriteChannelWrapper(writeChannel: ByteWriteChannel, private val log: L
}
}
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
private val writeActor = GlobalScope.actor<WriteActorQuery>(capacity = Channel.UNLIMITED) {
consumeEach { message ->
if (!writeChannel.isClosedForWrite) {

View File

@@ -105,6 +105,7 @@ interface CompileService : Remote {
// TODO: consider adding async version of shutdown and release
@Suppress("DEPRECATION")
@Deprecated("The usages should be replaced with `compile` method", ReplaceWith("compile"))
@Throws(RemoteException::class)
fun remoteCompile(
@@ -118,6 +119,7 @@ interface CompileService : Remote {
operationsTracer: RemoteOperationsTracer?
): CallResult<Int>
@Suppress("DEPRECATION")
@Deprecated("The usages should be replaced with `compile` method", ReplaceWith("compile"))
@Throws(RemoteException::class)
fun remoteIncrementalCompile(
@@ -149,6 +151,7 @@ interface CompileService : Remote {
@Throws(RemoteException::class)
fun clearJarCache()
@Suppress("DEPRECATION")
@Deprecated("The usages should be replaced with other `leaseReplSession` method", ReplaceWith("leaseReplSession"))
@Throws(RemoteException::class)
fun leaseReplSession(

View File

@@ -23,6 +23,7 @@ class CompileServiceClientRMIWrapper(
private fun reportNotImplemented(): Nothing = throw IllegalStateException("Unexpected call to deprecated method")
// deprecated methods :
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -36,6 +37,7 @@ class CompileServiceClientRMIWrapper(
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteIncrementalCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -49,6 +51,7 @@ class CompileServiceClientRMIWrapper(
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun leaseReplSession(
aliveFlagPath: String?,
targetPlatform: CompileService.TargetPlatform,
@@ -66,10 +69,12 @@ class CompileServiceClientRMIWrapper(
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineCheck(sessionId: Int, codeLine: ReplCodeLine): CompileService.CallResult<ReplCheckResult> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineCompile(
sessionId: Int,
codeLine: ReplCodeLine,
@@ -78,6 +83,7 @@ class CompileServiceClientRMIWrapper(
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineEval(
sessionId: Int,
codeLine: ReplCodeLine,

View File

@@ -329,7 +329,7 @@ fun configureDaemonJVMOptions(vararg additionalParams: String,
inheritAdditionalProperties: Boolean
): DaemonJVMOptions =
configureDaemonJVMOptions(DaemonJVMOptions(),
additionalParams = *additionalParams,
additionalParams = additionalParams,
inheritMemoryLimits = inheritMemoryLimits,
inheritOtherJvmOptions = inheritOtherJvmOptions,
inheritAdditionalProperties = inheritAdditionalProperties)

View File

@@ -16,4 +16,5 @@
package org.jetbrains.kotlin.daemon.common
interface JpsCompilerServicesFacade : CompilerServicesFacadeBase, CompilerCallbackServicesFacade
@Suppress("DEPRECATION")
interface JpsCompilerServicesFacade : CompilerServicesFacadeBase, CompilerCallbackServicesFacade

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("NOTHING_TO_INLINE")
package org.jetbrains.kotlin.daemon.common
import java.lang.management.ManagementFactory
@@ -101,7 +103,7 @@ inline fun endMeasureWallTime(perfCounters: PerfCounters, startState: List<Long>
}
inline fun beginMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean: ThreadMXBean): List<Long> {
inline fun beginMeasureWallAndThreadTimes(threadMXBean: ThreadMXBean): List<Long> {
val startTime = System.nanoTime()
val startThreadTime = threadMXBean.threadCpuTime()
val startThreadUserTime = threadMXBean.threadUserTime()
@@ -117,12 +119,7 @@ inline fun endMeasureWallAndThreadTimes(perfCounters: PerfCounters, threadMXBean
threadUser = threadMXBean.threadUserTime() - startThreadUserTime)
}
inline fun beginMeasureWallAndThreadTimes(perfCounters: PerfCounters) =
beginMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean())
inline fun endMeasureWallAndThreadTimes(perfCounters: PerfCounters, startState: List<Long>) =
endMeasureWallAndThreadTimes(perfCounters, ManagementFactory.getThreadMXBean(), startState)
inline fun beginMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean = false, threadMXBean: ThreadMXBean): List<Long> {
inline fun beginMeasureWallAndThreadTimesAndMemory(withGC: Boolean = false, threadMXBean: ThreadMXBean): List<Long> {
val startMem = usedMemory(withGC)
val startTime = System.nanoTime()
val startThreadTime = threadMXBean.threadCpuTime()
@@ -141,13 +138,6 @@ inline fun endMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, wit
memory = usedMemory(withGC) - startMem)
}
inline fun<R> beginMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean) =
beginMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean())
inline fun<R> endMeasureWallAndThreadTimesAndMemory(perfCounters: PerfCounters, withGC: Boolean, startState: List<Long>) =
endMeasureWallAndThreadTimesAndMemory(perfCounters, withGC, ManagementFactory.getThreadMXBean(), startState)
class DummyProfiler : Profiler {
override fun getCounters(): Map<Any?, PerfCounters> = mapOf(null to SimplePerfCounters())
override fun getTotalCounters(): PerfCounters = SimplePerfCounters()
@@ -174,7 +164,7 @@ class WallTotalProfiler : TotalProfiler() {
class WallAndThreadTotalProfiler : TotalProfiler() {
@Suppress("OVERRIDE_BY_INLINE")
override inline fun beginMeasure(obj: Any?) = beginMeasureWallAndThreadTimes(total, threadMXBean)
override inline fun beginMeasure(obj: Any?) = beginMeasureWallAndThreadTimes(threadMXBean)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun endMeasure(obj: Any?, startState: List<Long>) = endMeasureWallAndThreadTimes(total, threadMXBean, startState)
}
@@ -183,7 +173,7 @@ class WallAndThreadTotalProfiler : TotalProfiler() {
class WallAndThreadAndMemoryTotalProfiler(val withGC: Boolean) : TotalProfiler() {
@Suppress("OVERRIDE_BY_INLINE")
override inline fun beginMeasure(obj: Any?) =
beginMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean)
beginMeasureWallAndThreadTimesAndMemory(withGC, threadMXBean)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun endMeasure(obj: Any?, startState: List<Long>) =
endMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean, startState)
@@ -198,7 +188,7 @@ class WallAndThreadByClassProfiler() : TotalProfiler() {
@Suppress("OVERRIDE_BY_INLINE")
override inline fun beginMeasure(obj: Any?) =
beginMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean)
beginMeasureWallAndThreadTimes(threadMXBean)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun endMeasure(obj: Any?, startState: List<Long>) =
endMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean, startState)

View File

@@ -170,7 +170,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val opts2 = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
assertEquals( -1, DaemonJVMOptionsMemoryComparator().compare(opts, opts2))
assertEquals("300m", listOf(opts, opts2).maxWith(DaemonJVMOptionsMemoryComparator())?.maxMemory)
assertEquals("300m", listOf(opts, opts2).maxWithOrNull(DaemonJVMOptionsMemoryComparator())?.maxMemory)
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)

View File

@@ -244,7 +244,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
assertEquals(-1, DaemonJVMOptionsMemoryComparator().compare(opts, opts2))
assertEquals("300m", listOf(opts, opts2).maxWith(DaemonJVMOptionsMemoryComparator())?.maxMemory)
assertEquals("300m", listOf(opts, opts2).maxWithOrNull(DaemonJVMOptionsMemoryComparator())?.maxMemory)
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.daemon.experimental.unit
import io.ktor.network.sockets.aSocket
import io.ktor.util.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
@@ -24,6 +25,7 @@ import java.io.ObjectOutputStream
import java.net.InetSocketAddress
import java.util.logging.Logger
@OptIn(KtorExperimentalAPI::class)
class TestServer(val serverPort: Int = 6999) {
private val serverSocket = aSocket(selectorMgr).tcp().bind(InetSocketAddress(serverPort))
private val log = Logger.getLogger("TestServer")

View File

@@ -229,7 +229,7 @@ class ConnectionsTest : KotlinIntegrationTestBase() {
private fun expectNewDaemon(serverType: ServerType, extraAction: (CompileServiceAsync) -> Unit = {}) = expectDaemon(
getDaemons = ::getNewDaemonsOrAsyncWrappers,
chooseDaemon = { daemons -> daemons.maxWith(comparator)!!.daemon },
chooseDaemon = { daemons -> daemons.maxWithOrNull(comparator)!!.daemon },
getInfo = { d -> runBlocking { d.getDaemonInfo() } },
registerClient = { d -> runBlocking { d.registerClient(generateClient()) } },
port = { d -> d.serverPort },

View File

@@ -309,6 +309,7 @@ abstract class CompileServiceImplBase(
CompileService.CallResult.Good(ExitCode.COMPILATION_ERROR.code)
} else when (compilationOptions.compilerMode) {
CompilerMode.JPS_COMPILER -> {
@Suppress("UNCHECKED_CAST")
servicesFacade as JpsServicesFacadeT
withIC(enabled = servicesFacade.hasIncrementalCaches()) {
doCompile(sessionId, daemonReporter, tracer = null) { eventManger, profiler ->
@@ -609,6 +610,7 @@ abstract class CompileServiceImplBase(
body: KotlinJvmReplServiceT.() -> CompileService.CallResult<R>
): CompileService.CallResult<R> =
withValidClientOrSessionProxy(sessionId) { session ->
@Suppress("UNCHECKED_CAST")
(session?.data as? KotlinJvmReplServiceT?)?.body() ?: CompileService.CallResult.Error("Not a REPL session $sessionId")
}
@@ -703,6 +705,7 @@ class CompileServiceImpl(
CompileService.CallResult.Good(res)
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -728,6 +731,7 @@ class CompileServiceImpl(
}
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun remoteIncrementalCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -784,7 +788,7 @@ class CompileServiceImpl(
override fun leaseReplSession(
aliveFlagPath: String?,
targetPlatform: CompileService.TargetPlatform,
servicesFacade: CompilerCallbackServicesFacade,
@Suppress("DEPRECATION") servicesFacade: CompilerCallbackServicesFacade,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<out Any?>?,
@@ -819,15 +823,17 @@ class CompileServiceImpl(
// TODO: add more checks (e.g. is it a repl session)
override fun releaseReplSession(sessionId: Int): CompileService.CallResult<Nothing> = releaseCompileSession(sessionId)
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineCheck(sessionId: Int, codeLine: ReplCodeLine): CompileService.CallResult<ReplCheckResult> =
ifAlive(minAliveness = Aliveness.Alive) {
withValidRepl(sessionId) {
@Suppress("DEPRECATION")
CompileService.CallResult.Good(check(codeLine))
}
}
private fun createCompileServices(
facade: CompilerCallbackServicesFacade,
@Suppress("DEPRECATION") facade: CompilerCallbackServicesFacade,
eventManager: EventManager,
rpcProfiler: Profiler
): Services {
@@ -835,7 +841,7 @@ class CompileServiceImpl(
if (facade.hasIncrementalCaches()) {
builder.register(
IncrementalCompilationComponents::class.java,
RemoteIncrementalCompilationComponentsClient(facade, eventManager, rpcProfiler)
RemoteIncrementalCompilationComponentsClient(facade, rpcProfiler)
)
}
if (facade.hasLookupTracker()) {
@@ -857,6 +863,7 @@ class CompileServiceImpl(
return builder.build()
}
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineCompile(
sessionId: Int,
codeLine: ReplCodeLine,
@@ -864,10 +871,12 @@ class CompileServiceImpl(
): CompileService.CallResult<ReplCompileResult> =
ifAlive(minAliveness = Aliveness.Alive) {
withValidRepl(sessionId) {
@Suppress("DEPRECATION")
CompileService.CallResult.Good(compile(codeLine, history))
}
}
@Suppress("OverridingDeprecatedMember")
override fun remoteReplLineEval(
sessionId: Int,
codeLine: ReplCodeLine,
@@ -997,7 +1006,7 @@ class CompileServiceImpl(
val comparator =
compareByDescending<DaemonWithMetadata, DaemonJVMOptions>(DaemonJVMOptionsMemoryComparator(), { it.jvmOptions })
.thenBy(FileAgeComparator()) { it.runFile }
aliveWithOpts.maxWith(comparator)?.let { bestDaemonWithMetadata ->
aliveWithOpts.maxWithOrNull(comparator)?.let { bestDaemonWithMetadata ->
val fattestOpts = bestDaemonWithMetadata.jvmOptions
if (fattestOpts memorywiseFitsInto daemonJVMOptions && FileAgeComparator().compare(
bestDaemonWithMetadata.runFile,

View File

@@ -126,7 +126,7 @@ open class KotlinJvmReplService(
templateClasspath: List<File>,
templateClassName: String,
messageCollector: MessageCollector,
@Deprecated("drop it")
// TODO: drop it
protected val operationsTracer: RemoteOperationsTracer?
) : KotlinJvmReplServiceBase(disposable, compilerId, templateClasspath, templateClassName, messageCollector) {
@@ -142,9 +142,11 @@ open class KotlinJvmReplService(
@Deprecated("remove after removal state-less check/compile/eval methods")
protected val defaultStateFacade: RemoteReplStateFacadeServer by lazy { createRemoteState() }
@Suppress("DEPRECATION")
@Deprecated("Use check(state, line) instead")
fun check(codeLine: ReplCodeLine): ReplCheckResult = check(defaultStateFacade.state, codeLine)
@Suppress("DEPRECATION", "UNUSED_PARAMETER")
@Deprecated("Use compile(state, line) instead")
fun compile(codeLine: ReplCodeLine, verifyHistory: List<ReplCodeLine>?): ReplCompileResult = compile(defaultStateFacade.state, codeLine)

View File

@@ -17,14 +17,17 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
import org.jetbrains.kotlin.progress.CompilationCanceledException
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
import java.util.concurrent.TimeUnit
import java.util.logging.Logger
val CANCELED_STATUS_CHECK_THRESHOLD_NS = TimeUnit.MILLISECONDS.toNanos(100)
class RemoteCompilationCanceledStatusClient(val facade: CompilerCallbackServicesFacade, val profiler: Profiler = DummyProfiler()): CompilationCanceledStatus {
class RemoteCompilationCanceledStatusClient(
@Suppress("DEPRECATION") val facade: CompilerCallbackServicesFacade,
val profiler: Profiler = DummyProfiler()
): CompilationCanceledStatus {
private val log by lazy { Logger.getLogger("compiler") }

View File

@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
@@ -13,7 +12,7 @@ import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import java.io.File
class RemoteExpectActualTracker(
val facade: CompilerCallbackServicesFacade,
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
val profiler: Profiler = DummyProfiler()
): ExpectActualTracker {
override fun report(expectedFile: File, actualFile: File) {

View File

@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
@@ -24,8 +23,11 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
import org.jetbrains.kotlin.modules.TargetId
class RemoteIncrementalCacheClient(val facade: CompilerCallbackServicesFacade, val target: TargetId, val profiler: Profiler = DummyProfiler()): IncrementalCache {
class RemoteIncrementalCacheClient(
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
val target: TargetId,
val profiler: Profiler = DummyProfiler()
): IncrementalCache {
override fun getObsoletePackageParts(): Collection<String> = profiler.withMeasure(this) { facade.incrementalCache_getObsoletePackageParts(target) }
override fun getObsoleteMultifileClasses(): Collection<String> = profiler.withMeasure(this) { facade.incrementalCache_getObsoleteMultifileClassFacades(target) }

View File

@@ -16,13 +16,15 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
class RemoteIncrementalCompilationComponentsClient(val facade: CompilerCallbackServicesFacade, eventManager: EventManager, val profiler: Profiler = DummyProfiler()) : IncrementalCompilationComponents {
class RemoteIncrementalCompilationComponentsClient(
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
val profiler: Profiler = DummyProfiler()
) : IncrementalCompilationComponents {
override fun getIncrementalCache(target: TargetId): IncrementalCache = RemoteIncrementalCacheClient(facade, target, profiler)
}

View File

@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
@@ -13,8 +12,10 @@ import org.jetbrains.kotlin.incremental.js.IrTranslationResultValue
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
import java.io.File
class RemoteIncrementalDataProvider(val facade: CompilerCallbackServicesFacade, val rpcProfiler: Profiler) :
IncrementalDataProvider {
class RemoteIncrementalDataProvider(
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
val rpcProfiler: Profiler
) : IncrementalDataProvider {
override val serializedIrFiles: Map<File, IrTranslationResultValue>
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.

View File

@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
import org.jetbrains.kotlin.incremental.js.FunctionWithSourceInfo
@@ -13,8 +12,11 @@ import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
import org.jetbrains.kotlin.incremental.js.JsInlineFunctionHash
import java.io.File
class RemoteIncrementalResultsConsumer(val facade: CompilerCallbackServicesFacade, eventManager: EventManager, val rpcProfiler: Profiler) :
IncrementalResultsConsumer {
class RemoteIncrementalResultsConsumer(
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
eventManager: EventManager,
val rpcProfiler: Profiler
) : IncrementalResultsConsumer {
override fun processIrFile(
sourceFile: File,
fileData: ByteArray,

View File

@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.daemon
import com.intellij.util.containers.StringInterner
import gnu.trove.THashMap
import gnu.trove.THashSet
import org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
@@ -28,9 +27,8 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.components.Position
import org.jetbrains.kotlin.incremental.components.ScopeKind
class RemoteLookupTrackerClient(
val facade: CompilerCallbackServicesFacade,
@Suppress("DEPRECATION") val facade: org.jetbrains.kotlin.daemon.common.CompilerCallbackServicesFacade,
eventManager: EventManager,
val profiler: Profiler = DummyProfiler()
) : LookupTracker {

View File

@@ -10,15 +10,13 @@ package org.jetbrains.kotlin.daemon.experimental
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
import io.ktor.network.sockets.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import org.jetbrains.kotlin.cli.common.repl.ReplCompileResult
@@ -29,7 +27,10 @@ import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.daemon.CompileServiceImplBase
import org.jetbrains.kotlin.daemon.CompilerSelector
import org.jetbrains.kotlin.daemon.EventManager
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.daemon.common.experimental.*
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.*
import org.jetbrains.kotlin.daemon.experimental.CompileServiceTaskScheduler.*
import org.jetbrains.kotlin.daemon.nowSeconds
import org.jetbrains.kotlin.daemon.report.experimental.CompileServicesFacadeMessageCollector
@@ -45,12 +46,6 @@ import java.util.concurrent.TimeUnit
import java.util.logging.Level
import java.util.logging.Logger
import kotlin.concurrent.schedule
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.*
import org.jetbrains.kotlin.daemon.common.experimental.*
import io.ktor.network.sockets.*
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.daemon.EventManager
import org.jetbrains.kotlin.daemon.report.DaemonMessageReporter
// TODO: this classes should replace their non-experimental versions eventually.
@@ -79,6 +74,7 @@ private class CompileServiceTaskScheduler(log: Logger) {
fun isShutdownActionInProgress() = shutdownActionInProgress
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
private val queriesActor = GlobalScope.actor<CompileServiceTask>(capacity = Channel.UNLIMITED) {
var currentTaskId = 0
var shutdownTask: ExclusiveTask? = null
@@ -179,10 +175,10 @@ class CompileServiceServerSideImpl(
} ?: false
override suspend fun serverHandshake(input: ByteReadChannelWrapper, output: ByteWriteChannelWrapper, log: Logger): Boolean {
return tryAcquireHandshakeMessage(input, log) && trySendHandshakeMessage(output, log)
return tryAcquireHandshakeMessage(input) && trySendHandshakeMessage(output)
}
private lateinit var scheduler: CompileServiceTaskScheduler
private var scheduler: CompileServiceTaskScheduler
constructor(
serverSocket: ServerSocketWrapper,
@@ -500,7 +496,7 @@ class CompileServiceServerSideImpl(
}
.thenBy(FileAgeComparator()) { it.runFile }
.thenBy { it.daemon.serverPort }
aliveWithOpts.maxWith(comparator)?.let { bestDaemonWithMetadata ->
aliveWithOpts.maxWithOrNull(comparator)?.let { bestDaemonWithMetadata ->
val fattestOpts = bestDaemonWithMetadata.jvmOptions
if (fattestOpts memorywiseFitsInto daemonJVMOptions && FileAgeComparator().compare(
bestDaemonWithMetadata.runFile,
@@ -655,7 +651,7 @@ class CompileServiceServerSideImpl(
if (facade.hasIncrementalCaches()) {
builder.register(
IncrementalCompilationComponents::class.java,
RemoteIncrementalCompilationComponentsClient(facade, eventManager, rpcProfiler)
RemoteIncrementalCompilationComponentsClient(facade, rpcProfiler)
)
}
if (facade.hasLookupTracker()) {

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