Compare commits

...

812 Commits

Author SHA1 Message Date
Margarita Bobova
282fd2cf8a Move 1.4.x changelog to a separate file 2021-06-22 20:58:02 +07:00
Margarita Bobova
d2a196c599 Add changelog for 1.5.20 2021-06-22 20:57:56 +07:00
Yahor Berdnikau
4ac3753feb Restore removed 'kotlinPluginVersion' property.
And marked it as '@Deprecated'.

^KT-47317 Fixed
2021-06-21 15:35:18 +00:00
Victor Petukhov
eec6efbdbf Use proper applicability for constraint warnings
^KT-47316 Fixed
2021-06-21 14:04:14 +00:00
Marina Shishkina
dc8fa061bf rrr/1.5.20-release/ayalyshev/change-notes
Update links in the plugin description

Update UTM for the kotlinlang link

Add change notes for 1.5.20


Co-authored-by: Anton Yalyshev <Anton.Yalyshev@jetbrains.com>
2021-06-21 11:37:50 +00:00
Yaroslav Chernyshev
2ffcc16663 Add regression test for MPP android source set with resources 2021-06-18 15:08:24 +00:00
Yaroslav Chernyshev
679e768464 Fix adding non-directory to resources for Android source set
#KTIJ-17113 Fixed
2021-06-18 15:08:23 +00:00
Stanislav Erokhin
6b8cae27ef Add workaround for compiler downloader for 1.5.20 release binaries
Because of migration K/N to kotlin repo we still have some problems
with version transformation.
Right now, when in 1.5.20-release branch we have build number
(and DeployVersion) something like 1.5.20-256 K/N mechanic interprets it
as Release version and almost all artifacts have names just 1.5.20.
For example: kotlin-native-prebuilt-linux-1.5.20.tar.gz
But they are stored in the separate folder releases/1.5.20-256
and I use this in this commit.

For release version the build number should be -1, because the version
should be just 1.5.20 but we should check it or even revert the commit
2021-06-15 11:57:50 +00:00
Yahor Berdnikau
7d180b8bd7 Treat toolchain as input only for JVM tasks.
Kotlin compiler for non-JVM tasks does not care about current JDK
version and should always produce same output disregard on
which JDK it is running on.

^KT-45611 In Progress
2021-06-11 08:33:32 +00:00
Yahor Berdnikau
a5e1ec9682 Revert "Warn on using 'jdkHome' option in Gradle builds."
This reverts commit 588ba10a13.

^KT-45611 In Progress
2021-06-11 08:33:31 +00:00
Margarita Bobova
2fbb0015a7 Add changelog for 1.5.20-RC 2021-06-10 11:52:29 +03:00
Margarita Bobova
bbf25464a5 Add changelog for 1.5.20-M1 2021-06-10 11:52:24 +03:00
Vladimir Dolzhenko
821233bfa1 Optimize SdkInfo lookup for a huge monorepo with no SdkInfo
DFS of SdkInfo on moduleInfo and reuse cached libraryInfo dependencies
fix traverse order

#KT-47065 Fixed
Relates to #KT-46622

(cherry picked from commit de76aeb9d1)
2021-06-09 13:11:57 +00:00
Abduqodiri Qurbonzoda
4bdfbbd61b Get rid of platform differences in Regex.split() doc
(cherry picked from commit fdd9287836)
2021-06-08 13:12:24 +00:00
Abduqodiri Qurbonzoda
88490b0baf Get rid of platform differences in Regex.findAll() doc
(cherry picked from commit 0b521b5183)
2021-06-08 13:12:23 +00:00
Abduqodiri Qurbonzoda
02a160ad93 Get rid of platform differences in Grouping<T, K>.eachCount() doc
(cherry picked from commit 53b6c25533)
2021-06-08 13:12:22 +00:00
Abduqodiri Qurbonzoda
4fec97230d Get rid of platform differences in Array.orEmpty() doc
(cherry picked from commit 91d1baf3b5)
2021-06-08 13:12:21 +00:00
Abduqodiri Qurbonzoda
ee02d89392 Get rid of platform differences in Collection<T>.toTypedArray() doc
(cherry picked from commit cc3c33b8ae)
2021-06-08 13:12:20 +00:00
Abduqodiri Qurbonzoda
f75bf9543a Get rid of platform differences in MutableList.sortWith() doc
(cherry picked from commit c64592665b)
2021-06-08 13:12:19 +00:00
Abduqodiri Qurbonzoda
a02d5d7cf3 Get rid of platform differences in MutableList.sort() doc
(cherry picked from commit a9946b01e6)
2021-06-08 13:12:19 +00:00
Abduqodiri Qurbonzoda
87402aff6f Get rid of platform differences in Regex.find doc
(cherry picked from commit 225be54c61)
2021-06-08 13:12:18 +00:00
Abduqodiri Qurbonzoda
ada38f2739 Add default value for K/N actual functions #KT-46183
(cherry picked from commit 7fdd1154ee)
2021-06-08 13:12:17 +00:00
Ilya Goncharov
4c3e9227d1 [Gradle, JS] Actualize versions of source-map-loader because of bug
https://github.com/webpack-contrib/source-map-loader/issues/147

^KT-46608 fixed
2021-06-08 12:09:42 +00:00
Yahor Berdnikau
fb3eacbb68 Fix failing test.
Set minimal required by AGP Gradle version.
2021-06-03 12:06:52 +00:00
Svyatoslav Scherbina
a83f92c860 [Native] Clean up nested comment when exporting kdoc to objc header (#4410)
Co-authored-by: Vladimir Ivanov <vladimir.d.ivanov@jetbrains.com>
2021-06-02 14:48:39 +00:00
Pavel Punegov
6c71220cd6 Fix native version generator in case of empty build.number 2021-06-02 13:14:55 +00:00
Pavel Punegov
5290734ac4 [native] a special case for the build.number
This is release build without a build number in the end.
2021-06-02 13:14:54 +00:00
Mikhael Bogdanov
7f4d208bb7 Support class type parameters annotation checking
(cherry picked from commit b72aa76415)
2021-06-02 08:17:40 +00:00
Mikhael Bogdanov
36a4661474 Support annotations on class type parameters
#KT-43714

(cherry picked from commit a8186d19d6)
2021-06-02 08:17:40 +00:00
Sergey Bogolepov
3548feb218 Deprecate Architecture.bitness property
There is no such thing as "bitness" of CPU achitecture.
Something more appropriate and correct (e.g. ABI) should be
introduced instead.

(cherry picked from commit b541721a79)
2021-06-01 07:19:48 +00:00
Sergey Bogolepov
6ce8b019ac Revert "Drop useless bitness property from Architecture"
As it turn outs, `Architecture.bitness` leaks to public Gradle API and
we need to deprecate it gracefully.
This reverts commit 79bf2a1f.

(cherry picked from commit bed42e9ab2)
2021-06-01 07:19:48 +00:00
Abduqodiri Qurbonzoda
5a4cebadd6 Equivalize isLowerCase and isUpperCase behavior in all platforms #KT-46184
(cherry picked from commit d934c97bf5)
2021-05-31 16:06:43 +00:00
Abduqodiri Qurbonzoda
9141dc124d Support all digit chars on JS and Native #KT-46002
(cherry picked from commit 54994a289f)
2021-05-31 16:06:42 +00:00
Alexander Likhachev
6622fe1014 [Gradle, JS] Add test for KT-47045
(cherry picked from commit 94a94a557d)
2021-05-31 13:31:39 +00:00
Alexander Likhachev
64a3feadc5 [Gradle, JS] Prevent adding unintended implicit dependencies
The way JS compilations are mapped to task requirements were changed from `compilation` objects to compilations's `disambiguatedName` in order to support Gradle configuration cache. This may lead to implicitly adding unwanted dependencies in multi-module projects since compilation's `disambiguatedName` is unique within a module, not within a whole multi-module project.
#KT-47045 Fixed

(cherry picked from commit 89f8c5a651)
2021-05-31 13:31:39 +00:00
Anton Lakotka
353227fd0a Set kotlin-project-model as api dependency for kotlin-gradle-plugin-api
LanguageSettingsBuilder depends on LanguageSetting interface from KPM
which forces api dependency scope

^KT-46517 Fixed
^KT-46975 Fixed

(cherry picked from commit 8481f4a9d2)
2021-05-31 13:29:46 +00:00
Alexander Udalov
3a6a8f9e71 IR: get overridden directly from IrProperty when resolving fake override
The previous way of getting them either via getter or setter failed on
Java properties which only have a backing field. Now that IrProperty has
overriddenSymbols (after 53c1de172f), it makes sense to use it directly
instead. Use it only in SyntheticAccessorLowering though to avoid
breaking Kotlin/Native (see KT-47019).

 #KT-46900 Fixed

(cherry picked from commit 96f0b53761)
2021-05-31 09:52:47 +00:00
pyos
1d4b6f1867 JVM_IR: use correct dispatch receiver type in more references
#KT-46902 Fixed

(cherry picked from commit d37ceb47be)
2021-05-29 07:12:16 +00:00
pyos
b02cca6829 JVM: be more careful when removing unused constants
1. if an argument of a `pop` cannot be removed, then all other potential
   arguments of that `pop` can't be removed either, and the same applies
   to other `pop`s that touch them;
2. the same is true for primitive conversions, but this is even trickier
   to implement correctly, so I simply did the same thing as with
   boxing operators: replace the conversion itself with a `pop` and keep
   the argument as-is.

Somehow this actually removes *more* redundant primitive type conversions
than the old code in a couple bytecode text tests, so I've patched them
to kind of use the value, forcing the instructions to stay.

 #KT-46921 Fixed

(cherry picked from commit 34878d17eb)
2021-05-28 14:04:28 +00:00
pyos
c4ec9d75ab JVM: remove CHECKCAST handling from PopBackwardPropagationTransformer
Redundant CHECKCASTs should've been removed by a previous pass.

(cherry picked from commit 2f60ce21a0)
2021-05-28 14:04:27 +00:00
pyos
8afc0534b8 JVM: do not remove NOPs in PopBackwardPropagationTransformer
There is a pass that removes NOPs and runs afterwards anyway.

(cherry picked from commit 535934dc28)
2021-05-28 14:04:26 +00:00
Ilya Goncharov
cec51899eb [Gradle, JS] Add test with dynamic webpack.config.d 2021-05-28 10:51:10 +00:00
Ilya Goncharov
11c4f86f1b [Gradle, JS] In KotlinWebpack configDirectory as getter not lazy
It is useful to dynamically creating config directory during build execution

^KT-46976 fixed

(cherry picked from commit f2a067eda0)
2021-05-28 10:51:09 +00:00
Marina Shishkina
4ad02b7c1e [K/N][IR] Temporary fix for super types variance
#KT-46837 Fixed


Co-authored-by: Igor Chevdar <Igor.Chevdar@jetbrains.com>
2021-05-27 12:52:09 +00:00
Konstantin Tskhovrebov
961b9e62dd Change assemble AppleFrameworkTask name to using framework name prefix
#KT-46892
2021-05-26 15:37:30 +00:00
Ilya Goncharov
5a3fa8f6b2 [IR] Not try Null constant in fold constant
^KT-46859 fixed
2021-05-26 10:06:03 +00:00
Dmitry Petrov
6d3669613f JVM_IR KT-46822 don't generate too deep StringBuilder.append trees
(cherry picked from commit 261b42f5c5)
2021-05-26 09:09:33 +00:00
Ivan Gavrilovic
ba6177afed KT-46820: Kotlin gradle plugin - prevent multiple threads from registering task
... as that is not supported by the underlying mechanism.
Build service that holds info about the incremnetal compilation
may be instantiated only during execution, and multiple tasks may
try to do that. Because the container which holds info about all
build services is not thread-safe, this change adds synchronization.

Fixes #KT-46820
2021-05-26 08:03:21 +00:00
Alexander Udalov
77b37d122e Psi2ir: do not load abbreviated types with not found classifier
This is not an ideal fix of the problem since the fact that
AbbreviatedType's classifier should be a TypeAliasDescriptor is a
reasonable assumption that might fail somewhere else, later in the
pipeline.

Previous attempts to fix this issue that were unsuccessful:

1) Do not load abbreviations for such types in deserialization at all.
   Unfortunately, it broke quite a few things like reflection and
   decompiler, where types frequently refer to symbols not reachable
   from the point where they're requested, yet we have the FQ name of
   the typealias, which is enough to render the abbreviation properly in
   both these use cases.

2) Load classifiers for unresolved abbreviations as
   MockTypeAliasDescriptor instead of MockClassDescriptor in
   NotFoundClasses. Technically this was a revert of
   e19c1b5364. But this failed because we
   don't have enough information about such typealias to correctly set
   its `expandedType`/`underlyingType` (just using nullable Any as
   before that commit is not good enough). We only know its underlying
   class (from one usage of such typealias), and even supporting that
   would involve a major refactoring of TypeDeserializer which is
   painful.

 #KT-45308 Fixed

(cherry picked from commit 6ca7b39f6a)
2021-05-25 10:47:32 +00:00
Andrey Uskov
e0610b825f Implemented collecting use-old-backend flag from Gradle
#KT-46689 Fixed

(cherry picked from commit 41dd6250d4)
2021-05-23 23:58:47 +03:00
Dmitriy Dolovov
bfb5d28dfb [Native] Support suspend functions as supertypes (remove debug code)
^KT-46777
2021-05-21 17:36:56 +00:00
Steven Schäfer
a18edd23ca JVM IR: Do not unbox Results in suspend lambda invoke methods (KT-46813) 2021-05-21 15:05:05 +00:00
pyos
2e6d729987 JVM: expect a continuation parameter in default suspend references
(cherry picked from commit 21f2b3fa2b)
2021-05-21 10:43:28 +00:00
pyos
a357cf51bd Add tests for default inline suspend lambdas
Broken on JVM and JVM_IR

(cherry picked from commit 7eedcf75f9)
2021-05-21 10:43:27 +00:00
pyos
7b8ac963d7 JVM_IR: try to load mangled invoke from default lambdas
Old compiler versions still won't be able to load default lambdas
generated by JVM_IR, but this way we avoid incorrect behavior of
function references taking inline class types that unbox to Any.

 #KT-46601 Fixed

(cherry picked from commit 57c934987c)
2021-05-21 10:43:26 +00:00
pyos
20d5b85a4f Add a test for KT-46601
(cherry picked from commit 34ac232a82)
2021-05-21 10:43:26 +00:00
pyos
3ac9820929 JVM: move descriptors from DefaultLambda to PsiDefaultLambda
Also, produce more correct results in IrDefaultLambda's
`invokeMethodParameters` and `invokeMethodReturnType`. This affects
whether the inliner inserts inline class boxings/unboxings around lambda
calls; while this doesn't matter now due to KT-46601, it would if the
naming was fixed.

(cherry picked from commit c32ccbb39a)
2021-05-21 10:43:25 +00:00
pyos
8a81862155 JVM: move PSI-based LambdaInfo to PsiInlineCodegen
(cherry picked from commit 7c168d663a)
2021-05-21 10:43:24 +00:00
pyos
1743c9a0db JVM: rearrange some LambdaInfo stuff
(cherry picked from commit 493b4e6c27)
2021-05-21 10:43:23 +00:00
pyos
64b393a7b6 JVM: expect consistent signatures from LambdaInfo
(cherry picked from commit 14e1417ea8)
2021-05-21 10:43:23 +00:00
Steven Schäfer
69dc5311fd JVM IR: Avoid double mangling of function reference invoke methods
(cherry picked from commit 84d78035e4)
2021-05-21 10:43:22 +00:00
Sergey Bogolepov
6639204df4 Support explicit C++ flags in run_konan tool
(cherry picked from commit f3a935adb9)
2021-05-20 14:10:26 +00:00
Sergey Bogolepov
a0c2d56929 Remove obsolete Gradle native plugin configuration
(cherry picked from commit 25ebb3fa75)
2021-05-20 14:10:26 +00:00
Sergey Bogolepov
c1e21db714 [Kotlin/Native] Add a workaround for Xcode 12.5
SDKs from Xcode 12.5 contain C++ stdlib and it
breaks compilation of C++ parts of compiler.
Mitigate this problem by explicitly specifying
path to C++ stdlib.

(cherry picked from commit 274d18a141)
2021-05-20 14:10:25 +00:00
pyos
8af88bd595 JVM_IR: support @JvmStatic transformations in LateinitLowering
#KT-46759 Fixed

(cherry picked from commit b2ef854aa1)
2021-05-19 16:57:37 +00:00
pyos
16af6986bc JVM_IR: do not evaluate receiver of static calls if it is pure
#KT-46802 Fixed

(cherry picked from commit f1f13b6e97)
2021-05-19 16:57:37 +00:00
Dmitriy Dolovov
fe4768e44a [Native] Support suspend functions as supertypes
^KT-46777
2021-05-19 13:06:24 +00:00
Victor Petukhov
8a9b59a043 Process raw types during erasion properly
^KT-46670 Fixed
^KT-46476 Fixed
2021-05-19 12:40:47 +00:00
Steven Schäfer
2cf48c2ca7 Parcelize: Handle class hierarchies of Parcelers (KT-46567)
(cherry picked from commit bf7db84451)
2021-05-19 10:25:14 +00:00
Steven Schäfer
44c1135e51 IR: Lower shared variables in enum entries (KT-46605)
(cherry picked from commit 60bc0f4baf)
2021-05-19 10:24:39 +00:00
Yahor Berdnikau
8b367f5667 Deprecate 'kotlin.parallel.tasks.in.project' build property.
Default value will use Gradle parallel execution option value.

^KT-46401 Fixed
2021-05-19 09:00:48 +00:00
Konstantin Tskhovrebov
d0006bfa18 Delete umbrella Apple framework tasks and register concrete tasks.
#KT-46680

(cherry picked from commit 80ce3a5cf8)
2021-05-19 08:46:31 +00:00
Svyatoslav Scherbina
94b9c8de90 Native: deprecate SymbolName annotation
(cherry picked from commit 570d860217)
2021-05-19 08:40:27 +00:00
Vladimir Dolzhenko
ab71251c35 Cache all module dependencies to avoid O(n^2) calc complexity
Quite noticeable when there is a big module that has 100+ libraries and many modules depends on it

#KT-46622 Fixed

(cherry picked from commit b01478746c)
2021-05-19 08:36:40 +00:00
Andrey Zinovyev
3015cfceb7 Add missing base-compiler-plugins-ide-support dependencies
(cherry picked from commit 82b7f589ad)
2021-05-18 15:36:46 +00:00
Andrey Zinovyev
c05ae5116b [lombok] Map lombok MODULE to java PackageVisibility
Because that's what lombok does
#KT-46469 Fixed

(cherry picked from commit 89f0a790c9)
2021-05-18 15:36:45 +00:00
Andrey Zinovyev
9932bb1f21 [lombok] Fix fallback to config for array annotation's parameter
If annotation's parameter is not explicitly defined, it should be
taken from config
#KT-46529 Fixed

(cherry picked from commit 468fc86a3f)
2021-05-18 15:36:44 +00:00
Andrey Zinovyev
2fc078ae8b [lombok] Config keys are case-insensitive
#KT-46531 Fixed

(cherry picked from commit 57d3f98ece)
2021-05-18 15:36:44 +00:00
Mads Ager
e634f411d0 Do not insert Nothing handling in JvmStatic wrapper.
Fixes KT-46568.

(cherry picked from commit 3db5ba98ad)
2021-05-18 14:57:19 +00:00
Mads Ager
ac155c628f Revert "JVM IR: mute testJvmStaticAndJvmInline for 1.5.20"
This reverts commit 9f092e7faa.
2021-05-18 14:57:18 +00:00
Victor Petukhov
aa40bd9ece Report warnings by enhanced base types 2021-05-18 10:49:26 +00:00
Victor Petukhov
b028249360 Extract type preparation during type checking to a separate component 2021-05-18 10:49:25 +00:00
Victor Petukhov
c47cf5b6d9 Add test for enhancement in usages of annotated type parameter 2021-05-18 10:49:24 +00:00
Victor Petukhov
9b363c24ed Update tests 2021-05-18 10:49:24 +00:00
Victor Petukhov
7e0d41cfbe Merge foreign annotation tests for sources and binaries into single directory 2021-05-18 10:49:23 +00:00
Victor Petukhov
6a35af2cb0 [Jspecify] Use bounds of type parameters for warnings reporting as well 2021-05-18 10:49:22 +00:00
Victor Petukhov
54c624eb51 [Jspecify] Use arguments of enhancement of type instead of arguments of base type during getting enhancement of type deeply 2021-05-18 10:49:21 +00:00
Victor Petukhov
ba26894ffd [Jspecify] Use enhancement of type with enhancement if possible during substitution 2021-05-18 10:49:21 +00:00
Victor Petukhov
c5ab14204d [Jspecify] Substitute enhancement of type instead of type itself directly 2021-05-18 10:49:20 +00:00
Victor Petukhov
a679b71a97 [Jspecify] Do preserving flexibility when adding equality constraints by taking into account type with enhancement 2021-05-18 10:49:19 +00:00
Victor Petukhov
63049edf44 [Jspecify] Report warnings on violated bounds of method type parameters 2021-05-18 10:49:18 +00:00
Dmitry Petrov
ecc185fdaa JVM_IR KT-46597 fix receiver type for inlined callable reference
Receiver type is used by SyntheticAccessorLowering to determine class in
which a synthetic accessor should be generated.
2021-05-18 10:07:44 +00:00
Yahor Berdnikau
588ba10a13 Warn on using 'jdkHome' option in Gradle builds.
User should instead use KotlinJavaToolchain that will take care of
tracking major java version and provide nicer API.

Gradle will still pass jdkHome value to the compiler, but it should
be changed in Kotlin 1.6 release.

^KT-45611 Fixed
2021-05-18 09:27:48 +00:00
Alexander Udalov
9f9ea3eb14 Fix accidental usage of ASM from jdk.internal
#KT-46402 Fixed

(cherry picked from commit ee6586fe4f)
2021-05-17 14:33:34 +00:00
Yan Zhulanow
feda393272 Remove CLI and some of daemon-related modules from compiler-for-ide
These modules is not required by the plugin, and the plugin verifier
warns about unsatisfied dependencies of the modules.

CLI is needed in tests so a separate artifact is created instead.

(cherry picked from commit e90cc30edb)
2021-05-14 16:55:15 +00:00
Dmitry Petrov
c86277ca9c JVM_IR KT-46578 resolve fake overrides for fields 2021-05-14 16:44:33 +00:00
Mikhail Glukhikh
cf88160254 FIR2IR KT-46578 add overridden properties generation 2021-05-14 16:44:32 +00:00
Dmitry Petrov
e0f6422b11 IR KT-46578 add IrProperty#overriddenSymbols 2021-05-14 16:44:31 +00:00
Pavel Punegov
37c10750b6 Use newer version of Kotlin/Native in the testNativeCompilerDownloading 2021-05-14 15:55:41 +00:00
Yahor Berdnikau
5382b8832a Fix exposing provided by Gradle Kotlin dependencies.
Ensure that Gradle plugin dependencies do not include kotlin-stdlib,
kotlin-reflect and other dependencies that are provided by Gradle
runtime.

^KT-41142 Fixed
2021-05-14 15:23:39 +00:00
pyos
0174227fa7 JVM_IR: propagate reified type parameter usages from inline lambdas
...to whichever class they are inlined into, not the class they are
declared in (which is not the same if the lambda is crossinline).

 #KT-46584 Fixed

(cherry picked from commit 3fc2cc410c)
2021-05-14 14:16:05 +00:00
pyos
b9060f2c8a JVM_IR: use correct types for generated inline reference wrappers
Doesn't change anything, but still.

(cherry picked from commit 420bc6cbe8)
2021-05-14 14:16:04 +00:00
pyos
34e74e94c3 PSI2IR/FIR2IR: do not approximate T!! before translation
This leads to weird effects when it's in a contravariant position,
because it's approximated by Nothing.

(cherry picked from commit d5d6736e67)
2021-05-14 14:16:03 +00:00
pyos
bf2b87e65c JVM_IR: remove a hack from InlineCallableReferenceToLambda
It breaks other things, the same problem is hit by FunctionReference,
and it's the translation layer's fault anyway.

 #KT-46555 Fixed

(cherry picked from commit a37db99841)
2021-05-14 14:16:02 +00:00
pyos
5042c6a4b5 JVM_IR: get unbound property reference receiver type from KProperty1
(cherry picked from commit cff74b31d4)
2021-05-14 14:16:01 +00:00
Steven Schäfer
e7ecbc7f8b JVM IR: Fix handling of anonymous initializers in inline classes (#4372)
Fixes KT-46554

(cherry picked from commit b2378620c3)
2021-05-14 13:57:32 +00:00
Mads Ager
97c187c8ca [JVM IR] Fix constant folding to use basic types always.
Fixes KT-46540.

(cherry picked from commit 2c5a4dcb98)
2021-05-14 13:57:04 +00:00
Alexander Udalov
9f092e7faa JVM IR: mute testJvmStaticAndJvmInline for 1.5.20 2021-05-14 13:56:35 +00:00
Mads Ager
01220d01fc [JVM IR] Copy attributes for JVM_STATIC_WRAPPERS.
(cherry picked from commit d397efb2bd)
2021-05-14 13:56:34 +00:00
Dmitry Petrov
d4d2e70866 JVM_IR KT-46562 don't use LambdaMetafactory for Serializable SAMs
TODO support serializable lambdas creation with LambdaMetafactory

(cherry picked from commit ac0aaff611)
2021-05-14 13:43:48 +00:00
Dmitry Petrov
5e6ef97a39 JVM_IR KT-46408 properly map fake overrides in method handles
(cherry picked from commit 83e3a702c5)
2021-05-14 13:43:47 +00:00
Dmitry Petrov
ac4599785b JVM_IR KT-45779 don't generate intrinsic method refs via invokedynamic
(cherry picked from commit 72804d2e8c)
2021-05-14 13:43:46 +00:00
Steven Schäfer
098ff2f68b Parcelize: Port the fix for KT-41553 to android-extensions
Fixes KT-46590.

(cherry picked from commit 1198b40c11)
2021-05-14 13:27:32 +00:00
Alexander Udalov
e90eebb45b JVM IR: fix inheritance from mutable collections of Int
For subclasses of `AbstractMutableList<Int>` which are not inline
classes, the special bridge `remove` had a parameter of type `Int`
(mapped to JVM primitive int) before this fix. The hack in
`MethodSignatureMapper` changed this type to `Int?`, yet the body of the
special bridge still loaded it as non-nullable, which resulted in
incorrect bytecode.

It looks like a part of this hack in `BridgeLowering` was made only for
inline classes which are subclasses of mutable collections. Supposedly
it should be extended to non-inline classes, so that `remove` special
bridge would have consistent IR by the time it reaches codegen.

 #KT-46516 Fixed

(cherry picked from commit e079fb665e)
2021-05-14 13:27:03 +00:00
Mikhail Glukhikh
6617c9559c FIR / FE 1.0: fix exception for lambda with unresolved name
#KT-46515 Fixed
2021-05-14 13:05:43 +00:00
Vladimir Dolzhenko
6224a57ff6 Update declarations to be searchable by their JvmName annotation
Relates to #KT-23653 PR#4313

(cherry picked from commit d70b889004)


Co-authored-by: n-p-s <6024770+n-p-s@users.noreply.github.com>
2021-05-14 10:42:00 +00:00
Ilmir Usmanov
ce6e820d02 Do not unbox nullable Result, since before usage it is coerced
#KT-46505
2021-05-14 07:32:56 +00:00
pyos
7be8dc42d4 JVM_IR: omit bound receiver in IrExpressionLambdaImpl parameters
and remove a hack intended to replace the missing type conversions this
caused.

 #KT-46505 Fixed
2021-05-14 07:32:54 +00:00
pyos
ca128f8363 JVM: remove LambdaInfo.invokeMethodDescriptor 2021-05-14 07:32:52 +00:00
Steven Schäfer
aac72684e8 JVM IR: Handle overloaded values functions in MappedEnumWhenLowering
Fixes KT-46579.

(cherry picked from commit 6aaff9dfb7)
2021-05-13 16:13:13 +00:00
Vladimir Dolzhenko
2b7dad072b Do not set diagnostics callback if it is already set
Relates to #KT-37702
#EA-258953 Fixed
2021-05-13 15:44:24 +00:00
Ilya Goncharov
665669d44f [Gradle, JS] Fix with beta version of webpack-dev-server to work with webpack 5
^KT-46162 fixed
^KT-46331 fixed
2021-05-13 13:44:29 +00:00
Dmitriy Novozhilov
8aaf3e5e9d [Parser] Fix OOM in parsing of incorrect string literals
^KT-46455 Fixed
KT-34410
KT-46564
2021-05-13 13:39:15 +00:00
Pavel Punegov
e656eefc5f Update Build gradle plugin to 0.0.28 2021-05-12 11:09:12 +00:00
Pavel Punegov
5aace3c298 [native] VersionGenerator: fix error string 2021-05-12 11:09:12 +00:00
Pavel Punegov
f9f2ceeca9 Return milestone property back to support older versions of plugins
Older gradle plugin's NativeCompilerDownloader uses milestone property.
2021-05-12 11:09:11 +00:00
Pavel Punegov
a4ba393dfb Revert "[kotlin-gradle-plugin] workaround for old k/n artifacts"
This reverts commit 5c80dbfd
2021-05-12 11:09:10 +00:00
Pavel Punegov
cd3d721c62 Revert "[tests][kotlin-gradle-plugin] workaround for old k/n artifacts"
This reverts commit f051119c to drop obsolete native version support
2021-05-12 11:09:10 +00:00
Pavel Punegov
b32f0816bc [native] Support milestones in meta versions
Add milestones to MetaVersion to replace standalone parameter in
compiler version generator. This makes native version match Kotlin one.
2021-05-12 11:09:09 +00:00
Vasily Levchenko
cc253cd301 [performance][build][kotlin-build-gradle-plugin] version 0.0.27 (fix)
(cherry picked from commit b389fd6667)
2021-05-12 11:09:08 +00:00
Vasily Levchenko
6ee9a9a6bf [build][kotlin-build-gradle-plugin] version 0.0.27
- reading konanVersion and konanMetaVersion from project properties

(cherry picked from commit 788d3c022a)
2021-05-12 11:09:08 +00:00
Vasily Levchenko
a0d7996502 [dependencies][kotlin-build-gradle-plugin] version 0.0.27
- reading konanVersion and konanMetaVersion from project properties

(cherry picked from commit 9cbcafa8d1)
2021-05-12 11:09:07 +00:00
Mikhael Bogdanov
0386476d20 Generate type annotations on class type parameters bounds
#KT-13228
 #KT-46539 Fixed

(cherry picked from commit cd7841ceed)
2021-05-10 12:22:28 +02:00
Mikhael Bogdanov
864320bc56 Generate class annotation in AbstractAsmLikeInstructionListingTest
(cherry picked from commit f574f89f78)
2021-05-10 12:22:27 +02:00
Mikhael Bogdanov
6f823c735a Extract generation of type parameters annotations and annotation on their bounds into utils
(cherry picked from commit 40eeee48b6)
2021-05-10 12:22:27 +02:00
Mikhael Bogdanov
b289705e30 Generate function type parameter annotations and type annotations on their bounds into bytecode
Generate type parameter annotation by default for `-Xjvm-target 1.8` and above

 #KT-46539
 #KT-13228
 #KT-46545 Fixed

(cherry picked from commit cbe3c66156)
2021-05-10 12:22:27 +02:00
Mikhael Bogdanov
d600dd992c Make copy for disabled ir tests
(cherry picked from commit 209ec68591)
2021-05-10 12:22:27 +02:00
Mikhael Bogdanov
f83cba19dd Render generic signature in type parameters tests
(cherry picked from commit 5ff4d648f4)
2021-05-10 12:22:26 +02:00
Mikhael Bogdanov
d297170d0a Render all annotations in type parameters tests
(cherry picked from commit 6182228de8)
2021-05-10 12:22:26 +02:00
Mads Ager
55a4a6d0e4 [JVM_IR] Guard against infinite recursion in JvmIrCodegenFactory.
Fixed KTIJ-11580.

(cherry picked from commit 6bc4e124fb)
2021-05-07 18:04:45 +02:00
pyos
8e36847fce JVM_IR: permit @NoArg if super constructor is already zero-argument
#KT-46537 Fixed

(cherry picked from commit 36a25353e9)
2021-05-07 16:25:04 +02:00
Alexander Udalov
51e071555d JVM IR: cast indy-SAM receiver type from KFunctionN to FunctionN
#KT-46512 Fixed

(cherry picked from commit d306d8a90e)
2021-05-07 16:20:25 +02:00
Alexander Udalov
91317576a4 JVM IR: generate adapted callable references as synthetic
As well as suspend conversion adapters, which are unsupported by default
right now.

 #KT-46259 Fixed

(cherry picked from commit 6e3009b82e)
2021-05-07 16:20:12 +02:00
Leonid Startsev
e39987eac4 Use correct type in KClassReference
Make sure that writeSelf function remains static

(cherry picked from commit d60a8f9baa)
2021-05-06 22:55:25 +03:00
Leonid Startsev
bf196ea60a Remove unnecessary ignoreIndexTo outside writeSelf
It never worked: descriptor.declaresDefaultValue used by property.isOptional
works only for current module
(since it looks up psi), so we never access default value initializers
outside current module

(cherry picked from commit a58f29aa06)
2021-05-06 22:55:18 +03:00
Leonid Startsev
2cf33c095d Use SerializerFactory interface and generate function
for sealed and abstract serializable classes.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1116
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1078

(cherry picked from commit 66f39ca185)
2021-05-06 22:55:12 +03:00
pyos
8ece9192ad Add a couple more tests for array constructors and references
(cherry picked from commit 1181854bd6)
2021-05-06 17:46:42 +02:00
pyos
f6b6107d1f JVM_IR: remove JvmArrayConstructorLowering
ExpressionCodegen already spills the stack before any loop, so it has
no effect.

(cherry picked from commit a30cfc332d)
2021-05-06 17:46:42 +02:00
pyos
7c3012cd42 JVM_IR: move ArrayConstructor below function reference phases
This allows taking function references to inline array constructors.

Also, redundant classes are no longer generated when function references
are passed as arguments to the array constructors.

 #KT-46426 Fixed

(cherry picked from commit 9f53d70109)
2021-05-06 17:46:41 +02:00
Mads Ager
ef4e4f566c [JVM_IR] Deal with inline-class arguments in large arity lambdas.
FunctionNVarargBridgeLowering checked the name of the method instead
of whether the method overrides an invoke method. That doesn't work
when the name of the function gets mangled because of inline class
arguments.

Fixed KT-45084.

(cherry picked from commit b6fa28ea81)
2021-05-06 17:28:44 +02:00
Yahor Berdnikau
a3af99b1a0 Enable kotlin java toolchain support for kapt task.
With this change 'KaptWithoutKotlincTask' will also support overriding
default Gradle JDK to run kapt. In such case only 'in-process' kapt
 worker isolation mode is supported.

If user does not provide custom JDK, kapt worker isolation mode will
be 'no-isolation' as before.

^KT-45611 In Progress
2021-05-06 16:58:04 +02:00
Ivan Gavrilovic
a29762e303 [Gradle] Create kotlinOptions during task init and keep outputFile for js
This is so that existing build scripts using
withType() do not break. Also, fix the failing
test.

It was necessary to keep outputFile for the js compile task
as it was accessed from the build scripts. Instead, a new
property is introduced which uses Gradle lazy properties.
2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
110997bc73 [Gradle] Add Android bootclasspath lazily 2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
112a7f2946 [Gradle] Support getting the sourceSet name from tasks when...
...Gradle property is being used, instead of the direct String
value.
2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
43d15d6dee [Gradle] Fix adding KAPT generated classess to the compilation classes output 2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
34e0a3caa8 [Gradle] Use Gradle properties for KAPT tasks
Use lazy properties to configure KAPT tasks and in the model builder.
Also, avoid eager dependency resolution of the kaptExternalClasspath
file collection.
2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
29768d3079 [Gradle] Introduce classes to configure KAPT tasks
Avoid storing references to KotlinCompile task and use lazy properties
to configure task. Values are kept in-sync with the
Kotlin compile task (for the stub generation) using this mechanism.
2021-05-06 16:55:51 +02:00
Ivan Gavrilovic
d85b29e78f [Gradle] Use task properties to modify task configuration
This change migrates to using properties of KGP tasks and Gradle
built-in tasks. Also, in TaskProvider class, Configurator instances are
created to configure KGP tasks.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
9cd9cc97bd [Gradle] Extract configuration of KotlinJsIrLink to a class
Migrate KotlinJsIrLink to properties create Configurator class
to configure the task properties.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
12de1e8de0 [Gradle] Extract configuration of KotlinCompileCommon to a class
Migrate KotlinCompileCommon to properties create Configurator class
to configure the task properties.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
388bb74264 [Gradle] Use ConfigurableFileCollection for task local state
Use ConfigurableFileCollection so that tasks can simply append to the
file collection and tasks that do not need this, can simply do nothing.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
b9b423b9f8 [Gradle] Update compile tasks to use properties and clean up code
Update AbstractKotlinCompile, KotlinCompile, and Kotlin2JsCompile to
use Gradle properties, and introduce Configurator classes that are
using configuration-time data to configure task. Also, introduce
TaskConfigurator interface that should be implemented by classes that
are used to configure tasks.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
b6e6f75b43 [Gradle] Remove KotlinCompileTaskData
When getting the incremental compilation information use the
task graph which processes all tasks present in it. Tasks have
all information that is needed to get IncrementalModuleInfo for all
compilations.
2021-05-06 16:55:50 +02:00
Ivan Gavrilovic
8ae2b1c0ef [Gradle] Remove deprecated ways to specify compiler classpath
This change removes options to specify compiler classpath using
deprecated properties that were deprecated for more than 2 years.
2021-05-06 16:55:43 +02:00
Andrey Zinovyev
dd967e4a88 [lombok] Actualize README
(cherry picked from commit cba21c68a3)
2021-05-06 12:36:47 +00:00
Andrey Zinovyev
c129882542 [lombok] Add message about experimental status of the plugin
(cherry picked from commit c8a81911c0)
2021-05-06 12:36:46 +00:00
Andrey Zinovyev
62c22b1860 [lombok] Support import from gradle to IDE
Introduce base module for ide compiler plugins

(cherry picked from commit 8afb6d2761)
2021-05-06 12:36:45 +00:00
Andrey Zinovyev
32cf82ba4b [lombok] IDE plugin with maven import handler
(cherry picked from commit b58bea6fa1)
2021-05-06 12:36:45 +00:00
Andrey Zinovyev
e322ccee07 [lombok] Rename maven subplugin to 'lombok'
(cherry picked from commit 07daf2165a)
2021-05-06 12:36:44 +00:00
Andrey Zinovyev
92636074ca [lombok] Add maven plugin integration test with kapt
(cherry picked from commit b88f54b31a)
2021-05-06 12:36:43 +00:00
Andrey Zinovyev
c357fe2686 [lombok] Simple maven plugin to enable lombok support
(cherry picked from commit 3e883120dd)
2021-05-06 12:36:42 +00:00
Anton Lakotka
d90db76619 Fail only when KotlinPm20ProjectExtension is passed
to buildKotlinProjectStructureMetadata
#Fixes KTIJ-11586
2021-05-06 12:53:33 +02:00
Alexander Udalov
d5b9b6d962 IR: fix capturing of type parameters in local functions
collectPotentiallyCapturedTypeParameters no longer stops on the first
class when going through parents. This is needed because otherwise type
parameters of the containing class, and its outer classes, were never
considered "captured", and thus not duplicated/remapped later in
LocalDeclarationsLowering.

This led to the IR where a local function referenced generic type
parameters of the outer class. On JVM, local function is generated into
a private static function in that container class, and static functions
can't use generic type parameters, which crashed some bytecode
processing tools.

Also, add another explicit call to `seeType` to cover references to
generic type parameters in function return types.

 #KT-45941 Fixed

(cherry picked from commit c14a890e7e)
2021-05-04 21:11:20 +02:00
Alexander Udalov
d6e3cd8926 JVM IR: fix ::class reference and type mapping for scripts
#KT-46284 Fixed

(cherry picked from commit 276ffd5a4b)
2021-05-04 16:03:10 +02:00
sebastian.sellmair
320aa586e2 [Commonizer] Logging: NativeDistributionCommonizationCache: Log in level 'quite' on cache misses
^KT-36679 Verification Pending

(cherry picked from commit a1ed81146e)
2021-05-04 11:25:02 +02:00
sebastian.sellmair
b2f6218857 [Commonizer] Logging: Implement CommonizerLogLevel and hide verbose output by default
^KT-36679 Fixed

(cherry picked from commit b48850c993)
2021-05-04 11:25:01 +02:00
sebastian.sellmair
9ec4f503fb [Commonizer] Logging: Implement ProgressLogger.fork
^KT-36679

(cherry picked from commit 7349ec8f2f)
2021-05-04 11:24:59 +02:00
sebastian.sellmair
ea1859809d [Commonizer] Logging: Remove 'COMMONIZATION' prologue
^KT-36679

(cherry picked from commit ec440aecf6)
2021-05-04 11:24:58 +02:00
sebastian.sellmair
7dc80cd57f [Commonizer] Logging: 'Preparing commonized Kotlin/Native libraries': show outputTarget instead of flat list of targets
^KT-36679

(cherry picked from commit 9d9e11d6d8)
2021-05-04 11:24:57 +02:00
sebastian.sellmair
c7902eee64 [Commonizer] Logging: Show [Step x of y] only when more than one task is scheduled
^KT-36679

(cherry picked from commit 0d9e32f963)
2021-05-04 11:24:56 +02:00
Mads Ager
6de79570e8 JVM_IR: Add more local variable tests for finally code.
(cherry picked from commit 0c77565104)
2021-05-03 11:00:33 +02:00
Mads Ager
1641e8d97e [JVM] Split the variable range for external finally blocks in inliner
When external finally blocks are inlined none of the current locals
are in scope of the finally block.

(cherry picked from commit 6095d8a7fa)
2021-05-03 11:00:33 +02:00
Mads Ager
241d4f973d [JVM_IR] Fix range of locals in connection with finally blocks.
For code such as:

```
try {
  var y = "y"
  for (i in 0 until 1) {
    return y
  }
} finally {
  println("finally")
}
```

The local variables `y` and `i` ended up covering the finally block as
well in the debugger.

This change splits the range of the locals so that they do
not cover the finally block.

This change does not change the inliner to do similar transformations,
so the range of locals is still wrong win finally blocks when inlined
into an inline function. Added a failing test to that effect.

(cherry picked from commit 6d9f02cfc6)
2021-05-03 11:00:32 +02:00
Mikhael Bogdanov
0ff28e00c8 Mute test on JDK 6
(cherry picked from commit 84e67da2af)
2021-05-03 07:50:38 +02:00
Mikhael Bogdanov
39111bd33c Put reification markers came from super object signature
#KT-44770 Fixed
  #KT-30696 Open

(cherry picked from commit 95d95f9a9b)
2021-05-03 07:50:37 +02:00
Victor Petukhov
87a1a9de10 Use platform-independent line separator in jspecify tests handler
(cherry picked from commit 9eaec8d919)
2021-05-01 13:42:50 +03:00
Simon Ogorodnik
da07980f0c FIR: Fix gradle integration tests broken by c6fa3634
(cherry picked from commit 6365164c21)
2021-04-30 22:20:28 +03:00
Stanislav Erokhin
b8ad5b8c56 Fix binary compatibility with AS Arctic Fox C14 and AS 4.2 2021-04-30 19:26:43 +02:00
Sergey Shanshin
504e172f29 Fix IR compilation of external serializers in native
(cherry picked from commit 8dd307573a)
2021-04-30 19:23:54 +03:00
Victor Petukhov
6844b9047a Temporary disable failing jspecify tests on Windows
(cherry picked from commit 4fb78fab93)
2021-04-30 17:54:52 +03:00
Victor Petukhov
88b4914b2e Fix FIR tests 2021-04-30 16:49:16 +03:00
Victor Petukhov
0294a3f1a1 Introduce warnings reporting by missed constraints because of incorrect optimization in the constraints processor
(cherry picked from commit 7c62e9aecd)
2021-04-30 15:46:46 +03:00
Victor Petukhov
72761a9255 Revert "Don't stop constraints processing if all type variables have proper equality constraints"
This reverts commit b87c2a15

(cherry picked from commit e110b49cab)
2021-04-30 15:46:44 +03:00
Victor Petukhov
5aba18ad15 Mute foreign annotations tests with compiled java through psi class files reading
(cherry picked from commit f330d67740)
2021-04-30 14:50:10 +03:00
Victor Petukhov
b20a7efdb5 Add jspecify license
(cherry picked from commit 78ffefe107)
2021-04-30 14:50:09 +03:00
Victor Petukhov
2832137461 Implement caching module annotations per class id
(cherry picked from commit 909f0d8bdb)
2021-04-30 14:50:09 +03:00
Victor Petukhov
85eef93f1d Leave KotlinCliJavaFileManager::findClass only passing JavaClassFinder.Request
(cherry picked from commit 2e57ff25ee)
2021-04-30 14:50:08 +03:00
Victor Petukhov
8db78e45b0 Move foreign annotations logic into the corresponding configurator for the tests
(cherry picked from commit 072bba109f)
2021-04-30 14:50:07 +03:00
Victor Petukhov
8d959dc8ef Implement jspecify marks processing in the tests properly, by adding specific handler and cleanuper
(cherry picked from commit e93133a28f)
2021-04-30 14:50:06 +03:00
Victor Petukhov
c7092b1e1d Support type enhancement on freshly supported module level annotations
^KT-45189 Fixed

(cherry picked from commit b9536a25d6)
2021-04-30 14:49:57 +03:00
Victor Petukhov
b8ae6d607d Support reading annotations on java 9 module on sources and binaries
(cherry picked from commit bc5e92033b)
2021-04-30 14:49:56 +03:00
Victor Petukhov
01e1e512fb Add directive ALL_JAVA_AS_BINARIES and use it explicitly for foreign annotations tests with compiled java
(cherry picked from commit 24685ee9d6)
2021-04-30 14:49:52 +03:00
Victor Petukhov
eccd2c389e Update some third-party annotations
(cherry picked from commit 89270399db)
2021-04-30 14:49:45 +03:00
Victor Petukhov
9d937f96ce Add basic Java 9 module tests
(cherry picked from commit cdcde634e8)
2021-04-30 14:49:44 +03:00
Victor Petukhov
125e229dcf Add Java 9 jspecify annotations including module level ones
(cherry picked from commit 757fdb2b32)
2021-04-30 14:49:43 +03:00
Victor Petukhov
b3a664ce13 Support java 9 modules in the diagnostic tests both in sources and binaries
(cherry picked from commit 71755b7a5e)
2021-04-30 14:49:39 +03:00
Victor Petukhov
f7bd9285c1 Introduce special common directives for tests based on foreign annotation tests
(cherry picked from commit 1f0616439c)
2021-04-30 14:49:35 +03:00
Victor Petukhov
330c801957 [Jspecify] Move diagnostic tests against compiled java under the new tests infrastructure
(cherry picked from commit 6065f0e2d0)
2021-04-30 14:49:31 +03:00
Victor Petukhov
50cb6a5308 [Jspecify] Move jspecify test runner under the new tests infrastructure
(cherry picked from commit 8f097b14cc)
2021-04-30 14:49:28 +03:00
Victor Petukhov
5be8b728f1 Move foreign annotation tests into diagnostics folder
(cherry picked from commit 6f9694174f)
2021-04-30 14:49:14 +03:00
Victor Petukhov
19cc7866b3 [Jspecify] Remove Kotlin use sites generator: consider manually picking changes from the jspecify repo
(cherry picked from commit 57bd4d3a98)
2021-04-30 14:49:13 +03:00
Victor Petukhov
1fd3575d57 Clean-up JavaModuleInfo.kt
(cherry picked from commit 49e838781c)
2021-04-30 14:49:12 +03:00
Victor Petukhov
d9dc51549f Build recursive raw types and raw types which contain type parameters properly
1) Substitute erasure of other type parameters
2) Use star projection at top level for recursive raw types

^KT-46126 Fixed

(cherry picked from commit 8dd71ec5c8)
2021-04-30 10:54:35 +03:00
Yahor Berdnikau
77e9a8ae13 Made GradleCompileTaskProvder compative with configuration cache.
After moving compilerRunner() method evaluation into execution phase,
creation of GradleCompileTaskProvider class started to violate
configuration cache.

^KT-45611 In Progress
2021-04-29 20:20:28 +02:00
Yahor Berdnikau
9d98d93c9d Introduce KotlinJavaToolchain compile tasks input.
This task input provides a way to set different from current Gradle
JDK and use it for Kotlin files compilation. By default it provides
current Gradle JDK.

Provided JDK major version is used as task input, so on providing
different JDK user will see cache miss.

All required interfaces are located inside api module.

^KT-45611 In Progress
2021-04-29 20:20:17 +02:00
Yahor Berdnikau
3e69bcba47 Print path to java executable Kotlin daemon was started with.
Useful for tests to validate toolchain correct behaviour.

^KT-45611 In Progress
2021-04-29 20:20:08 +02:00
Yahor Berdnikau
47a7a28446 Add helper methods simplifying working with lazy properties from Kotlin.
Just allow to write Kotlin code easier and nicer when using Gradle
lazy properties.

^KT-45611 In Progress
2021-04-29 20:19:57 +02:00
Yahor Berdnikau
7573f73d9b Add initial test setup to enable and test Gradle build cache.
This will allow to write JUnit5 tests to verify tasks are re-using
build cache on rebuilding same project from clean state.

^KT-45611 In Progress
2021-04-29 20:19:45 +02:00
Ivan Gavrilovic
fd55fcfca0 [Gradle] Simplify Parcelize Gradle plugin
Do not iterate over all configurations, just
add the dependency to the compile and runtime classpath.
2021-04-29 16:41:19 +02:00
sebastian.sellmair
beba85a848 [Commonizer] Calculate 'commonModuleNames' in hierarchical context
^KT-46330 Verification Pending
2021-04-28 02:03:20 +03:00
Nikolay Krasko
f7fdffefd6 Add an explicit dependency on dist for UAST tests 2021-04-27 22:00:18 +03:00
Dmitry Petrov
b34e2c1474 JVM_IR KT-36646 fuze primitive equality with safe call 2021-04-27 19:41:31 +03:00
Dmitry Petrov
72849a3dc3 JVM_IR update test for KT-36637 2021-04-27 19:41:29 +03:00
Dmitry Petrov
bdf914e8d5 JVM_IR use static 'hashCode' for boxed primitives on JVM 1.8+ 2021-04-27 19:41:28 +03:00
Dmitriy Novozhilov
07b15f9de6 [FIR] Support effective visibility with @PublishedApi
#KT-46270 Fixed
2021-04-27 18:39:10 +03:00
Dmitriy Novozhilov
32c3f85679 [FIR] Add inline checker for bodies of inline functions
This checker doesn't support `@PublishedAPI` yet, so some BB tests for it
 were muted. #KT-46270
2021-04-27 18:39:09 +03:00
Dmitriy Novozhilov
7e052c1eb1 [FIR] Fix suppressing diagnostics for some expressions 2021-04-27 18:39:07 +03:00
Dmitriy Novozhilov
2a08923c51 [FIR] Add more utilities for builtin functional types 2021-04-27 18:39:06 +03:00
Dmitriy Novozhilov
8925b8c922 [FIR] Fix leaking mutable map type of resolved argument mapping 2021-04-27 18:39:05 +03:00
Dmitriy Novozhilov
1afb844e1a [FIR] Fix FirExpressionWithSmartcastImpl.acceptChildren 2021-04-27 18:39:03 +03:00
Dmitriy Novozhilov
12331cb10c [FIR] Build resolved declaration status for all non-raw declarations 2021-04-27 18:39:02 +03:00
Ivan Kochurkin
d54808e33f [FIR] Implement CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS diagnostics, fix tests 2021-04-27 18:27:39 +03:00
Alexander Likhachev
f2f2df90aa [Gradle] Prevent early resolve of compiler classpath
#KT-45834 Fixed
2021-04-27 18:21:19 +03:00
Dmitry Petrov
660208740e PSI2IR KT-44013 WA: function interface constructor call accepted by FE 2021-04-27 17:35:37 +03:00
Ivan Kochurkin
704b5a0e13 [FIR] Implement UNDERSCORE_IS_RESERVED, UNDERSCORE_USAGE_WITHOUT_BACKTICKS diagnostics (lighttree) 2021-04-27 17:03:53 +03:00
Ivan Kochurkin
ea2d9f7c0c [FIR] Implement UNDERSCORE_IS_RESERVED, UNDERSCORE_USAGE_WITHOUT_BACKTICKS diagnostics (psi only) 2021-04-27 17:03:52 +03:00
Sergey Bogolepov
cc4adb798f Add cacheable targets for macos_arm64 host. 2021-04-27 13:47:20 +00:00
Andrey Zinovyev
0c6066db74 [KAPT] Don't fail on illegal delegate
Kapt ignores error diagnostics, but backend can't
 compile such code at all
This is workaround so backend won't fail.
#KT-46176 Fixed
2021-04-27 16:18:44 +03:00
Ilmir Usmanov
0c0710bb79 Fix outer class accesses inside suspendImpl functions
We need to generate this$0 fields to get to the outer class and generate
accesses to these fields inside suspendImpl function.
 #KT-46214 Fixed
2021-04-27 10:44:18 +02:00
Pavel Kirpichenkov
71365d2452 [IDE] Move library dependency filtering to dependencies cache
The primary client of LibraryDependenciesCache is LibraryInfo,
but it is also used for maintaining modification trackers of
source-dependent libraries. Moving dependency filtering to
cache allows keeping all client in sync.

^KT-45908 In Progress
2021-04-27 10:14:13 +03:00
Mikhael Bogdanov
dfc6d85aee Enable runtime string concatenation by default (for -Xjvm-target=9 or greater)
#KT-42522 Fixed
2021-04-27 09:08:28 +02:00
Ilmir Usmanov
dc2485ae71 Support suspend functions as superinterfaces
Forbid mixing suspend and non-suspend functional supertypes.
Since JVM BE generates suspend functional types as non-suspend ones
with SuspendFunction marker interface, there is not way to distinguish
non-suspend functional type from suspend one if they are mixed.
 #KT-18707 Fixed
2021-04-26 22:14:32 +02:00
Alexander Udalov
37ccd82b6c Fix some warnings in kotlin-gradle-plugin 2021-04-26 22:02:26 +03:00
Alexander Udalov
19a5c2f1c8 Fix warnings related to appendln in kotlin-gradle-plugin
`appendln` is deprecated, but its replacement `appendLine` can't be used
yet in kotlin-gradle-plugin because it's compiled with API version 1.3.
2021-04-26 22:02:25 +03:00
Alexander Udalov
e5128a8772 Improve generated code for Gradle properties
Fix warnings about double nullability and useless elvis.
2021-04-26 22:02:24 +03:00
Svyatoslav Kuzmich
ccc27b6a0c [IR] Add module property to IrFile 2021-04-26 18:52:42 +03:00
Vasily Levchenko
6f2af740cb [kotlin-native][tests][lldb] adds possibility to run simple lldb scenarious with simulator 2021-04-26 14:46:51 +00:00
Ilya Gorbunov
ed3542cdf5 Support covariant MutableMap.entries.remove in JS/IR
Workaround for KT-43321
Follow up to KT-41278
2021-04-26 17:45:27 +03:00
Anton Yalyshev
666ad1f9d5 1.5.0 Change-notes correction. Restore excessively removed items 2021-04-26 16:23:11 +03:00
Anton Yalyshev
ea7ea979ee 1.5.0 Change-notes correction according to KT-42522 2021-04-26 16:01:00 +03:00
Ilya Kirillov
e2acc507d4 FIR IDE: fix inconsistency in element collecting in DiagnosticTraversalCounterTest 2021-04-26 15:11:47 +03:00
Dmitriy Novozhilov
9cb740bfdb Fix tests broken in c6fa3634 2021-04-26 15:11:46 +03:00
Steven Schäfer
a1c1a32515 JVM: Fix unsigned literals in API version < 1.5 2021-04-26 15:11:45 +03:00
Mark Punzalan
af2d0ad36f FIR: Properly set light-tree source for all nested types (e.g.,
nullable function type) and error type refs.
2021-04-26 15:11:44 +03:00
Mark Punzalan
1835185b16 FIR: Remove duplicated diagnostics on annotations on types. 2021-04-26 15:11:43 +03:00
Mark Punzalan
edb6b337dc FIR: Resolve anonymous function bodies during
IMPLICIT_TYPES_BODY_RESOLVE phase.

This fixes an issue where some FirAnnotationCalls can be left with some
implicit type refs if they have anonymous functions in the arguments.
2021-04-26 15:11:42 +03:00
Mark Punzalan
e69b729e21 FIR checker: Create a new kind of checker FirTypeChecker and add
FirSuspendModifierChecker to report WRONG_MODIFIER_TARGET for `suspend`
on  non-functional types.
2021-04-26 15:11:41 +03:00
Dmitriy Novozhilov
4282d17467 [FIR] Optimize imports 2021-04-26 15:11:40 +03:00
Mark Punzalan
b88913af1d FIR checker: Report WRONG_MODIFIER_TARGET for suspend on
non-functional types.
2021-04-26 15:11:39 +03:00
Mark Punzalan
9a4742c08d FIR: Properly build nullable suspend function types, and aggregate
modifiers and annotations within KtTypeReference/REFERENCE_TYPE nodes.
2021-04-26 15:11:38 +03:00
Mark Punzalan
9cf5ac1fbd FIR: Render "?" on nullable function types. 2021-04-26 15:11:37 +03:00
Ilya Gorbunov
a9cc046ec9 Add missing constructor for expect annotation class JvmRecord
KT-46280
2021-04-26 10:41:49 +00:00
Alexander Dudinsky
2c29957cb8 Move tests from GradleImportingTestCase to MultiplePluginVersionGradleImportingTestCase 2021-04-26 13:20:00 +03:00
Alexander Dudinsky
e96f64e6c9 Refactor MultiplePluginVersionGradleImportingTestCase
By this commit:
- Used `isTeamcityBuild` flag for a separating local run of the tests from CI
  For local run by default uses master version of gradle-plugin and
  LATEST_SUPPORTED_GRADLE_VERSION of the Gradle.
  But you can specify versions for local run by overriding sysenv
  `IMPORTING_TESTS_LOCAL_RUN_PARAMS`.
  For example: export IMPORTING_TESTS_LOCAL_RUN_PARAMS=6.7.1:1.4.30
- Moved main logic from `GradleImportingTestCase` to
  `MultiplePluginVersionGradleImportingTestCase` for removing the first one later
- Removed `AbstractModelBuilderTest` as useless only
 `DistributionLocator` left from this class.
2021-04-26 13:19:59 +03:00
Ilya Gorbunov
b59f668a50 Change the way kotlin.js source map paths are postprocessed
The idea is that we do no longer use `sourceMapBaseDirs` parameter
of `compileKotlin2Js` task to remove prefix from source paths,
but instead preserve the full paths relative to the output directory.
This allows us to avoid duplicate file names and to identify
source files more reliably.
Then, after sources have been embedded in the source map, we remove
several relative prefixes from source paths.
2021-04-26 13:13:21 +03:00
Mikhail Glukhikh
29d2a6acee FIR: fold String arguments inside string concatenation call
Related to KT-28006
2021-04-26 12:50:57 +03:00
Mikhail Glukhikh
f278de8768 FIR: don't call toString() inside string concatenations 2021-04-26 12:50:55 +03:00
Igor Chevdar
7dcdbf283b [box-tests] Added test 2021-04-26 11:53:27 +05:00
Igor Chevdar
eb1dcdb344 [K/N][IR] Fixed bug with enum companion init
Fixes https://youtrack.jetbrains.com/issue/KT-46048
2021-04-26 11:53:27 +05:00
Igor Chevdar
476b3befaf [K/N][IR] Refactored enums lowering a bit 2021-04-26 11:53:26 +05:00
Andrey Zinovyev
01dd3d6ed4 [lombok] Refactoring, cleaning, better tests
Add assertions to tests
Add lombok license
Provide String.[de]capitalize() implementation
Get rid of weak map because it seems it is useless here
2021-04-25 18:18:18 +03:00
Andrey Zinovyev
c4147bc2fd [lombok] Add integration test for gradle plugin 2021-04-25 18:18:17 +03:00
Andrey Zinovyev
5a6819daa8 [lombok] Check that nullability actually works 2021-04-25 18:18:16 +03:00
Andrey Zinovyev
1fb4590978 [lombok] Some cleaning and docs 2021-04-25 18:18:15 +03:00
Andrey Zinovyev
9ebce7849c [lombok] Skip generation with AccessLevel.NONE 2021-04-25 18:18:15 +03:00
Andrey Zinovyev
be4a518a25 [lombok] Support for lombok.accessors.prefix config 2021-04-25 18:18:14 +03:00
Andrey Zinovyev
17e4a6142c [lombok] Strip prefixes defined in @Accessors 2021-04-25 18:18:13 +03:00
Andrey Zinovyev
f2c0b8c68d [lombok] Strip 'is' prefix in boolean properties 2021-04-25 18:18:12 +03:00
Andrey Zinovyev
8a2279de2b [lombok] Use config values as default in annotation parsing 2021-04-25 18:18:11 +03:00
Andrey Zinovyev
c7b2c731af [lombok] Basic @Value support 2021-04-25 18:18:11 +03:00
Andrey Zinovyev
97fc187e77 [lombok] @Data support 2021-04-25 18:18:10 +03:00
Andrey Zinovyev
99f9b79c87 [lombok] Add simple way to use lombok plugin in one project with kapt 2021-04-25 18:18:09 +03:00
Andrey Zinovyev
79d49e6dbd [lombok] Gradle sublugin for no-kapt project 2021-04-25 18:18:08 +03:00
Andrey Zinovyev
8011452c28 [lombok] Don't generate members that already exist 2021-04-25 18:18:07 +03:00
Andrey Zinovyev
d459cde010 [lombok] Run compiled code 2021-04-25 18:18:06 +03:00
Andrey Zinovyev
411441c332 [lombok] Generic classes support 2021-04-25 18:18:06 +03:00
Andrey Zinovyev
afcb2ca904 [lombok] Support @RequiredArgsConstructor 2021-04-25 18:18:05 +03:00
Andrey Zinovyev
b336a335bf [lombok] Support @AllArgsConstructor 2021-04-25 18:18:04 +03:00
Andrey Zinovyev
59f936fdef [lombok] Generate no-arg static factory method 2021-04-25 18:18:03 +03:00
Andrey Zinovyev
37926f333e [lombok] Generate no-arg constructor 2021-04-25 18:18:03 +03:00
Andrey Zinovyev
e9a33e0335 [lombok] Introduce synthetic constructors generation 2021-04-25 18:18:02 +03:00
Andrey Zinovyev
e0216cc9f4 [lombok] Add readme with (not) supported features 2021-04-25 18:18:01 +03:00
Andrey Zinovyev
e0a95ff556 [lombok] @With support 2021-04-25 18:18:00 +03:00
Andrey Zinovyev
7fd8f7b3bc [lombok] @Setter support 2021-04-25 18:17:59 +03:00
Andrey Zinovyev
70e3877efc [lombok] Basic config support 2021-04-25 18:17:57 +03:00
Andrey Zinovyev
5ceefa3e3b [lombok] Support for class level @Getter 2021-04-25 18:17:56 +03:00
Andrey Zinovyev
e4bd33eb4f [lombok] Support for fluent getters 2021-04-25 18:17:55 +03:00
Andrey Zinovyev
f71e08df4d [lombok] Experimental lombok plugin prototype
Add extension point for java descriptors
Add simple usage of this point to generate getter method
Add simple test infrastructure to test compilation with lombok plugin
2021-04-25 18:17:53 +03:00
Yahor Berdnikau
ac86ad252f Optionally make java executable path contribute to the daemon id.
This change will allow to start Kotlin daemon instances using different
from the current user JDK version and use it to compile Kotlin files.
Old behaviour, when java executable path is not set, is still working
 and still,by default, using current user JDK version.

For example, user for some reason wants to use JDK 1.8 as active one,
 but compile current project using JDK 16.

Main goal is to support Gradle toolchains.

^KT-45611 In Progress
2021-04-24 11:12:47 +03:00
Yahor Berdnikau
1d47f4ad2b Consolidate compiler id digest.
Change all calculations of compiler id digest to use
 'CompilerId#digest()' method.

^KT-45611 In Progress
2021-04-24 11:12:46 +03:00
Simon Ogorodnik
c6fa363487 [FIR] Add warning if FIR is used 2021-04-23 19:49:46 +03:00
Victor Petukhov
7a81d0de8a Regenerate tests 2021-04-23 19:28:26 +03:00
sebastian.sellmair
7be48a0b4b CommonizerHierarchicalIT: Enable test commonizeHierarchicallyMultiModule
^KT-46107 Fixed
2021-04-23 16:25:59 +00:00
sebastian.sellmair
63e5298be9 Update 'versions.kotlin-native' to 1.5.20-dev-5613
^KT-46107
2021-04-23 16:25:59 +00:00
Konstantin Tskhovrebov
b894b7df6e Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks. 2021-04-23 19:23:58 +03:00
Konstantin Tskhovrebov
c8ef0715b9 Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode.
#KT-27240
2021-04-23 19:23:57 +03:00
Alexander Udalov
0c3f2eefe0 Migrate bytecodeListing tests to new test infrastructure 2021-04-23 17:58:16 +02:00
Alexander Udalov
7e170770ea Minor, move around bytecode listing tests 2021-04-23 17:58:16 +02:00
sebastian.sellmair
28690b7f32 KotlinToolRunner: Add "java.system.class.loader" to execSystemPropertiesBlacklist
IDE integration tests will forward an unvailable intellij classloader
which will fail the execution.
2021-04-23 14:34:17 +00:00
sebastian.sellmair
7b8926f85b [Commonizer] Allow propagation of leaf targets
^KT-46248 Verification Pending
2021-04-23 14:34:17 +00:00
sebastian.sellmair
7c1520a424 [Commonizer] Implement SingleTargetPropagationTest to cover KT-46248
^KT-46248
2021-04-23 14:34:16 +00:00
sebastian.sellmair
965e328766 CommonizerIT: implement test KT-46248 single supported native target dependency propagation to cover KT-46248
^KT-46248
2021-04-23 14:34:15 +00:00
Mikhail Glukhikh
683872ecbf FIR: use more precise checkers when possible 2021-04-23 17:29:43 +03:00
Mikhail Glukhikh
5c224ad17c FIR: fix positioning in fun interface checker 2021-04-23 17:29:34 +03:00
Артём
393a19db54 FIR: introduce FunInterfaceDeclarationChecker 2021-04-23 17:29:25 +03:00
Victor Petukhov
867d7b5bca Allow type variable fixation into intersection type if it isn't meaningless (i.e. has one or more final classes, or two or more open classes)
^KT-46186 Fixed
2021-04-23 15:12:13 +03:00
Victor Petukhov
310d98c4f7 Don't require existence of the corresponding type argument during computing target type to apply type use annotation loaded from class file
^KT-46131 Fixed
2021-04-23 15:12:12 +03:00
sebastian.sellmair
13b1664edf CommonizerIT: Implement additional test KT-46142 standalone native source set
^46142
Before this test, the behaviour was tested as integration test in the IDE.
This Gradle integration test will detect issues even earlier.
2021-04-23 15:02:15 +03:00
Konstantin Tskhovrebov
ee4a1d173d Revert "Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks."
This reverts commit 6db3960d
2021-04-23 12:11:42 +03:00
Konstantin Tskhovrebov
8840a9ecd1 Revert "Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode."
This reverts commit c2cdf9c7
2021-04-23 12:11:19 +03:00
Ilmir Usmanov
f7a9bc3521 Minor. Make test actually suspend and add a test without suspension 2021-04-23 03:50:08 +02:00
pyos
23ffbe4d9e JVM_IR: do not box inline classes in suspend multifile bridges 2021-04-23 03:49:47 +02:00
pyos
7d95943b8b JVM_IR: do not box inline classes in suspend synthetic accessors 2021-04-23 03:49:43 +02:00
Alexander Likhachev
857bee6ced [Build] Remove empty source directories warning
There're should be no more cache misses on empty directories with Gradle 6.8. See https://docs.gradle.org/6.8/release-notes.html#more-cache-hits-when-empty-directories-are-present
2021-04-23 03:52:45 +03:00
Alexander Likhachev
03f9d78eb3 [Build] Add workaround to make local publishing serializable
Also signing plugin now being applied only when signing is required.
#KT-44611 In Progress
2021-04-23 03:52:41 +03:00
Sergey Igushkin
4e6c483ccc Add a final override for project in KotlinGradleFragmentInternal 2021-04-23 00:43:14 +03:00
Sergey Igushkin
bb35d9271f Minor fix: don't use lazy in KotlinPm20ProjectExtension.modules 2021-04-23 00:43:14 +03:00
Sergey Igushkin
53f02a53f0 Add caching to dependency resolvers in PM20 + some refactoring 2021-04-23 00:43:13 +03:00
Sergey Igushkin
1f0089c5de Refactor the dependency graph resolver to be more readable 2021-04-23 00:43:13 +03:00
Sergey Igushkin
d07c76fca4 Add kotlin-project-model artifacts to the set of trusted artifacts 2021-04-23 00:43:12 +03:00
Sergey Igushkin
6be33448d6 Rework adding sources to FilteringSourceRootsContainer in JVM tasks
Support adding lazily-evaluated file collections (i.e. tracking their
source roots lazily, as opposed to eagerly evaluating the source roots.
2021-04-23 00:43:12 +03:00
Sergey Igushkin
e59a57d11c Add ":kotlin-project-model" to the list of modules installed for tests 2021-04-23 00:43:11 +03:00
Sergey Igushkin
e7b81c52a7 Get rid of DependencyDiscovery in favor of DependencyGraphResolver 2021-04-23 00:43:11 +03:00
Sergey Igushkin
d602470027 Fix compilation of the tests in kotlin-project-model 2021-04-23 00:43:10 +03:00
Sergey Igushkin
fe351f26ef For now, publish the sources elements variant with usage=kotlin-sources 2021-04-23 00:43:10 +03:00
Sergey Igushkin
a94597d85a Experimental sources publication in the PM2.0 prototype 2021-04-23 00:43:10 +03:00
Sergey Igushkin
44fcd7e891 Use KotlinCompilationTaskConfigurator for metadata compilation tasks 2021-04-23 00:43:09 +03:00
Sergey Igushkin
4cb6303fa8 Get rid of kotlinPluginVersion in the constructors throughout the plugin
We passed the kotlinPluginVersion which was only used for a single
purpose in countless constructors.

In fact, the plugin version is easy to load at the call site, as it gets
loaded from the plugin's resources.

So rework the plugin version loading code so that it doesn't rely on the
applied plugin, and don't pass the plugin version in all those
constructors.
2021-04-23 00:43:09 +03:00
Sergey Igushkin
2a5d511b66 Minor fix: handle kotlinOptions more carefully, store them where needed 2021-04-23 00:43:08 +03:00
Sergey Igushkin
00e5e462ea Further refactor compile task configuration: extract the configurator 2021-04-23 00:43:08 +03:00
Anton Lakotka
1a85da5ff8 Make language settings nullable in KotlinModuleFragment
There is no lang settings when importing from klibs (yet)
2021-04-23 00:43:07 +03:00
Anton Lakotka
c3264a2979 Add language consistency checks for fragments
Migrate exiting consistency checker for source sets to be generic
and reuse it for fragments
2021-04-23 00:43:07 +03:00
Anton Lakotka
de4221afd8 Add immutable LanguageSettings interface and apply it to compilation
LanguageSettingsBuilder extends LanguageSettings
2021-04-23 00:43:06 +03:00
Sergey Igushkin
54c6ae2cce (minor) Rename modelClasses.kt -> KotlinJvmVariantFactory.kt 2021-04-23 00:43:06 +03:00
Sergey Igushkin
3be2734c63 Refactor the setup of compilation in the PM20 implementation prototype 2021-04-23 00:43:05 +03:00
Sergey Igushkin
c1fe0d7158 Add publishing configurator, call it from the variant factories 2021-04-23 00:43:05 +03:00
Sergey Igushkin
1271fabffa Fix Maven scope mapping for the runtime dependencies in PM20 publishing 2021-04-23 00:43:04 +03:00
Sergey Igushkin
27015a657c Don't pass the IDE paths to the extracted klibs that don't exist 2021-04-23 00:43:04 +03:00
Sergey Igushkin
470103bfac Don't rely on the current project in dep-resolution if module is given 2021-04-23 00:43:04 +03:00
Sergey Igushkin
f029179fe0 Add basic support for Kotlin/Native variants to the PM20 Gradle plugin 2021-04-23 00:43:00 +03:00
Sergey Igushkin
401fbae8d8 Handle dependency module IDs more carefully in dependency resolution 2021-04-23 00:42:37 +03:00
Sergey Igushkin
ea458e6848 Add some API interfaces for Gradle PM20 entities in the API module 2021-04-23 00:42:37 +03:00
Sergey Igushkin
a52c6858a9 Minor fixes in exposed configurations 2021-04-23 00:42:37 +03:00
Sergey Igushkin
134fb7741e Fix getChosenVariant implementation for project(...) dependencies 2021-04-23 00:42:36 +03:00
Sergey Igushkin
ec3fa2610e Support basic publishing with maven-publish in the PM20 plugin 2021-04-23 00:42:36 +03:00
Sergey Igushkin
0bf408e147 (minor) Add isAllowCommonizer stub to the PM2.0 project extension
This prevents the IDE from failures during Gradle project sync
2021-04-23 00:42:35 +03:00
Sergey Igushkin
4e0485c523 Expose compiled metadata for project deps, set capabilities on elements 2021-04-23 00:42:35 +03:00
Sergey Igushkin
147fd22cfb (minor) Fix static init issue with Gradle multi-threaded resolve 2021-04-23 00:42:35 +03:00
Sergey Igushkin
f1f97b4104 Support published MPP consumption with PM2.0 projects 2021-04-23 00:42:34 +03:00
Sergey Igushkin
70b88ada93 Gradle plugin prototype that uses the project model 2.0 2021-04-23 00:42:34 +03:00
Sergey Igushkin
d66f95b80e Resolve dependencies as graph, support multiple modules in a project 2021-04-22 23:42:06 +03:00
Sergey Igushkin
f1fb438d00 Refactor: make fragments resolver consistent with variant resolver 2021-04-22 23:42:05 +03:00
Sergey Igushkin
7103aa3100 ModuleOrigin -> ModuleIdentifier 2021-04-22 23:42:04 +03:00
Sergey Igushkin
66b8a444c2 Add a basic markdown doc explaining dependency resolution. 2021-04-22 23:42:02 +03:00
Sergey Igushkin
6aee396e4b Build PM2.0 in o.j.k.multiplatform (+ dependency resolution API) 2021-04-22 23:42:01 +03:00
Sergey Igushkin
994f940a31 Dependency resolution API in PM2.0 2021-04-22 23:42:00 +03:00
Sergey Igushkin
f189ebc983 Project Model 2.0 initial commit: core entities 2021-04-22 23:41:59 +03:00
Konstantin Tskhovrebov
6db3960d56 Add integration tests for "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks. 2021-04-22 20:33:20 +03:00
Konstantin Tskhovrebov
c2cdf9c796 Register "assembleAppleFrameworkForXcode" and "embedAndSignAppleFrameworkForXcode" tasks when gradle is run from Xcode.
#KT-27240
2021-04-22 20:33:20 +03:00
Alexander Udalov
99e022d023 IR: minor, remove duplicate visibility field 2021-04-22 17:42:18 +02:00
Dmitriy Novozhilov
d4162f876f [FIR] Fix some warnings 2021-04-22 14:32:06 +03:00
Dmitriy Novozhilov
234ab3b35d [FIR] Fix all illegal usages of declarationSiteSession in compiler
There are still some usages in IDE which should be investigated
2021-04-22 14:32:04 +03:00
Dmitriy Novozhilov
f98f41bbc3 [FIR] Rename session to declarationSiteSession in declaration builders 2021-04-22 14:32:03 +03:00
Dmitriy Novozhilov
c3b1be1a39 [FIR] Rename FirDeclaration.session to declarationSiteSession 2021-04-22 14:32:02 +03:00
Dmitriy Novozhilov
46f5c2073d [FIR] Make most of declarations a sealed classes/interfaces 2021-04-22 14:32:00 +03:00
Dmitriy Novozhilov
7f7373dad2 [FIR] Support sealed classes and interfaces in FIR tree generator 2021-04-22 14:31:59 +03:00
Dmitriy Novozhilov
951daeea3a [FIR] Add typealias to AbstractFirBasedSymbol<*> in FirDiagnosticsList 2021-04-22 14:31:58 +03:00
Vasily Levchenko
1ae41443a2 [kotlin-native][build] clean task fix 2021-04-22 11:16:55 +00:00
Jinseong Jeon
24d792fb49 FIR checker: warn useless elvis 2021-04-22 13:10:54 +03:00
Alexander Udalov
b2005302dc JVM, JVM IR: erase generic SAM supertypes
Also, do not try to use invokedynamic on SAM calls with intersection
types, because intersection type is not allowed as an immediate type
projection of a supertype, and constructing a fake override in
LambdaMetafactoryArgumentsBuilder led to an exception. This fixes the
problem which was worked around earlier in e6c089ef, effectively
reverting that commit.

The main motivation for this change is that LambdaMetafactory also
doesn't generate generic signature for SAM wrapper classes at runtime.
Since these classes are synthetic, nobody should rely on the fact that
they have generic supertypes, which was observable only via Java
reflection.

 #KT-46149 Fixed
 #KT-46238 Fixed
2021-04-22 10:53:15 +02:00
Andrey Zinovyev
1093bffc62 [KAPT] Cache annotation processors' classloaders
Adds experimental feature to cache annotation processors' classloaders
It should increase speed of KAPT for consecutive runs
Works for gradle only (it stores cl in gradle daemon)
#KT-28901 Fixed
2021-04-22 11:51:14 +03:00
Mikhail Glukhikh
e6b9935df9 FIR: drop source-based check from InferenceUtils 2021-04-22 10:26:47 +03:00
sebastian.sellmair
75d9cd3814 [Minor] KotlinLibraryResolverImpl: Improve readability in resolveDependencies 2021-04-21 20:05:57 +00:00
sebastian.sellmair
3c4d0a1814 CInteropCommonizerTask: Mark dependency on commonized native distribution as @Classpath 2021-04-21 20:05:56 +00:00
sebastian.sellmair
f4617b2c03 Do not forward external dependencies on c-interop commonization.
^KT-46109
^KT-46107 Fixed
2021-04-21 20:05:56 +00:00
sebastian.sellmair
22ea5c7de4 Demote fatal error to warning on unresolved libraries mentioned in Klib's manifest 'depends' for metadata compilation
^KT-46107
2021-04-21 20:05:55 +00:00
sebastian.sellmair
95a1a4e66a CommonizerHierarchicalIT: Implement test commonizeHierarchicallyMultiModule
^KT-46107
2021-04-21 20:05:54 +00:00
sebastian.sellmair
5fb30b05ff Implement CommonizerIT.test KT-46234 intermediate source set with only one native target to cover KT-46234
^KT-46234
2021-04-21 20:05:06 +00:00
Ilya Kirillov
e2786197ff FIR IDE: support reporting of FirLightSourceElement based diagnostics 2021-04-21 22:22:32 +03:00
Ilya Kirillov
47e8b2f9dc FIR IDE: remove copy-pasted code from DeclarationCopyBuilder 2021-04-21 21:17:00 +03:00
Ilya Kirillov
a76c5d66eb FIR: introduce FirDeclarationBuilder as a base class for all FIR declaration builders 2021-04-21 21:16:58 +03:00
Ilya Kirillov
da6c5e13d5 FIR IDE: add completion support to classes and to type aliases 2021-04-21 21:16:56 +03:00
Ilya Kirillov
a5c33c8d42 FIR IDE: simplify completion context retrieving 2021-04-21 21:16:55 +03:00
Mikhail Zarechenskiy
f8efe3b5df Make function open to overrie it IDE specific part
Namely, this function is overrided in 211 & 212 platforms, see ScriptDefinitionsManager
2021-04-21 20:00:22 +03:00
Dmitry Petrov
5324cbe729 Minor: update tests 2021-04-21 19:10:32 +03:00
Steven Schäfer
8c9ad81c76 Psi2Ir: Fold constants when generating IR
This is necessary to avoid stack overflow errors on large constant
expressions.
2021-04-21 19:10:31 +03:00
Steven Schäfer
e87d816994 Psi2Ir: Remove unused code 2021-04-21 19:10:31 +03:00
Steven Schäfer
d3d4e94cd6 JVM: Fix constant folding for unsigned values 2021-04-21 19:10:31 +03:00
Dmitry Petrov
732405895f Add tests for KT-45308 2021-04-21 17:36:12 +03:00
Dmitry Petrov
f228c3bb04 Add tests for KT-45236 2021-04-21 17:24:41 +03:00
Yahor Berdnikau
4f352950d9 Include Dukat generated sources into generic 'sourcesJar' output.
Gradle 7 complains that "sourcesJar" task uses inputs from Dukat
generate task outputs directory, but this tasks does not have explicit
dependency.

^KT-46006 Fixed
2021-04-21 16:48:16 +03:00
Mikhail Glukhikh
a097a58edf Introduce helper FirExpression.unwrapArgument() in fir:tree 2021-04-21 16:19:09 +03:00
pyos
e6d923f65c FIR: rename HIDDEN to INVISIBLE_REFERENCE
Some of them should be INVISIBLE_MEMBER though
2021-04-21 16:18:21 +03:00
pyos
f1cf6b54e7 FIR2IR: convert some error calls to non-error IR
This allows suppressing "invisible reference"-type errors, which some
people do in production code.
2021-04-21 16:02:01 +03:00
Mikhail Glukhikh
6833e83a6f Minor fix in FirInlineClassDeclarationChecker 2021-04-21 16:01:51 +03:00
Alexander Udalov
7fe10e27a1 Minor, fix failing codegen tests on different JDKs
#KT-46238
2021-04-21 14:43:10 +02:00
Anton Yalyshev
fe5e968896 Add change-notes for 1.5.0 release 2021-04-21 14:13:46 +03:00
Vladimir Dolzhenko
590a8d088d Refine locking to avoid dead lock
#KT-46215 Fixed
2021-04-21 11:01:12 +00:00
Mikhail Glukhikh
6ae4c3f281 Drop state from FirMethodOfAnyImplementedInInterfaceChecker 2021-04-21 13:22:14 +03:00
Mikhail Glukhikh
e0fe122ee9 Drop stored types from FirInlineClassDeclarationChecker 2021-04-21 13:22:13 +03:00
Mikhail Glukhikh
9bc3404833 Drop state from FirInapplicableLateinitChecker 2021-04-21 13:22:11 +03:00
Mikhail Glukhikh
e0c8a6658b FIR: handle annotations on non-containers more precisely 2021-04-21 13:22:10 +03:00
Mikhail Glukhikh
04daf8fce8 FIR: add messages for two accessor diagnostics 2021-04-21 13:22:09 +03:00
Julia
387dafb8c5 [FIR] Introduce AnnotationUsedAsAnnotationArgumentChecker 2021-04-21 13:22:07 +03:00
Alexander Udalov
27ddc31f15 Ignore codegen test using streams on Android 2021-04-21 11:39:08 +02:00
Dmitry Petrov
59de12c609 Minor: mute bytecode text check in some box tests failing in FIR 2021-04-21 11:27:12 +03:00
Dmitry Petrov
f519150c08 JVM_IR KT-46189 lower tailrec functions after local declarations 2021-04-21 11:27:11 +03:00
Sergey Bogolepov
645014092c Add a mention of KT-46231. 2021-04-21 15:14:33 +07:00
Ilya Gorbunov
4ae5efd6da Prevent calling AssertContentEquals with two Set arguments
It's unclear whether these sets are intended to be compared with
the unordered Set equality, or with the ordered Iterable equality.

KT-32996
2021-04-21 03:08:35 +03:00
Alexander Udalov
21e9bd7ea2 Add regression tests for obsolete issues
#KT-9304
 #KT-14961
 #KT-16549
 #KT-21080
 #KT-28234
 #KT-30102
 #KT-31994
 #KT-34291
 #KT-38099
 #KT-41174
 #KT-44622
 #KT-44701
 #KT-44781
 #KT-44849
 #KT-44978
 #KT-45081
 #KT-45286
 #KT-45383
 #KT-45444
 #KT-45907
2021-04-20 21:24:29 +02:00
Ivan Gavrilovic
2666a93e6a [Gradle] Avoid using dependsOn and add output provider to the file collection 2021-04-20 22:13:25 +03:00
Alexander Udalov
e6c089ef40 IR: fix SAM conversion for types with contravariant intersection argument type
In the added test, the problem was that the SAM type as computed by
`SamTypeFactory.createByValueParameter` was `Consumer<{BaseClass &
BaseInterface}>`, which was latter approximated in psi2ir during the
KotlinType->IrType conversion to `Consumer<out Any?>` (here:
3034d9d791/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt (L606)),
because intersection type argument is approximated to `out Any?`.

To avoid this, replace intersection type in immediate arguments of a SAM
type with the common supertype of its components at the same place where
we're getting rid of projections.

 #KT-45945 Fixed
2021-04-20 17:31:14 +02:00
Andrey Zinovyev
ac0af39660 [FIR][LT] Enable parallel execution for LT tests 2021-04-20 18:13:07 +03:00
Andrey Zinovyev
0a811bdd1a [FIR][LT] Don't store lexer in static context 2021-04-20 18:13:06 +03:00
Andrey Zinovyev
5fc1514104 [FIR][LightTree] Better expression identification
And some refactoring
Regenerate IDE parts
2021-04-20 18:13:06 +03:00
Andrey Zinovyev
2f7d6da22f [FIR][LightTree] Generate and fix missing tests
Add TYPE_PARAMETERS_LIST positioning
Use whole branch as source in when branches
2021-04-20 18:13:05 +03:00
Andrey Zinovyev
b9ae22207e [FIR] Fix tests data for diagnostic tests
For tests failed after light tree changes
2021-04-20 18:13:03 +03:00
Andrey Zinovyev
ee48fc320d [FIR][LightTree] Mark fake nodes in FOR loop
+ fix bunch of tests
2021-04-20 18:13:02 +03:00
Andrey Zinovyev
0a68edf3bd [FIR][LightTree] More fixes in diagnostic positioning
Keep tree padding for modifiers
More REFERENCE_EXPRESSIONS kinds
Fix source for some call expressions
2021-04-20 18:13:01 +03:00
Andrey Zinovyev
f3dc8dfb21 [FIR][LightTree] Use same fake elements kinds as in psi
Otherwise type resolution(!) for empty lambda works differently
2021-04-20 18:13:00 +03:00
Andrey Zinovyev
e8e9f67069 [FIR][LightTree] Enum and property source fixes
Also set dispatchReceiverType for properties from value params
2021-04-20 18:12:59 +03:00
Andrey Zinovyev
1fb8c3b1d7 [FIR][LightTree] Properly unwrap function inside parentheses 2021-04-20 18:12:58 +03:00
Andrey Zinovyev
05f0507cbb [FIR][LightTree] Proper source for enum constructor call 2021-04-20 18:12:57 +03:00
Andrey Zinovyev
bed45affe1 [FIR][LightTree] Don't report diagnostics on some nameless declarations 2021-04-20 18:12:56 +03:00
Andrey Zinovyev
684c4c2825 [FIR][LightTree] Don't position on trailing comments 2021-04-20 18:12:55 +03:00
Andrey Zinovyev
0d99b01dcb [FIR][LightTree] Pass source elements in FOR loop parts 2021-04-20 18:12:54 +03:00
Andrey Zinovyev
8bbdc20809 [FIR][LightTree] Pass source elements in when conditions 2021-04-20 18:12:54 +03:00
Andrey Zinovyev
9c8e92f5af [FIR][LightTree] Fix DEFAULT positioning strategy for object literals 2021-04-20 18:12:53 +03:00
Andrey Zinovyev
70f9b77cce [FIR][LightTree] Keep source in FOR loop elements 2021-04-20 18:12:52 +03:00
Andrey Zinovyev
27766c2575 [FIR] Consistent isLocal for objects inside Enum entries 2021-04-20 18:12:51 +03:00
Andrey Zinovyev
7084fec651 [FIR][LightTree] Position strategies fixes
Skip leading comments in DEFAULT strategy
Keep node offset 'padding' when getting child
2021-04-20 18:12:50 +03:00
Andrey Zinovyev
8ea3b52454 [FIR][LightTree] Fix finding error nodes in tree
When there are links to to 'upper levels' lt elements in fir tree
2021-04-20 18:12:49 +03:00
Andrey Zinovyev
dc19e39dd2 [FIR][LightTree] Properly locate return keyword 2021-04-20 18:12:47 +03:00
Andrey Zinovyev
088db0e138 [FIR] Report SEALED_CLASS_CONSTRUCTOR_CALL on expression 2021-04-20 18:12:46 +03:00
Andrey Zinovyev
48994976d4 [FIR][LightTree] Skip comments and whitespaces when marking elements 2021-04-20 18:12:45 +03:00
Andrey Zinovyev
dcbb1fb22b [FIR][LightTree] Extract syntax errors from subtrees 2021-04-20 18:12:45 +03:00
Andrey Zinovyev
7dedd04ed9 [FIR] Add SYNTAX diagnostics for light tree 2021-04-20 18:12:43 +03:00
Dmitriy Novozhilov
3e0eb06e3e [FIR] Add FirOldFrontendDiagnosticsWithLightTreeTestGenerated 2021-04-20 18:12:42 +03:00
Igor Yakovlev
e4870740e1 [LC] Fixed light classes nullability for Kotlin 1.5
Fixed #KT-44472
2021-04-20 15:21:12 +02:00
Igor Yakovlev
63160293fb [LC] Fix invalid nullability for properties
Fixed #KT-46097 and #KT-41671
2021-04-20 15:21:12 +02:00
Andrey Zinovyev
8071a1e246 [KAPT] Keep constant references in annotations with array values
#KT-29929 Fixed
2021-04-20 15:47:03 +03:00
Yahor Berdnikau
9e9450caa2 Fix adding associated compilation for Kotlin Native.
Kotlin native does not support 'compileOnly' or 'runtimeOnly'
configurations. In this case associated compilations are added as
'implementation'.

^KT-45911 Fixed
2021-04-20 10:15:15 +02:00
Abduqodiri Qurbonzoda
57c4f79c1c Update Char.digitToInt documentation 2021-04-20 04:36:05 +03:00
Ilya Kirillov
26e39b3d2a FIR IDE: do not resolve all members for getting inner classes for light classes 2021-04-20 01:32:26 +03:00
Ilya Kirillov
051310124b FIR IDE: do not fail duplicating classes with members 2021-04-20 01:32:25 +03:00
Mark Punzalan
73b796f184 FIR IDE: Enable RemoveExclExclCallFix for UNNECESSARY_NON_NULL_ASSERTION. 2021-04-19 22:29:07 +02:00
Mark Punzalan
34609b264d FIR IDE: Move RemoveExclExclCallFix to idea-frontend-independent. 2021-04-19 22:29:07 +02:00
Alexander Udalov
4fffed4165 Improve test on equals/hashCode for KProperty accessors
Remove duplication & unnecessary checks, check equality in both
directions, check hashCode, add more cases, rename variables for
clarity.

 #KT-13490
2021-04-19 20:39:54 +02:00
Xin Wang
c959b271a4 Override "hashCode" and "equals" for Getter and Setter to fix KT-13490 2021-04-19 20:39:54 +02:00
Dmitry Petrov
46d5e974df JVM_IR KT-46160 don't use LambdaMetafactory for mutifile class members 2021-04-19 19:32:34 +03:00
yantimirov-timur
1dfc3c0520 FIR: add getter visibility and setter return type checks 2021-04-19 19:21:09 +03:00
Abduqodiri Qurbonzoda
eedc4d8c3f [K/N] Fix measureTimeMillis and measureNanoTime doc 2021-04-19 19:14:34 +03:00
Abduqodiri Qurbonzoda
aa04f60df4 [K/N] Fix Floating.toInt/toLong doc 2021-04-19 19:14:33 +03:00
Abduqodiri Qurbonzoda
4c66c1c137 [K/N] Fix Primitive.shl/shr/ushr doc 2021-04-19 19:14:32 +03:00
Abduqodiri Qurbonzoda
19ecb78531 [K/N] Fix Primitive.rem doc 2021-04-19 19:14:30 +03:00
Abduqodiri Qurbonzoda
2cfbad9477 [K/N] Fix Primitive.div doc 2021-04-19 19:14:29 +03:00
Abduqodiri Qurbonzoda
b5e3dc414f Fix Array.iterator doc 2021-04-19 19:14:28 +03:00
Abduqodiri Qurbonzoda
8a1855e4da [K/N] Fix Range.isEmpty doc 2021-04-19 19:14:27 +03:00
Abduqodiri Qurbonzoda
71c5c8b20a Fix Range.isEmpty doc 2021-04-19 19:14:25 +03:00
Abduqodiri Qurbonzoda
fb4ddd2f6e [K/N] Fix StringBuilder.deleteRange doc 2021-04-19 19:14:23 +03:00
Abduqodiri Qurbonzoda
76b297fd73 [K/N] Fix StringBuilder.clear doc 2021-04-19 19:14:21 +03:00
Abduqodiri Qurbonzoda
597b18582a [K/N] Fix Char.isISOControl doc 2021-04-19 19:14:19 +03:00
Abduqodiri Qurbonzoda
bb2a50a4eb Fix Char.isISOControl doc 2021-04-19 19:14:17 +03:00
Abduqodiri Qurbonzoda
d1f18c4651 Add @see doc references to java isUpperCase and isLowerCase 2021-04-19 19:14:14 +03:00
Abduqodiri Qurbonzoda
22dcc92951 Fix Char.isTitleCase doc 2021-04-19 19:14:13 +03:00
Abduqodiri Qurbonzoda
e83ceb9d40 [K/N] Fix String.replace doc 2021-04-19 19:14:11 +03:00
Abduqodiri Qurbonzoda
36aee8f2b4 Fix String.replace doc 2021-04-19 19:14:10 +03:00
Abduqodiri Qurbonzoda
dab09e7052 Fix CharSequence.repeat doc 2021-04-19 19:14:08 +03:00
Ilya Goncharov
c73dadbcdf [Gradle, JS] Install dukat only if there is dependency with generateExternals
^KT-46178 fixed
2021-04-19 17:29:51 +03:00
pyos
dab693b075 Revert "JVM IR: Implement CHECK_NOT_NULL as a lowering"
This reverts commit dcd72b06d8.

Using a temporary variable has an effect on casts and GC.
2021-04-19 16:05:12 +02:00
Ilmir Usmanov
f5379c5a04 Add @JvmInline annotation in common code if JVM target is present
#KTIJ-8863 Fixed
 #KT-46088 Fixed
2021-04-19 16:56:31 +03:00
Ivan Kochurkin
00bc04b3df [FIR] Implement ELSE_MISPLACED_IN_WHEN diagnostics, fix tests 2021-04-19 15:46:38 +03:00
Dmitry Petrov
7f4da93cc3 JVM_IR KT-45998 protected companion object member accessors with indy 2021-04-19 15:41:21 +03:00
Dmitry Petrov
9a4a39e680 JVM_IR KT-45998 fix protected companion object member accessors
Also, make sure it works with indy-based SAM conversions.
2021-04-19 15:41:19 +03:00
Mikhail Glukhikh
b1fb0ba9e1 Fix FirDiagnosticsList (remove earlier dropped FirSourceElements) 2021-04-19 15:29:07 +03:00
Mikhail Glukhikh
8a2cab346a Fix FIR IDE tests (EXPRESSION_EXPECTED, ITERATOR_MISSING, etc.) 2021-04-19 15:11:17 +03:00
Tianyu Geng
b5caa658d6 FIR: introduce delegate diagnostics
This commit adds diagnostics for the following

* DELEGATE_SPECIAL_FUNCTION_MISSING
* DELEGATE_SPECIAL_FUNCTION_AMBIGUITY
* DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
2021-04-19 15:11:16 +03:00
Tianyu Geng
454ae3b17a FIR checker: report UNSAFE_CALL for overloaded function calls
Previously if an unsafe call is to an overloaded function, FIR checkers
report NONE_APPLICABLE. This change instead report them as UNSAFE_CALL
or its variants.
2021-04-19 15:11:13 +03:00
Mikhail Glukhikh
92df1f575a Fir2IrVisitor: simplify creating for-loop blocks due to changed FIR side 2021-04-19 15:11:13 +03:00
Tianyu Geng
6a03f31e50 FIR: add UnsafeCall resolution diagnostics
Previously unsafe call is reported as part of InapplicableWrongReceiver.
This makes it difficult for the downstream checkers to report different
diagnostics.
2021-04-19 15:11:13 +03:00
Mikhail Glukhikh
43a2ad0467 FIR: don't flatten for loop blocks in raw FIR builder 2021-04-19 15:11:12 +03:00
Mikhail Glukhikh
a736d62edd FirForLoopChecker: report also OPERATOR_MODIFIER if appropriate + minor
This commits checks iterator/hasNext/next functions whether they are
declared as operator or not. Also, it changes logic of hasNext/next
error reporting, now we're able to report errors about both these
functions.
2021-04-19 15:11:10 +03:00
Mikhail Glukhikh
2e14b65644 Introduce FirForLoopChecker 2021-04-19 15:10:58 +03:00
Mikhail Glukhikh
4ddc0ed3fe FIR: introduce block checkers 2021-04-19 15:10:39 +03:00
Mikhail Glukhikh
eb831b9afc FIR: support separate ANONYMOUS_FUNCTION_WITH_NAME 2021-04-19 15:10:38 +03:00
Mikhail Glukhikh
6b95bcdbdb FIR: support separate ASSIGNMENT_IN_EXPRESSION_CONTEXT 2021-04-19 15:10:18 +03:00
Mikhail Glukhikh
9894b97058 FIR: rename EXPRESSION_REQUIRED to EXPRESSION_EXPECTED 2021-04-19 15:09:50 +03:00
Ilya Kirillov
26ea0be635 FIR IDE: temporary update testdata until diagnostic collection for delegated objects is fixed 2021-04-19 13:52:47 +02:00
Ilya Kirillov
f40f506852 FIR: move components from AbstractDiagnosticCollectorVisitor to CheckerRunningDiagnosticCollectorVisitor 2021-04-19 13:52:46 +02:00
Ilya Kirillov
ea233cddf8 FIR: rename goToNestedDeclarations -> visitNestedElements 2021-04-19 13:52:46 +02:00
Ilya Kirillov
eed143d17b FIR: remove beforeRunningAllComponentsOnElement/beforeRunningSingleComponentOnElement from AbstractDiagnosticCollectorVisitor 2021-04-19 13:52:45 +02:00
Ilya Kirillov
41e822e8cb FIR IDE: fix duplicated diagnostic collection 2021-04-19 13:52:44 +02:00
Ilya Kirillov
5829f1a6e7 FIR IDE: add more test cases to TraversalCounterTestGenerated 2021-04-19 13:52:43 +02:00
Ilya Kirillov
e78e8f8c79 FIR IDE: fix behaviour of DiagnosticTraversalCounterTest 2021-04-19 13:52:43 +02:00
Ilya Kirillov
32c1101959 FIR IDE: introduce tests for checking diagnostic visitor context collection 2021-04-19 13:52:42 +02:00
Ilya Kirillov
ac993754e1 FIR IDE: collect diagnostics context under read lock 2021-04-19 13:52:41 +02:00
Ilya Kirillov
ce62348709 FIR IDE: do not report suppressed diagnostics 2021-04-19 13:52:41 +02:00
Ilya Kirillov
fd082b1574 FIR IDE: get rid of DiagnosticCollectorDeclarationAction 2021-04-19 13:52:40 +02:00
Ilya Kirillov
e79c133331 FIR IDE: separate diagnostics collection and checker context collection 2021-04-19 13:52:39 +02:00
Ilya Kirillov
29a0c448a6 FIR IDE: remove FirIdeFileDiagnosticsCollector as unused 2021-04-19 13:52:38 +02:00
Ilya Kirillov
023f4e9f46 FIR: extract DiagnosticCollectingVisitor to separate file 2021-04-19 13:52:38 +02:00
Ilya Kirillov
f9d415eda6 FIR: make AbstractDiagnosticCollector.Visitor non-inner 2021-04-19 13:52:37 +02:00
Ilya Kirillov
284e828cd6 FIR: extract context related functions from AbstractDiagnosticCollector.Visitor to super class 2021-04-19 13:52:36 +02:00
Dmitriy Novozhilov
e3b5cc491d [Test] Throw exception from compiler at a first place 2021-04-19 14:32:37 +03:00
Dmitriy Novozhilov
7fb2bf00c5 Force resolve annotations in annotation checker
#KT-46173 Fixed
2021-04-19 14:32:36 +03:00
Dmitriy Novozhilov
83bae89ed8 [Test] Show diff between fir file and testdata text if FE 1.0 and FIR test files don't match 2021-04-19 14:32:35 +03:00
Ivan Kochurkin
4353365968 [FIR] Implement NULL_FOR_NONNULL_TYPE diagnostics, fix tests 2021-04-19 12:46:08 +03:00
sebastian.sellmair
9336e4b09b HierarchicalKotlinNativePlatformDependencies: Provide platform dependencies to source sets not participating in any commonization
^KT-46142 Verification Pending
2021-04-17 14:58:15 +00:00
Aleksei.Cherepanov
b5ef6c9316 Add tests for SAM conversions
Add tests for KT-45191 [JPS] Marking method as "default" in Java SAM interface doesn't affect dependencies, which was fixed in intlellij(212): cbad0d91 support kotlin-generated lambda usage

#KT-45191 Fixed
2021-04-17 03:36:17 +03:00
Andrei Klunnyi
81a5ae7780 KT-44431 Quickfix to move to sealed: suggests tests source root
From now on we display the source root matching the target directory.

^KT-44431 Fixed
2021-04-16 19:38:52 +02:00
Andrei Klunnyi
eed4cb4f00 KT-44431 Quickfix to move to sealed: refactoring
Sealed super class directory is now calculated in a more
straightforward way.
2021-04-16 19:38:52 +02:00
Abduqodiri Qurbonzoda
3a8d1c4b5e Remove redundant @OptIn 2021-04-16 19:01:28 +03:00
Abduqodiri Qurbonzoda
f253b1fb15 Incorrect description for JVM toUpperCase method #KT-45884 2021-04-16 19:01:09 +03:00
Ilmir Usmanov
7b14975740 Add 'value' modifier to modifier order
Otherwise, there will be unfixable 'non-canonical modifier order'
warning
 #KT-46088
 #KTIJ-5636 Fixed
2021-04-16 18:51:44 +03:00
sebastian.sellmair
7525d9a1ce KotlinNativeTest: Append stdOut and stdErr to failure message 2021-04-16 14:56:33 +00:00
sebastian.sellmair
05a6d89151 [Minor] Re-format :kotlin-klib-commonizer and :kotlin-klib-commonizer-api 2021-04-16 14:56:32 +00:00
sebastian.sellmair
f893709e5b [Commonizer] CommonizeLibcurlTest: Add commonizeSuccessfully with unsupported targets
This test will assert behaviour on 'unsupported' targets requested from the commonizer

^KT-46077
2021-04-16 14:56:31 +00:00
sebastian.sellmair
bbcfde7231 [Commonizer] Add 'commonizer_target' and 'commonizer_native_targets' to commonized klib's manifest
^KT-46077 Fixed
2021-04-16 14:56:31 +00:00
Alexander Likhachev
6f96c225d7 [Gradle, K/N] Prefer injection over lateinit vars for task configuration
#KT-45801 Fixed
2021-04-16 17:39:53 +03:00
Dmitriy Novozhilov
b530427bb2 Fix substitution of generic types in contracts
#KT-41078 Fixed
2021-04-16 17:23:24 +03:00
Dmitriy Novozhilov
91fedd6a12 [FIR] Substitute types from arguments in evaluating of contract
#KT-41078
2021-04-16 17:23:22 +03:00
Anton Lakotka
80f95528c2 [MPP] Always use native plugin artifact for native compilations
#KT-46122 Fixed
2021-04-16 16:25:06 +03:00
Anton Lakotka
d75d42da9d [MPP] Test that native common compilation uses native plugin artifacts
#KT-46122 In Progress
2021-04-16 16:25:04 +03:00
Dmitriy Novozhilov
c65553bb8a [FIR] Get rid of source element type parameter from diagnostic factories 2021-04-16 14:08:11 +03:00
Dmitriy Novozhilov
4133f38c8c [FIR] Transform annotations of property receiver type 2021-04-16 11:12:56 +03:00
Dmitriy Novozhilov
564de2790f [FIR] Resolve array literals in independent context 2021-04-16 11:12:56 +03:00
Dmitriy Novozhilov
cc0f28b698 [FIR] Store type of function call and qualified access from error reference 2021-04-16 11:12:56 +03:00
Dmitriy Novozhilov
e869f8091a [FIR] Properly handle callable references which were resolved with error 2021-04-16 11:12:55 +03:00
Dmitriy Novozhilov
450fb5e915 [Test] Add handler to detect implicit types which were left in resolved FIR 2021-04-16 10:52:58 +03:00
Ilya Gorbunov
ce7092a638 More efficient Char(Int) in common, JS, and JS-IR 2021-04-16 03:58:34 +03:00
Ilya Gorbunov
8041c3aa1d Support Char.code in constant evaluator, KT-46036
But do not consider Char.code a pure integer constant.
2021-04-16 03:58:34 +03:00
Alexander Udalov
0a446230f7 Reorder LanguageFeature entries according to sinceVersion 2021-04-15 21:41:17 +02:00
Alexander Udalov
168d8b07a8 Minor, fix warnings on new stdlib API
In modules where allWarningsAsErrors is not yet enabled.
2021-04-15 18:39:06 +02:00
Dmitry Petrov
e89ab71bf8 JVM_IR KT-45934 don't generate declaration stubs for delegates 2021-04-15 17:59:19 +03:00
Dmitry Petrov
cc415f62b5 JVM_IR KT-46092 fix array spread operator in Kotlin->Java call 2021-04-15 17:11:21 +03:00
Pavel Punegov
b5fae96934 [native][tests] Fix incorrect enum in ExecutorService 2021-04-15 16:54:25 +03:00
Pavel Punegov
5903d015b8 [native][tests] Change architecture requirements in simulator executor
This requirement doesn't work for watchos_x86 on macos_x64 so create
a list of compatible requirements.
2021-04-15 13:34:00 +00:00
Mikhail Glukhikh
9b3f1b9b8a Inference: handle Exact constraints with captured types properly
#KT-41818 Fixed
2021-04-15 15:55:41 +03:00
Mikhail Glukhikh
51d348d5fa FIR: report FUN_INTERFACE_CONSTRUCTOR_REFERENCE on deserialized properly
This fixes KT-46100 for FIR
2021-04-15 15:54:18 +03:00
Ilya Kirillov
676e29e96e fix up: do not read declaration phase without read lock hold 2021-04-15 15:24:04 +03:00
Ilya Kirillov
d7e3c65c45 FIR: add renderDeclarationOrigin to FirRender 2021-04-15 15:24:02 +03:00
Ilya Kirillov
0e98480be3 FIR: update resolve phase for declaration when visiting with FirContractResolveTransformer 2021-04-15 15:24:01 +03:00
Ilya Kirillov
5de4c5fc28 FIR: allow declaring specific set of parameters for FirRenderer 2021-04-15 15:24:00 +03:00
Ilya Kirillov
fee83051e9 FIR: encapsulate creating of cli-only session components into single function 2021-04-15 15:23:59 +03:00
Ilya Kirillov
0a80fbb078 FIR IDE: do not read declaration phase without read lock hold 2021-04-15 15:23:57 +03:00
Ilya Kirillov
0cf00d0f72 FIR: fix FirDefaultPropertyAccessor phase to BODY_RESOLVE 2021-04-15 15:23:56 +03:00
Ilya Kirillov
39b2cd1027 FIR: do not provide symbols with different ClassId in JavaSymbolProvider
JavaSymbolProvider uses KotlinPsiElementFinderWrapper for finding classes.
CliFinder looks for Java classing assuming that class with ClassId=a/b/C
lives in directory a/b and do not look into real package name of Java class.
This causes that we may find some classes which we should not see from current scope.

Also, the IDE implementation works correctly here (it also checks file package)
which cause different behaviour of FIR IDE and FIR

This change also requires to fix testdata and make Java classes live
in directory consistent with file package
2021-04-15 15:23:53 +03:00
pyos
82cadba80b FIR: report errors on FirResolvedTypeRef with ConeClassErrorType
Not sure what the difference from FirErrorTypeRef is.
2021-04-15 14:59:30 +03:00
pyos
474d1d48f7 FIR: allow fun T.() = ... as an instance of (T) -> ...
It was already done by the previous commit by mistake, but it broke if
there are other value parameters because the type of the first parameter
would be inferred to be same as the type of the receiver.
2021-04-15 14:59:29 +03:00
pyos
0a25550fc2 FIR: allow fun (x: T) ... as an instance of T.() -> ...
and disallow > 1 implicit parameters in lambdas.
2021-04-15 14:59:28 +03:00
pyos
354acc1fd5 FIR: permit * as FunctionN type argument
`() -> *` is not valid, but `F<*>` where `typealias F<T> = () -> T` is.
2021-04-15 14:59:27 +03:00
Denis.Zharkov
32dacc37c0 FIR: Fix OverloadResolutionByLambdaReturnType case 2021-04-15 14:48:20 +03:00
Ilmir Usmanov
1c48fb28db Generate return when generating continuation class for expression body
Otherwise, the function will return Unit instead of correct value.
 #KT-46007 Fixed
2021-04-15 13:54:45 +03:00
Simon Ogorodnik
539d3e5df2 Add full-pipeline modularized tests for old frontend 2021-04-15 13:36:00 +03:00
Ivan Gavrilovic
11b92bc597 [Gradle] Fix init script for coroutines
Use doFirst instead of beforeTask to add javaagent args for coroutines debugging.
2021-04-15 12:39:25 +03:00
Andrei Klunnyi
2bb7f6a168 KT-45347 Quickfix to move to sealed parent: do not suggest for binaries
^KT-45347 Fixed
2021-04-15 11:17:36 +02:00
Svyatoslav Scherbina
d531df1643 Native: add KotlinThrowable.asError() to the generated Obj-C framework
This method can be useful when overriding a throwing Kotlin method in
Swift or Obj-C. In this case, a user can call asError to wrap Kotlin exception
to (NS)Error and then throw it to Kotlin, which will unwrap it back.

^KT-45127 Fixed
2021-04-15 08:21:30 +00:00
Pavel Punegov
c988ecf59b Ignore test in native backend due to the KT-44037 (KT-38181) 2021-04-15 07:59:26 +00:00
Pavel Punegov
d07c990fc2 Add test to native ignore list due to the KT-44571 2021-04-15 07:59:25 +00:00
Pavel Punegov
0f5edaa02f Ignore test in the native backend. It redefines JvmInline class 2021-04-15 07:59:24 +00:00
Pavel Punegov
ca4cebf3e3 Exclude test in native backend due to KT-42020.
Also return back two tests for fixed KT-42684 and KT-45139
2021-04-15 07:59:23 +00:00
Pavel Punegov
6aa7628808 Fixes to Kotlin/Native test directives infrastructure.
* parse files and modules separately
* fix default and support modules usage
* add another way to ignore backend (new directive)
* add new test to exclude list
2021-04-15 07:59:22 +00:00
Alexander Gorshenev
7d13aaad24 Native klib testing: a binary compatibility tweak.
Link versioned libraries against dependencies of the same version.
2021-04-15 07:59:21 +00:00
Tianyu Geng
4d2e3a2379 FIR: Fix resolving += to ignore + if it doesn't return correct type
This is the FIR fix of the FE change tracked by
https://youtrack.jetbrains.com/issue/KT-45503

Consider the following code:

```
fun foo() {
  var l = mutableListOf("")
  l += ""
}
```

The above code used to be considered invalid due to ambiguous `+=`. But
after KT-45503, it's now considered valid code because `plus` is not
really a valid option for this code. This is because the return type
of `plus` for `List` is `List`, which does not match the type of
variable `l`.

As for now, FIR rejects the above code due to ambiguous `+=`. This
change fixes that by also consider the return type when resolving `+=`.
2021-04-15 10:34:05 +03:00
Tianyu Geng
c43faa2ada FIR: refactor FirExpressionsResolveTransformer#transformAssignmentOperatorStatement
No logic change. This commit only rearrange stuff to make it cleaner
2021-04-15 10:34:04 +03:00
Dmitriy Novozhilov
861f69822b [FIR] Fix infinite recursion of ConeDefinitelyNotNullType 2021-04-15 10:30:29 +03:00
Dmitriy Novozhilov
7c6a9aa963 [FIR] Store cachedExpandedType in WeakPair instead of usual Pair
WeakPair is a renamed OneElementWeakMap
2021-04-15 10:30:29 +03:00
Dmitriy Novozhilov
dd96c3b56e [FIR] Turn some checkers into classes to prevent memory leaks
This is temporary solution until those checkers will be fixed
#KT-46058
2021-04-15 10:30:29 +03:00
Dmitriy Novozhilov
085bddbfc0 [FIR] Force checker components to create checkers sets on each access
This is needed to add ability to recreate checkers which are not objects
  for each session
2021-04-15 10:30:26 +03:00
Dmitriy Novozhilov
1f62a2d8cc [FIR] Add disposing of FirJavaElementFinder in FIR compiler entrypoint 2021-04-15 10:30:09 +03:00
Mark Punzalan
957f6ddafd FIR checker: Enable ReplaceWithDotCallFix for UNNECESSARY_SAFE_CALL. 2021-04-14 22:30:42 +02:00
Dmitry Petrov
f1eeb72c01 PSI2IR KT-46069 resolve IR-based type parameter descriptors to symbols 2021-04-14 21:27:01 +03:00
Anton Bannykh
ba80086ae3 JS PIR generator: eliminate deprecated String.capitalize 2021-04-14 21:04:39 +03:00
Mikhail Glukhikh
4c13fe5631 FIR: handle SAM constructor properly in visibility checker
#KT-46074 Fixed
2021-04-14 20:50:54 +03:00
ebukreev
d8a2f82cbd FIR: inroduce FirFunInterfaceConstructorReferenceChecker 2021-04-14 19:53:43 +03:00
Dmitry Petrov
531a0de399 JVM_IR KT-46060 'contains' operator without receiver is non-optimizable 2021-04-14 19:18:42 +03:00
Mark Punzalan
21a3a14289 FIR: Use intersection of all upper bounds for parameterized types in
ConeKotlinType.canBeNull.

^KT-45903 In progress
2021-04-14 19:17:10 +03:00
Andrei Klunnyi
ac85f9d983 KT-45348 Sealed Inheritors Inspection: binary Kotlin parent is ignored
^KT-45348 Fixed
2021-04-14 18:12:28 +02:00
Ilya Kirillov
0051451ed7 FIR: add error message when FirBasedSymbol.fir is not initialized 2021-04-14 18:37:35 +03:00
Dmitriy Novozhilov
69ff45971f Suppress HIDDEN diagnostics from FIR to fix FIR bootstrap compilation 2021-04-14 18:30:56 +03:00
Dmitriy Novozhilov
1f0ecade34 [FIR] Transform annotations of type refs in body resolve stage
Also fix building CFG for annotation calls
2021-04-14 18:30:56 +03:00
Dmitriy Novozhilov
aec13defc4 [Test] Add proper annotation target in SupertypesAndBounds test 2021-04-14 18:30:55 +03:00
Dmitriy Novozhilov
0b2943d34c Prohibit using annotations without TYPE target in several type positions
#KT-8325 Fixed
#KT-19455 Fixed
#KT-25876 Fixed
#KT-28449 Fixed
2021-04-14 18:30:54 +03:00
Dmitriy Novozhilov
1cff17bb58 Cleanup ConstantExpressionEvaluator 2021-04-14 18:30:53 +03:00
Dmitriy Novozhilov
bee2a69e21 Implement new logic of approximation of integer literals in position of receiver
#KT-38895 In Progress
2021-04-14 18:30:52 +03:00
Dmitriy Novozhilov
6afb905ad6 Add deprecation warning about new integer operators on literals resolution
#KT-38895
2021-04-14 18:30:51 +03:00
Dmitriy Novozhilov
53b6d6f767 Prohibit references to members of containing class in super constructor of nested object
#KT-25289 In Progress
2021-04-14 18:30:49 +03:00
Andrey Zinovyev
3c093f57ba [FIR] Add DYNAMIC_UPPER_BOUND check
+Fix some failing diagnostic tests
+Use PositioningStrategy to locate reified modifier
2021-04-14 18:11:18 +03:00
Andrey Zinovyev
0d525bbe85 [FIR] Add MISPLACED_TYPE_PARAMETER_CONSTRAINTS check 2021-04-14 18:11:17 +03:00
Andrey Zinovyev
412b941486 [FIR] Add DEPRECATED_TYPE_PARAMETER_SYNTAX check 2021-04-14 18:11:16 +03:00
Andrey Zinovyev
2b8c22c08a [FIR] Add CYCLIC_GENERIC_UPPER_BOUND check 2021-04-14 18:11:14 +03:00
Andrey Zinovyev
03215f4e0a [FIR] Add TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER check 2021-04-14 18:11:13 +03:00
Andrey Zinovyev
470993ac07 [FIR] Add TYPE_PARAMETERS_NOT_ALLOWED check 2021-04-14 18:11:12 +03:00
Andrey Zinovyev
5ff82addc9 [FIR] Add REIFIED_TYPE_PARAMETER_NO_INLINE check 2021-04-14 18:11:10 +03:00
Andrey Zinovyev
14fe570a00 [FIR] Add more type params checks
VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED
BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED
2021-04-14 18:11:09 +03:00
Andrei Klunnyi
fb1b253d1e KT-46063 Quick fix: remaining when branches for 'expect' sealed
'List<WhenMissingCase>.hasUnknown' property was changed in 4222bb9a.
As a result quickfix's AddWhenRemainingBranchesFix.Companion.isAvailable
started responding 'no'.
This commit restores original property and provides a separate one for
compiler needs.

^KT-46063 Fixed
2021-04-14 15:57:15 +02:00
Alexander Udalov
005aa57f6d Remove obsolete module cli-js-klib
It's no longer used anywhere in the build.
2021-04-14 13:47:02 +02:00
Alexander Udalov
988d1365a8 Remove dependency of backend.wasm on ir.tree.impl and ir.tree.persistent 2021-04-14 13:47:02 +02:00
Alexander Udalov
643c3f26c1 Remove dependency of backend.js on ir.tree.impl
By taking the instance of IrFactory either from SymbolTable, or passing
it from cli-js which depends on both ir.tree.impl and
ir.tree.persistent, and can choose the appropriate implementation.
2021-04-14 13:47:02 +02:00
Alexander Udalov
9aed55a1f4 IR: minor, improve toString for IrBasedTypeParameterDescriptor
The motivation is that in the "Unbound symbols are not allowed" error
message like the one in KT-46069, the type parameter is rendered via
`render()`, and that contains only its name/variance, and doesn't help
in finding where the member with that type parameter is declared.
2021-04-14 13:16:05 +02:00
Ting-Yuan Huang
6c989bfd4b Support array of annotation in KotlinJvmBinaryClass
KotlinJvmBinaryClass.AnnotationArrayArgumentVisitor didn't cover the
case when the element type is an Annotation. Therefore, when the
compiler read an array of annotations from JVM binary classes built from
Kotlin sources, it got an empty array regardless of what was written in
the bytecode.

For example, Foo.value below is read as an empty array when SomeClass
resides in another Kotlin module.

  @Foo(
    value = [Bar(1), Bar(2)]
  )
  class SomeClass
2021-04-14 13:14:26 +02:00
Dmitriy Dolovov
5e392a511f [K/N][IR] Generate missing return when using Nothing-returning safe call as lambda result or function expression body
^KT-42832
2021-04-14 13:20:41 +03:00
Ilya Kirillov
b4813d31e6 Mute FirKotlinHighlightingPassTestGenerated.Checker.testResolveTypeInAnnotationArgumentRuntime as flaky 2021-04-14 11:48:41 +02:00
Ilmir Usmanov
74b1fdcc60 Minor. Add regression test
#KT-45991
2021-04-14 10:48:59 +02:00
Ilmir Usmanov
29c975fc43 Minor. Add regression test
#KT-45539 Obsolete
2021-04-14 10:48:57 +02:00
Ilmir Usmanov
19b1b48e87 Minor. Add tests to check returning inline class from default method
#KT-45539 Obsolete
2021-04-14 10:48:54 +02:00
Andrey Zinovyev
8c464b4de5 [KAPT] Bring back properties resolution in light analysis
Because kapt fails on evaluation constant expressions of SomeType::class
2021-04-14 07:50:22 +00:00
Nikolay Krasko
9bbfe5a7a2 Add dependencies verification for prepareSonatypeStaging.gradle
File is applied conditionally when sonatype publication is enabled.
2021-04-14 00:53:02 +03:00
Steven Schäfer
7a9ff15d73 JVM IR: Handle suspend interface default methods with generic types (KT-45166) 2021-04-13 23:04:32 +02:00
Dmitry Petrov
7d62f0b5aa JVM_IR KT-45187 use Arrays.copyOf to copy an array in spread operator
Creating a new array (and copying data into it with System.arraycopy)
doesn't work in generic case, because the actual array class depends on
call site.
2021-04-13 22:27:37 +03:00
zadorotskas
334d0a8b5a FIR: introduce three diagnostics for const val 2021-04-13 21:36:46 +03:00
Mikhail Glukhikh
cc106085e2 FIR: add minor TODO / comments to mismatch checkers 2021-04-13 21:36:44 +03:00
Mikhail Glukhikh
b8af3d79d4 FIR: minimize explicit use of <destruct> name 2021-04-13 21:36:43 +03:00
Mikhail Glukhikh
78fc87ffb1 FIR: apply minor test data fixes around type mismatch problems 2021-04-13 21:36:41 +03:00
Mikhail Glukhikh
9accd8c9ad FIR: use unsafe .coneType in type mismatch checkers when possible 2021-04-13 21:36:40 +03:00
Mikhail Glukhikh
b58e5b182c FIR: add test fixing builder inference case 2021-04-13 21:36:38 +03:00
Mikhail Glukhikh
f7147dc6f3 CoroutineTransformerMethodVisitor: fix potential type mismatch
The fixed code compiles properly only due to null smart cast.
Without it, e.g. in FIR, we'd have type mismatch error for this return.
2021-04-13 21:36:37 +03:00
Mikhail Glukhikh
69d1ef423a FIR initializer: don't report type mismatch on incompatible extensions
This commit suppresses type mismatch error from KT-45989
2021-04-13 21:36:36 +03:00
Mikhail Glukhikh
fa4d664a18 FIR initializer: don't report type mismatch in SomeInt = Int case 2021-04-13 21:36:34 +03:00
vldf
57d2eb5da2 Introduce FirFunctionReturnTypeMismatchChecker 2021-04-13 21:36:33 +03:00
vldf
24f1f1221e Introduce FirInitializerTypeMismatchChecker 2021-04-13 21:36:31 +03:00
Ilya Chernikov
7ed35e5c2b FIR: Introduce smart containers in supertypes search
assuming that we may have quite many searches resulting
in a single supertypes, smart containers here reduce
allocations.
2021-04-13 16:18:41 +02:00
Ilya Chernikov
038a8af80e FIR: convert some hot void visitors to any
reduces call indirection (Nothing -> Void bridges) and therefore
callstack depth
2021-04-13 16:18:41 +02:00
Ilya Chernikov
34694cbec5 FIR: get rid of transformSingle in the generated code
further reduce of the callstack depth
2021-04-13 16:18:40 +02:00
Ilya Chernikov
9d557c8b79 FIR: reduce visitor/transformer indirection
performance: do not route transform calls via
visitors, reduce call stack depth on transformations
2021-04-13 16:18:40 +02:00
Ilya Chernikov
dfd5e80ce9 FIR: Get rid of CompositeTransformResult 2021-04-13 16:18:39 +02:00
Yahor Berdnikau
00df2c4a9e Fix failing non-JUnit5 tests.
They have failed due to migration to new plugin api in test projects.

^KT-45744 Fixed
2021-04-13 16:48:20 +03:00
Yahor Berdnikau
9ef5817f8b Update SimpleKotlinGradleIT.kt tests to use new DSL.
^KT-45744 In Progress
2021-04-13 16:48:19 +03:00
Yahor Berdnikau
aabb05104e Extract common versions to the separate file.
^KT-45744 In Progress
2021-04-13 16:48:18 +03:00
Yahor Berdnikau
8db67ec24b Add file system watching option to build options.
Default build option value - disabled.

In Gradle 7 it is enabled by default, and I suspect it causes flaky
build failure when 'TempDir' tries to delete test project.

^KT-45744 In Progress
2021-04-13 16:48:17 +03:00
Yahor Berdnikau
81621a79a6 Add flag to enable Gradle process debugging.
^KT-45744 In Progress
2021-04-13 16:48:16 +03:00
Yahor Berdnikau
9ae47004d0 Append by default heap dump options.
^KT-45744 In Progress
2021-04-13 16:48:15 +03:00
Yahor Berdnikau
ffa11eacca Add task to run only JUnit 5 KGP tests.
^KT-45744 In Progress
2021-04-13 16:48:14 +03:00
Yahor Berdnikau
34f1c58f1e Add Gradle task to clean test kit cache dir.
Always run it on CI when tests will finish.
^KT-45744 In Progress
2021-04-13 16:48:13 +03:00
Yahor Berdnikau
644882df61 Set default max Gradle version to '7.0'.
^KT-45744 In Progress
2021-04-13 16:48:11 +03:00
Yahor Berdnikau
93230d72f5 Add build option to control Gradle parallelism.
Limit workers count, so when running tests parallel, they will not
compete over CPU usage.

^KT-45744 In Progress
2021-04-13 16:48:10 +03:00
Yahor Berdnikau
3c78c94fb1 Add configuration cache support to the default build options.
^KT-45744 In Progress
2021-04-13 16:48:08 +03:00
Yahor Berdnikau
8b393910d3 Add support for tests mute-in database in JUnit 5.
^KT-45744 In Progress
2021-04-13 16:48:07 +03:00
Yahor Berdnikau
7ffdafe791 Enable forwarding successful Gradle test output on demand.
^KT-45744 In Progress
2021-04-13 16:48:05 +03:00
Yahor Berdnikau
5b218bdad2 Set tests lifecycle to be 'PER_CLASS'.
Usually Gradle tests should be pretty isolated between each other to use
'PER_METHOD' lifecycle.

^KT-45744 In Progress
2021-04-13 16:48:03 +03:00
Yahor Berdnikau
40c525c4a6 Add '.testKitDir/' to '.gitignore' file.
^KT-45744 In Progress
2021-04-13 16:48:02 +03:00
Yahor Berdnikau
35a020340c Don't share temp directory between tests.
Apparently this causes problems on Windows CI runners.

^KT-45744 In Progress
2021-04-13 16:48:00 +03:00
Yahor Berdnikau
0ca4254cba Setup running tests against different Gradle versions.
^KT-45744 In Progress
2021-04-13 16:47:59 +03:00
Yahor Berdnikau
4583cd3634 Allow to add jupiter-params dependency.
^KT-45744 In Progress
2021-04-13 16:47:58 +03:00
Yahor Berdnikau
3dcac00aec Add basic file content transformations.
^KT-45744 In Progress
2021-04-13 16:47:57 +03:00
Yahor Berdnikau
f5dfe7ce95 Automatically add 'pluginManagement' block to settings.gradle file.
Only in the case when it does not exist.
^KT-45744 In Progress
2021-04-13 16:47:56 +03:00
Yahor Berdnikau
9e2cdc7337 Add file or directory exists/does not exist assertions.
^KT-45744 In Progress
2021-04-13 16:47:55 +03:00
Yahor Berdnikau
710287920b Add initial setup to build common options.
^KT-45744 In Progress
2021-04-13 16:47:54 +03:00
Yahor Berdnikau
7549d14a36 Add Gradle output assertions.
^KT-45744 In Progress
2021-04-13 16:47:53 +03:00
Yahor Berdnikau
b7864c1e43 Add tasks assertions.
^KT-45744 In Progress
2021-04-13 16:47:51 +03:00
Yahor Berdnikau
e13f21e461 Add basic DSL based on Gradle TestKit for KGP integration tests.
^KT-45744 In Progress
2021-04-13 16:47:50 +03:00
Ivan Kochurkin
847ab40707 [FIR] Implement DIVISION_BY_ZERO diagnostics, fix tests 2021-04-13 16:22:08 +03:00
Ivan Kochurkin
964bba3530 [FIR] Implement FLOAT_LITERAL_OUT_OF_RANGE diagnostics, fix tests 2021-04-13 16:22:06 +03:00
Ivan Kochurkin
4cf30cd1fa [FIR] Implement INT_LITERAL_OUT_OF_RANGE diagnostics, fix tests 2021-04-13 16:22:05 +03:00
Ivan Kochurkin
fb06da2d75 [FIR] Implement WRONG_LONG_SUFFIX diagnostics, fix tests 2021-04-13 16:22:03 +03:00
Vasily Levchenko
62ffc0033d [kotlin-native][test][dynamic test] tests provoking generating empty structs kt-42796 2021-04-13 12:10:58 +00:00
Vasily Levchenko
2adea2122e [kotlin-native][build][test infrostructure] don't ignore compiler exit code 2021-04-13 12:10:57 +00:00
Vasily Levchenko
c68ac4f6b6 [interop][c][reverse] avoid generating empty structures for leaf packages without exportable declations
- fixes KT-42796
2021-04-13 12:10:57 +00:00
Roman Golyshev
0d7eb971ca Fix test data 2021-04-13 11:40:24 +00:00
Roman Golyshev
e0fca9d2f6 FIR IDE: Add visibility checks to the completion
Visibility checks currently do not work in some cases, for example:

- public nested class of private class is seen globally
- private_for_this does not work
- some other cases I am not yet aware of

If `FirVisibilityChecker.isVisible` fix those issues, they will be fixed
automatically in the completion
2021-04-13 11:40:23 +00:00
Roman Golyshev
78b2324a51 Refactor KotlinFirCompletionContributor
Replace extensions checking lambdas with `ExtensionApplicabilityChecker`
type
2021-04-13 11:40:22 +00:00
Roman Golyshev
86348ed981 Refactor KotlinFirCompletionContributor
Remove some code duplication
2021-04-13 11:40:22 +00:00
Roman Golyshev
ff71dda065 FIR IDE: Add KtVisibilityChecker component 2021-04-13 11:40:21 +00:00
Roman Golyshev
28d8d2d903 FIR IDE: Search for the first non-local declaration in EnclosingDeclarationContext::detect
Local declarations do not have a stable `ClassId`, which is used in
`declarationUtils.collectDesignation`. Local classes will always have
`outerClassId.isLocal = true`, even when it is not true (see
`org.jetbrains.kotlin.fir.builder.Context.currentClassId` for why this
happens)
2021-04-13 11:40:20 +00:00
Roman Golyshev
0d2158325a Remove redundant ticks from test data 2021-04-13 11:40:19 +00:00
Roman Golyshev
fcd0168381 Refactor AbstractHighLevelMultiFileJvmBasicCompletionTest
Use `KotlinFixtureCompletionBaseTestCase` base because it can override
`getProjectDescriptor`, so the tests will see full JDK

Without it, there were problems when classes from JDK appeared in the
completion (`Serialization`, for example)
2021-04-13 11:40:18 +00:00
pyos
cc7187e49b JVM_IR: cast argument of enumValueOf to String in bytecode
Generic functions and implicit casts may return a supertype instead.

 #KT-45865 Fixed
2021-04-13 13:24:24 +02:00
Anton Bannykh
afaf3b5e28 JS PIR: replace deprecated toLowerCase with lowercase 2021-04-13 14:20:00 +03:00
Andrei Klunnyi
73d2e1a42d KT-46049 Java-Kotlin sealed inheritors inspection: refactoring 2021-04-13 12:34:07 +02:00
Andrei Klunnyi
2fce968de0 KT-46049 Java-Kotlin sealed inheritors inspection: false positive for type parameter
^KT-46049 Fixed
2021-04-13 12:34:07 +02:00
pyos
85b4668b7c JVM_IR: optimize more if-null chains
1. consider reads of fields from the same file "stable" just like
    functions, i.e. assume their nullability information is correct
 2. apply if-null fusion repeatedly until the subject is no longer a
    nested if-null expression
2021-04-13 11:48:36 +03:00
Denis.Zharkov
0b0a6d6ede Fix false positive ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL
Previously added additional processing at findEnclosingSuspendFunction
seems unnecessary anymore

^KT-43258 Fixed
2021-04-13 11:47:05 +03:00
Dmitriy Novozhilov
803d47daaa Distinguish classes from different sourcesets in SealedInheritorInSameModuleChecker
#KT-45848 Fixed
#KT-46031
2021-04-13 11:21:58 +03:00
Dmitriy Novozhilov
66e4d5664a [Test] Properly setup KtFile.isCommonSource in tests 2021-04-13 11:21:57 +03:00
Jinseong Jeon
619360fe4d FIR checker: report UNINITIALIZED_ENUM_(ENTRY|COMPANION) 2021-04-13 08:25:16 +03:00
Ivan Kochurkin
ad9b962536 [FIR] Fix tests (ARGUMENT_TYPE_MISMATCH instead of INCOMPATIBLE_CANDIDATE) 2021-04-12 23:49:55 +03:00
Ivan Kochurkin
4ffab5fe5a [FIR] Add new test argParamTypeMismatch.kt for ARGUMENT_TYPE_MISMATCH diagnostics 2021-04-12 23:49:54 +03:00
Ivan Kochurkin
a09b836334 [FIR] Add new ARGUMENT_TYPE_MISMATCH diagnostics and related classes, throw it in corresponding cases 2021-04-12 23:49:52 +03:00
Dmitry Petrov
7e03f8ea80 JVM_IR KT-45853 include return type into Java method IdSignature
This is a hack required to accept [potentially] incorrect input
provided by the front-end; see KT-46042.
2021-04-12 22:52:08 +03:00
Matthew Gharrity
5ce746f1ec ULC field has null nameIdentifier
KtUltraLightFieldForSourceDeclaration implements PsiField, for which
getNameIdentifier() is marked @NonNull, so some clients expect a
non-null return value.

#KT-45629 Fixed
2021-04-12 21:41:54 +03:00
Nikolay Krasko
6cbdcbe53b Trust zip with gradle sources 2021-04-12 20:10:42 +03:00
Jinseong Jeon
9af108df77 FIR LT: set source for destructured value parameter of lambda 2021-04-12 19:20:03 +03:00
Yahor Berdnikau
c6aa5d1495 Fix plugin is using deprecated method that is removed in AGP 7.0.
^KT-45950 Fixed
2021-04-12 18:20:42 +03:00
Yahor Berdnikau
9100be4566 Set Android Gradle Plugin dependency version to 3.4.0.
This is required to get method deprecations and new proposed methods.
2021-04-12 18:20:41 +03:00
Dmitry Petrov
f59b49db68 JVM_IR KT-45967 generate accessor for argument of indy intrinsic
TODO handle inaccessible constructors gracefully
2021-04-12 17:36:24 +03:00
Sergey Shanshin
5f9fe8e5de Fix IR compilation of kotlix.serialization runtime in native 2021-04-12 17:08:08 +03:00
Abduqodiri Qurbonzoda
39731fd493 Merge Stdlib generators 2021-04-12 16:51:24 +03:00
Alexander Udalov
e9a969875c Minor, fix typo in the issue reference in comment 2021-04-12 15:43:35 +02:00
Dmitry Petrov
162363a324 JVM: CHECK_BYTECODE_TEST directive + use it in INVOKEDYNAMIC tests 2021-04-12 16:43:15 +03:00
Ilya Chernikov
ca352c9556 Fix jvm method reading when descriptor and signature do not match
#KT-38325 fixed
2021-04-12 16:23:53 +03:00
Mikhail Glukhikh
c75331bf2a Implicit nothing type argument: handle nullable case properly
#KT-41620 Fixed
2021-04-12 15:51:46 +03:00
Alexander Udalov
115e2673ae Minor, fix javac deprecation warning in DynamicBundle 2021-04-12 14:38:09 +02:00
Yahor Berdnikau
2d9a3f364c Update advance Gradle version to 7.0 for KGP tests.
^KT-44949 Fixed
2021-04-12 15:02:02 +03:00
Victor Petukhov
73a2838555 Do substitution captured type's super types as well
^KT-45982 Fixed
2021-04-12 14:00:40 +03:00
Victor Petukhov
e8275d2527 Complete old inference's callable references properly, by updating descriptor, resolved call and recorded expression's type
^KT-45721 Fixed
^KT-44994 Fixed
2021-04-12 14:00:38 +03:00
Victor Petukhov
d804e73c22 Avoid subtype checking between type variable of self type and captured star projection only for invariant positions
Subtyping with non-invariant positions may produce useful constraints

^KT-46001 Fixed
2021-04-12 13:44:09 +03:00
Ilya Chernikov
0274c41919 [minor] FIR: fix deprecation in test 2021-04-12 10:08:54 +02:00
Alexander Likhachev
9e78e43c49 [Gradle] Always declare system property reads for compile tasks
When Kotlin plugin is applied in buildSrc or included build that defines Gradle plugins it can cause Gradle to report undeclared system property reads at configuration time. Declaring all system properties reads through Gradle providers to cover all these cases.
#KT-45910 Fixed
2021-04-12 03:15:10 +03:00
Andrey Zinovyev
47407c4445 [FIR] Add NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER check 2021-04-11 16:18:07 +00:00
Alexander Udalov
ea22f4b681 IR: check absence of extension receiver in isMethodOfAny
Otherwise extension methods named toString/equals/hashCode were
generated incorrectly on JVM IR, which could result in
AbstractMethodError at runtime.

 #KT-45963 Fixed
2021-04-11 13:54:13 +02:00
Abduqodiri Qurbonzoda
98d31a1813 Expand KDoc of inc() and dec() operators #KT-43701 2021-04-10 03:23:04 +03:00
sebastian.sellmair
b311820159 [Minor] Fix CommonizerDependencyTest.sample identityString on Windows 2021-04-09 23:36:02 +02:00
Dmitriy Dolovov
14838a6b7b Update Kotlin/Native: 1.5.20-dev-4865 2021-04-09 23:36:02 +02:00
sebastian.sellmair
6d31750673 [Commonizer] assembelCirTree: Supoprt TypeAlias -> Class commonization 2021-04-09 23:36:02 +02:00
sebastian.sellmair
28adf6345d [Minor] Optimize imports of CirProperty.kt 2021-04-09 23:36:02 +02:00
sebastian.sellmair
9c1c506b21 [Minor] Move ClassesToProcess into .tree.deserializer package 2021-04-09 23:36:02 +02:00
sebastian.sellmair
d0f8395556 [Commonizer] Remove old mergers 2021-04-09 23:36:01 +02:00
sebastian.sellmair
14161c8250 [Commonizer] Prevent copying missing modules that are already present in destination 2021-04-09 23:36:01 +02:00
sebastian.sellmair
02c1d7fad3 [Gradle] HierarchicalNativeDistributionCommonizerTask: Ensure that native distribution commonization tasks can't run in parallel 2021-04-09 23:36:01 +02:00
sebastian.sellmair
c4562fd1db [Gradle] GetCommonizerTargetOfSourceSet: Gracefully handle common non-hmpp workaround 2021-04-09 23:36:01 +02:00
sebastian.sellmair
2aeb08e245 [Gradle] Implement internal intransitiveMetadataConfiguration
- Implemented additional intransitiveMetadataConfiguration to support
dependencies that shall not be added transitively to dependsOn edges
2021-04-09 23:36:00 +02:00
sebastian.sellmair
4e40bd6371 [Minor] Make CInteropProcess cacheable 2021-04-09 23:36:00 +02:00
sebastian.sellmair
ce0fdbd2df [Minor] Make CInteropCommonizerTask cacheable 2021-04-09 23:36:00 +02:00
sebastian.sellmair
9ac7b61094 [Gradle] HierarchicalNativeDistributionCommonizerTask: Implement project global caching
- Implement NativeDistributionCommonizationCache which will act similar
to the 'SuccessMarker' used in the non hierarchical commonization task.

- Implement 'kotlin.mpp.enableNativeDistributionCommonizationCache'
Gradle property to disable project global caching. The cache is
turned on by default.
2021-04-09 23:36:00 +02:00
sebastian.sellmair
50d0439af3 [Minor] Share 'Test: Commonizer' run configuration 2021-04-09 23:36:00 +02:00
sebastian.sellmair
2bb0dbaf38 [Gradle] Implement CommonizerHierarchicalIT integration test 2021-04-09 23:36:00 +02:00
sebastian.sellmair
d9eb130f82 [Gradle] Enable hierarchical commonization by default 2021-04-09 23:35:59 +02:00
sebastian.sellmair
933c52d470 [Commonizer] Gracefully handle absent targets for hierarchical commonization 2021-04-09 23:35:59 +02:00
sebastian.sellmair
bbe499c1b6 [Commonizer] Re-introduce node builders 'parentCommonDeclaration' context 2021-04-09 23:35:59 +02:00
sebastian.sellmair
947dc71bda [Gradle] Leave native source sets: Add expect parts explictely 2021-04-09 23:35:59 +02:00
sebastian.sellmair
9cb67e06e3 [Commonizer] Only serialize common or LeafCommonizerTargets 2021-04-09 23:35:59 +02:00
sebastian.sellmair
10692b5b7c [Minor] Add commonizer classpath to HierarchicalNativeDistributionCommonizerTask 2021-04-09 23:35:58 +02:00
sebastian.sellmair
88a913c7dc [Commonizer] NativeLibraryLoader: Improve error message when loading a library fails 2021-04-09 23:35:58 +02:00
sebastian.sellmair
250915f377 [Commonizer] Implement AbstractInlineSourcesCommonizationTest and hierarchical commonization tests 2021-04-09 23:35:58 +02:00
sebastian.sellmair
a2436699ea [Commonizer] Implement basic tests for CirTree merging 2021-04-09 23:35:58 +02:00
sebastian.sellmair
f252c3e2c1 [Commonizer] Implement CirTreeDependenciesDeserializerTest 2021-04-09 23:35:57 +02:00
sebastian.sellmair
c03d995e07 [Commonizer] Implement basic tests for CirTree deserializers 2021-04-09 23:35:57 +02:00
sebastian.sellmair
8c941fc203 [Gradle] Implement support for hierarchical commonization 2021-04-09 23:35:57 +02:00
sebastian.sellmair
68c3e39058 [Commonizer] Implement support for hierarchical commonization 2021-04-09 23:35:57 +02:00
sebastian.sellmair
46a20c81cc Implement CommonizerTarget.allLeaves 2021-04-09 23:35:56 +02:00
sebastian.sellmair
a78645e858 Implement CommonizerTarget.withAllAncestors 2021-04-09 23:35:56 +02:00
sebastian.sellmair
47f36c04fc Move transitiveClosure into :commonizer-api 2021-04-09 23:35:56 +02:00
sebastian.sellmair
35e1f8a520 Implement CommonizerTarget isAncestorOf and isDescendentOf 2021-04-09 23:35:56 +02:00
sebastian.sellmair
108debdcc9 [Commonizer] Implement CirTree and CirTree deserializers and CirTree merging 2021-04-09 23:35:56 +02:00
sebastian.sellmair
cb1f3c3e32 [Commonizer] Make nodeBuilders contextless 2021-04-09 23:35:55 +02:00
sebastian.sellmair
66bc751407 [Commonizer] Inline 'hasAnythingToCommonize' 2021-04-09 23:35:55 +02:00
sebastian.sellmair
0a35d75039 [Commonizer] CommonizerParameters: Require TargetProviders as constructor argument 2021-04-09 23:35:55 +02:00
sebastian.sellmair
79c6b406ba [Commonizer] Allow empty SharedCommonizerTarget 2021-04-09 23:35:55 +02:00
sebastian.sellmair
cdbede09df Move 'TargetDependent' into commonizer module make it an interface 2021-04-09 23:35:55 +02:00
Ilmir Usmanov
bce92d824a Minor. Add tests to check returning Result from functions
Mainly, that virtual functions, returning Result, are mangled.
 #KT-45855
2021-04-09 22:09:03 +03:00
Vladimir Dolzhenko
613eda5016 Fix PackageFragmentProvider#isEmpty(FqName) for REPL 2021-04-09 21:06:32 +03:00
Anton Bannykh
bcaad7487f JS PIR: regenerate .proto 2021-04-09 19:54:24 +03:00
Anton Bannykh
923303c2c1 JS PIR: move PIR proto messages to a separate file 2021-04-09 19:54:23 +03:00
Anton Bannykh
8fe8419ad4 JS IR: serialize declarations without mutable state 2021-04-09 19:54:21 +03:00
Anton Bannykh
1e822aa28a JS PIR: carrier serializer implementation 2021-04-09 19:54:20 +03:00
Anton Bannykh
c97066527c JS PIR: carrier serializer / deserializer 2021-04-09 19:54:19 +03:00
Anton Bannykh
030498c5e1 JS IR: updated .proto 2021-04-09 19:54:18 +03:00
Anton Bannykh
5de04f49ca JS PIR: updated declarations 2021-04-09 19:54:17 +03:00
Anton Bannykh
1f0d83b420 JS PIR: update the generator
- Use symbols in carriers
- .proto messages for carriers
- carrier serializer/derserializer
2021-04-09 19:54:16 +03:00
Anton Bannykh
c224dd4cb1 JS IR: JsMapping serialization 2021-04-09 19:54:15 +03:00
Anton Bannykh
ba5582de99 IntArray and LongArray serialization 2021-04-09 19:54:14 +03:00
Anton Bannykh
387b84b37c JS IR: simplify DCE root calculation 2021-04-09 19:54:13 +03:00
Mads Ager
b27a109a1e [JVM] Fix shrinking of local range for dead variables.
Coroutine transform would occasionally *extend* the range of a
local instead of shrinking it (if the next suspension point
is after the end point for the local). That leads to the local
variable table having a local that covers code where it is not
defined. That is invalid and leads to D8 removing the locals
table from the code.
2021-04-09 19:06:13 +03:00
Ilya Kirillov
ebdbcbb7b6 FIR IDE: encapsulate designation into class 2021-04-09 17:49:43 +02:00
Ilya Kirillov
aff1788a4c FIR IDE: initialize FirSession with correct language settings 2021-04-09 17:48:48 +02:00
Ilya Kirillov
9c6445d863 FIR IDE: add more test cases to file FileStructureTest 2021-04-09 17:48:48 +02:00
Ilya Kirillov
fc2bb2e3e6 FIR IDE: fix resolve in case of duplicating classes 2021-04-09 17:48:47 +02:00
Ilya Kirillov
73c175213c FIR IDE: fix lazy resolve of type aliases 2021-04-09 17:48:47 +02:00
Ilya Kirillov
0ad64b2113 FIR IDE: fix recursive supertypes resolve in light classes 2021-04-09 17:48:47 +02:00
Ilya Kirillov
60ea64143c FIR IDE: reuse scope session between different resolve calls for the same file 2021-04-09 17:47:05 +02:00
Ilya Kirillov
a9fc3dd1ea FIR IDE: fix unresolved file annotations arguments 2021-04-09 17:46:24 +02:00
Ilya Kirillov
790cafa671 FIR IDE: fix deadlock in symbol providers 2021-04-09 17:46:23 +02:00
Ilya Goncharov
266daed2cb [Gradle, JS] Mark visited dependencies inside dependency graph traversing 2021-04-09 17:32:44 +03:00
Vasily Levchenko
fd17e5e700 [build][kotlin-native][clean] adds kotlin-native/build to clean 2021-04-09 14:14:32 +00:00
Vasily Levchenko
3192b05586 [build][kotlin-native][g/c] drop unused hacks 2021-04-09 14:14:31 +00:00
Vladimir Dolzhenko
3034d9d791 Temporary (partial) rollback optimize in PackageFragmentProvider#isEmpty(FqName) 2021-04-09 15:10:47 +02:00
Vladimir Dolzhenko
0761c4bf94 Optimize KtFile.getScript 2021-04-09 14:45:20 +02:00
Mikhail Glukhikh
254e41b70d FIR: apply bad test data changes related to ABSTRACT_*_NOT_IMPLEMENTED 2021-04-09 14:52:41 +03:00
Mikhail Glukhikh
818c54e3a6 FIR: report ABSTRACT_*_NOT_IMPLEMENTED on appropriate intersections 2021-04-09 14:52:34 +03:00
Sergey Bogolepov
0fa2821ac1 Add missing targetToolchain.macos_arm64-linux_arm32_hfp property 2021-04-09 18:26:23 +07:00
Vladimir Dolzhenko
04268a720f Optimize KtFile.isScript 2021-04-09 12:17:51 +02:00
Denis.Zharkov
37813d9d82 Add version requirements for declarations with !! types
^KT-26245 Related
2021-04-09 13:06:40 +03:00
Denis.Zharkov
403406f92d Ignore not-null assertion test related to T!! on JVM_IR
^KT-45935 Related
2021-04-09 13:06:39 +03:00
Denis.Zharkov
16ca8ddbbd Do not parse !! as part of annotation type
^KT-26245 Related
2021-04-09 13:06:38 +03:00
Denis.Zharkov
37f923a98f Do not approximate DefinitelyNotNullType in public declarations
Because since 1.6 they become normal denotable types

^KT-26245 Fixed
2021-04-09 13:06:37 +03:00
Denis.Zharkov
e74a0c7ef7 Pass languageVersionSettings to AbstractTypeApproximator 2021-04-09 13:06:35 +03:00
Denis.Zharkov
59372fd15f Enable ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated since 1.6
^KT-36770 Fixed
2021-04-09 13:06:34 +03:00
Denis.Zharkov
bd05ef19de Add blackbox test for definitely-not-null types
^KT-26245 Fixed
2021-04-09 13:06:32 +03:00
Denis.Zharkov
30eb9ad32f Add serialization/deserialization of definitely-not-null types
^KT-26245 In Progress
2021-04-09 13:06:31 +03:00
Denis.Zharkov
6ca6bb2d45 Load configuration for FirLoadCompiledKotlin 2021-04-09 13:06:29 +03:00
Denis.Zharkov
b9d2a1842a Support definitely-not-null generic T!! types in Parsing and FE1.0
^KT-26245 In Progress
2021-04-09 13:06:28 +03:00
Jinseong Jeon
5a0b75bd89 FIR checker: warn unnecessary safe calls 2021-04-09 12:32:45 +03:00
Jinseong Jeon
2ecb6733ed FIR checker: warn unnecessary non-null assertions 2021-04-09 12:32:45 +03:00
Mikhail Glukhikh
5229d4e4f4 Apply bad LT test changes related to COMPONENT_FUNCTION_..._MISMATCH 2021-04-09 12:32:44 +03:00
Jinseong Jeon
87c50235ed FIR checker: report COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH 2021-04-09 12:32:44 +03:00
Vladimir Dolzhenko
e511eec90e Added optimized PackageFragmentProvider#isEmpty(FqName) 2021-04-09 09:27:39 +00:00
Andrey Zinovyev
37055c5a09 [FIR] Add REPEATED_BOUND, CONFLICTING_UPPER_BOUNDS diagnostics 2021-04-09 07:38:39 +00:00
Sergey Bogolepov
81d4c19d8b Fix Android NDK targets
Android NDK dirs omit vendor part of triple,
so we have to respect its decision.
2021-04-09 13:11:14 +07:00
Mikhail Glukhikh
3e9ef56c31 Forbid using ext.property type parameter also for delegate ext.receiver 2021-04-09 07:56:35 +03:00
Mikhail Glukhikh
e2cc0510de Rewrite FirDeclarationDataRegistry.data to avoid type parameter problems 2021-04-09 07:56:35 +03:00
Mikhail Glukhikh
0c17ce2f44 Suppress DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER in code 2021-04-09 07:56:35 +03:00
Mikhail Glukhikh
fcbab45a88 FE 1.0: introduce DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER error
#KT-24643 Fixed
2021-04-09 07:56:35 +03:00
Ilya Gorbunov
d062f54360 Remove test exclusions after KT-45136 is fixed 2021-04-09 06:45:11 +03:00
Dmitry Petrov
ed88aa43a4 JVM_IR KT-45868 look for parent for delegating lambda in scope stack 2021-04-08 23:49:59 +03:00
Dmitry Petrov
c2a5b0b6e2 JVM_IR KT-45920 don't add special bridge if it clashes with known method 2021-04-08 23:48:39 +03:00
Yahor Berdnikau
92d200e093 Update advance Gradle version to 7.0-rc-2.
^KT-44949 In Progress
2021-04-08 21:24:43 +03:00
Ilya Goncharov
583dba51c1 [Gradle, JS] Initialize File hasher service during IDEA import 2021-04-08 20:24:43 +03:00
Nikolay Krasko
7d78e610b1 Allow ProtoBufCompareConsistencyTest to work on teamcity 2021-04-08 18:51:12 +03:00
Nikolay Krasko
14ead33db6 Add teamcity problems when generating files instead of exception 2021-04-08 18:51:10 +03:00
Nikolay Krasko
3757bd0c1f Use environment variable for getting TEAMCITY_VERSION 2021-04-08 18:51:09 +03:00
Nikolay Krasko
02e37dceeb Regenerate LightAnalysisModeTestGenerated.java 2021-04-08 18:51:08 +03:00
Abduqodiri Qurbonzoda
46338224e1 Remove deprecated JQuery 2021-04-08 18:43:16 +03:00
5111 changed files with 145482 additions and 35068 deletions

View File

@@ -63,27 +63,6 @@
<option name="FOR_BRACE_FORCE" value="1" />
<option name="FIELD_ANNOTATION_WRAP" value="0" />
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="DOWHILE_BRACE_FORCE" value="1" />
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
</codeStyleSettings>
<codeStyleSettings language="PROTO">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
@@ -101,4 +80,4 @@
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
</codeStyleSettings>
</code_scheme>
</component>
</component>

View File

@@ -3,6 +3,7 @@
<words>
<w>cinterops</w>
<w>interops</w>
<w>klibrary</w>
</words>
</dictionary>
</component>
</component>

View File

@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test: Commonizer" type="GradleRunConfiguration" factoryName="Gradle" folderName="Tests">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--tests &quot;org.jetbrains.kotlin.gradle.CommonizerHierarchicalIT&quot; --tests &quot;org.jetbrains.kotlin.gradle.CommonizerIT&quot; --tests &quot;org.jetbrains.kotlin.commonizer.**&quot;" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":native:kotlin-klib-commonizer-api:test" />
<option value=":native:kotlin-klib-commonizer:test" />
<option value=":kotlin-gradle-plugin-integration-tests:test" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>false</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,11 @@ buildscript {
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/plugins.gradle.org/m2")
maven("https://cache-redirector.jetbrains.com/repo.maven.apache.org/maven2")
} else {
maven("https://plugins.gradle.org/m2")
mavenCentral()
}
}
@@ -27,7 +30,7 @@ buildscript {
dependencies {
bootstrapCompilerClasspath(kotlin("compiler-embeddable", bootstrapKotlinVersion))
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.28")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath(kotlin("serialization", bootstrapKotlinVersion))
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
@@ -192,7 +195,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.5.20-dev-3553"
extra["versions.kotlin-native"] = "1.5.20-dev-5613"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -368,7 +371,8 @@ val gradlePluginProjects = listOf(
":kotlin-annotation-processing-gradle",
":kotlin-noarg",
":kotlin-sam-with-receiver",
":kotlin-parcelize-compiler"
":kotlin-parcelize-compiler",
":kotlin-lombok"
)
apply {
@@ -577,26 +581,6 @@ allprojects {
}
}
if ((gradle.startParameter as? org.gradle.api.internal.StartParameterInternal)?.isConfigurationCache != true) {
// TODO: remove it once Gradle is bumped to 6.8:
// See https://docs.gradle.org/6.8/release-notes.html#more-cache-hits-when-empty-directories-are-present
gradle.buildFinished {
val taskGraph = gradle?.taskGraph
if (taskGraph != null) {
taskGraph.allTasks
.filterIsInstance<SourceTask>()
.filter { it.didWork }
.forEach {
it.source.visit {
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath)
}
}
}
}
}
}
gradle.taskGraph.whenReady {
fun Boolean.toOnOff(): String = if (this) "on" else "off"
val profile = if (isTeamcityBuild) "CI" else "Local"
@@ -975,12 +959,14 @@ tasks {
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-build-common-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-compiler-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-compiler-cli-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:compiler-components-for-jps:publish",
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide:publish",
":kotlin-script-runtime:publish",
":kotlin-script-util:publish",
":kotlin-scripting-common:publish",

View File

@@ -22,7 +22,7 @@ buildscript {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.28")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.bootstrapKotlinVersion}")
}
@@ -92,7 +92,27 @@ repositories {
}
}
val generateCompilerVersion by tasks.registering(VersionGenerator::class) {
/*
A special case for the build.number that doesn't have a number in it.
This means that this is a final release artifacts
*/
open class VersionGeneratorNullableBuild : VersionGenerator() {
override val buildNumber: String?
@Optional
@Input
get() {
val number = project.findProperty("build.number")?.toString()
val buildNumberSplit = number
?.split("-".toRegex())
?.toTypedArray()
if (buildNumberSplit?.get(buildNumberSplit.size - 1)?.toIntOrNull() == null) {
return null
}
return number
}
}
val generateCompilerVersion by tasks.registering(VersionGeneratorNullableBuild::class) {
kotlinNativeVersionInResources=true
defaultVersionFileLocation()
}
@@ -144,7 +164,7 @@ java {
dependencies {
implementation(kotlin("stdlib", embeddedKotlinVersion))
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.28")
implementation("com.gradle.publish:plugin-publish-plugin:0.14.0")
implementation("net.rubygrapefruit:native-platform:${property("versions.native-platform")}")

View File

@@ -18,9 +18,10 @@ buildscript {
} else {
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" }
}
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.26")
classpath("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.28")
}
}

View File

@@ -118,7 +118,8 @@ fun DependencyHandler.projectArchives(name: String): ProjectDependency = project
fun Project.testApiJUnit5(
vintageEngine: Boolean = false,
runner: Boolean = false,
suiteApi: Boolean = false
suiteApi: Boolean = false,
jupiterParams: Boolean = false
) {
with(dependencies) {
val platformVersion = commonVer("org.junit", "junit-bom")
@@ -127,6 +128,11 @@ fun Project.testApiJUnit5(
if (vintageEngine) {
testApi("org.junit.vintage:junit-vintage-engine:$platformVersion")
}
if (jupiterParams) {
testApi("org.junit.jupiter:junit-jupiter-params:$platformVersion")
}
val componentsVersion = commonVer("org.junit.platform", "")
val components = mutableListOf(

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2010-2021 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.
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
}
publish()
standardPublicJars()
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
dependencies {
compileOnly(kotlinStdlib())
compileOnly(gradleApi())
}
// These dependencies will be provided by Gradle and we should prevent version conflict
fun Configuration.excludeGradleCommonDependencies() {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
}
configurations {
"implementation" {
excludeGradleCommonDependencies()
}
"api" {
excludeGradleCommonDependencies()
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.languageVersion = "1.3"
kotlinOptions.apiVersion = "1.3"
kotlinOptions.freeCompilerArgs += listOf(
"-Xskip-prerelease-check",
"-Xskip-runtime-version-check",
"-Xsuppress-version-warnings"
)
}
tasks.named<Jar>("jar") {
callGroovy("manifestAttributes", manifest, project)
}

View File

@@ -5,6 +5,7 @@
package plugins
import PublishToMavenLocalSerializable
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.attributes.Usage
@@ -13,10 +14,10 @@ import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
import java.util.*
@@ -27,7 +28,6 @@ class KotlinBuildPublishingPlugin @Inject constructor(
) : Plugin<Project> {
override fun apply(target: Project): Unit = with(target) {
apply<MavenPublishPlugin>()
apply<SigningPlugin>()
val publishedRuntime = configurations.maybeCreate(RUNTIME_CONFIGURATION).apply {
isCanBeConsumed = false
@@ -132,32 +132,40 @@ fun Project.configureDefaultPublishing() {
}
}
configureSigning()
val signingRequired = project.providers.gradleProperty("signingRequired").forUseAtConfigurationTime().orNull?.toBoolean()
?: project.providers.gradleProperty("isSonatypeRelease").forUseAtConfigurationTime().orNull?.toBoolean() ?: false
if (signingRequired) {
apply<SigningPlugin>()
configureSigning()
}
tasks.register("install") {
dependsOn(tasks.named("publishToMavenLocal"))
}
// workaround for Gradle configuration cache
// TODO: remove it when https://github.com/gradle/gradle/pull/16945 merged into used in build Gradle version
tasks.withType(PublishToMavenLocal::class.java) {
val originalTask = this
val serializablePublishTask =
tasks.register(originalTask.name + "Serializable", PublishToMavenLocalSerializable::class.java) {
publication = originalTask.publication
}
originalTask.onlyIf { false }
originalTask.dependsOn(serializablePublishTask)
}
tasks.withType<PublishToMavenRepository>()
.matching { it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository") }
.all { configureRepository() }
}
private fun Project.configureSigning() {
val signingRequired = provider {
project.findProperty("signingRequired")?.toString()?.toBoolean()
?: project.property("isSonatypeRelease") as Boolean
}
configure<SigningExtension> {
setRequired(signingRequired)
sign(extensions.getByType<PublishingExtension>().publications) // all publications
useGpgCmd()
}
tasks.withType<Sign>().configureEach {
setOnlyIf { signingRequired.get() }
}
}
fun TaskProvider<PublishToMavenRepository>.configureRepository() =
@@ -181,4 +189,4 @@ private fun PublishToMavenRepository.configureRepository() {
}
}
}
}
}

View File

@@ -7,13 +7,22 @@
// usages in build scripts are not tracked properly
@file:Suppress("unused")
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.internal.tasks.testing.filter.DefaultTestFilter
import org.gradle.api.publish.internal.PublishOperation
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
import org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication
import org.gradle.api.publish.maven.internal.publisher.MavenPublisher
import org.gradle.api.publish.maven.internal.publisher.ValidatingMavenPublisher
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.testing.Test
import org.gradle.internal.serialization.Cached
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import org.gradle.kotlin.dsl.support.serviceOf
@@ -38,6 +47,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-compiler-runner",
":kotlin-daemon-embeddable",
":kotlin-daemon-client",
":kotlin-project-model",
":kotlin-gradle-plugin-api",
":kotlin-gradle-plugin",
":kotlin-gradle-plugin-model",
@@ -279,3 +289,30 @@ fun Task.useAndroidSdk() {
fun Task.useAndroidJar() {
TaskUtils.useAndroidJar(this)
}
// Workaround to make PublishToMavenLocal compatible with Gradle configuration cache
// TODO: remove it when https://github.com/gradle/gradle/pull/16945 merged into used in build Gradle version
abstract class PublishToMavenLocalSerializable : AbstractPublishToMaven() {
private val normalizedPublication = Cached.of { this.computeNormalizedPublication() }
private fun computeNormalizedPublication(): MavenNormalizedPublication {
val publicationInternal: MavenPublicationInternal = publicationInternal
?: throw InvalidUserDataException("The 'publication' property is required")
duplicatePublicationTracker.checkCanPublishToMavenLocal(publicationInternal)
return publicationInternal.asNormalisedPublication()
}
@TaskAction
open fun publish() {
val normalizedPublication = normalizedPublication.get()
object : PublishOperation(normalizedPublication.name, "mavenLocal") {
override fun publish() {
val localPublisher = mavenPublishers.getLocalPublisher(
temporaryDirFactory
)
val validatingPublisher: MavenPublisher = ValidatingMavenPublisher(localPublisher)
validatingPublisher.publish(normalizedPublication, null)
}
}.run()
}
}

View File

@@ -87,4 +87,4 @@ open class SamTypeFactory {
companion object {
val INSTANCE = SamTypeFactory()
}
}
}

View File

@@ -18,6 +18,7 @@ interface TypeMappingContext<Writer : JvmDescriptorTypeWriter<Type>> {
val typeContext: TypeSystemCommonBackendContextForTypeMapping
fun getClassInternalName(typeConstructor: TypeConstructorMarker): String
fun getScriptInternalName(typeConstructor: TypeConstructorMarker): String
fun Writer.writeGenericType(type: SimpleTypeMarker, asmType: Type, mode: TypeMappingMode)
}
@@ -117,9 +118,7 @@ object AbstractTypeMapper {
}
typeConstructor.isScript() -> {
val asmType = AsmTypes.JAVA_CLASS_TYPE
with(context) { sw?.writeGenericType(type, asmType, mode) }
return asmType
return Type.getObjectType(context.getScriptInternalName(typeConstructor))
}
typeConstructor.isTypeParameter() -> {

View File

@@ -158,7 +158,14 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
for (int i = 0; i < superInterfaceTypes.size(); i++) {
KotlinType superInterfaceType = superInterfaceTypes.get(i);
sw.writeInterface();
superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName();
Type superInterfaceAsmType;
if (samType != null && superInterfaceType.getConstructor() == samType.getType().getConstructor()) {
superInterfaceAsmType = typeMapper.mapSupertype(superInterfaceType, null);
sw.writeAsmType(superInterfaceAsmType);
} else {
superInterfaceAsmType = typeMapper.mapSupertype(superInterfaceType, sw);
}
superInterfaceAsmTypes[i] = superInterfaceAsmType.getInternalName();
sw.writeInterfaceEnd();
}

View File

@@ -265,13 +265,23 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
);
}
private static void addReifiedParametersFromSignature(@NotNull MemberCodegen member, @NotNull ClassDescriptor descriptor) {
private static void addReifiedParametersFromSignature(@NotNull MemberCodegen<?> member, @NotNull ClassDescriptor descriptor) {
for (KotlinType type : descriptor.getTypeConstructor().getSupertypes()) {
for (TypeProjection supertypeArgument : type.getArguments()) {
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
if (parameterDescriptor != null && parameterDescriptor.isReified()) {
processTypeArguments(member, type);
}
}
private static void processTypeArguments(@NotNull MemberCodegen<?> member, KotlinType type) {
for (TypeProjection supertypeArgument : type.getArguments()) {
if (supertypeArgument.isStarProjection()) continue;
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
if (parameterDescriptor != null) {
if (parameterDescriptor.isReified()) {
member.getReifiedTypeParametersUsages().addUsedReifiedParameter(parameterDescriptor.getName().asString());
}
} else {
processTypeArguments(member, supertypeArgument.getType());
}
}
}
@@ -3009,7 +3019,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@NotNull
private KotlinType approximateCapturedType(@NotNull KotlinType type) {
if (state.getLanguageVersionSettings().supportsFeature(LanguageFeature.NewInference)) {
TypeApproximator approximator = new TypeApproximator(state.getModule().getBuiltIns());
TypeApproximator approximator = new TypeApproximator(state.getModule().getBuiltIns(), state.getLanguageVersionSettings());
KotlinType approximatedType =
TypeUtils.contains(type, (containedType) -> CapturedTypeConstructorKt.isCaptured(containedType)) ?

View File

@@ -188,6 +188,12 @@ class JvmRuntimeTypes(
else -> if (isMutable) mutablePropertyReferences else propertyReferences
}
return classes[arity].defaultType
return if (arity >= 0) {
classes[arity].defaultType
} else {
//in case of ErrorUtils.ERROR_PROPERTY there would be no dispatchReceiverParameter and arity becomes negative
//so we just take zero argument reference class (because it is incorrect anyway)
classes[0].defaultType
}
}
}

View File

@@ -999,7 +999,7 @@ class CoroutineTransformerMethodVisitor(
else -> next = next.next
}
}
return next
return null
}
// It's necessary to preserve some sensible invariants like there should be no jump in the middle of try-catch-block
@@ -1329,7 +1329,7 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
variable.desc,
variable.signature,
variable.start,
nextSuspensionPointStartLabel(variable.start),
min(variable.end, nextSuspensionPointStartLabel(variable.start)),
variable.index
)
)

View File

@@ -320,8 +320,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
val splitBy = SimpleInterval(start.info as LabelNode, extension.finallyIntervalEnd)
processor.tryBlocksMetaInfo.splitAndRemoveCurrentIntervals(splitBy, true)
//processor.getLocalVarsMetaInfo().splitAndRemoveIntervalsFromCurrents(splitBy);
processor.localVarsMetaInfo.splitAndRemoveCurrentIntervals(splitBy, true);
mark.dropTo()
}
@@ -330,8 +329,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
}
processor.substituteTryBlockNodes(intoNode)
//processor.substituteLocalVarTable(intoNode);
processor.substituteLocalVarTable(intoNode);
}
protected abstract fun generateAssertFieldIfNeeded(info: RootInliningContext)

View File

@@ -5,32 +5,14 @@
package org.jetbrains.kotlin.codegen.inline
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil
import org.jetbrains.kotlin.codegen.PropertyReferenceCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.*
import org.jetbrains.kotlin.codegen.binding.MutableClosure
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
import org.jetbrains.kotlin.codegen.coroutines.isCapturedSuspendLambda
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.coroutines.isSuspendLambda
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.*
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.*
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode
import kotlin.properties.Delegates
@@ -47,7 +29,9 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
abstract val invokeMethod: Method
abstract val invokeMethodDescriptor: FunctionDescriptor
abstract val invokeMethodParameters: List<KotlinType?>
abstract val invokeMethodReturnType: KotlinType?
abstract val capturedVars: List<CapturedParamDesc>
@@ -56,6 +40,8 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
lateinit var node: SMAPAndMethodNode
val reifiedTypeParametersUsages = ReifiedTypeParametersUsages()
abstract fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>)
open val hasDispatchReceiver = true
@@ -90,31 +76,21 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
object NonInlineableArgumentForInlineableParameterCalledInSuspend : FunctionalArgument
object NonInlineableArgumentForInlineableSuspendParameter : FunctionalArgument
class PsiDefaultLambda(
lambdaClassType: Type,
capturedArgs: Array<Type>,
parameterDescriptor: ValueParameterDescriptor,
offset: Int,
needReification: Boolean
) : DefaultLambda(lambdaClassType, capturedArgs, parameterDescriptor, offset, needReification) {
override fun mapAsmSignature(sourceCompiler: SourceCompilerForInline): Method {
return sourceCompiler.state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor).asmMethod
abstract class ExpressionLambda(isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
node = sourceCompiler.generateLambdaBody(this, reifiedTypeParametersUsages)
node.node.preprocessSuspendMarkers(forInline = true, keepFakeContinuation = false)
}
override fun findInvokeMethodDescriptor(): FunctionDescriptor =
parameterDescriptor.type.memberScope
.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND)
.single()
abstract fun isCapturedSuspend(desc: CapturedParamDesc): Boolean
}
abstract class DefaultLambda(
override val lambdaClassType: Type,
private val capturedArgs: Array<Type>,
val parameterDescriptor: ValueParameterDescriptor,
isCrossinline: Boolean,
val offset: Int,
val needReification: Boolean
) : LambdaInfo(parameterDescriptor.isCrossinline) {
) : LambdaInfo(isCrossinline) {
final override var isBoundCallableReference by Delegates.notNull<Boolean>()
private set
@@ -124,80 +100,52 @@ abstract class DefaultLambda(
final override lateinit var invokeMethod: Method
private set
override lateinit var invokeMethodDescriptor: FunctionDescriptor
final override lateinit var capturedVars: List<CapturedParamDesc>
private set
var originalBoundReceiverType: Type? = null
private set
override val isSuspend = parameterDescriptor.isSuspendLambda
override val isSuspend = false // TODO: it should probably be true sometimes, but it never was
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
val classBytes = loadClassBytesByInternalName(sourceCompiler.state, lambdaClassType.internalName)
val classReader = ClassReader(classBytes)
var isPropertyReference = false
var isFunctionReference = false
classReader.accept(object : ClassVisitor(Opcodes.API_VERSION) {
override fun visit(
version: Int,
access: Int,
name: String,
signature: String?,
superName: String?,
interfaces: Array<out String>?
) {
isPropertyReference = superName in PROPERTY_REFERENCE_SUPER_CLASSES
isFunctionReference = superName == FUNCTION_REFERENCE.internalName || superName == FUNCTION_REFERENCE_IMPL.internalName
super.visit(version, access, name, signature, superName, interfaces)
}
}, ClassReader.SKIP_CODE or ClassReader.SKIP_FRAMES or ClassReader.SKIP_DEBUG)
invokeMethodDescriptor = findInvokeMethodDescriptor().let {
//property reference generates erased 'get' method
if (isPropertyReference) it.original else it
}
val descriptor = Type.getMethodDescriptor(Type.VOID_TYPE, *capturedArgs)
val constructor = getMethodNode(classBytes, "<init>", descriptor, lambdaClassType)?.node
val superName = ClassReader(classBytes).superName
val isPropertyReference = superName in PROPERTY_REFERENCE_SUPER_CLASSES
val isFunctionReference = superName == FUNCTION_REFERENCE.internalName || superName == FUNCTION_REFERENCE_IMPL.internalName
val constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, *capturedArgs)
val constructor = getMethodNode(classBytes, "<init>", constructorDescriptor, lambdaClassType)?.node
assert(constructor != null || capturedArgs.isEmpty()) {
"Can't find non-default constructor <init>$descriptor for default lambda $lambdaClassType"
"Can't find non-default constructor <init>$constructorDescriptor for default lambda $lambdaClassType"
}
capturedVars =
if (isFunctionReference || isPropertyReference)
constructor?.desc?.let { Type.getArgumentTypes(it) }?.singleOrNull()?.let {
originalBoundReceiverType = it
listOf(capturedParamDesc(AsmUtil.RECEIVER_PARAMETER_NAME, it.boxReceiverForBoundReference()))
listOf(capturedParamDesc(AsmUtil.RECEIVER_PARAMETER_NAME, AsmUtil.boxType(it)))
} ?: emptyList()
else
constructor?.findCapturedFieldAssignmentInstructions()?.map { fieldNode ->
capturedParamDesc(fieldNode.name, Type.getType(fieldNode.desc))
}?.toList() ?: emptyList()
isBoundCallableReference = (isFunctionReference || isPropertyReference) && capturedVars.isNotEmpty()
val methodName = (if (isPropertyReference) OperatorNameConventions.GET else OperatorNameConventions.INVOKE).asString()
val signature = mapAsmSignature(sourceCompiler)
node = getMethodNode(classBytes, methodName, signature.descriptor, lambdaClassType, signatureAmbiguity = true)
?: error("Can't find method '$methodName$signature' in '${classReader.className}'")
invokeMethod = Method(node.node.name, node.node.desc)
val invokeNameFallback = (if (isPropertyReference) OperatorNameConventions.GET else OperatorNameConventions.INVOKE).asString()
val invokeMethod = mapAsmMethod(sourceCompiler, isPropertyReference)
// TODO: `signatureAmbiguity = true` ignores the argument types from `invokeDescriptor` and only looks at the count.
// This effectively masks incorrect results from `mapAsmDescriptor`, which hopefully won't manifest in another way.
node = getMethodNode(classBytes, invokeMethod.name, invokeMethod.descriptor, lambdaClassType, signatureAmbiguity = true)
?: getMethodNode(classBytes, invokeNameFallback, invokeMethod.descriptor, lambdaClassType, signatureAmbiguity = true)
?: error("Can't find method '$invokeMethod' in '${lambdaClassType.internalName}'")
this.invokeMethod = Method(node.node.name, node.node.desc)
if (needReification) {
//nested classes could also require reification
reifiedTypeInliner.reifyInstructions(node.node)
reifiedTypeParametersUsages.mergeAll(reifiedTypeInliner.reifyInstructions(node.node))
}
}
protected abstract fun mapAsmSignature(sourceCompiler: SourceCompilerForInline): Method
protected abstract fun findInvokeMethodDescriptor(): FunctionDescriptor
protected abstract fun mapAsmMethod(sourceCompiler: SourceCompilerForInline, isPropertyReference: Boolean): Method
private companion object {
val PROPERTY_REFERENCE_SUPER_CLASSES =
@@ -208,131 +156,3 @@ abstract class DefaultLambda(
.mapTo(HashSet(), Type::getInternalName)
}
}
internal fun Type.boxReceiverForBoundReference() =
AsmUtil.boxType(this)
internal fun Type.boxReceiverForBoundReference(kotlinType: KotlinType, typeMapper: KotlinTypeMapper) =
DescriptorAsmUtil.boxType(this, kotlinType, typeMapper)
abstract class ExpressionLambda(isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>) {
node = sourceCompiler.generateLambdaBody(this)
node.node.preprocessSuspendMarkers(forInline = true, keepFakeContinuation = false)
}
abstract fun getInlineSuspendLambdaViewDescriptor(): FunctionDescriptor
abstract fun isCapturedSuspend(desc: CapturedParamDesc): Boolean
}
class PsiExpressionLambda(
expression: KtExpression,
private val typeMapper: KotlinTypeMapper,
private val languageVersionSettings: LanguageVersionSettings,
isCrossInline: Boolean,
override val isBoundCallableReference: Boolean
) : ExpressionLambda(isCrossInline) {
override val lambdaClassType: Type
override val invokeMethod: Method
override val invokeMethodDescriptor: FunctionDescriptor
val classDescriptor: ClassDescriptor
val propertyReferenceInfo: PropertyReferenceInfo?
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
override val returnLabels: Map<String, Label?>
override val isSuspend: Boolean
var closure: CalculatedClosure
private set
init {
val bindingContext = typeMapper.bindingContext
val function =
bindingContext.get<PsiElement, SimpleFunctionDescriptor>(BindingContext.FUNCTION, functionWithBodyOrCallableReference)
if (function == null && expression is KtCallableReferenceExpression) {
val variableDescriptor =
bindingContext.get(BindingContext.VARIABLE, functionWithBodyOrCallableReference) as? VariableDescriptorWithAccessors
?: throw AssertionError("Reference expression not resolved to variable descriptor with accessors: ${expression.getText()}")
classDescriptor = bindingContext.get(CLASS_FOR_CALLABLE, variableDescriptor)
?: throw IllegalStateException("Class for callable not found: $variableDescriptor\n${expression.text}")
lambdaClassType = typeMapper.mapClass(classDescriptor)
val getFunction = PropertyReferenceCodegen.findGetFunction(variableDescriptor)
invokeMethodDescriptor = PropertyReferenceCodegen.createFakeOpenDescriptor(getFunction, classDescriptor)
val resolvedCall = expression.callableReference.getResolvedCallWithAssert(bindingContext)
propertyReferenceInfo = PropertyReferenceInfo(
resolvedCall.resultingDescriptor as VariableDescriptor, getFunction
)
} else {
propertyReferenceInfo = null
invokeMethodDescriptor = function ?: throw AssertionError("Function is not resolved to descriptor: " + expression.text)
classDescriptor = bindingContext.get(CLASS_FOR_CALLABLE, invokeMethodDescriptor)
?: throw IllegalStateException("Class for invoke method not found: $invokeMethodDescriptor\n${expression.text}")
lambdaClassType = asmTypeForAnonymousClass(bindingContext, invokeMethodDescriptor)
}
bindingContext.get<ClassDescriptor, MutableClosure>(CLOSURE, classDescriptor).let {
assert(it != null) { "Closure for lambda should be not null " + expression.text }
closure = it!!
}
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
isSuspend = invokeMethodDescriptor.isSuspend
}
override val capturedVars: List<CapturedParamDesc> by lazy {
arrayListOf<CapturedParamDesc>().apply {
val captureThis = closure.capturedOuterClassDescriptor
if (captureThis != null) {
val kotlinType = captureThis.defaultType
val type = typeMapper.mapType(kotlinType)
val descriptor = EnclosedValueDescriptor(
AsmUtil.CAPTURED_THIS_FIELD, null,
StackValue.field(type, lambdaClassType, AsmUtil.CAPTURED_THIS_FIELD, false, StackValue.LOCAL_0),
type, kotlinType
)
add(getCapturedParamInfo(descriptor))
}
val capturedReceiver = closure.capturedReceiverFromOuterContext
if (capturedReceiver != null) {
val type = typeMapper.mapType(capturedReceiver).let {
if (isBoundCallableReference) it.boxReceiverForBoundReference() else it
}
val fieldName = closure.getCapturedReceiverFieldName(typeMapper.bindingContext, languageVersionSettings)
val descriptor = EnclosedValueDescriptor(
fieldName, null,
StackValue.field(type, capturedReceiver, lambdaClassType, fieldName, false, StackValue.LOCAL_0),
type, capturedReceiver
)
add(getCapturedParamInfo(descriptor))
}
closure.captureVariables.values.forEach { descriptor ->
add(getCapturedParamInfo(descriptor))
}
}
}
val isPropertyReference: Boolean
get() = propertyReferenceInfo != null
override fun getInlineSuspendLambdaViewDescriptor(): FunctionDescriptor {
return getOrCreateJvmSuspendFunctionView(
invokeMethodDescriptor,
languageVersionSettings.isReleaseCoroutines(),
typeMapper.bindingContext
)
}
override fun isCapturedSuspend(desc: CapturedParamDesc): Boolean =
isCapturedSuspendLambda(closure, desc.fieldName, typeMapper.bindingContext)
}

View File

@@ -23,13 +23,10 @@ import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.nullCheck.isCheckParameterIsNotNull
import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.SmartSet
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -233,52 +230,34 @@ class MethodInliner(
return
}
// in case of inlining suspend lambda reference as ordinary parameter of inline function:
// suspend fun foo (...) ...
// inline fun inlineMe(c: (...) -> ...) ...
// builder {
// inlineMe(::foo)
// }
// we should create additional parameter for continuation.
var coroutineDesc = desc
val actualInvokeDescriptor: FunctionDescriptor
if (info.isSuspend) {
actualInvokeDescriptor = (info as ExpressionLambda).getInlineSuspendLambdaViewDescriptor()
val parametersSize = actualInvokeDescriptor.valueParameters.size +
(if (actualInvokeDescriptor.extensionReceiverParameter != null) 1 else 0)
// And here we expect invoke(...Ljava/lang/Object;) be replaced with invoke(...Lkotlin/coroutines/Continuation;)
// if this does not happen, insert fake continuation, since we could not have one yet.
val argumentTypes = Type.getArgumentTypes(desc)
if (argumentTypes.size != parametersSize &&
// But do not add it in IR. In IR we already have lowered lambdas with additional parameter, while in Old BE we don't.
!inliningContext.root.state.isIrBackend
) {
val nullableAnyType = inliningContext.root.sourceCompilerForInline.compilationContextDescriptor.builtIns.nullableAnyType
val expectedParameters = info.invokeMethod.argumentTypes
val expectedKotlinParameters = info.invokeMethodParameters
val argumentCount = Type.getArgumentTypes(desc).size.let {
if (!inliningContext.root.state.isIrBackend && info.isSuspend && it < expectedParameters.size) {
// Inlining suspend lambda into a function that takes a non-suspend lambda.
// In the IR backend, this cannot happen as inline lambdas are not lowered.
addFakeContinuationMarker(this)
coroutineDesc = Type.getMethodDescriptor(Type.getReturnType(desc), *argumentTypes, AsmTypes.OBJECT_TYPE)
}
} else {
actualInvokeDescriptor = info.invokeMethodDescriptor
it + 1
} else it
}
assert(argumentCount == expectedParameters.size && argumentCount == expectedKotlinParameters.size) {
"inconsistent lambda arguments: $argumentCount on stack, ${expectedParameters.size} expected, " +
"${expectedKotlinParameters.size} Kotlin types"
}
val valueParameters =
listOfNotNull(actualInvokeDescriptor.extensionReceiverParameter) + actualInvokeDescriptor.valueParameters
val erasedInvokeFunction = ClosureCodegen.getErasedInvokeFunction(actualInvokeDescriptor)
val invokeParameters = erasedInvokeFunction.valueParameters
val valueParamShift = max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
val parameterTypesFromDesc = info.invokeMethod.argumentTypes
putStackValuesIntoLocalsForLambdaOnInvoke(
listOf(*parameterTypesFromDesc), valueParameters, invokeParameters, valueParamShift, this, coroutineDesc
)
if (parameterTypesFromDesc.isEmpty()) {
// There won't be no parameters processing and line call can be left without actual instructions.
// Note: if function is called on the line with other instructions like 1 + foo(), 'nop' will still be generated.
visitInsn(Opcodes.NOP)
var valueParamShift = max(nextLocalIndex, markerShift) + expectedParameters.sumOf { it.size }
for (index in argumentCount - 1 downTo 0) {
val type = expectedParameters[index]
StackValue.coerce(AsmTypes.OBJECT_TYPE, nullableAnyType, type, expectedKotlinParameters[index], this)
valueParamShift -= type.size
store(valueParamShift, type)
}
if (expectedParameters.isEmpty()) {
nop() // add something for a line number to bind onto
}
inlineOnlySmapSkipper?.onInlineLambdaStart(remappingMethodAdapter, info, sourceMapper.parent)
inlineOnlySmapSkipper?.onInlineLambdaStart(remappingMethodAdapter, info.node.node, sourceMapper.parent)
addInlineMarker(this, true)
val lambdaParameters = info.addAllParameters(nodeRemapper)
@@ -303,10 +282,9 @@ class MethodInliner(
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info.returnLabels, invokeCall.finallyDepthShift)
result.mergeWithNotChangeInfo(lambdaResult)
result.reifiedTypeParametersUsages.mergeAll(lambdaResult.reifiedTypeParametersUsages)
result.reifiedTypeParametersUsages.mergeAll(info.reifiedTypeParametersUsages)
StackValue
.onStack(info.invokeMethod.returnType, info.invokeMethodDescriptor.returnType)
.put(OBJECT_TYPE, erasedInvokeFunction.returnType, this)
StackValue.coerce(info.invokeMethod.returnType, info.invokeMethodReturnType, OBJECT_TYPE, nullableAnyType, this)
setLambdaInlining(false)
addInlineMarker(this, false)
inlineOnlySmapSkipper?.onInlineLambdaEnd(remappingMethodAdapter)
@@ -1073,46 +1051,6 @@ class MethodInliner(
}
}
private fun putStackValuesIntoLocalsForLambdaOnInvoke(
directOrder: List<Type>,
directOrderOfArguments: List<ParameterDescriptor>,
directOrderOfInvokeParameters: List<ValueParameterDescriptor>,
shift: Int,
iv: InstructionAdapter,
descriptor: String
) {
val actualParams = Type.getArgumentTypes(descriptor)
assert(actualParams.size == directOrder.size) {
"Number of expected and actual parameters should be equal, but ${actualParams.size} != ${directOrder.size}!"
}
var currentShift = shift + directOrder.sumOf { it.size }
val safeToUseArgumentKotlinType =
directOrder.size == directOrderOfArguments.size && directOrderOfArguments.size == directOrderOfInvokeParameters.size
for (index in directOrder.lastIndex downTo 0) {
val type = directOrder[index]
currentShift -= type.size
val typeOnStack = actualParams[index]
val argumentKotlinType: KotlinType?
val invokeParameterKotlinType: KotlinType?
if (safeToUseArgumentKotlinType) {
argumentKotlinType = directOrderOfArguments[index].type
invokeParameterKotlinType = directOrderOfInvokeParameters[index].type
} else {
argumentKotlinType = null
invokeParameterKotlinType = null
}
if (typeOnStack != type || invokeParameterKotlinType != argumentKotlinType) {
StackValue.onStack(typeOnStack, invokeParameterKotlinType).put(type, argumentKotlinType, iv)
}
iv.store(currentShift, type)
}
}
//process local and global returns (local substituted with goto end-label global kept unchanged)
@JvmStatic
fun processReturns(

View File

@@ -5,20 +5,25 @@
package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
import org.jetbrains.kotlin.builtins.isSuspendFunctionTypeOrSubtype
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil.getMethodAsmFlags
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor
import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView
import org.jetbrains.kotlin.codegen.coroutines.isCapturedSuspendLambda
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtIfExpression
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
@@ -28,8 +33,11 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.MethodNode
class PsiInlineCodegen(
@@ -140,9 +148,9 @@ class PsiInlineCodegen(
val receiverKotlinType = receiver.kotlinType
val boxedReceiver =
if (receiverKotlinType != null)
receiver.type.boxReceiverForBoundReference(receiverKotlinType, state.typeMapper)
DescriptorAsmUtil.boxType(receiver.type, receiverKotlinType, state.typeMapper)
else
receiver.type.boxReceiverForBoundReference()
AsmUtil.boxType(receiver.type)
putClosureParametersOnStack(
lambdaInfo,
@@ -214,3 +222,154 @@ class PsiInlineCodegen(
override fun descriptorIsDeserialized(memberDescriptor: CallableMemberDescriptor): Boolean =
memberDescriptor is DescriptorWithContainerSource
}
private val FunctionDescriptor.explicitParameters
get() = listOfNotNull(extensionReceiverParameter) + valueParameters
class PsiExpressionLambda(
expression: KtExpression,
private val typeMapper: KotlinTypeMapper,
private val languageVersionSettings: LanguageVersionSettings,
isCrossInline: Boolean,
override val isBoundCallableReference: Boolean
) : ExpressionLambda(isCrossInline) {
override val lambdaClassType: Type
override val invokeMethod: Method
val invokeMethodDescriptor: FunctionDescriptor
override val invokeMethodParameters: List<KotlinType?>
get() {
val actualInvokeDescriptor = if (isSuspend)
getOrCreateJvmSuspendFunctionView(
invokeMethodDescriptor, languageVersionSettings.isReleaseCoroutines(), typeMapper.bindingContext
)
else
invokeMethodDescriptor
return actualInvokeDescriptor.explicitParameters.map { it.returnType }
}
override val invokeMethodReturnType: KotlinType?
get() = invokeMethodDescriptor.returnType
val classDescriptor: ClassDescriptor
val propertyReferenceInfo: PropertyReferenceInfo?
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
override val returnLabels: Map<String, Label?>
override val isSuspend: Boolean
val closure: CalculatedClosure
init {
val bindingContext = typeMapper.bindingContext
val function = bindingContext.get(BindingContext.FUNCTION, functionWithBodyOrCallableReference)
if (function == null && expression is KtCallableReferenceExpression) {
val variableDescriptor =
bindingContext.get(BindingContext.VARIABLE, functionWithBodyOrCallableReference) as? VariableDescriptorWithAccessors
?: throw AssertionError("Reference expression not resolved to variable descriptor with accessors: ${expression.getText()}")
classDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, variableDescriptor)
?: throw IllegalStateException("Class for callable not found: $variableDescriptor\n${expression.text}")
lambdaClassType = typeMapper.mapClass(classDescriptor)
val getFunction = PropertyReferenceCodegen.findGetFunction(variableDescriptor)
invokeMethodDescriptor = PropertyReferenceCodegen.createFakeOpenDescriptor(getFunction, classDescriptor)
val resolvedCall = expression.callableReference.getResolvedCallWithAssert(bindingContext)
propertyReferenceInfo = PropertyReferenceInfo(resolvedCall.resultingDescriptor as VariableDescriptor, getFunction)
} else {
propertyReferenceInfo = null
invokeMethodDescriptor = function ?: throw AssertionError("Function is not resolved to descriptor: " + expression.text)
classDescriptor = bindingContext.get(CodegenBinding.CLASS_FOR_CALLABLE, invokeMethodDescriptor)
?: throw IllegalStateException("Class for invoke method not found: $invokeMethodDescriptor\n${expression.text}")
lambdaClassType = CodegenBinding.asmTypeForAnonymousClass(bindingContext, invokeMethodDescriptor)
}
closure = bindingContext.get(CodegenBinding.CLOSURE, classDescriptor)
?: throw AssertionError("null closure for lambda ${expression.text}")
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
isSuspend = invokeMethodDescriptor.isSuspend
}
override val capturedVars: List<CapturedParamDesc> by lazy {
arrayListOf<CapturedParamDesc>().apply {
val captureThis = closure.capturedOuterClassDescriptor
if (captureThis != null) {
val kotlinType = captureThis.defaultType
val type = typeMapper.mapType(kotlinType)
val descriptor = EnclosedValueDescriptor(
AsmUtil.CAPTURED_THIS_FIELD, null,
StackValue.field(type, lambdaClassType, AsmUtil.CAPTURED_THIS_FIELD, false, StackValue.LOCAL_0),
type, kotlinType
)
add(getCapturedParamInfo(descriptor))
}
val capturedReceiver = closure.capturedReceiverFromOuterContext
if (capturedReceiver != null) {
val type = typeMapper.mapType(capturedReceiver).let {
if (isBoundCallableReference) AsmUtil.boxType(it) else it
}
val fieldName = closure.getCapturedReceiverFieldName(typeMapper.bindingContext, languageVersionSettings)
val descriptor = EnclosedValueDescriptor(
fieldName, null,
StackValue.field(type, capturedReceiver, lambdaClassType, fieldName, false, StackValue.LOCAL_0),
type, capturedReceiver
)
add(getCapturedParamInfo(descriptor))
}
closure.captureVariables.values.forEach { descriptor ->
add(getCapturedParamInfo(descriptor))
}
}
}
val isPropertyReference: Boolean
get() = propertyReferenceInfo != null
override fun isCapturedSuspend(desc: CapturedParamDesc): Boolean =
isCapturedSuspendLambda(closure, desc.fieldName, typeMapper.bindingContext)
}
class PsiDefaultLambda(
override val lambdaClassType: Type,
capturedArgs: Array<Type>,
private val parameterDescriptor: ValueParameterDescriptor,
offset: Int,
needReification: Boolean
) : DefaultLambda(capturedArgs, parameterDescriptor.isCrossinline, offset, needReification) {
private lateinit var invokeMethodDescriptor: FunctionDescriptor
override val invokeMethodParameters: List<KotlinType?>
get() = invokeMethodDescriptor.explicitParameters.map { it.returnType }
override val invokeMethodReturnType: KotlinType?
get() = invokeMethodDescriptor.returnType
override fun mapAsmMethod(sourceCompiler: SourceCompilerForInline, isPropertyReference: Boolean): Method {
val substitutedDescriptor = parameterDescriptor.type.memberScope
.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND)
.single()
invokeMethodDescriptor = when {
// Property references: `(A) -> B` => `get(Any?): Any?`
isPropertyReference -> substitutedDescriptor.original
// Suspend function references: `suspend (A) -> B` => `invoke(A, Continuation<B>): Any?`
// TODO: default suspend lambdas are currently uninlinable
parameterDescriptor.type.isSuspendFunctionType ->
getOrCreateJvmSuspendFunctionView(
substitutedDescriptor,
sourceCompiler.state.languageVersionSettings.isReleaseCoroutines(),
sourceCompiler.state.bindingContext
)
// Non-suspend function references and lambdas: `(A) -> B` => `invoke(A): B`
else -> substitutedDescriptor
}
return sourceCompiler.state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor).asmMethod
}
}

View File

@@ -48,7 +48,7 @@ interface SourceCompilerForInline {
val lazySourceMapper: SourceMapper
fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode
fun generateLambdaBody(lambdaInfo: ExpressionLambda, reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode
fun doCreateMethodNodeFromSource(
callableDescriptor: FunctionDescriptor,
@@ -130,7 +130,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
override val lazySourceMapper
get() = codegen.parentCodegen.orCreateSourceMapper
override fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode {
override fun generateLambdaBody(lambdaInfo: ExpressionLambda, reifiedTypeParameters: ReifiedTypeParametersUsages): SMAPAndMethodNode {
lambdaInfo as? PsiExpressionLambda ?: error("TODO")
val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor
val jvmMethodSignature = state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor)

View File

@@ -2,11 +2,10 @@
* 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.
*/
@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
package org.jetbrains.kotlin.codegen.inline.coroutines
import com.intellij.util.ArrayUtil
import jdk.internal.org.objectweb.asm.Type
import org.jetbrains.kotlin.codegen.ClassBuilder
import org.jetbrains.kotlin.codegen.coroutines.*
import org.jetbrains.kotlin.codegen.inline.*
@@ -20,6 +19,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
@@ -287,4 +287,4 @@ private class CapturedLambdaInterpreter : BasicInterpreter(Opcodes.API_VERSION)
override fun merge(v: BasicValue?, w: BasicValue?): BasicValue? =
if (v is PossibleLambdaLoad && w is PossibleLambdaLoad && v.insn == w.insn) v else super.merge(v, w)
}
}

View File

@@ -579,8 +579,8 @@ class InlineOnlySmapSkipper(codegen: BaseExpressionCodegen) {
const val LOCAL_VARIABLE_INLINE_ARGUMENT_SYNTHETIC_LINE_NUMBER = 1
}
fun onInlineLambdaStart(mv: MethodVisitor, info: LambdaInfo, smap: SourceMapper) {
val firstLine = info.node.node.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
fun onInlineLambdaStart(mv: MethodVisitor, lambda: MethodNode, smap: SourceMapper) {
val firstLine = lambda.instructions.asSequence().mapNotNull { it as? LineNumberNode }.firstOrNull()?.line ?: -1
if (callLineNumber >= 0 && firstLine == callLineNumber) {
// We want the debugger to be able to break both on the inline call itself, plus on each
// invocation of the inline lambda passed to it. For that to happen there needs to be at least

View File

@@ -17,12 +17,9 @@
package org.jetbrains.kotlin.codegen.optimization.boxing
import org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor
import org.jetbrains.kotlin.codegen.optimization.common.debugText
import org.jetbrains.kotlin.codegen.optimization.common.isLoadOperation
import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
import org.jetbrains.kotlin.codegen.optimization.fixStack.peekWords
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.removeNodeGetNext
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.tree.*
@@ -32,91 +29,66 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
import java.util.*
private typealias Transformation = (AbstractInsnNode) -> Unit
class PopBackwardPropagationTransformer : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
if (!OptimizationMethodVisitor.canBeOptimizedUsingSourceInterpreter(methodNode)) return
Transformer(methodNode).transform()
if (methodNode.instructions.any { it.isPop() || it.isPurePush() }) {
Transformer(methodNode).transform()
}
}
private class Transformer(val methodNode: MethodNode) {
private interface Transformation {
fun apply(insn: AbstractInsnNode)
}
private inline fun Transformation(crossinline body: (AbstractInsnNode) -> Unit): Transformation =
object : Transformation {
override fun apply(insn: AbstractInsnNode) {
body(insn)
}
}
private val REPLACE_WITH_NOP = Transformation { insnList.set(it, createRemovableNopInsn()) }
private val REPLACE_WITH_POP1 = Transformation { insnList.set(it, InsnNode(Opcodes.POP)) }
private val REPLACE_WITH_POP2 = Transformation { insnList.set(it, InsnNode(Opcodes.POP2)) }
private val INSERT_POP1_AFTER = Transformation { insnList.insert(it, InsnNode(Opcodes.POP)) }
private val INSERT_POP2_AFTER = Transformation { insnList.insert(it, InsnNode(Opcodes.POP2)) }
private val REPLACE_WITH_NOP: Transformation = { insnList.set(it, InsnNode(Opcodes.NOP)) }
private val REPLACE_WITH_POP1: Transformation = { insnList.set(it, InsnNode(Opcodes.POP)) }
private val REPLACE_WITH_POP2: Transformation = { insnList.set(it, InsnNode(Opcodes.POP2)) }
private val INSERT_POP1_AFTER: Transformation = { insnList.insert(it, InsnNode(Opcodes.POP)) }
private val INSERT_POP2_AFTER: Transformation = { insnList.insert(it, InsnNode(Opcodes.POP2)) }
private val insnList = methodNode.instructions
private val insns = insnList.toArray()
private val dontTouchInsnIndices = BitSet(insns.size)
private val transformations = hashMapOf<AbstractInsnNode, Transformation>()
private val removableNops = hashSetOf<InsnNode>()
private val frames by lazy { analyzeMethodBody() }
fun transform() {
if (insns.none { it.isPop() || it.isPurePush() }) return
computeTransformations()
for ((insn, transformation) in transformations.entries) {
transformation.apply(insn)
}
postprocessNops()
}
private fun analyzeMethodBody(): Array<out Frame<SourceValue>?> {
val frames = Analyzer<SourceValue>(HazardsTrackingInterpreter()).analyze("fake", methodNode)
postprocessStackHazards(frames)
return frames
}
private fun postprocessStackHazards(frames: Array<out Frame<SourceValue>?>) {
val insns = methodNode.instructions.toArray()
for (i in frames.indices) {
val frames = Analyzer(HazardsTrackingInterpreter()).analyze("fake", methodNode)
for ((i, insn) in insns.withIndex()) {
val frame = frames[i] ?: continue
val insn = insns[i]
when (insn.opcode) {
Opcodes.POP2 -> {
val top2 = frame.peekWords(2) ?: throwIncorrectBytecode(insn, frame)
top2.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP_X1 -> {
val top2 = frame.peekWords(1, 1) ?: throwIncorrectBytecode(insn, frame)
top2.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP2_X1 -> {
val top3 = frame.peekWords(2, 1) ?: throwIncorrectBytecode(insn, frame)
top3.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP_X2 -> {
val top3 = frame.peekWords(1, 2) ?: throwIncorrectBytecode(insn, frame)
top3.forEach { it.insns.markAsDontTouch() }
}
Opcodes.DUP2_X2 -> {
val top4 = frame.peekWords(2, 2) ?: throwIncorrectBytecode(insn, frame)
top4.forEach { it.insns.markAsDontTouch() }
Opcodes.POP ->
frame.top()?.let { input ->
// If this POP won't be removed, other POPs that touch the same values have to stay as well.
if (input.insns.any { it.shouldKeep() } || input.longerWhenFusedWithPop()) {
input.insns.markAsDontTouch()
}
}
Opcodes.POP2 -> frame.peekWords(2)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP_X1 -> frame.peekWords(1, 1)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP2_X1 -> frame.peekWords(2, 1)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP_X2 -> frame.peekWords(1, 2)?.forEach { it.insns.markAsDontTouch() }
Opcodes.DUP2_X2 -> frame.peekWords(2, 2)?.forEach { it.insns.markAsDontTouch() }
}
}
val transformations = hashMapOf<AbstractInsnNode, Transformation>()
for ((i, insn) in insns.withIndex()) {
val frame = frames[i] ?: continue
if (insn.opcode == Opcodes.POP) {
val input = frame.top() ?: continue
if (input.insns.none { it.shouldKeep() }) {
transformations[insn] = REPLACE_WITH_NOP
input.insns.forEach {
if (it !in transformations) {
transformations[it] = it.combineWithPop(frames, input.size)
}
}
}
}
}
}
private fun throwIncorrectBytecode(insn: AbstractInsnNode?, frame: Frame<SourceValue>): Nothing {
throw AssertionError("Incorrect bytecode at ${methodNode.instructions.indexOf(insn)}: ${insn.debugText} $frame")
for ((insn, transformation) in transformations.entries) {
transformation(insn)
}
}
private inner class HazardsTrackingInterpreter : SourceInterpreter(Opcodes.API_VERSION) {
@@ -133,9 +105,7 @@ class PopBackwardPropagationTransformer : MethodTransformer() {
}
override fun unaryOperation(insn: AbstractInsnNode, value: SourceValue): SourceValue {
if (insn.opcode != Opcodes.CHECKCAST && !insn.isPrimitiveTypeConversion()) {
value.insns.markAsDontTouch()
}
value.insns.markAsDontTouch()
return super.unaryOperation(insn, value)
}
@@ -164,153 +134,48 @@ class PopBackwardPropagationTransformer : MethodTransformer() {
}
}
private fun computeTransformations() {
transformations.clear()
for (i in insns.indices) {
if (frames[i] == null) continue
val insn = insns[i]
if (insn.opcode == Opcodes.POP) {
propagatePopBackwards(insn, 0)
}
}
}
private fun propagatePopBackwards(insn: AbstractInsnNode, poppedValueSize: Int) {
if (transformations.containsKey(insn)) return
private fun SourceValue.longerWhenFusedWithPop() = insns.fold(0) { x, insn ->
when {
insn.opcode == Opcodes.POP -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
if (sources.all { !isDontTouch(it) } && sources.any { isTransformablePopOperand(it) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
insn.isPurePush() -> x - 1
insn.isPrimitiveBoxing() || insn.isPrimitiveTypeConversion() -> x
else -> x + 1
}
} > 0
private fun AbstractInsnNode.combineWithPop(frames: Array<out Frame<SourceValue>?>, resultSize: Int): Transformation =
when {
isPurePush() -> REPLACE_WITH_NOP
isPrimitiveBoxing() || isPrimitiveTypeConversion() -> {
val index = insnList.indexOf(this)
val frame = frames[index] ?: throw AssertionError("dead instruction #$index used by non-dead instruction")
val input = frame.top() ?: throw AssertionError("coercion instruction at #$index has no input")
when (input.size) {
1 -> REPLACE_WITH_POP1
2 -> REPLACE_WITH_POP2
else -> throw AssertionError("Unexpected pop value size: ${input.size}")
}
}
insn.opcode == Opcodes.CHECKCAST -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
val resultType = (insn as TypeInsnNode).desc
if (sources.all { !isDontTouch(it) } && sources.any { isTransformableCheckcastOperand(it, resultType) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
} else {
transformations[insn] = insertPopAfterTransformation(poppedValueSize)
else ->
when (resultSize) {
1 -> INSERT_POP1_AFTER
2 -> INSERT_POP2_AFTER
else -> throw AssertionError("Unexpected pop value size: $resultSize")
}
}
insn.isPrimitiveBoxing() -> {
val boxedValueSize = getInputTop(insn).size
transformations[insn] = replaceWithPopTransformation(boxedValueSize)
}
insn.isPurePush() -> {
transformations[insn] = replaceWithNopTransformation()
}
insn.isPrimitiveTypeConversion() -> {
val inputTop = getInputTop(insn)
val sources = inputTop.insns
if (sources.all { !isDontTouch(it) }) {
transformations[insn] = replaceWithNopTransformation()
sources.forEach { propagatePopBackwards(it, inputTop.size) }
} else {
transformations[insn] = replaceWithPopTransformation(poppedValueSize)
}
}
else -> {
transformations[insn] = insertPopAfterTransformation(poppedValueSize)
}
}
}
private fun postprocessNops() {
var node: AbstractInsnNode? = insnList.first
var hasRemovableNops = false
while (node != null) {
node = node.next
val begin = node ?: break
while (node != null && node !is LabelNode) {
if (node in removableNops) {
hasRemovableNops = true
}
node = node.next
}
val end = node
if (hasRemovableNops) {
removeUnneededNopsInRange(begin, end)
}
hasRemovableNops = false
}
}
private fun removeUnneededNopsInRange(begin: AbstractInsnNode, end: AbstractInsnNode?) {
var node: AbstractInsnNode? = begin
var keepNop = true
while (node != null && node != end) {
if (node in removableNops && !keepNop) {
node = insnList.removeNodeGetNext(node)
} else {
if (node.isMeaningful) keepNop = false
node = node.next
}
}
}
private fun replaceWithPopTransformation(size: Int): Transformation =
when (size) {
1 -> REPLACE_WITH_POP1
2 -> REPLACE_WITH_POP2
else -> throw AssertionError("Unexpected pop value size: $size")
}
private fun insertPopAfterTransformation(size: Int): Transformation =
when (size) {
1 -> INSERT_POP1_AFTER
2 -> INSERT_POP2_AFTER
else -> throw AssertionError("Unexpected pop value size: $size")
}
private fun replaceWithNopTransformation(): Transformation =
REPLACE_WITH_NOP
private fun createRemovableNopInsn() =
InsnNode(Opcodes.NOP).apply { removableNops.add(this) }
private fun getInputTop(insn: AbstractInsnNode): SourceValue {
val i = insnList.indexOf(insn)
val frame = frames[i] ?: throw AssertionError("Unexpected dead instruction #$i")
return frame.top() ?: throw AssertionError("Instruction #$i has empty stack on input")
}
private fun isTransformableCheckcastOperand(it: AbstractInsnNode, resultType: String) =
it.isPrimitiveBoxing() && (it as MethodInsnNode).owner == resultType
private fun isTransformablePopOperand(insn: AbstractInsnNode) =
insn.opcode == Opcodes.CHECKCAST || insn.isPrimitiveBoxing() || insn.isPurePush()
private fun isDontTouch(insn: AbstractInsnNode) =
dontTouchInsnIndices[insnList.indexOf(insn)]
private fun AbstractInsnNode.shouldKeep() =
dontTouchInsnIndices[insnList.indexOf(this)]
}
}
fun AbstractInsnNode.isPurePush() =
isLoadOperation() ||
opcode in Opcodes.ACONST_NULL..Opcodes.LDC + 2 ||
isUnitInstance()
isLoadOperation() || opcode in Opcodes.ACONST_NULL..Opcodes.LDC + 2 || isUnitInstance()
fun AbstractInsnNode.isPop() =
opcode == Opcodes.POP || opcode == Opcodes.POP2
fun AbstractInsnNode.isUnitInstance() =
opcode == Opcodes.GETSTATIC &&
this is FieldInsnNode && owner == "kotlin/Unit" && name == "INSTANCE"
opcode == Opcodes.GETSTATIC && this is FieldInsnNode && owner == "kotlin/Unit" && name == "INSTANCE"
fun AbstractInsnNode.isPrimitiveTypeConversion() =
opcode in Opcodes.I2L..Opcodes.I2S

View File

@@ -39,7 +39,7 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
override fun transform(internalClassName: String, node: MethodNode) {
val interpreter = RedundantBoxingInterpreter(node.instructions, generationState)
val frames = MethodTransformer.analyze(internalClassName, node, interpreter)
val frames = analyze(internalClassName, node, interpreter)
interpretPopInstructionsForBoxedValues(interpreter, node, frames)
@@ -168,7 +168,8 @@ class RedundantBoxingMethodTransformer(private val generationState: GenerationSt
val frame = frames[i] ?: continue
val insn = insnList[i]
if ((insn.opcode == Opcodes.ASTORE || insn.opcode == Opcodes.ALOAD) &&
(insn as VarInsnNode).`var` == localVariableNode.index) {
(insn as VarInsnNode).`var` == localVariableNode.index
) {
if (insn.getOpcode() == Opcodes.ASTORE) {
values.add(frame.top()!!)
} else {

View File

@@ -27,19 +27,19 @@ import org.jetbrains.org.objectweb.asm.commons.Method
import java.util.*
private val EXTERNAL_SOURCES_KINDS = arrayOf(
JvmDeclarationOriginKind.CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL,
JvmDeclarationOriginKind.DEFAULT_IMPL_DELEGATION_TO_SUPERINTERFACE_DEFAULT_IMPL,
JvmDeclarationOriginKind.DELEGATION,
JvmDeclarationOriginKind.BRIDGE
JvmDeclarationOriginKind.CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL,
JvmDeclarationOriginKind.DEFAULT_IMPL_DELEGATION_TO_SUPERINTERFACE_DEFAULT_IMPL,
JvmDeclarationOriginKind.DELEGATION,
JvmDeclarationOriginKind.BRIDGE
)
private val PREDEFINED_SIGNATURES = listOf(
"getClass()Ljava/lang/Class;",
"notify()V",
"notifyAll()V",
"wait()V",
"wait(J)V",
"wait(JI)V"
"getClass()Ljava/lang/Class;",
"notify()V",
"notifyAll()V",
"wait()V",
"wait(J)V",
"wait(JI)V"
).map { signature ->
RawSignature(signature.substringBefore('('), signature.substring(signature.indexOf('(')), MemberKind.METHOD)
}
@@ -77,8 +77,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
val elements = LinkedHashSet<PsiElement>()
if (noOwnImplementations) {
elements.addIfNotNull(data.classOrigin.element)
}
else {
} else {
for (origin in data.signatureOrigins) {
var element = origin.element
@@ -96,9 +95,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
}
override fun onClassDone(
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
) {
reportDiagnosticsTasks.add {
reportClashingWithPredefinedSignatures(classOrigin, classInternalName, signatures)
@@ -107,9 +106,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
}
private fun reportClashingWithPredefinedSignatures(
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
) {
for (predefinedSignature in PREDEFINED_SIGNATURES) {
if (!signatures.containsKey(predefinedSignature)) continue
@@ -122,9 +121,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
}
private fun reportClashingSignaturesInHierarchy(
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
) {
val descriptor = classOrigin.descriptor
if (descriptor !is ClassDescriptor) return
@@ -141,9 +140,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
for ((rawSignature, origins) in groupedBySignature.entrySet()) {
if (origins.size <= 1) continue
val diagnostic = computeDiagnosticToReport(classOrigin, classInternalName, rawSignature, origins)
when (diagnostic) {
when (val diagnostic = computeDiagnosticToReport(classOrigin, classInternalName, rawSignature, origins)) {
is ConflictingDeclarationError.AccidentalOverride -> {
diagnostics.report(ErrorsJvm.ACCIDENTAL_OVERRIDE.on(diagnostic.element, diagnostic.data))
}
@@ -156,16 +153,17 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
private sealed class ConflictingDeclarationError(val element: PsiElement, val data: ConflictingJvmDeclarationsData) {
class AccidentalOverride(element: PsiElement, data: ConflictingJvmDeclarationsData) :
ConflictingDeclarationError(element, data)
ConflictingDeclarationError(element, data)
class ConflictingInheritedJvmDeclarations(element: PsiElement, data: ConflictingJvmDeclarationsData) :
ConflictingDeclarationError(element, data)
ConflictingDeclarationError(element, data)
}
private fun computeDiagnosticToReport(
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
rawSignature: RawSignature,
origins: Collection<JvmDeclarationOrigin>
classOrigin: JvmDeclarationOrigin,
classInternalName: String,
rawSignature: RawSignature,
origins: Collection<JvmDeclarationOrigin>
): ConflictingDeclarationError? {
var memberElement: PsiElement? = null
var ownNonFakeCount = 0
@@ -211,19 +209,17 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
if (member is PropertyDescriptor) {
processMember(member.getter)
processMember(member.setter)
}
else if (member is FunctionDescriptor) {
} else if (member is FunctionDescriptor) {
val signatures =
if (member.kind == FAKE_OVERRIDE)
member.overriddenTreeUniqueAsSequence(useOriginal = true)
// drop the root (itself)
.drop(1)
.mapTo(HashSet()) { it.asRawSignature() }
else
setOf(member.asRawSignature())
if (member.kind == FAKE_OVERRIDE)
member.overriddenTreeUniqueAsSequence(useOriginal = true)
// drop the root (itself)
.drop(1)
.mapTo(HashSet()) { it.asRawSignature() }
else
setOf(member.asRawSignature())
signatures.forEach {
rawSignature ->
signatures.forEach { rawSignature ->
groupedBySignature.putValue(rawSignature, OtherOrigin(member))
}
}
@@ -232,10 +228,10 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
descriptor.defaultType.memberScope.getContributedDescriptors().forEach(::processMember)
descriptor.getParentJavaStaticClassScope()?.run {
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filter {
it is FunctionDescriptor && DescriptorVisibilities.isVisibleIgnoringReceiver(it, descriptor)
}
.forEach(::processMember)
.filter {
it is FunctionDescriptor && DescriptorVisibilities.isVisibleIgnoringReceiver(it, descriptor)
}
.forEach(::processMember)
}
return groupedBySignature

View File

@@ -245,6 +245,7 @@ class GenerationState private constructor(
this.moduleName,
languageVersionSettings,
useOldManglingSchemeForFunctionsWithInlineClassesInSignatures,
IncompatibleClassTracker.DoNothing,
target,
isIrBackend
)
@@ -330,7 +331,7 @@ class GenerationState private constructor(
val typeApproximator: TypeApproximator? =
if (languageVersionSettings.supportsFeature(LanguageFeature.NewInference))
TypeApproximator(module.builtIns)
TypeApproximator(module.builtIns, languageVersionSettings)
else
null

View File

@@ -0,0 +1,17 @@
/*
* Copyright 2010-2021 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.state
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
interface IncompatibleClassTracker {
fun record(binaryClass: KotlinJvmBinaryClass)
object DoNothing : IncompatibleClassTracker {
override fun record(binaryClass: KotlinJvmBinaryClass) {
}
}
}

View File

@@ -87,6 +87,9 @@ class KotlinTypeMapper @JvmOverloads constructor(
private val moduleName: String,
val languageVersionSettings: LanguageVersionSettings,
private val useOldInlineClassesManglingScheme: Boolean,
// temporary returned to preserve binary compatibility with Dagger in IDE
// https://android.googlesource.com/platform/tools/adt/idea/+/refs/heads/mirror-goog-studio-master-dev/dagger/src/com/android/tools/idea/dagger/DaggerAnnotatedElementsSearch.kt
private val incompatibleClassTracker: IncompatibleClassTracker = IncompatibleClassTracker.DoNothing,
val jvmTarget: JvmTarget = JvmTarget.DEFAULT,
private val isIrBackend: Boolean = false,
private val typePreprocessor: ((KotlinType) -> KotlinType?)? = null,

View File

@@ -87,11 +87,6 @@ fun CallableMemberDescriptor.createTypeParameterWithNewName(
return newDescriptor
}
fun KotlinType.removeExternalProjections(): KotlinType {
val newArguments = arguments.map { TypeProjectionImpl(Variance.INVARIANT, it.type) }
return replace(newArguments)
}
fun isInlineClassConstructorAccessor(descriptor: FunctionDescriptor): Boolean =
descriptor is AccessorForConstructorDescriptor &&
descriptor.calleeDescriptor.constructedClass.isInlineClass()

View File

@@ -16,10 +16,10 @@
package org.jetbrains.kotlin.cli.common
import com.intellij.util.LineSeparator
import java.util.*
enum class CompilerSystemProperties(val property: String) {
/**
* @param alwaysDirectAccess Gradle has a list of properties that can be read without declaring, see https://github.com/gradle/gradle/blob/f191a61cec61afe308f2b45184cb303d32706a6f/subprojects/configuration-cache/src/main/kotlin/org/gradle/configurationcache/SystemPropertyAccessListener.kt#L32
*/
enum class CompilerSystemProperties(val property: String, val alwaysDirectAccess: Boolean = false) {
COMPILE_DAEMON_ENABLED_PROPERTY("kotlin.daemon.enabled"),
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY("kotlin.daemon.jvm.options"),
COMPILE_DAEMON_OPTIONS_PROPERTY("kotlin.daemon.options"),
@@ -36,24 +36,31 @@ enum class CompilerSystemProperties(val property: String) {
KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY("kotlin.environment.keepalive"),
COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS("kotlin.daemon.custom.run.files.path.for.tests"),
KOTLIN_COLORS_ENABLED_PROPERTY("kotlin.colors.enabled"),
OS_NAME("os.name"),
OS_NAME("os.name", alwaysDirectAccess = true),
TMP_DIR("java.io.tmpdir"),
USER_HOME("user.home"),
JAVA_VERSION("java.specification.version"),
JAVA_HOME("java.home"),
JAVA_CLASS_PATH("java.class.path"),
USER_HOME("user.home", alwaysDirectAccess = true),
JAVA_VERSION("java.specification.version", alwaysDirectAccess = true),
JAVA_HOME("java.home", alwaysDirectAccess = true),
JAVA_CLASS_PATH("java.class.path", alwaysDirectAccess = true),
;
var value
get() = (systemPropertyGetter ?: System::getProperty)(property)
private fun <T> getProperFunction(custom: T?, default: T): T {
if (alwaysDirectAccess) return default
return custom ?: default
}
var value: String?
get() {
return getProperFunction(systemPropertyGetter, System::getProperty)(property)
}
set(value) {
(systemPropertySetter ?: System::setProperty)(property, value!!)
getProperFunction(systemPropertySetter, System::setProperty)(property, value!!)
}
val safeValue
get() = value ?: error("No value for $property system property")
fun clear(): String? = (systemPropertyCleaner ?: System::clearProperty)(property)
fun clear(): String? = getProperFunction(systemPropertyCleaner, System::clearProperty)(property)
companion object {
var systemPropertyGetter: ((String) -> String?)? = null

View File

@@ -377,7 +377,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"""
)
var stringConcat: String? by NullableStringFreezableVar(JvmStringConcat.INLINE.description)
var stringConcat: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xsam-conversions",

View File

@@ -1,20 +0,0 @@
plugins {
kotlin("jvm")
id("jps-compatible")
}
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) }
}
compile(intellijDep()) { includeJars("trove4j", "guava", "jdom", rootProject = rootProject) }
compile(intellijCoreDep()) { includeJars("intellij-core") }
}
sourceSets {
"main" { projectDefault() }
}

View File

@@ -1,153 +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.
*/
// Internal CLI for building JS IR libraries
package org.jetbrains.kotlin.ir.backend.js
import com.intellij.openapi.Disposable
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiManager
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
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
import org.jetbrains.kotlin.resolve.multiplatform.isCommonSource
import org.jetbrains.kotlin.serialization.js.ModuleKind
import org.jetbrains.kotlin.util.Logger
import java.io.File
fun buildConfiguration(environment: KotlinCoreEnvironment, moduleName: String): CompilerConfiguration {
val runtimeConfiguration = environment.configuration.copy()
runtimeConfiguration.put(CommonConfigurationKeys.MODULE_NAME, moduleName)
runtimeConfiguration.put(JSConfigurationKeys.MODULE_KIND, ModuleKind.PLAIN)
runtimeConfiguration.put(
CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY,
PrintingMessageCollector(System.err, MessageRenderer.PLAIN_RELATIVE_PATHS, false)
)
runtimeConfiguration.languageVersionSettings = LanguageVersionSettingsImpl(
LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE,
specificFeatures = mapOf(
LanguageFeature.AllowContractsForCustomFunctions to LanguageFeature.State.ENABLED,
LanguageFeature.MultiPlatformProjects to LanguageFeature.State.ENABLED
),
analysisFlags = mapOf(
AnalysisFlags.useExperimental to listOf(
"kotlin.RequiresOptIn",
"kotlin.contracts.ExperimentalContracts",
"kotlin.ExperimentalMultiplatform",
),
AnalysisFlags.allowResultReturnType to true
)
)
return runtimeConfiguration
}
@Suppress("RedundantSamConstructor")
private val environment =
KotlinCoreEnvironment.createForProduction(Disposable { }, CompilerConfiguration(), EnvironmentConfigFiles.JS_CONFIG_FILES)
fun createPsiFile(fileName: String): KtFile {
val psiManager = PsiManager.getInstance(environment.project)
val fileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
val file = fileSystem.findFileByPath(fileName) ?: error("File not found: $fileName")
return psiManager.findFile(file) as KtFile
}
fun buildKLib(
moduleName: String,
sources: List<String>,
outputPath: String,
allDependencies: KotlinLibraryResolveResult,
commonSources: List<String>
) {
val configuration = buildConfiguration(environment, moduleName)
generateKLib(
project = environment.project,
files = sources.map { source ->
val file = createPsiFile(source)
if (source in commonSources) {
file.isCommonSource = true
}
file
},
analyzer = AnalyzerWithCompilerReport(configuration),
configuration = configuration,
allDependencies = allDependencies,
friendDependencies = emptyList(),
irFactory = PersistentIrFactory(), // TODO: IrFactoryImpl?
outputKlibPath = outputPath,
nopack = true
)
}
private fun listOfKtFilesFrom(paths: List<String>): List<String> {
val currentDir = File("")
return paths.flatMap { path ->
File(path)
.walkTopDown()
.filter { it.extension == "kt" }
.map { it.relativeToOrSelf(currentDir).path }
.asIterable()
}.distinct()
}
fun main(args: Array<String>) {
val inputFiles = mutableListOf<String>()
var outputPath: String? = null
val dependencies = mutableListOf<String>()
val commonSources = mutableListOf<String>()
var moduleName: String? = null
var index = 0
while (index < args.size) {
val arg = args[index++]
when (arg) {
"-n" -> moduleName = args[index++]
"-o" -> outputPath = args[index++]
"-d" -> dependencies += args[index++]
"-c" -> commonSources += args[index++]
else -> inputFiles += arg
}
}
if (outputPath == null) {
error("Please set path to .klm file: `-o some/dir/module-name.klm`")
}
if (moduleName == null) {
error("Please set module name: `-n module-name`")
}
val resolvedLibraries = jsResolveLibraries(
dependencies, emptyList(), messageCollectorLogger(MessageCollector.NONE)
)
buildKLib(moduleName, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
}
// Copied here from `K2JsIrCompiler` instead of reusing in order to avoid circular dependencies between Gradle tasks
private fun messageCollectorLogger(collector: MessageCollector) = object : Logger {
override fun warning(message: String)= collector.report(CompilerMessageSeverity.STRONG_WARNING, message)
override fun error(message: String) = collector.report(CompilerMessageSeverity.ERROR, message)
override fun log(message: String) = collector.report(CompilerMessageSeverity.LOGGING, message)
override fun fatal(message: String): Nothing {
collector.report(CompilerMessageSeverity.ERROR, message)
(collector as? GroupingMessageCollector)?.flush()
kotlin.error(message)
}
}

View File

@@ -11,6 +11,7 @@ dependencies {
compile(project(":compiler:backend-common"))
compile(project(":compiler:ir.backend.common"))
compile(project(":compiler:ir.serialization.js"))
compile(project(":compiler:ir.tree.impl"))
compile(project(":compiler:backend.js"))
compile(project(":compiler:backend.wasm"))
compile(project(":js:js.translator"))

View File

@@ -17,7 +17,8 @@ import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR
import org.jetbrains.kotlin.cli.common.ExitCode.OK
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.DCE_RUNTIME_DIAGNOSTIC_EXCEPTION
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.DCE_RUNTIME_DIAGNOSTIC_LOG
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.extensions.ScriptEvaluationExtension
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
@@ -38,6 +39,7 @@ 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.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
import org.jetbrains.kotlin.js.config.*
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
@@ -230,6 +232,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
AnalyzerWithCompilerReport(config.configuration),
config.configuration,
PhaseConfig(wasmPhases),
IrFactoryImpl,
allDependencies = resolvedLibraries,
friendDependencies = friendDependencies,
exportedDeclarations = setOf(FqName("main"))
@@ -256,6 +259,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
AnalyzerWithCompilerReport(config.configuration),
config.configuration,
phaseConfig,
if (arguments.irDceDriven) PersistentIrFactory() else IrFactoryImpl,
allDependencies = resolvedLibraries,
friendDependencies = friendDependencies,
mainArguments = mainCallArguments,

View File

@@ -4,7 +4,6 @@ package com.intellij;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.util.ReflectionUtil;
@@ -93,7 +92,8 @@ public abstract class DynamicBundle extends AbstractBundle {
public static final DynamicBundle INSTANCE = new DynamicBundle("") {
};
public static class LanguageBundleEP extends AbstractExtensionPointBean {
@SuppressWarnings("deprecation")
public static class LanguageBundleEP extends com.intellij.openapi.extensions.AbstractExtensionPointBean {
public static final ExtensionPointName<LanguageBundleEP> EP_NAME = ExtensionPointName.create("com.intellij.languageBundle");
}

View File

@@ -21,7 +21,7 @@ class CodeAnalysisMeasurement(private val lines: Int?, val milliseconds: Long) :
override fun render(): String = formatMeasurement("ANALYZE", milliseconds, lines)
}
class CodeGenerationMeasurement(private val lines: Int?, private val milliseconds: Long) : PerformanceMeasurement {
class CodeGenerationMeasurement(private val lines: Int?, val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = formatMeasurement("GENERATE", milliseconds, lines)
}

View File

@@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.light.LightJavaModule
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.cli.common.config.ContentRoot
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
@@ -37,6 +38,7 @@ import org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleFinder
import org.jetbrains.kotlin.cli.jvm.modules.JavaModuleGraph
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.isValidJavaFqName
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
import org.jetbrains.kotlin.resolve.jvm.modules.KOTLIN_STDLIB_MODULE_NAME
@@ -52,10 +54,13 @@ class ClasspathRootsResolver(
private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?,
private val javaModuleFinder: CliJavaModuleFinder,
private val requireStdlibModule: Boolean,
private val outputDirectory: VirtualFile?
private val outputDirectory: VirtualFile?,
private val javaFileManager: KotlinCliJavaFileManager
) {
val javaModuleGraph = JavaModuleGraph(javaModuleFinder)
private val searchScope = GlobalSearchScope.allScope(psiManager.project)
data class RootsAndModules(val roots: List<JavaRoot>, val modules: List<JavaModule>)
private data class RootWithPrefix(val root: VirtualFile, val packagePrefix: String?)
@@ -160,7 +165,7 @@ class ClasspathRootsResolver(
}
if (moduleInfoFile != null) {
val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null
val moduleInfo = JavaModuleInfo.read(moduleInfoFile, javaFileManager, searchScope) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile)
}

View File

@@ -35,6 +35,10 @@ class CliVirtualFileFinder(
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? =
findBinaryClass(classId, classId.relativeClassName.asString().replace('.', '$') + ".class")
override fun findSourceOrBinaryVirtualFile(classId: ClassId) =
findBinaryClass(classId, classId.relativeClassName.asString().replace('.', '$') + ".class")
?: findSourceClass(classId, classId.relativeClassName.asString() + ".java")
override fun findMetadata(classId: ClassId): InputStream? {
assert(!classId.isNestedClass) { "Nested classes are not supported here: $classId" }
@@ -61,8 +65,11 @@ class CliVirtualFileFinder(
return findBinaryClass(classId, BuiltInSerializerProtocol.getBuiltInsFileName(packageFqName))?.inputStream
}
private fun findBinaryClass(classId: ClassId, fileName: String): VirtualFile? =
index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, _ ->
private fun findClass(classId: ClassId, fileName: String, rootType: Set<JavaRoot.RootType>) =
index.findClass(classId, acceptedRootTypes = rootType) { dir, _ ->
dir.findChild(fileName)?.takeIf(VirtualFile::isValid)
}?.takeIf { it in scope }
private fun findBinaryClass(classId: ClassId, fileName: String) = findClass(classId, fileName, JavaRoot.OnlyBinary)
private fun findSourceClass(classId: ClassId, fileName: String) = findClass(classId, fileName, JavaRoot.OnlySource)
}

View File

@@ -82,7 +82,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
private val binaryCache: MutableMap<ClassId, JavaClass?> = THashMap()
private val signatureParsingComponent = BinaryClassSignatureParser()
fun findClass(classId: ClassId, searchScope: GlobalSearchScope): JavaClass? = findClass(JavaClassFinder.Request(classId), searchScope)
fun findClass(classId: ClassId, searchScope: GlobalSearchScope) = findClass(JavaClassFinder.Request(classId), searchScope)
override fun findClass(request: JavaClassFinder.Request, searchScope: GlobalSearchScope): JavaClass? {
val (classId, classFileContentFromRequest, outerClassFromRequest) = request

View File

@@ -33,13 +33,11 @@ import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.extensions.ExtensionsArea
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.pom.java.LanguageLevel
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.JavaClassSupersImpl
@@ -94,6 +92,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
import org.jetbrains.kotlin.resolve.extensions.ExtraImportsProviderExtension
import org.jetbrains.kotlin.resolve.jvm.extensions.SyntheticJavaResolveExtension
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
@@ -191,11 +190,17 @@ class KotlinCoreEnvironment private constructor(
sourceFiles.sortBy { it.virtualFile.path }
val javaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
val jdkHome = configuration.get(JVMConfigurationKeys.JDK_HOME)
val jrtFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JRT_PROTOCOL)
val javaModuleFinder = CliJavaModuleFinder(jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
})
val javaModuleFinder = CliJavaModuleFinder(
jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
},
javaFileManager,
project
)
val outputDirectory =
configuration.get(JVMConfigurationKeys.MODULES)?.singleOrNull()?.getOutputDirectory()
@@ -208,7 +213,8 @@ class KotlinCoreEnvironment private constructor(
this::contentRootToVirtualFile,
javaModuleFinder,
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE),
outputDirectory?.let(this::findLocalFile)
outputDirectory?.let(this::findLocalFile),
javaFileManager
)
val (initialRoots, javaModules) =
@@ -232,7 +238,7 @@ class KotlinCoreEnvironment private constructor(
updateClasspathFromRootsIndex(this)
}
(ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl).initialize(
javaFileManager.initialize(
rootsIndex,
packagePartProviders,
SingleJavaFileRootsIndex(singleJavaFileRoots),
@@ -241,7 +247,7 @@ class KotlinCoreEnvironment private constructor(
project.registerService(
JavaModuleResolver::class.java,
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList())
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList(), project)
)
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)
@@ -577,6 +583,7 @@ class KotlinCoreEnvironment private constructor(
fun registerPluginExtensionPoints(project: MockProject) {
ExpressionCodegenExtension.registerExtensionPoint(project)
SyntheticResolveExtension.registerExtensionPoint(project)
SyntheticJavaResolveExtension.registerExtensionPoint(project)
ClassBuilderInterceptorExtension.registerExtensionPoint(project)
AnalysisHandlerExtension.registerExtensionPoint(project)
PackageFragmentProviderExtension.registerExtensionPoint(project)

View File

@@ -78,10 +78,7 @@ import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.config.APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.extensions.*
import org.jetbrains.kotlin.extensions.internal.CandidateInterceptor
import org.jetbrains.kotlin.extensions.internal.TypeResolutionInterceptor
@@ -96,6 +93,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.ModuleAnnotationsResolver
import org.jetbrains.kotlin.resolve.extensions.ExtraImportsProviderExtension
import org.jetbrains.kotlin.resolve.jvm.extensions.SyntheticJavaResolveExtension
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
@@ -192,11 +190,16 @@ class KotlinCoreEnvironment private constructor(
sourceFiles.sortBy { it.virtualFile.path }
val javaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
val jdkHome = configuration.get(JVMConfigurationKeys.JDK_HOME)
val jrtFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JRT_PROTOCOL)
val javaModuleFinder = CliJavaModuleFinder(jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
})
val javaModuleFinder = CliJavaModuleFinder(
jdkHome?.path?.let { path ->
jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR)
},
javaFileManager
)
val outputDirectory =
configuration.get(JVMConfigurationKeys.MODULES)?.singleOrNull()?.getOutputDirectory()
@@ -209,7 +212,8 @@ class KotlinCoreEnvironment private constructor(
this::contentRootToVirtualFile,
javaModuleFinder,
!configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE),
outputDirectory?.let(this::findLocalFile)
outputDirectory?.let(this::findLocalFile),
javaFileManager
)
val (initialRoots, javaModules) =
@@ -233,7 +237,7 @@ class KotlinCoreEnvironment private constructor(
updateClasspathFromRootsIndex(this)
}
(ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl).initialize(
javaFileManager.initialize(
rootsIndex,
packagePartProviders,
SingleJavaFileRootsIndex(singleJavaFileRoots),
@@ -242,7 +246,7 @@ class KotlinCoreEnvironment private constructor(
project.registerService(
JavaModuleResolver::class.java,
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList())
CliJavaModuleResolver(classpathRootsResolver.javaModuleGraph, javaModules, javaModuleFinder.systemModules.toList(), project)
)
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)
@@ -569,6 +573,7 @@ class KotlinCoreEnvironment private constructor(
fun registerPluginExtensionPoints(project: MockProject) {
ExpressionCodegenExtension.registerExtensionPoint(project)
SyntheticResolveExtension.registerExtensionPoint(project)
SyntheticJavaResolveExtension.registerExtensionPoint(project)
ClassBuilderInterceptorExtension.registerExtensionPoint(project)
AnalysisHandlerExtension.registerExtensionPoint(project)
PackageFragmentProviderExtension.registerExtensionPoint(project)

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.*
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiJavaModule
@@ -36,8 +37,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.OUTPUT
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.WARNING
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.writeAll
@@ -304,6 +304,11 @@ object KotlinToJVMBytecodeCompiler {
val project = environment.project
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
environment.messageCollector.report(
STRONG_WARNING,
"ATTENTION!\n This build uses in-dev FIR: \n -Xuse-fir"
)
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
val projectConfiguration = environment.configuration
@@ -427,6 +432,9 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
Disposer.dispose(environment.project)
}
val mainClassFqName: FqName? =

View File

@@ -49,6 +49,9 @@ fun CompilerConfiguration.addJvmSdkRoots(files: List<File>) {
val CompilerConfiguration.jvmClasspathRoots: List<File>
get() = getList(CLIConfigurationKeys.CONTENT_ROOTS).filterIsInstance<JvmClasspathRoot>().map(JvmContentRoot::file)
val CompilerConfiguration.jvmModularRoots: List<File>
get() = getList(CLIConfigurationKeys.CONTENT_ROOTS).filterIsInstance<JvmModulePathRoot>().map(JvmContentRoot::file)
@JvmOverloads
fun CompilerConfiguration.addJavaSourceRoot(file: File, packagePrefix: String? = null) {
add(CLIConfigurationKeys.CONTENT_ROOTS, JavaSourceRoot(file, packagePrefix))

View File

@@ -45,6 +45,7 @@ data class JavaRoot(val file: VirtualFile, val type: RootType, val prefixFqName:
companion object RootTypes {
val OnlyBinary: Set<RootType> = EnumSet.of(RootType.BINARY)
val OnlySource: Set<RootType> = EnumSet.of(RootType.SOURCE)
val SourceAndBinary: Set<RootType> = EnumSet.of(RootType.BINARY, RootType.SOURCE)
}
}

View File

@@ -54,19 +54,20 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
}
}
if (arguments.stringConcat != null) {
val runtimeStringConcat = JvmStringConcat.fromString(arguments.stringConcat!!)
val stringConcat = arguments.stringConcat
if (stringConcat != null) {
val runtimeStringConcat = JvmStringConcat.fromString(stringConcat)
if (runtimeStringConcat != null) {
put(JVMConfigurationKeys.STRING_CONCAT, runtimeStringConcat)
if (jvmTarget.majorVersion < JvmTarget.JVM_9.majorVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
messageCollector.report(
WARNING,
"`-Xstring-concat=${arguments.stringConcat}` does nothing with JVM target `${jvmTarget.description}`."
"`-Xstring-concat=$stringConcat` does nothing with JVM target `${jvmTarget.description}`."
)
}
} else {
messageCollector.report(
ERROR, "Unknown `-Xstring-concat` mode: ${arguments.stringConcat}\n" +
ERROR, "Unknown `-Xstring-concat` mode: $stringConcat\n" +
"Supported modes: ${JvmStringConcat.values().joinToString { it.description }}"
)
}

View File

@@ -16,16 +16,25 @@
package org.jetbrains.kotlin.cli.jvm.modules
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiJavaModule
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleFinder
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
class CliJavaModuleFinder(
jrtFileSystemRoot: VirtualFile?,
private val javaFileManager: KotlinCliJavaFileManager,
project: Project
) : JavaModuleFinder {
private val modulesRoot = jrtFileSystemRoot?.findChild("modules")
private val userModules = linkedMapOf<String, JavaModule>()
private val allScope = GlobalSearchScope.allScope(project)
fun addUserModule(module: JavaModule) {
userModules.putIfAbsent(module.name, module)
}
@@ -41,7 +50,7 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? {
val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null
val moduleInfo = JavaModuleInfo.read(file) ?: return null
val moduleInfo = JavaModuleInfo.read(file, javaFileManager, allScope) ?: return null
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file)
}
}

View File

@@ -18,18 +18,24 @@ package org.jetbrains.kotlin.cli.jvm.modules
import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver
import java.util.concurrent.ConcurrentHashMap
class CliJavaModuleResolver(
private val moduleGraph: JavaModuleGraph,
private val userModules: List<JavaModule>,
private val systemModules: List<JavaModule.Explicit>
private val systemModules: List<JavaModule.Explicit>,
private val project: Project
) : JavaModuleResolver {
init {
assert(userModules.count(JavaModule::isSourceModule) <= 1) {
@@ -37,6 +43,14 @@ class CliJavaModuleResolver(
}
}
private val virtualFileFinder by lazy { VirtualFileFinder.getInstance(project) }
override fun getAnnotationsForModuleOwnerOfClass(classId: ClassId): List<JavaAnnotation>? {
val virtualFile = virtualFileFinder.findSourceOrBinaryVirtualFile(classId) ?: return null
return (findJavaModule(virtualFile) as? JavaModule.Explicit)?.moduleInfo?.annotations
}
private val sourceModule: JavaModule? = userModules.firstOrNull(JavaModule::isSourceModule)
private fun findJavaModule(file: VirtualFile): JavaModule? {
@@ -77,4 +91,8 @@ class CliJavaModuleResolver(
return null
}
companion object {
private const val MODULE_ANNOTATIONS_CACHE_SIZE = 10000
}
}

View File

@@ -62,8 +62,9 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
val pluginLoadResult = loadPlugins(paths, arguments, configuration)
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult
val commonSources = arguments.commonSources?.toSet() ?: emptySet()
for (arg in arguments.freeArgs) {
configuration.addKotlinSourceRoot(arg, isCommon = true)
configuration.addKotlinSourceRoot(arg, isCommon = arg in commonSources)
}
if (arguments.classpath != null) {
configuration.addJvmClasspathRoots(arguments.classpath!!.split(File.pathSeparatorChar).map(::File))

View File

@@ -101,7 +101,11 @@ object KotlinCompilerClient {
fun CompileService.leaseImpl(): CompileServiceSession? {
// the newJVMOptions could be checked here for additional parameters, if needed
registerClient(clientAliveFlagFile.absolutePath)
reportingTargets.report(DaemonReportCategory.DEBUG, "connected to the daemon")
val javaExecutablePath = compilerId.javaExecutable?.absolutePath ?: "'user jvm'"
reportingTargets.report(
DaemonReportCategory.DEBUG,
"connected to the daemon. Daemon is using following 'java' executable to run itself: $javaExecutablePath"
)
if (!leaseSession) return CompileServiceSession(this, CompileService.NO_SESSION)
@@ -367,8 +371,14 @@ object KotlinCompilerClient {
}
private fun startDaemon(compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions, reportingTargets: DaemonReportingTargets): Boolean {
val javaExecutable = File(File(CompilerSystemProperties.JAVA_HOME.safeValue, "bin"), "java")
private fun startDaemon(
compilerId: CompilerId,
daemonJVMOptions: DaemonJVMOptions,
daemonOptions: DaemonOptions,
reportingTargets: DaemonReportingTargets
): Boolean {
val daemonJavaExecutable = compilerId.javaExecutable
?: File(File(CompilerSystemProperties.JAVA_HOME.safeValue, "bin"), "java")
val serverHostname = CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value ?: error("${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property} is not set!")
val platformSpecificOptions = listOf(
// hide daemon window
@@ -380,7 +390,7 @@ object KotlinCompilerClient {
listOf("--illegal-access=permit")
else emptyList()
val args = listOf(
javaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) +
daemonJavaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) +
platformSpecificOptions +
daemonJVMOptions.mappers.flatMap { it.toArgs("-") } +
javaIllegalAccessWorkaround +

View File

@@ -49,7 +49,7 @@ suspend fun walkDaemonsAsync(
useRMI: Boolean = true,
useSockets: Boolean = true
): List<DaemonWithMetadataAsync> { // TODO: replace with Deferred<List<DaemonWithMetadataAsync>> and use mapNotNullAsync to speed this up
val classPathDigest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString()
val classPathDigest = compilerId.digest()
val portExtractor = makePortFromRunFilenameExtractor(classPathDigest)
return registryDir.walk().toList() // list, since walk returns Sequence and Sequence.map{...} is not inline => coroutines dont work
.map { Pair(it, portExtractor(it.name)) }

View File

@@ -217,7 +217,7 @@ class CompileServiceRMIWrapper(val server: CompileServiceServerSide, daemonOptio
runFileDir,
makeRunFilenameString(
timestamp = "%tFT%<tH-%<tM-%<tS.%<tLZ".format(Calendar.getInstance(TimeZone.getTimeZone("Z"))),
digest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString(),
digest = compilerId.digest(),
port = port.toString()
)
)

View File

@@ -55,7 +55,7 @@ fun walkDaemons(registryDir: File,
filter: (File, Int) -> Boolean = { _, _ -> true },
report: (DaemonReportCategory, String) -> Unit = { _, _ -> }
): Sequence<DaemonWithMetadata> {
val classPathDigest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString()
val classPathDigest = compilerId.digest()
val portExtractor = makePortFromRunFilenameExtractor(classPathDigest)
return registryDir.walk()
.map { Pair(it, portExtractor(it.name)) }

View File

@@ -231,12 +231,38 @@ fun ByteArray.toHexString(): String = joinToString("", transform = { "%02x".form
data class CompilerId(
var compilerClasspath: List<String> = listOf(),
var compilerVersion: String = ""
var compilerVersion: String = "",
var javaExecutable: File? = null
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
get() = listOf(PropMapper(this, CompilerId::compilerClasspath, toString = { it.joinToString(File.pathSeparator) }, fromString = { it.trimQuotes().split(File.pathSeparator) }),
StringPropMapper(this, CompilerId::compilerVersion))
get() = listOf(
PropMapper(
dest = this,
prop = CompilerId::compilerClasspath,
toString = { it.joinToString(File.pathSeparator) },
fromString = { it.trimQuotes().split(File.pathSeparator) }
),
StringPropMapper(
dest = this,
prop = CompilerId::compilerVersion
),
PropMapper(
dest = this,
prop = CompilerId::javaExecutable,
toString = { it?.absolutePath },
fromString = { File(it.trimQuotes()) },
skipIf = { it == null }
)
)
fun digest(): String = compilerClasspath
.map { File(it).absolutePath }
.run {
javaExecutable?.let { plus(it.absolutePath) } ?: this
}
.distinctStringsDigest()
.toHexString()
companion object {
@JvmStatic
@@ -245,6 +271,15 @@ data class CompilerId(
@JvmStatic
fun makeCompilerId(paths: Iterable<File>): CompilerId =
CompilerId(compilerClasspath = paths.map { it.absolutePath })
@JvmStatic
fun makeCompilerId(
paths: Iterable<File>,
javaExecutable: File
): CompilerId = CompilerId(
compilerClasspath = paths.map { it.absolutePath },
javaExecutable = javaExecutable
)
}
}

View File

@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.daemon
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import junit.framework.TestCase
@@ -277,6 +278,129 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
}
private fun getJdk8Location() = System.getenv("JDK_18") ?: System.getenv("JAVA_HOME")
fun testNewDaemonIsNotStartedForSameJavaExecutable() {
withFlagFile(getTestName(true), "-client1.alive") { flagFile1 ->
withFlagFile(getTestName(true), "-client2.alive") { flagFile2 ->
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val compilerIdJdk8 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(getJdk8Location()).resolve("bin/java")
)
withLogFile("kotlin-daemon-test-1") { logFile ->
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
assertTrue(logFile.length() == 0L)
val daemon1 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile1,
daemonJVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemon1)
logFile.assertLogContainsSequence("INFO: starting daemon")
val daemon2 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile2,
daemonJVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemon2)
val logContent = logFile.readText().lines()
assert(
logContent.filter { it.contains("INFO: starting daemon") }.size == 1
) {
"Second daemon instance was started!"
}
assert(
logContent.filter {
it.contains("INFO: Registered a client alive file: ${flagFile2.absolutePath}")
}.size == 1
) {
"Second client was not connected to the same instance!"
}
KotlinCompilerClient.shutdownCompileService(compilerIdJdk8, daemonOptions)
Thread.sleep(100)
logFile.assertLogContainsSequence("Shutdown started")
}
}
}
}
// Ignored on Windows OS due to https://bugs.openjdk.java.net/browse/JDK-8189953 bug in JDK 9
// Should be unignored once JDK10+ will be available by default on CI agents
fun testNewDaemonIsStartedOnJavaExecutableChange() {
if (SystemInfo.isWindows) return
withFlagFile(getTestName(true), "-client1.alive") { flagFile1 ->
withFlagFile(getTestName(true), "-client2.alive") { flagFile2 ->
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val compilerIdJdk8 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(getJdk8Location()).resolve("bin/java")
)
val compilerIdJdk9 = CompilerId.makeCompilerId(
compilerClassPath +
File(KotlinIntegrationTestBase.getCompilerLib(), "kotlin-compiler-sources.jar"),
File(System.getenv("JDK_9")).resolve("bin/java")
)
withLogFile("kotlin-daemon-test-1") { logFile1 ->
withLogFile("kotlin-daemon-test-2") { logFile2 ->
val daemonJdk8JVMOptions = makeTestDaemonJvmOptions(logFile1)
assertTrue(logFile1.length() == 0L)
val daemonJdk9JVMOptions = makeTestDaemonJvmOptions(logFile2)
assertTrue(logFile2.length() == 0L)
val daemonJdk7 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk8,
flagFile1,
daemonJdk8JVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemonJdk7)
logFile1.assertLogContainsSequence("INFO: starting daemon")
val daemonJdk9 = KotlinCompilerClient.connectToCompileService(
compilerIdJdk9,
flagFile2,
daemonJdk9JVMOptions,
daemonOptions,
DaemonReportingTargets(out = System.err),
autostart = true
)
assertNotNull("failed to connect daemon", daemonJdk9)
logFile2.assertLogContainsSequence("INFO: starting daemon")
KotlinCompilerClient.shutdownCompileService(compilerIdJdk8, daemonOptions)
KotlinCompilerClient.shutdownCompileService(compilerIdJdk9, daemonOptions)
Thread.sleep(100)
logFile1.assertLogContainsSequence("Shutdown started")
logFile2.assertLogContainsSequence("Shutdown started")
}
}
}
}
}
fun testDaemonRunError() {
withFlagFile(getTestName(true), ".alive") { flagFile ->
val daemonOptions = DaemonOptions(shutdownDelayMilliseconds = 1, verbose = true, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)

View File

@@ -243,7 +243,7 @@ abstract class CompileServiceImplBase(
runFileDir,
makeRunFilenameString(
timestamp = "%tFT%<tH-%<tM-%<tS.%<tLZ".format(Calendar.getInstance(TimeZone.getTimeZone("Z"))),
digest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest().toHexString(),
digest = compilerId.digest(),
port = port.toString()
)
)

View File

@@ -56,6 +56,11 @@ public class FirLoadCompiledKotlinGenerated extends AbstractFirLoadCompiledKotli
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.kt");
}
@TestMetadata("AnnotationInArray.kt")
public void testAnnotationInArray() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -438,6 +443,11 @@ public class FirLoadCompiledKotlinGenerated extends AbstractFirLoadCompiledKotli
runTest("compiler/testData/loadJava/compiledKotlin/annotations/types/ClassLiteralArgument.kt");
}
@TestMetadata("DefinitelyNotNull.kt")
public void testDefinitelyNotNull() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/types/DefinitelyNotNull.kt");
}
@TestMetadata("ReceiverParameter.kt")
public void testReceiverParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.kt");

View File

@@ -29,6 +29,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("annotationUsedAsAnnotationArgument.kt")
public void testAnnotationUsedAsAnnotationArgument() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt");
}
@TestMetadata("asImports.kt")
public void testAsImports() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/asImports.kt");
@@ -174,6 +179,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
}
@TestMetadata("funInterfaceDeclaration.kt")
public void testFunInterfaceDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/funInterfaceDeclaration.kt");
}
@TestMetadata("functionTypeAlias.kt")
public void testFunctionTypeAlias() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/functionTypeAlias.kt");
@@ -496,6 +506,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt");
}
@TestMetadata("argParamTypeMismatch.kt")
public void testArgParamTypeMismatch() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argParamTypeMismatch.kt");
}
@TestMetadata("argumentsOfAnnotations.kt")
public void testArgumentsOfAnnotations() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/argumentsOfAnnotations.kt");
@@ -941,6 +956,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/constVal"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("const.kt")
public void testConst() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/const.kt");
}
@TestMetadata("constValNotTopLevelOrObject.kt")
public void testConstValNotTopLevelOrObject() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValNotTopLevelOrObject.kt");
@@ -970,6 +990,24 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/contracts")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Contracts extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/contracts"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("genericContract.kt")
public void testGenericContract() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1150,6 +1188,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/methodOfAnyImplementedInInterface.kt");
}
@TestMetadata("multipleBounds.kt")
public void testMultipleBounds() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/multipleBounds.kt");
}
@TestMetadata("nonConstValInAnnotationArgument.kt")
public void testNonConstValInAnnotationArgument() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.kt");
@@ -2681,6 +2724,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/problems/doubleGenericDiamond.kt");
}
@TestMetadata("fakeTypeMismatchOnExtensionReference.kt")
public void testFakeTypeMismatchOnExtensionReference() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/fakeTypeMismatchOnExtensionReference.kt");
}
@TestMetadata("falseIntersection.kt")
public void testFalseIntersection() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/falseIntersection.kt");
@@ -2807,11 +2855,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt");
}
@TestMetadata("leakedImplicitType.kt")
public void testLeakedImplicitType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt");
}
@TestMetadata("referenceToExtension.kt")
public void testReferenceToExtension() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt");
}
@TestMetadata("referenceToField.kt")
public void testReferenceToField() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/references/simple.kt");
@@ -2835,6 +2893,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/samConstructors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("funInterfaceConstructorReference.kt")
public void testFunInterfaceConstructorReference() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/samConstructors/funInterfaceConstructorReference.kt");
}
@TestMetadata("genericSam.kt")
public void testGenericSam() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSam.kt");

View File

@@ -9,6 +9,7 @@ import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.jvm.compiler.AbstractLoadJavaTest
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetModule
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.test.ConfigurationKind
@@ -54,6 +55,7 @@ abstract class AbstractFirLoadCompiledKotlin : AbstractFirLoadBinariesTest() {
val file = File(path)
val configuration = newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), emptyList<File>())
AbstractLoadJavaTest.updateConfigurationWithDirectives(file.readText(), configuration)
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
return compileKotlinToDirAndGetModule(listOf(file), tmpdir, environment)

View File

@@ -0,0 +1,20 @@
public final annotation class Anno : R|kotlin/Annotation| {
public final val value: R|kotlin/Array<test/Bnno>|
public get(): R|kotlin/Array<test/Bnno>|
public constructor(value: R|kotlin/Array<test/Bnno>|): R|test/Anno|
}
@R|test/Anno|(value = <implicitArrayOf>(@R|test/Bnno|(value = String(x)) , @R|test/Bnno|(value = String(y)) )) public final class AnnotationInArray : R|kotlin/Any| {
public constructor(): R|test/AnnotationInArray|
}
public final annotation class Bnno : R|kotlin/Annotation| {
public final val value: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(value: R|kotlin/String|): R|test/Bnno|
}

View File

@@ -0,0 +1 @@
public final fun <T> foo(x: R|T!!|, y: R|kotlin/collections/List<T!!>|, z: R|(T!!) -> T!!|): R|T!!|

View File

@@ -1,4 +1,4 @@
public final annotation class A : R|kotlin/Annotation| {
@R|kotlin/annotation/Target|(allowedTargets = <implicitArrayOf>(R|kotlin/annotation/AnnotationTarget.TYPE|())) public final annotation class A : R|kotlin/Annotation| {
public constructor(): R|test/A|
}

View File

@@ -1,5 +1,5 @@
public open class MethodWithFunctionTypes : R|kotlin/Any| {
public open fun foo(f: R|(kotlin/String?) -> kotlin/String|): R|kotlin/String.() -> kotlin/String?|
public open fun foo(f: R|(kotlin/String?) -> kotlin/String|): R|(kotlin/String.() -> kotlin/String?)?|
public constructor(): R|test/MethodWithFunctionTypes|

View File

@@ -1,16 +1,16 @@
public final val nonConstVal1: R|kotlin/Int|
public final val nonConstVal1: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final class C : R|kotlin/Any| {
public final companion object Companion : R|kotlin/Any| {
public final val nonConstVal3: R|kotlin/Int|
public final val nonConstVal3: R|kotlin/Int| = Int(3)
public get(): R|kotlin/Int|
private constructor(): R|test/C.Companion|
}
public final val nonConstVal2: R|kotlin/Int|
public final val nonConstVal2: R|kotlin/Int| = Int(2)
public get(): R|kotlin/Int|
public constructor(): R|test/C|

View File

@@ -1,8 +1,16 @@
public final fun test1(): R|suspend () -> kotlin/Unit|
public final fun test1N(): R|(suspend () -> kotlin/Unit)?|
public final fun test2(): R|suspend kotlin/Int.() -> kotlin/Int|
public final fun test2N(): R|(suspend kotlin/Int.() -> kotlin/Int)?|
public final fun test3(): R|kotlin/collections/List<kotlin/coroutines/SuspendFunction0<kotlin/Unit>>|
public final fun test3N(): R|kotlin/collections/List<kotlin/coroutines/SuspendFunction0<kotlin/Unit>?>|
public final fun test4(): R|suspend () -> kotlin/coroutines/SuspendFunction0<kotlin/Unit>|
public final fun test4N(): R|(suspend () -> kotlin/coroutines/SuspendFunction0<kotlin/Unit>?)?|

View File

@@ -0,0 +1,27 @@
FILE: annotationUsedAsAnnotationArgument.kt
public final annotation class Ann : R|kotlin/Annotation| {
public constructor(): R|Ann| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann2 : R|kotlin/Annotation| {
public constructor(): R|Ann2| {
super<R|kotlin/Any|>()
}
}
public final annotation class Ann3 : R|kotlin/Annotation| {
public constructor(arg: R|kotlin/Int|, s: R|kotlin/String|): R|Ann3| {
super<R|kotlin/Any|>()
}
public final val arg: R|kotlin/Int| = R|<local>/arg|
public get(): R|kotlin/Int|
public final val s: R|kotlin/String| = R|<local>/s|
public get(): R|kotlin/String|
}
@R|Ann3|(@R|Ann3|(@R|Ann|() Int(5), String()) @R|Ann2|() Int(1), String()) public final val a: R|kotlin/Int| = Int(0)
public get(): R|kotlin/Int|

View File

@@ -0,0 +1,11 @@
annotation class Ann
annotation class Ann2
annotation class Ann3(val arg: Int, val s: String)
@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann3(
<!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann<!> 5, ""
)<!> <!ANNOTATION_USED_AS_ANNOTATION_ARGUMENT!>@Ann2<!> 1, ""
) val a = 0

View File

@@ -15,5 +15,5 @@ class B : A() {
}
fun test(b: B) {
b.<!HIDDEN!>foo<!>("")
b.<!INVISIBLE_REFERENCE!>foo<!>("")
}

View File

@@ -0,0 +1,17 @@
FILE: argParamTypeMismatch.kt
public final fun foo(first: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun foo2(first: R|kotlin/String|, second: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
lval int: R|kotlin/Int| = Int(1)
<Inapplicable(INAPPLICABLE): /foo>#(R|<local>/int|)
<Inapplicable(INAPPLICABLE): /foo>#(Int(2))
<Inapplicable(INAPPLICABLE): /foo>#(R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
^ Int(20)
}
))
R|/foo2|(String(asdf), Int(3))
<Inapplicable(INAPPLICABLE): /foo2>#(Int(4), String(asdf))
<Inapplicable(INAPPLICABLE): /foo2>#(Int(5), Int(6))
}

View File

@@ -0,0 +1,13 @@
fun foo(first: String) {}
fun foo2(first: String, second: Int) {}
fun test() {
val int = 1
foo(<!ARGUMENT_TYPE_MISMATCH!>int<!>)
foo(<!ARGUMENT_TYPE_MISMATCH!>2<!>)
foo(<!ARGUMENT_TYPE_MISMATCH!>run { 20 }<!>)
foo2("asdf", 3)
foo2(<!ARGUMENT_TYPE_MISMATCH!>4<!>, <!ARGUMENT_TYPE_MISMATCH!>"asdf"<!>)
foo2(<!ARGUMENT_TYPE_MISMATCH!>5<!>, 6)
}

View File

@@ -9,7 +9,7 @@ public @interface Ann {
// FILE: main.kt
@Ann(x = 10, s = "")
<!INAPPLICABLE_CANDIDATE!>@Ann(10, "")<!>
@Ann(<!ARGUMENT_TYPE_MISMATCH!>10<!>, <!ARGUMENT_TYPE_MISMATCH!>""<!>)
@Ann(x = 10, s = "", y = 10)
class A

View File

@@ -21,6 +21,6 @@ fun test() {
baz(1, "my", "yours")
baz(1, z = true)
<!INAPPLICABLE_CANDIDATE!>baz<!>(0, "", false)
baz(0, "", <!ARGUMENT_TYPE_MISMATCH!>false<!>)
}

View File

@@ -6,8 +6,8 @@ fun foo2(block: (C, C) -> Unit) = block(C(0, ""), C(0, ""))
fun test() {
foo1 { (x, y) -> C(x, y) }
foo1 { (x: Int, y: String) -> C(x, y) }
foo1 { (x: String, y: Int) -> <!INAPPLICABLE_CANDIDATE!>C<!>(x, y) }
foo1 { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>x: String<!>, <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>y: Int<!>) -> C(<!ARGUMENT_TYPE_MISMATCH!>x<!>, <!ARGUMENT_TYPE_MISMATCH!>y<!>) }
foo2 { (x, y), (z, w) -> C(x + z, y + w) }
foo2 { (x: Int, y: String), (z: Int, w: String) -> C(x + z, y + w) }
foo2 { (x: String, y: Int), (z: String, w: Int) -> <!INAPPLICABLE_CANDIDATE!>C<!>(x + z, y + w) }
foo2 { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>x: String<!>, <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>y: Int<!>), (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>z: String<!>, <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>w: Int<!>) -> C(<!ARGUMENT_TYPE_MISMATCH!>x + z<!>, <!ARGUMENT_TYPE_MISMATCH!>y + w<!>) }
}

View File

@@ -5,7 +5,7 @@ fun takeAny(x: Any) {}
fun takeString(x: String) {}
fun test_0() {
1l
1L
1
10000000000
}
@@ -17,9 +17,9 @@ fun test_1() {
}
fun test_2() {
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(10000000000)
takeInt(<!ARGUMENT_TYPE_MISMATCH!>10000000000<!>)
takeLong(10000000000)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1000<!>)
}
fun test_3() {
@@ -35,14 +35,14 @@ fun test_4() {
}
fun test_5() {
<!INAPPLICABLE_CANDIDATE!>takeString<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeString<!>(run { 1 })
takeString(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
takeString(<!ARGUMENT_TYPE_MISMATCH!>run { 1 }<!>)
}
annotation class Ann(val x: Byte)
@Ann(10)
fun test_6() {
<!INAPPLICABLE_CANDIDATE!>@Ann(300)<!>
@Ann(<!ARGUMENT_TYPE_MISMATCH!>300<!>)
val x = ""
}

View File

@@ -9,7 +9,7 @@ public @interface Ann {
@Ann("a", "b")
fun test_1() {}
<!INAPPLICABLE_CANDIDATE!>@Ann(arrayOf("a", "b"))<!>
@Ann(<!ARGUMENT_TYPE_MISMATCH!>arrayOf("a", "b")<!>)
fun test_2() {}
@Ann(*arrayOf("a", "b"))

View File

@@ -13,6 +13,6 @@ fun takeOutA(array: Array<out A>) {}
fun test(array: Array<B>) {
A.take(array)
<!INAPPLICABLE_CANDIDATE!>takeA<!>(array)
takeA(<!ARGUMENT_TYPE_MISMATCH!>array<!>)
takeOutA(array)
}

View File

@@ -16,7 +16,7 @@ fun test(ordinal: Int) {
buildString {
insert(KDocTemplate()) {
definition {
ordinal?.let {}
ordinal<!UNNECESSARY_SAFE_CALL!>?.<!>let {}
}
}
}

View File

@@ -31,33 +31,33 @@ fun test_3() {
fun takeByte(b: Byte) {}
fun test_4() {
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + 127)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 - 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(-100 - 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(10 * 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 * 100)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1 + 1<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1 + 127<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1 - 1<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>-100 - 100<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>10 * 10<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>100 * 100<!>)
<!UNRESOLVED_REFERENCE!>taleByte<!>(10 / 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 % 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 % 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 and 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(128 and 511)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 or 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 or 0)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(511 xor 511)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(512 xor 511)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>100 % 10<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1000 % 10<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1000 and 100<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>128 and 511<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>100 or 100<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1000 or 0<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>511 xor 511<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>512 xor 511<!>)
}
fun test_5() {
takeByte(-1)
takeByte(+1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1.inv())
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1.inv()<!>)
}
fun test_6() {
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(run { 127 + 1 })
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + run { 1 })
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(run { 1 + 1 })
takeByte(<!ARGUMENT_TYPE_MISMATCH!>run { 127 + 1 }<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>1 + run { 1 }<!>)
takeByte(<!ARGUMENT_TYPE_MISMATCH!>run { 1 + 1 }<!>)
1 + 1
run { 1 }
1 + run { 1 }

View File

@@ -8,10 +8,10 @@ fun test() {
foo(third = false, second = 2.71, fourth = "?!", first = 0)
foo(<!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>)<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>(0.0, false, 0, "")
foo(<!ARGUMENT_TYPE_MISMATCH!>0.0<!>, <!ARGUMENT_TYPE_MISMATCH!>false<!>, <!ARGUMENT_TYPE_MISMATCH!>0<!>, "")
foo(1, 2.0, third = true, "")
foo(second = 0.0, first = 0, fourth = ""<!NO_VALUE_FOR_PARAMETER!>)<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>(first = 0.0, second = 0, third = "", fourth = false)
foo(first = <!ARGUMENT_TYPE_MISMATCH!>0.0<!>, second = <!ARGUMENT_TYPE_MISMATCH!>0<!>, third = <!ARGUMENT_TYPE_MISMATCH!>""<!>, fourth = <!ARGUMENT_TYPE_MISMATCH!>false<!>)
foo(first = 0, second = 0.0, third = false, fourth = "", <!ARGUMENT_PASSED_TWICE!>first<!> = 1)
foo(0, 0.0, false, <!NAMED_PARAMETER_NOT_FOUND!>foth<!> = ""<!NO_VALUE_FOR_PARAMETER!>)<!>
}

View File

@@ -8,5 +8,5 @@ FILE: stringTemplates.kt
public final fun foo(s: R|kotlin/String|): R|kotlin/Unit| {
}
public final fun test(a: R|A|): R|kotlin/Unit| {
R|/foo|(<strcat>(R|<local>/a|.R|kotlin/Any.toString|()))
R|/foo|(<strcat>(R|<local>/a|))
}

View File

@@ -7,8 +7,8 @@ fun test() {
foo(1, "my", "yours")
foo(1, *arrayOf("my", "yours"))
<!INAPPLICABLE_CANDIDATE!>foo<!>("")
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, 2)
foo(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
foo(1, <!ARGUMENT_TYPE_MISMATCH!>2<!>)
bar(1, z = true, y = *arrayOf("my", "yours"))

View File

@@ -9,7 +9,7 @@ fun bar(x: B) {}
fun test(c: C) {
// Argument mapping error
<!INAPPLICABLE_CANDIDATE!>foo<!>("")
foo(<!ARGUMENT_TYPE_MISMATCH!>""<!>)
// Ambiguity
<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>(c)

View File

@@ -1,5 +1,5 @@
FILE: safeCallOnTypeAlias.kt
public final typealias MyTypeAlias = R|() -> kotlin/String?|
public final typealias MyTypeAlias = R|(() -> kotlin/String?)?|
public final fun foo(x: R|MyTypeAlias|): R|kotlin/Unit| {
R|<local>/x|?.{ $subj$.R|kotlin/let|<R|() -> kotlin/String?|, R|kotlin/String?|>(<L> = let@fun <anonymous>(y: R|() -> kotlin/String?|): R|kotlin/String?| <inline=Inline, kind=EXACTLY_ONCE> {
^ R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String?|>|()?.{ $subj$.R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(<L> = let@fun <anonymous>(result: R|kotlin/String|): R|kotlin/String| <inline=Inline, kind=EXACTLY_ONCE> {

View File

@@ -191,63 +191,68 @@ digraph complex_kt {
subgraph cluster_19 {
color=blue
56 [label="Enter block"];
57 [label="Access variable this@R|/firstIsInstanceOrNull|"];
58 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()"];
59 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
subgraph cluster_20 {
color=blue
60 [label="Enter while loop"];
57 [label="Enter block"];
58 [label="Access variable this@R|/firstIsInstanceOrNull|"];
59 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()"];
60 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
subgraph cluster_21 {
color=blue
61 [label="Enter loop condition"];
62 [label="Access variable R|<local>/<iterator>|"];
63 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
64 [label="Exit loop condition"];
}
subgraph cluster_22 {
color=blue
65 [label="Enter loop block"];
61 [label="Enter while loop"];
subgraph cluster_22 {
color=blue
62 [label="Enter loop condition"];
63 [label="Access variable R|<local>/<iterator>|"];
64 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
65 [label="Exit loop condition"];
}
subgraph cluster_23 {
color=blue
66 [label="Enter block"];
67 [label="Access variable R|<local>/<iterator>|"];
68 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"];
69 [label="Variable declaration: lval element: R|kotlin/Any?|"];
66 [label="Enter loop block"];
subgraph cluster_24 {
color=blue
70 [label="Enter when"];
67 [label="Enter block"];
68 [label="Access variable R|<local>/<iterator>|"];
69 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"];
70 [label="Variable declaration: lval element: R|kotlin/Any?|"];
subgraph cluster_25 {
color=blue
71 [label="Enter when branch condition "];
72 [label="Access variable R|<local>/element|"];
73 [label="Type operator: (R|<local>/element| is R|T|)"];
74 [label="Exit when branch condition"];
71 [label="Enter when"];
subgraph cluster_26 {
color=blue
72 [label="Enter when branch condition "];
73 [label="Access variable R|<local>/element|"];
74 [label="Type operator: (R|<local>/element| is R|T|)"];
75 [label="Exit when branch condition"];
}
76 [label="Synthetic else branch"];
77 [label="Enter when branch result"];
subgraph cluster_27 {
color=blue
78 [label="Enter block"];
79 [label="Access variable R|<local>/element|"];
80 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
81 [label="Stub" style="filled" fillcolor=gray];
82 [label="Exit block" style="filled" fillcolor=gray];
}
83 [label="Exit when branch result" style="filled" fillcolor=gray];
84 [label="Exit when"];
}
75 [label="Synthetic else branch"];
76 [label="Enter when branch result"];
subgraph cluster_26 {
color=blue
77 [label="Enter block"];
78 [label="Access variable R|<local>/element|"];
79 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
80 [label="Stub" style="filled" fillcolor=gray];
81 [label="Exit block" style="filled" fillcolor=gray];
}
82 [label="Exit when branch result" style="filled" fillcolor=gray];
83 [label="Exit when"];
85 [label="Exit block"];
}
84 [label="Exit block"];
86 [label="Exit loop block"];
}
85 [label="Exit loop block"];
87 [label="Exit whileloop"];
}
86 [label="Exit whileloop"];
88 [label="Exit block"];
}
87 [label="Const: Null(null)"];
88 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
89 [label="Stub" style="filled" fillcolor=gray];
90 [label="Exit block" style="filled" fillcolor=gray];
89 [label="Const: Null(null)"];
90 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
91 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" style="filled" fillcolor=gray];
}
91 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
93 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
}
55 -> {56};
56 -> {57};
@@ -258,8 +263,8 @@ digraph complex_kt {
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {86 65};
65 -> {66};
64 -> {65};
65 -> {87 66};
66 -> {67};
67 -> {68};
68 -> {69};
@@ -268,24 +273,26 @@ digraph complex_kt {
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {76 75};
75 -> {83};
76 -> {77};
74 -> {75};
75 -> {77 76};
76 -> {84};
77 -> {78};
78 -> {79};
79 -> {91};
79 -> {80} [style=dotted];
79 -> {80};
80 -> {93};
80 -> {81} [style=dotted];
81 -> {82} [style=dotted];
82 -> {83} [style=dotted];
83 -> {84};
83 -> {84} [style=dotted];
84 -> {85};
85 -> {61} [color=green style=dashed];
86 -> {87};
85 -> {86};
86 -> {62} [color=green style=dashed];
87 -> {88};
88 -> {91};
88 -> {89} [style=dotted];
89 -> {90} [style=dotted];
88 -> {89};
89 -> {90};
90 -> {93};
90 -> {91} [style=dotted];
91 -> {92} [style=dotted];
92 -> {93} [style=dotted];
}

View File

@@ -25,13 +25,16 @@ FILE: complex.kt
}
public final inline fun <reified T : R|kotlin/Any|> R|kotlin/collections/List<*>|.firstIsInstanceOrNull(): R|T?| {
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>| = this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval element: R|kotlin/Any?| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()
when () {
(R|<local>/element| is R|T|) -> {
^firstIsInstanceOrNull R|<local>/element|
{
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>| = this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval element: R|kotlin/Any?| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()
when () {
(R|<local>/element| is R|T|) -> {
^firstIsInstanceOrNull R|<local>/element|
}
}
}
}

View File

@@ -72,7 +72,7 @@ fun test_4(x: Any, y: Any) {
}
)
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x) // Bad
takeInt(<!ARGUMENT_TYPE_MISMATCH!>x<!>) // Bad
takeInt(y) // OK
takeInt(a) // Bad
}

View File

@@ -19,85 +19,78 @@ digraph initBlockAndInPlaceLambda_kt {
subgraph cluster_2 {
color=red
4 [label="Enter function getter" style="filled" fillcolor=red];
5 [label="Exit function getter" style="filled" fillcolor=red];
4 [label="Enter class C" style="filled" fillcolor=red];
5 [label="Part of class initialization"];
6 [label="Exit class C" style="filled" fillcolor=red];
}
4 -> {5};
4 -> {5} [color=green];
5 -> {6} [style=dotted];
5 -> {10} [color=green];
5 -> {10} [style=dashed];
subgraph cluster_3 {
color=red
6 [label="Enter class C" style="filled" fillcolor=red];
7 [label="Part of class initialization"];
8 [label="Exit class C" style="filled" fillcolor=red];
7 [label="Enter function <init>" style="filled" fillcolor=red];
8 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
9 [label="Exit function <init>" style="filled" fillcolor=red];
}
6 -> {7} [color=green];
7 -> {8} [style=dotted];
7 -> {12} [color=green];
7 -> {12} [style=dashed];
7 -> {8};
8 -> {9};
subgraph cluster_4 {
color=red
9 [label="Enter function <init>" style="filled" fillcolor=red];
10 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
11 [label="Exit function <init>" style="filled" fillcolor=red];
}
9 -> {10};
10 -> {11};
subgraph cluster_5 {
color=red
12 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_6 {
10 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
13 [label="Enter block"];
14 [label="Access variable R|<local>/a|"];
15 [label="Access variable R|/A.b|"];
16 [label="Enter safe call"];
17 [label="Postponed enter to lambda"];
subgraph cluster_7 {
11 [label="Enter block"];
12 [label="Access variable R|<local>/a|"];
13 [label="Access variable R|/A.b|"];
14 [label="Enter safe call"];
15 [label="Postponed enter to lambda"];
subgraph cluster_6 {
color=blue
25 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_8 {
23 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
26 [label="Enter block"];
27 [label="Access variable R|<local>/a|"];
28 [label="Access variable R|<local>/it|"];
29 [label="Function call: R|/C.C|(...)"];
30 [label="Exit block"];
24 [label="Enter block"];
25 [label="Access variable R|<local>/a|"];
26 [label="Access variable R|<local>/it|"];
27 [label="Function call: R|/C.C|(...)"];
28 [label="Exit block"];
}
31 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
29 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
18 [label="Call arguments union" style="filled" fillcolor=yellow];
19 [label="Postponed exit from lambda"];
20 [label="Function call: $subj$.R|kotlin/let|<R|B|, R|C|>(...)"];
21 [label="Exit safe call"];
22 [label="Variable declaration: lval c: R|C?|"];
23 [label="Exit block"];
16 [label="Call arguments union" style="filled" fillcolor=yellow];
17 [label="Postponed exit from lambda"];
18 [label="Function call: $subj$.R|kotlin/let|<R|B|, R|C|>(...)"];
19 [label="Exit safe call"];
20 [label="Variable declaration: lval c: R|C?|"];
21 [label="Exit block"];
}
24 [label="Exit init block" style="filled" fillcolor=red];
22 [label="Exit init block" style="filled" fillcolor=red];
}
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {14};
13 -> {14 19};
14 -> {15};
15 -> {16 21};
16 -> {17};
17 -> {25};
17 -> {19} [color=red];
17 -> {25} [style=dashed];
18 -> {20} [color=red];
19 -> {20} [color=green];
15 -> {23};
15 -> {17} [color=red];
15 -> {23} [style=dashed];
16 -> {18} [color=red];
17 -> {18} [color=green];
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
22 -> {6} [color=green];
23 -> {24};
24 -> {8} [color=green];
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {18} [color=red];
31 -> {19} [color=green];
29 -> {16} [color=red];
29 -> {17} [color=green];
}

View File

@@ -44,27 +44,20 @@ digraph innerClassInAnonymousObject_kt {
subgraph cluster_5 {
color=red
14 [label="Enter function getter" style="filled" fillcolor=red];
15 [label="Exit function getter" style="filled" fillcolor=red];
14 [label="Enter property" style="filled" fillcolor=red];
15 [label="Exit anonymous object"];
16 [label="Exit property" style="filled" fillcolor=red];
}
14 -> {15};
subgraph cluster_6 {
color=red
16 [label="Enter property" style="filled" fillcolor=red];
17 [label="Exit anonymous object"];
18 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_7 {
color=blue
12 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
13 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
16 -> {17};
16 -> {0 5 8} [color=red];
17 -> {18};
17 -> {0 12} [color=green];
17 -> {0 12} [style=dashed];
14 -> {15};
14 -> {0 5 8} [color=red];
15 -> {16};
15 -> {0 12} [color=green];
15 -> {0 12} [style=dashed];
12 -> {13} [color=green];
}

View File

@@ -127,7 +127,7 @@ digraph jumps_kt {
}
51 [label="Variable declaration: lval y: R|kotlin/Int?|"];
52 [label="Access variable R|<local>/y|"];
53 [label="Function call: R|<local>/y|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): kotlin/Int.inc>#()"];
53 [label="Function call: R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/Int.inc>#()"];
54 [label="Exit block"];
}
55 [label="Exit function test_2" style="filled" fillcolor=red];

View File

@@ -22,7 +22,7 @@ FILE: jumps.kt
}
}
R|<local>/y|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): kotlin/Int.inc>#()
R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/Int.inc>#()
}
public final fun test_3(x: R|kotlin/Int?|): R|kotlin/Unit| {
while(Boolean(true)) {

View File

@@ -5,26 +5,19 @@ digraph lambdaAsReturnOfLambda_kt {
subgraph cluster_0 {
color=red
14 [label="Enter function getter" style="filled" fillcolor=red];
15 [label="Exit function getter" style="filled" fillcolor=red];
}
14 -> {15};
subgraph cluster_1 {
color=red
16 [label="Enter property" style="filled" fillcolor=red];
17 [label="Postponed enter to lambda"];
subgraph cluster_2 {
14 [label="Enter property" style="filled" fillcolor=red];
15 [label="Postponed enter to lambda"];
subgraph cluster_1 {
color=blue
0 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_3 {
subgraph cluster_2 {
color=blue
1 [label="Enter block"];
2 [label="Postponed enter to lambda"];
subgraph cluster_4 {
subgraph cluster_3 {
color=blue
8 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_5 {
subgraph cluster_4 {
color=blue
9 [label="Enter block"];
10 [label="Access variable R|<local>/foo|"];
@@ -43,15 +36,15 @@ digraph lambdaAsReturnOfLambda_kt {
}
7 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
18 [label="Postponed exit from lambda"];
19 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)"];
20 [label="Exit property" style="filled" fillcolor=red];
16 [label="Postponed exit from lambda"];
17 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)"];
18 [label="Exit property" style="filled" fillcolor=red];
}
14 -> {15};
15 -> {16 0};
15 -> {0} [style=dashed];
16 -> {17};
17 -> {18 0};
17 -> {0} [style=dashed];
18 -> {19};
19 -> {20};
17 -> {18};
0 -> {1};
1 -> {2};
2 -> {3 8};
@@ -67,39 +60,39 @@ digraph lambdaAsReturnOfLambda_kt {
11 -> {12};
12 -> {13};
subgraph cluster_6 {
subgraph cluster_5 {
color=red
21 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_7 {
19 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
22 [label="Enter block"];
23 [label="Exit block"];
20 [label="Enter block"];
21 [label="Exit block"];
}
24 [label="Exit function bar" style="filled" fillcolor=red];
22 [label="Exit function bar" style="filled" fillcolor=red];
}
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
subgraph cluster_8 {
subgraph cluster_7 {
color=red
25 [label="Enter function run" style="filled" fillcolor=red];
subgraph cluster_9 {
23 [label="Enter function run" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
26 [label="Enter block"];
27 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
28 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
29 [label="Stub" style="filled" fillcolor=gray];
30 [label="Exit block" style="filled" fillcolor=gray];
24 [label="Enter block"];
25 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
26 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
27 [label="Stub" style="filled" fillcolor=gray];
28 [label="Exit block" style="filled" fillcolor=gray];
}
31 [label="Exit function run" style="filled" fillcolor=red];
29 [label="Exit function run" style="filled" fillcolor=red];
}
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {31};
26 -> {29};
26 -> {27} [style=dotted];
27 -> {28} [style=dotted];
28 -> {29} [style=dotted];
29 -> {30} [style=dotted];
30 -> {31} [style=dotted];
}

View File

@@ -118,44 +118,49 @@ digraph loops_kt {
subgraph cluster_13 {
color=blue
37 [label="Enter block"];
38 [label="Const: Int(0)"];
39 [label="Const: Int(5)"];
40 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...)"];
41 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...).R|kotlin/ranges/IntProgression.iterator|()"];
42 [label="Variable declaration: lval <iterator>: R|kotlin/collections/IntIterator|"];
subgraph cluster_14 {
color=blue
43 [label="Enter while loop"];
38 [label="Enter block"];
39 [label="Const: Int(0)"];
40 [label="Const: Int(5)"];
41 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...)"];
42 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...).R|kotlin/ranges/IntProgression.iterator|()"];
43 [label="Variable declaration: lval <iterator>: R|kotlin/collections/IntIterator|"];
subgraph cluster_15 {
color=blue
44 [label="Enter loop condition"];
45 [label="Access variable R|<local>/<iterator>|"];
46 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
47 [label="Exit loop condition"];
}
subgraph cluster_16 {
color=blue
48 [label="Enter loop block"];
44 [label="Enter while loop"];
subgraph cluster_16 {
color=blue
45 [label="Enter loop condition"];
46 [label="Access variable R|<local>/<iterator>|"];
47 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
48 [label="Exit loop condition"];
}
subgraph cluster_17 {
color=blue
49 [label="Enter block"];
50 [label="Access variable R|<local>/<iterator>|"];
51 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()"];
52 [label="Variable declaration: lval i: R|kotlin/Int|"];
53 [label="Access variable R|<local>/x|"];
54 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
55 [label="Variable declaration: lval y: R|kotlin/Boolean|"];
56 [label="Exit block"];
49 [label="Enter loop block"];
subgraph cluster_18 {
color=blue
50 [label="Enter block"];
51 [label="Access variable R|<local>/<iterator>|"];
52 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()"];
53 [label="Variable declaration: lval i: R|kotlin/Int|"];
54 [label="Access variable R|<local>/x|"];
55 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
56 [label="Variable declaration: lval y: R|kotlin/Boolean|"];
57 [label="Exit block"];
}
58 [label="Exit loop block"];
}
57 [label="Exit loop block"];
59 [label="Exit whileloop"];
}
58 [label="Exit whileloop"];
60 [label="Exit block"];
}
59 [label="Access variable R|<local>/x|"];
60 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
61 [label="Exit block"];
61 [label="Access variable R|<local>/x|"];
62 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
63 [label="Exit block"];
}
62 [label="Exit function testFor" style="filled" fillcolor=red];
64 [label="Exit function testFor" style="filled" fillcolor=red];
}
36 -> {37};
37 -> {38};
@@ -168,8 +173,8 @@ digraph loops_kt {
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {58 48};
48 -> {49};
47 -> {48};
48 -> {59 49};
49 -> {50};
50 -> {51};
51 -> {52};
@@ -178,226 +183,226 @@ digraph loops_kt {
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {44} [color=green style=dashed];
58 -> {59};
57 -> {58};
58 -> {45} [color=green style=dashed];
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
subgraph cluster_18 {
subgraph cluster_19 {
color=red
63 [label="Enter function testWhileTrue" style="filled" fillcolor=red];
subgraph cluster_19 {
65 [label="Enter function testWhileTrue" style="filled" fillcolor=red];
subgraph cluster_20 {
color=blue
64 [label="Enter block"];
subgraph cluster_20 {
66 [label="Enter block"];
subgraph cluster_21 {
color=blue
65 [label="Enter while loop"];
subgraph cluster_21 {
color=blue
66 [label="Enter loop condition"];
67 [label="Const: Boolean(true)"];
68 [label="Exit loop condition"];
}
67 [label="Enter while loop"];
subgraph cluster_22 {
color=blue
69 [label="Enter loop block"];
subgraph cluster_23 {
color=blue
70 [label="Enter block"];
71 [label="Const: Int(1)"];
72 [label="Exit block"];
}
73 [label="Exit loop block"];
68 [label="Enter loop condition"];
69 [label="Const: Boolean(true)"];
70 [label="Exit loop condition"];
}
74 [label="Exit whileloop" style="filled" fillcolor=gray];
subgraph cluster_23 {
color=blue
71 [label="Enter loop block"];
subgraph cluster_24 {
color=blue
72 [label="Enter block"];
73 [label="Const: Int(1)"];
74 [label="Exit block"];
}
75 [label="Exit loop block"];
}
76 [label="Exit whileloop" style="filled" fillcolor=gray];
}
75 [label="Const: Int(1)" style="filled" fillcolor=gray];
76 [label="Exit block" style="filled" fillcolor=gray];
77 [label="Const: Int(1)" style="filled" fillcolor=gray];
78 [label="Exit block" style="filled" fillcolor=gray];
}
77 [label="Exit function testWhileTrue" style="filled" fillcolor=red style="filled" fillcolor=gray];
79 [label="Exit function testWhileTrue" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
68 -> {74} [style=dotted];
69 -> {70};
70 -> {71};
70 -> {76} [style=dotted];
71 -> {72};
72 -> {73};
73 -> {66} [color=green style=dashed];
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
73 -> {74};
74 -> {75};
75 -> {68} [color=green style=dashed];
76 -> {77} [style=dotted];
77 -> {78} [style=dotted];
78 -> {79} [style=dotted];
subgraph cluster_24 {
subgraph cluster_25 {
color=red
78 [label="Enter function testWhileTrueWithBreak" style="filled" fillcolor=red];
subgraph cluster_25 {
80 [label="Enter function testWhileTrueWithBreak" style="filled" fillcolor=red];
subgraph cluster_26 {
color=blue
79 [label="Enter block"];
subgraph cluster_26 {
81 [label="Enter block"];
subgraph cluster_27 {
color=blue
80 [label="Enter while loop"];
subgraph cluster_27 {
color=blue
81 [label="Enter loop condition"];
82 [label="Const: Boolean(true)"];
83 [label="Exit loop condition"];
}
82 [label="Enter while loop"];
subgraph cluster_28 {
color=blue
84 [label="Enter loop block"];
subgraph cluster_29 {
83 [label="Enter loop condition"];
84 [label="Const: Boolean(true)"];
85 [label="Exit loop condition"];
}
subgraph cluster_29 {
color=blue
86 [label="Enter loop block"];
subgraph cluster_30 {
color=blue
85 [label="Enter block"];
subgraph cluster_30 {
87 [label="Enter block"];
subgraph cluster_31 {
color=blue
86 [label="Enter when"];
subgraph cluster_31 {
color=blue
87 [label="Enter when branch condition "];
88 [label="Access variable R|<local>/b|"];
89 [label="Exit when branch condition"];
}
90 [label="Synthetic else branch"];
91 [label="Enter when branch result"];
88 [label="Enter when"];
subgraph cluster_32 {
color=blue
92 [label="Enter block"];
93 [label="Jump: break@@@[Boolean(true)] "];
94 [label="Stub" style="filled" fillcolor=gray];
95 [label="Exit block" style="filled" fillcolor=gray];
89 [label="Enter when branch condition "];
90 [label="Access variable R|<local>/b|"];
91 [label="Exit when branch condition"];
}
96 [label="Exit when branch result" style="filled" fillcolor=gray];
97 [label="Exit when"];
92 [label="Synthetic else branch"];
93 [label="Enter when branch result"];
subgraph cluster_33 {
color=blue
94 [label="Enter block"];
95 [label="Jump: break@@@[Boolean(true)] "];
96 [label="Stub" style="filled" fillcolor=gray];
97 [label="Exit block" style="filled" fillcolor=gray];
}
98 [label="Exit when branch result" style="filled" fillcolor=gray];
99 [label="Exit when"];
}
98 [label="Exit block"];
100 [label="Exit block"];
}
99 [label="Exit loop block"];
101 [label="Exit loop block"];
}
100 [label="Exit whileloop"];
102 [label="Exit whileloop"];
}
101 [label="Const: Int(1)"];
102 [label="Exit block"];
103 [label="Const: Int(1)"];
104 [label="Exit block"];
}
103 [label="Exit function testWhileTrueWithBreak" style="filled" fillcolor=red];
105 [label="Exit function testWhileTrueWithBreak" style="filled" fillcolor=red];
}
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
83 -> {100} [style=dotted];
84 -> {85};
85 -> {86};
85 -> {102} [style=dotted];
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {91 90};
90 -> {97};
91 -> {92};
92 -> {93};
93 -> {100};
93 -> {94} [style=dotted];
94 -> {95} [style=dotted];
89 -> {90};
90 -> {91};
91 -> {93 92};
92 -> {99};
93 -> {94};
94 -> {95};
95 -> {102};
95 -> {96} [style=dotted];
96 -> {97} [style=dotted];
97 -> {98};
98 -> {99};
99 -> {81} [color=green style=dashed];
97 -> {98} [style=dotted];
98 -> {99} [style=dotted];
99 -> {100};
100 -> {101};
101 -> {102};
101 -> {83} [color=green style=dashed];
102 -> {103};
103 -> {104};
104 -> {105};
subgraph cluster_33 {
subgraph cluster_34 {
color=red
104 [label="Enter function testWhileFalse" style="filled" fillcolor=red];
subgraph cluster_34 {
106 [label="Enter function testWhileFalse" style="filled" fillcolor=red];
subgraph cluster_35 {
color=blue
105 [label="Enter block"];
subgraph cluster_35 {
107 [label="Enter block"];
subgraph cluster_36 {
color=blue
106 [label="Enter while loop"];
subgraph cluster_36 {
color=blue
107 [label="Enter loop condition"];
108 [label="Const: Boolean(false)"];
109 [label="Exit loop condition"];
}
108 [label="Enter while loop"];
subgraph cluster_37 {
color=blue
110 [label="Enter loop block" style="filled" fillcolor=gray];
subgraph cluster_38 {
color=blue
111 [label="Enter block" style="filled" fillcolor=gray];
112 [label="Const: Int(1)" style="filled" fillcolor=gray];
113 [label="Exit block" style="filled" fillcolor=gray];
}
114 [label="Exit loop block" style="filled" fillcolor=gray];
109 [label="Enter loop condition"];
110 [label="Const: Boolean(false)"];
111 [label="Exit loop condition"];
}
115 [label="Exit whileloop"];
subgraph cluster_38 {
color=blue
112 [label="Enter loop block" style="filled" fillcolor=gray];
subgraph cluster_39 {
color=blue
113 [label="Enter block" style="filled" fillcolor=gray];
114 [label="Const: Int(1)" style="filled" fillcolor=gray];
115 [label="Exit block" style="filled" fillcolor=gray];
}
116 [label="Exit loop block" style="filled" fillcolor=gray];
}
117 [label="Exit whileloop"];
}
116 [label="Const: Int(1)"];
117 [label="Exit block"];
118 [label="Const: Int(1)"];
119 [label="Exit block"];
}
118 [label="Exit function testWhileFalse" style="filled" fillcolor=red];
120 [label="Exit function testWhileFalse" style="filled" fillcolor=red];
}
104 -> {105};
105 -> {106};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {115};
109 -> {110} [style=dotted];
110 -> {111} [style=dotted];
109 -> {110};
110 -> {111};
111 -> {117};
111 -> {112} [style=dotted];
112 -> {113} [style=dotted];
113 -> {114} [style=dotted];
114 -> {107} [color=green style=dotted];
115 -> {116};
116 -> {117};
114 -> {115} [style=dotted];
115 -> {116} [style=dotted];
116 -> {109} [color=green style=dotted];
117 -> {118};
subgraph cluster_39 {
color=red
119 [label="Enter function testDoWhileTrue" style="filled" fillcolor=red];
subgraph cluster_40 {
color=blue
120 [label="Enter block"];
subgraph cluster_41 {
color=blue
121 [label="Enter do-while loop"];
subgraph cluster_42 {
color=blue
122 [label="Enter loop block"];
subgraph cluster_43 {
color=blue
123 [label="Enter block"];
124 [label="Const: Int(1)"];
125 [label="Exit block"];
}
126 [label="Exit loop block"];
}
subgraph cluster_44 {
color=blue
127 [label="Enter loop condition"];
128 [label="Const: Boolean(true)"];
129 [label="Exit loop condition"];
}
130 [label="Exit do-whileloop" style="filled" fillcolor=gray];
}
131 [label="Const: Int(1)" style="filled" fillcolor=gray];
132 [label="Exit block" style="filled" fillcolor=gray];
}
133 [label="Exit function testDoWhileTrue" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
118 -> {119};
119 -> {120};
120 -> {121};
subgraph cluster_40 {
color=red
121 [label="Enter function testDoWhileTrue" style="filled" fillcolor=red];
subgraph cluster_41 {
color=blue
122 [label="Enter block"];
subgraph cluster_42 {
color=blue
123 [label="Enter do-while loop"];
subgraph cluster_43 {
color=blue
124 [label="Enter loop block"];
subgraph cluster_44 {
color=blue
125 [label="Enter block"];
126 [label="Const: Int(1)"];
127 [label="Exit block"];
}
128 [label="Exit loop block"];
}
subgraph cluster_45 {
color=blue
129 [label="Enter loop condition"];
130 [label="Const: Boolean(true)"];
131 [label="Exit loop condition"];
}
132 [label="Exit do-whileloop" style="filled" fillcolor=gray];
}
133 [label="Const: Int(1)" style="filled" fillcolor=gray];
134 [label="Exit block" style="filled" fillcolor=gray];
}
135 [label="Exit function testDoWhileTrue" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
121 -> {122};
122 -> {123};
123 -> {124};
@@ -406,128 +411,128 @@ digraph loops_kt {
126 -> {127};
127 -> {128};
128 -> {129};
129 -> {130} [style=dotted];
129 -> {122} [color=green style=dashed];
130 -> {131} [style=dotted];
129 -> {130};
130 -> {131};
131 -> {132} [style=dotted];
131 -> {124} [color=green style=dashed];
132 -> {133} [style=dotted];
133 -> {134} [style=dotted];
134 -> {135} [style=dotted];
subgraph cluster_45 {
subgraph cluster_46 {
color=red
134 [label="Enter function testDoWhileTrueWithBreak" style="filled" fillcolor=red];
subgraph cluster_46 {
136 [label="Enter function testDoWhileTrueWithBreak" style="filled" fillcolor=red];
subgraph cluster_47 {
color=blue
135 [label="Enter block"];
subgraph cluster_47 {
137 [label="Enter block"];
subgraph cluster_48 {
color=blue
136 [label="Enter do-while loop"];
subgraph cluster_48 {
138 [label="Enter do-while loop"];
subgraph cluster_49 {
color=blue
137 [label="Enter loop block"];
subgraph cluster_49 {
139 [label="Enter loop block"];
subgraph cluster_50 {
color=blue
138 [label="Enter block"];
subgraph cluster_50 {
140 [label="Enter block"];
subgraph cluster_51 {
color=blue
139 [label="Enter when"];
subgraph cluster_51 {
color=blue
140 [label="Enter when branch condition "];
141 [label="Access variable R|<local>/b|"];
142 [label="Exit when branch condition"];
}
143 [label="Synthetic else branch"];
144 [label="Enter when branch result"];
141 [label="Enter when"];
subgraph cluster_52 {
color=blue
145 [label="Enter block"];
146 [label="Jump: break@@@[Boolean(true)] "];
147 [label="Stub" style="filled" fillcolor=gray];
148 [label="Exit block" style="filled" fillcolor=gray];
142 [label="Enter when branch condition "];
143 [label="Access variable R|<local>/b|"];
144 [label="Exit when branch condition"];
}
149 [label="Exit when branch result" style="filled" fillcolor=gray];
150 [label="Exit when"];
145 [label="Synthetic else branch"];
146 [label="Enter when branch result"];
subgraph cluster_53 {
color=blue
147 [label="Enter block"];
148 [label="Jump: break@@@[Boolean(true)] "];
149 [label="Stub" style="filled" fillcolor=gray];
150 [label="Exit block" style="filled" fillcolor=gray];
}
151 [label="Exit when branch result" style="filled" fillcolor=gray];
152 [label="Exit when"];
}
151 [label="Exit block"];
153 [label="Exit block"];
}
152 [label="Exit loop block"];
154 [label="Exit loop block"];
}
subgraph cluster_53 {
subgraph cluster_54 {
color=blue
153 [label="Enter loop condition"];
154 [label="Const: Boolean(true)"];
155 [label="Exit loop condition"];
155 [label="Enter loop condition"];
156 [label="Const: Boolean(true)"];
157 [label="Exit loop condition"];
}
156 [label="Exit do-whileloop"];
158 [label="Exit do-whileloop"];
}
157 [label="Const: Int(1)"];
158 [label="Exit block"];
159 [label="Const: Int(1)"];
160 [label="Exit block"];
}
159 [label="Exit function testDoWhileTrueWithBreak" style="filled" fillcolor=red];
161 [label="Exit function testDoWhileTrueWithBreak" style="filled" fillcolor=red];
}
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
138 -> {139};
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {144 143};
143 -> {150};
144 -> {145};
145 -> {146};
146 -> {156};
146 -> {147} [style=dotted];
147 -> {148} [style=dotted];
142 -> {143};
143 -> {144};
144 -> {146 145};
145 -> {152};
146 -> {147};
147 -> {148};
148 -> {158};
148 -> {149} [style=dotted];
149 -> {150} [style=dotted];
150 -> {151};
151 -> {152};
150 -> {151} [style=dotted];
151 -> {152} [style=dotted];
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156} [style=dotted];
155 -> {137} [color=green style=dashed];
155 -> {156};
156 -> {157};
157 -> {158};
157 -> {158} [style=dotted];
157 -> {139} [color=green style=dashed];
158 -> {159};
subgraph cluster_54 {
color=red
160 [label="Enter function testDoWhileFalse" style="filled" fillcolor=red];
subgraph cluster_55 {
color=blue
161 [label="Enter block"];
subgraph cluster_56 {
color=blue
162 [label="Enter do-while loop"];
subgraph cluster_57 {
color=blue
163 [label="Enter loop block"];
subgraph cluster_58 {
color=blue
164 [label="Enter block"];
165 [label="Const: Int(1)"];
166 [label="Exit block"];
}
167 [label="Exit loop block"];
}
subgraph cluster_59 {
color=blue
168 [label="Enter loop condition"];
169 [label="Const: Boolean(false)"];
170 [label="Exit loop condition"];
}
171 [label="Exit do-whileloop"];
}
172 [label="Const: Int(1)"];
173 [label="Exit block"];
}
174 [label="Exit function testDoWhileFalse" style="filled" fillcolor=red];
}
159 -> {160};
160 -> {161};
161 -> {162};
subgraph cluster_55 {
color=red
162 [label="Enter function testDoWhileFalse" style="filled" fillcolor=red];
subgraph cluster_56 {
color=blue
163 [label="Enter block"];
subgraph cluster_57 {
color=blue
164 [label="Enter do-while loop"];
subgraph cluster_58 {
color=blue
165 [label="Enter loop block"];
subgraph cluster_59 {
color=blue
166 [label="Enter block"];
167 [label="Const: Int(1)"];
168 [label="Exit block"];
}
169 [label="Exit loop block"];
}
subgraph cluster_60 {
color=blue
170 [label="Enter loop condition"];
171 [label="Const: Boolean(false)"];
172 [label="Exit loop condition"];
}
173 [label="Exit do-whileloop"];
}
174 [label="Const: Int(1)"];
175 [label="Exit block"];
}
176 [label="Exit function testDoWhileFalse" style="filled" fillcolor=red];
}
162 -> {163};
163 -> {164};
164 -> {165};
@@ -537,9 +542,11 @@ digraph loops_kt {
168 -> {169};
169 -> {170};
170 -> {171};
170 -> {163} [color=green style=dotted];
171 -> {172};
172 -> {173};
172 -> {165} [color=green style=dotted];
173 -> {174};
174 -> {175};
175 -> {176};
}

View File

@@ -14,10 +14,13 @@ FILE: loops.kt
(R|<local>/x| is R|kotlin/String|)
}
public final fun testFor(x: R|kotlin/Any?|): R|kotlin/Unit| {
lval <iterator>: R|kotlin/collections/IntIterator| = Int(0).R|kotlin/Int.rangeTo|(Int(5)).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
lval y: R|kotlin/Boolean| = (R|<local>/x| is R|kotlin/String|)
{
lval <iterator>: R|kotlin/collections/IntIterator| = Int(0).R|kotlin/Int.rangeTo|(Int(5)).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
lval y: R|kotlin/Boolean| = (R|<local>/x| is R|kotlin/String|)
}
}
(R|<local>/x| is R|kotlin/String|)

View File

@@ -27,8 +27,8 @@ digraph postponedLambdaInConstructor_kt {
}
5 -> {6} [color=green];
6 -> {7} [style=dotted];
6 -> {29} [color=green];
6 -> {29} [style=dashed];
6 -> {27} [color=green];
6 -> {27} [style=dashed];
subgraph cluster_3 {
color=red
@@ -88,35 +88,28 @@ digraph postponedLambdaInConstructor_kt {
subgraph cluster_8 {
color=red
27 [label="Enter function getter" style="filled" fillcolor=red];
28 [label="Exit function getter" style="filled" fillcolor=red];
27 [label="Enter property" style="filled" fillcolor=red];
28 [label="Access variable R|<local>/s|"];
29 [label="Exit property" style="filled" fillcolor=red];
}
27 -> {28};
28 -> {29};
29 -> {7} [color=green];
subgraph cluster_9 {
color=red
29 [label="Enter property" style="filled" fillcolor=red];
30 [label="Access variable R|<local>/s|"];
31 [label="Exit property" style="filled" fillcolor=red];
}
29 -> {30};
30 -> {31};
31 -> {7} [color=green];
subgraph cluster_10 {
color=red
32 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_11 {
30 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
33 [label="Enter block"];
34 [label="Function call: this@R|/B|.R|/B.foo|()"];
35 [label="Exit block"];
31 [label="Enter block"];
32 [label="Function call: this@R|/B|.R|/B.foo|()"];
33 [label="Exit block"];
}
36 [label="Exit function foo" style="filled" fillcolor=red];
34 [label="Exit function foo" style="filled" fillcolor=red];
}
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
35 -> {36};
}

View File

@@ -21,312 +21,298 @@ digraph propertiesAndInitBlocks_kt {
subgraph cluster_2 {
color=red
5 [label="Enter function getter" style="filled" fillcolor=red];
6 [label="Exit function getter" style="filled" fillcolor=red];
5 [label="Enter property" style="filled" fillcolor=red];
6 [label="Const: Int(1)"];
7 [label="Exit property" style="filled" fillcolor=red];
}
5 -> {6};
6 -> {7};
subgraph cluster_3 {
color=red
7 [label="Enter property" style="filled" fillcolor=red];
8 [label="Const: Int(1)"];
9 [label="Exit property" style="filled" fillcolor=red];
8 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
9 [label="Enter block"];
10 [label="Const: Int(1)"];
11 [label="Jump: ^ Int(1)"];
12 [label="Stub" style="filled" fillcolor=gray];
13 [label="Exit block" style="filled" fillcolor=gray];
}
14 [label="Exit function getter" style="filled" fillcolor=red];
}
7 -> {8};
8 -> {9};
subgraph cluster_4 {
color=red
10 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
11 [label="Enter block"];
12 [label="Const: Int(1)"];
13 [label="Jump: ^ Int(1)"];
14 [label="Stub" style="filled" fillcolor=gray];
15 [label="Exit block" style="filled" fillcolor=gray];
}
16 [label="Exit function getter" style="filled" fillcolor=red];
}
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {16};
11 -> {14};
11 -> {12} [style=dotted];
12 -> {13} [style=dotted];
13 -> {14} [style=dotted];
14 -> {15} [style=dotted];
15 -> {16} [style=dotted];
subgraph cluster_6 {
subgraph cluster_5 {
color=red
17 [label="Enter function setter" style="filled" fillcolor=red];
subgraph cluster_7 {
15 [label="Enter function setter" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
18 [label="Enter block"];
19 [label="Const: Int(1)"];
20 [label="Assignment: F|/x2|"];
21 [label="Exit block"];
16 [label="Enter block"];
17 [label="Const: Int(1)"];
18 [label="Assignment: F|/x2|"];
19 [label="Exit block"];
}
22 [label="Exit function setter" style="filled" fillcolor=red];
20 [label="Exit function setter" style="filled" fillcolor=red];
}
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
subgraph cluster_7 {
color=red
21 [label="Enter property" style="filled" fillcolor=red];
22 [label="Const: Int(1)"];
23 [label="Exit property" style="filled" fillcolor=red];
}
21 -> {22};
22 -> {23};
subgraph cluster_8 {
color=red
23 [label="Enter property" style="filled" fillcolor=red];
24 [label="Const: Int(1)"];
25 [label="Exit property" style="filled" fillcolor=red];
}
23 -> {24};
24 -> {25};
subgraph cluster_9 {
color=red
37 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_10 {
35 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
38 [label="Enter block"];
39 [label="Const: Int(1)"];
40 [label="Const: Int(1)"];
41 [label="Function call: Int(1).R|kotlin/Int.plus|(...)"];
42 [label="Variable declaration: lval c: R|kotlin/Int|"];
43 [label="Function call: R|java/lang/Exception.Exception|()"];
44 [label="Throw: throw R|java/lang/Exception.Exception|()"];
45 [label="Stub" style="filled" fillcolor=gray];
46 [label="Exit block" style="filled" fillcolor=gray];
36 [label="Enter block"];
37 [label="Const: Int(1)"];
38 [label="Const: Int(1)"];
39 [label="Function call: Int(1).R|kotlin/Int.plus|(...)"];
40 [label="Variable declaration: lval c: R|kotlin/Int|"];
41 [label="Function call: R|java/lang/Exception.Exception|()"];
42 [label="Throw: throw R|java/lang/Exception.Exception|()"];
43 [label="Stub" style="filled" fillcolor=gray];
44 [label="Exit block" style="filled" fillcolor=gray];
}
47 [label="Exit function foo" style="filled" fillcolor=red];
45 [label="Exit function foo" style="filled" fillcolor=red];
}
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {47} [label=onUncaughtException];
42 -> {45} [label=onUncaughtException];
42 -> {43} [style=dotted];
43 -> {44} [style=dotted];
44 -> {45} [style=dotted];
45 -> {46} [style=dotted];
46 -> {47} [style=dotted];
subgraph cluster_10 {
color=red
46 [label="Enter function <init>" style="filled" fillcolor=red];
47 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
48 [label="Exit function <init>" style="filled" fillcolor=red];
}
46 -> {47};
47 -> {48};
subgraph cluster_11 {
color=red
48 [label="Enter function <init>" style="filled" fillcolor=red];
49 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
50 [label="Exit function <init>" style="filled" fillcolor=red];
}
48 -> {49};
49 -> {50};
subgraph cluster_12 {
color=red
51 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_13 {
49 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
52 [label="Enter block"];
53 [label="Function call: R|java/lang/Exception.Exception|()"];
54 [label="Throw: throw R|java/lang/Exception.Exception|()"];
55 [label="Stub" style="filled" fillcolor=gray];
56 [label="Const: Int(1)" style="filled" fillcolor=gray];
57 [label="Exit block" style="filled" fillcolor=gray];
50 [label="Enter block"];
51 [label="Function call: R|java/lang/Exception.Exception|()"];
52 [label="Throw: throw R|java/lang/Exception.Exception|()"];
53 [label="Stub" style="filled" fillcolor=gray];
54 [label="Const: Int(1)" style="filled" fillcolor=gray];
55 [label="Exit block" style="filled" fillcolor=gray];
}
58 [label="Exit init block" style="filled" fillcolor=red];
56 [label="Exit init block" style="filled" fillcolor=red];
}
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {58} [label=onUncaughtException];
52 -> {56} [label=onUncaughtException];
52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
54 -> {55} [style=dotted];
55 -> {56} [style=dotted];
56 -> {57} [style=dotted];
57 -> {58} [style=dotted];
58 -> {36} [color=green];
56 -> {34} [color=green];
subgraph cluster_14 {
subgraph cluster_13 {
color=red
59 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_15 {
57 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_14 {
color=blue
60 [label="Enter block"];
61 [label="Exit local class <getter>"];
62 [label="Exit block"];
58 [label="Enter block"];
59 [label="Exit local class <getter>"];
60 [label="Exit block"];
}
63 [label="Exit function getter" style="filled" fillcolor=red];
61 [label="Exit function getter" style="filled" fillcolor=red];
}
subgraph cluster_16 {
subgraph cluster_15 {
color=blue
64 [label="Enter class GetterLocalClass" style="filled" fillcolor=red];
65 [label="Part of class initialization"];
66 [label="Exit class GetterLocalClass" style="filled" fillcolor=red];
62 [label="Enter class GetterLocalClass" style="filled" fillcolor=red];
63 [label="Part of class initialization"];
64 [label="Exit class GetterLocalClass" style="filled" fillcolor=red];
}
57 -> {58};
58 -> {59};
58 -> {65 68} [color=red];
59 -> {60};
59 -> {65 62} [color=green];
59 -> {65 62} [style=dashed];
60 -> {61};
60 -> {67 70} [color=red];
61 -> {62};
61 -> {67 64} [color=green];
61 -> {67 64} [style=dashed];
62 -> {63};
64 -> {65} [color=green];
65 -> {66} [style=dotted];
65 -> {70} [color=green];
65 -> {70} [style=dashed];
62 -> {63} [color=green];
63 -> {64} [style=dotted];
63 -> {68} [color=green];
63 -> {68} [style=dashed];
subgraph cluster_16 {
color=red
65 [label="Enter function <init>" style="filled" fillcolor=red];
66 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
67 [label="Exit function <init>" style="filled" fillcolor=red];
}
65 -> {66};
66 -> {67};
subgraph cluster_17 {
color=red
67 [label="Enter function <init>" style="filled" fillcolor=red];
68 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
69 [label="Exit function <init>" style="filled" fillcolor=red];
}
67 -> {68};
68 -> {69};
subgraph cluster_18 {
color=red
70 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_19 {
68 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
71 [label="Enter block"];
72 [label="Function call: R|java/lang/Exception.Exception|()"];
73 [label="Throw: throw R|java/lang/Exception.Exception|()"];
74 [label="Stub" style="filled" fillcolor=gray];
75 [label="Exit block" style="filled" fillcolor=gray];
69 [label="Enter block"];
70 [label="Function call: R|java/lang/Exception.Exception|()"];
71 [label="Throw: throw R|java/lang/Exception.Exception|()"];
72 [label="Stub" style="filled" fillcolor=gray];
73 [label="Exit block" style="filled" fillcolor=gray];
}
76 [label="Exit init block" style="filled" fillcolor=red];
74 [label="Exit init block" style="filled" fillcolor=red];
}
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {76} [label=onUncaughtException];
71 -> {74} [label=onUncaughtException];
71 -> {72} [style=dotted];
72 -> {73} [style=dotted];
73 -> {74} [style=dotted];
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
76 -> {66} [color=green];
74 -> {64} [color=green];
subgraph cluster_20 {
subgraph cluster_19 {
color=red
77 [label="Enter property" style="filled" fillcolor=red];
78 [label="Postponed enter to lambda"];
subgraph cluster_21 {
75 [label="Enter property" style="filled" fillcolor=red];
76 [label="Postponed enter to lambda"];
subgraph cluster_20 {
color=blue
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
24 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
25 [label="Enter block"];
26 [label="Exit local class <anonymous>"];
27 [label="Function call: R|java/lang/Exception.Exception|()"];
28 [label="Throw: throw R|java/lang/Exception.Exception|()"];
29 [label="Stub" style="filled" fillcolor=gray];
30 [label="Exit block" style="filled" fillcolor=gray];
}
subgraph cluster_22 {
color=blue
27 [label="Enter block"];
28 [label="Exit local class <anonymous>"];
29 [label="Function call: R|java/lang/Exception.Exception|()"];
30 [label="Throw: throw R|java/lang/Exception.Exception|()"];
31 [label="Stub" style="filled" fillcolor=gray];
32 [label="Exit block" style="filled" fillcolor=gray];
32 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red];
33 [label="Part of class initialization"];
34 [label="Exit class InitializerLocalClass" style="filled" fillcolor=red];
}
subgraph cluster_23 {
color=blue
34 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red];
35 [label="Part of class initialization"];
36 [label="Exit class InitializerLocalClass" style="filled" fillcolor=red];
}
33 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
31 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
79 [label="Postponed exit from lambda"];
80 [label="Function call: R|/run|(...)"];
81 [label="Exit property" style="filled" fillcolor=red];
77 [label="Postponed exit from lambda"];
78 [label="Function call: R|/run|(...)"];
79 [label="Exit property" style="filled" fillcolor=red];
}
75 -> {76};
76 -> {24};
76 -> {77} [color=red];
76 -> {24} [style=dashed];
77 -> {78};
78 -> {26};
78 -> {79} [color=red];
78 -> {26} [style=dashed];
79 -> {80};
80 -> {81};
26 -> {33 27};
78 -> {79};
24 -> {31 25};
25 -> {26};
25 -> {35 46 49} [color=red];
26 -> {27};
26 -> {46 32} [color=green];
26 -> {46 32} [style=dashed];
27 -> {28};
27 -> {37 48 51} [color=red];
28 -> {29};
28 -> {48 34} [color=green];
28 -> {48 34} [style=dashed];
29 -> {30};
30 -> {81} [label=onUncaughtException];
28 -> {79} [label=onUncaughtException];
28 -> {29} [style=dotted];
29 -> {30} [style=dotted];
30 -> {31} [style=dotted];
31 -> {32} [style=dotted];
32 -> {33} [style=dotted];
33 -> {79} [color=green];
33 -> {26} [color=green style=dashed];
34 -> {35} [color=green];
35 -> {36} [style=dotted];
35 -> {51} [color=green];
35 -> {51} [style=dashed];
31 -> {77} [color=green];
31 -> {24} [color=green style=dashed];
32 -> {33} [color=green];
33 -> {34} [style=dotted];
33 -> {49} [color=green];
33 -> {49} [style=dashed];
subgraph cluster_24 {
subgraph cluster_23 {
color=red
82 [label="Enter function getter" style="filled" fillcolor=red];
83 [label="Exit function getter" style="filled" fillcolor=red];
}
82 -> {83};
subgraph cluster_25 {
color=red
84 [label="Enter property" style="filled" fillcolor=red];
subgraph cluster_26 {
80 [label="Enter property" style="filled" fillcolor=red];
subgraph cluster_24 {
color=blue
85 [label="Try expression enter"];
81 [label="Try expression enter"];
subgraph cluster_25 {
color=blue
82 [label="Try main block enter"];
subgraph cluster_26 {
color=blue
83 [label="Enter block"];
84 [label="Const: Int(1)"];
85 [label="Exit block"];
}
86 [label="Try main block exit"];
}
subgraph cluster_27 {
color=blue
86 [label="Try main block enter"];
87 [label="Catch enter"];
subgraph cluster_28 {
color=blue
87 [label="Enter block"];
88 [label="Const: Int(1)"];
89 [label="Exit block"];
88 [label="Enter block"];
89 [label="Const: Int(2)"];
90 [label="Exit block"];
}
90 [label="Try main block exit"];
91 [label="Catch exit"];
}
subgraph cluster_29 {
color=blue
91 [label="Catch enter"];
92 [label="Enter finally"];
subgraph cluster_30 {
color=blue
92 [label="Enter block"];
93 [label="Const: Int(2)"];
94 [label="Exit block"];
93 [label="Enter block"];
94 [label="Const: Int(0)"];
95 [label="Exit block"];
}
95 [label="Catch exit"];
96 [label="Exit finally"];
}
subgraph cluster_31 {
color=blue
96 [label="Enter finally"];
subgraph cluster_32 {
color=blue
97 [label="Enter block"];
98 [label="Const: Int(0)"];
99 [label="Exit block"];
}
100 [label="Exit finally"];
}
101 [label="Try expression exit"];
97 [label="Try expression exit"];
}
102 [label="Exit property" style="filled" fillcolor=red];
98 [label="Exit property" style="filled" fillcolor=red];
}
80 -> {81};
81 -> {82 87};
81 -> {92} [label=onUncaughtException];
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {86 91};
85 -> {96} [label=onUncaughtException];
86 -> {87};
85 -> {86};
86 -> {92 87};
87 -> {88};
87 -> {92} [label=onUncaughtException];
88 -> {89};
89 -> {90};
90 -> {96 91};
90 -> {91};
91 -> {92};
91 -> {96} [label=onUncaughtException];
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96};
96 -> {97};
96 -> {98} [label=onUncaughtException];
97 -> {98};
98 -> {99};
99 -> {100};
100 -> {101};
100 -> {102} [label=onUncaughtException];
101 -> {102};
}

View File

@@ -33,72 +33,58 @@ digraph safeCalls_kt {
subgraph cluster_4 {
color=red
8 [label="Enter function getter" style="filled" fillcolor=red];
9 [label="Exit function getter" style="filled" fillcolor=red];
8 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
9 [label="Enter block"];
10 [label="Access variable R|<local>/x|"];
11 [label="Enter safe call"];
12 [label="Function call: $subj$.R|/A.foo|()"];
13 [label="Exit safe call"];
14 [label="Enter safe call"];
15 [label="Function call: $subj$.R|/A.bar|()"];
16 [label="Exit safe call"];
17 [label="Exit block"];
}
18 [label="Exit function test_1" style="filled" fillcolor=red];
}
8 -> {9};
subgraph cluster_5 {
color=red
10 [label="Enter function getter" style="filled" fillcolor=red];
11 [label="Exit function getter" style="filled" fillcolor=red];
}
10 -> {11};
9 -> {10};
10 -> {11 13};
11 -> {12};
12 -> {13};
13 -> {14 16};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {18};
subgraph cluster_6 {
color=red
12 [label="Enter function test_1" style="filled" fillcolor=red];
19 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
13 [label="Enter block"];
14 [label="Access variable R|<local>/x|"];
15 [label="Enter safe call"];
16 [label="Function call: $subj$.R|/A.foo|()"];
17 [label="Exit safe call"];
18 [label="Enter safe call"];
19 [label="Function call: $subj$.R|/A.bar|()"];
20 [label="Exit safe call"];
21 [label="Exit block"];
20 [label="Enter block"];
21 [label="Access variable R|<local>/x|"];
22 [label="Enter safe call"];
23 [label="Access variable R|/B.foo|"];
24 [label="Exit safe call"];
25 [label="Enter safe call"];
26 [label="Access variable R|/B.bar|"];
27 [label="Exit safe call"];
28 [label="Exit block"];
}
22 [label="Exit function test_1" style="filled" fillcolor=red];
29 [label="Exit function test_2" style="filled" fillcolor=red];
}
12 -> {13};
13 -> {14};
14 -> {15 17};
15 -> {16};
16 -> {17};
17 -> {18 20};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
subgraph cluster_8 {
color=red
23 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
24 [label="Enter block"];
25 [label="Access variable R|<local>/x|"];
26 [label="Enter safe call"];
27 [label="Access variable R|/B.foo|"];
28 [label="Exit safe call"];
29 [label="Enter safe call"];
30 [label="Access variable R|/B.bar|"];
31 [label="Exit safe call"];
32 [label="Exit block"];
}
33 [label="Exit function test_2" style="filled" fillcolor=red];
}
21 -> {22 24};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26 28};
24 -> {25 27};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29 31};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
28 -> {29};
}

View File

@@ -0,0 +1,60 @@
FILE: const.kt
public final const val a: R|kotlin/String| = String(something)
public get(): R|kotlin/String|
public final const val b: <ERROR TYPE REF: Cannot infer variable type without initializer / getter / delegate>
public get(): <ERROR TYPE REF: Cannot infer variable type without initializer / getter / delegate>
public final const val c: R|kotlin/Nothing?| = Null(null)
public get(): R|kotlin/Nothing?|
public final const val d: R|ForConst.Companion| = Q|ForConst|
public get(): R|ForConst.Companion|
public final const val e: R|kotlin/String| = Q|ForConst|.R|/ForConst.Companion.one|()
public get(): R|kotlin/String|
public final const val f: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(2)).R|kotlin/Int.times|(Int(3)).R|kotlin/Int.div|(Int(4)).R|kotlin/Int.rem|(Int(5)).R|kotlin/Int.minus|(Int(1))
public get(): R|kotlin/Int|
public final const val g: R|kotlin/String| = <strcat>(String(string ), R|/f|)
public get(): R|kotlin/String|
public final const val h: R|kotlin/String| = String(string).R|kotlin/String.plus|(R|/g|)
public get(): R|kotlin/String|
public final const val i: R|kotlin/String| = Q|ForConst|.R|/ForConst.Companion.one|().R|kotlin/String.plus|(String(one))
public get(): R|kotlin/String|
public final const val j: R|kotlin/Int| = Int(4).R|kotlin/Int.times|(Q|ForConst|.R|/ForConst.Companion.two|())
public get(): R|kotlin/Int|
public final val k: R|kotlin/Int| = Int(3).R|kotlin/Int.minus|(Q|ForConst|.R|/ForConst.Companion.two|())
public get(): R|kotlin/Int|
public final const val l: R|kotlin/Int| = R|/k|
public get(): R|kotlin/Int|
public final class ForConst : R|kotlin/Any| {
public constructor(): R|ForConst| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|ForConst.Companion| {
super<R|kotlin/Any|>()
}
public final fun one(): R|kotlin/String| {
^one String(1)
}
public final fun two(): R|kotlin/Int| {
^two Int(2)
}
}
}
private final const val MAJOR_BITS: R|kotlin/Int| = Int(3)
private get(): R|kotlin/Int|
private final const val MINOR_BITS: R|kotlin/Int| = Int(4)
private get(): R|kotlin/Int|
private final const val PATCH_BITS: R|kotlin/Int| = Int(7)
private get(): R|kotlin/Int|
private final const val MAJOR_MASK: R|kotlin/Int| = Int(1).R|kotlin/Int.shl|(R|/MAJOR_BITS|).R|kotlin/Int.minus|(Int(1))
private get(): R|kotlin/Int|
private final const val MINOR_MASK: R|kotlin/Int| = Int(1).R|kotlin/Int.shl|(R|/MINOR_BITS|).R|kotlin/Int.minus|(Int(1))
private get(): R|kotlin/Int|
private final const val PATCH_MASK: R|kotlin/Int| = Int(1).R|kotlin/Int.shl|(R|/PATCH_BITS|).R|kotlin/Int.minus|(Int(1))
private get(): R|kotlin/Int|
private final const val stringFromJava: R|kotlin/String| = Q|Constants|.R|/Constants.FIRST|.R|kotlin/String.plus|(String(+)).R|kotlin/String.plus|(Q|Constants|.R|/Constants.SECOND|)
private get(): R|kotlin/String|

View File

@@ -0,0 +1,36 @@
// FILE: Constants.java
public class Constants {
public static final String FIRST = "1st";
public static final String SECOND = "2nd";
}
// FILE: const.kt
const val a = "something"
<!MUST_BE_INITIALIZED!><!CONST_VAL_WITHOUT_INITIALIZER!>const<!> val b<!>
<!TYPE_CANT_BE_USED_FOR_CONST_VAL!>const<!> val c = null
<!TYPE_CANT_BE_USED_FOR_CONST_VAL!>const<!> val d = ForConst
const val e = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>ForConst.one()<!>
const val f = ((1 + 2) * 3) / 4 % 5 - 1
const val g = "string $f"
const val h = "string" + g
const val i = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>ForConst.one() + "one"<!>
const val j = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>4 * ForConst.two()<!>
val k = 3 - ForConst.two()
const val l = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>k<!>
class ForConst{
companion object {
fun one(): String = "1"
fun two(): Int = 2
}
}
private const val MAJOR_BITS = 3
private const val MINOR_BITS = 4
private const val PATCH_BITS = 7
private const val MAJOR_MASK = (1 shl MAJOR_BITS) - 1 // False positive error
private const val MINOR_MASK = (1 shl MINOR_BITS) - 1 // False positive error
private const val PATCH_MASK = (1 shl PATCH_BITS) - 1 // False positive error
private const val stringFromJava = Constants.FIRST + "+" + Constants.SECOND

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