Compare commits

...

323 Commits

Author SHA1 Message Date
Igor Chevdar
de840b7e70 [IR][cache] Fix for https://youtrack.jetbrains.com/issue/KT-44764
The .konanLibrary is cached for each declaration for performance purposes, but it is only ok to do it
after IR has been lowered to its final state (or at least when declarations aren't being moved around),
so the fix respects that by only taking .konanLibrary of a IrFile (it is assumed that files stay on their place
during entire backend lowering procedure).

(cherry picked from commit e021138368b48e306ba99a96f47d93ecbe039f4d)
2021-03-15 10:35:33 +01:00
Alexander Udalov
99bf2c48a1 Fix/suppress some warnings
(cherry picked from commit d8a43c216925b3a9e1475b786978436835a57927)
2021-03-15 10:35:10 +01:00
Igor Chevdar
2d88f0cd79 Disposed target data
(cherry picked from commit 250be87acf66d5c780fb593f46da3540a536e049)
2021-03-15 10:20:27 +01:00
Vladimir Ivanov
842dbb9006 Add test for [KT-3706]
Issue is already fixed by metadata-based cinterop

(cherry picked from commit fd4f5b2c07ebdc431d6243ac087f911ee30e88ca)
2021-03-15 10:18:29 +01:00
Vladimir Ivanov
6594fac213 Fix sample file naming for case-sensitive FS
(cherry picked from commit 72235c31852fba4f2ab330d8178197c2584b1cda)
2021-03-15 10:16:20 +01:00
Andrey
fe6ddcc1fa [KAPT] Skip kapt tasks if no annotations processors are provided (#4190)
So we don't do any preparation, don't spin up compiler.  And user will see SKIPPED in task execution
2021-03-15 11:37:06 +03:00
Svyatoslav Scherbina
77161af92a Delete obsolete kotlin-native/GRADLE_PLUGIN.md 2021-03-15 08:30:23 +00:00
Dmitriy Dolovov
6791ae81db [Commonizer] Minor. Clean-up in AbstractCommonizerTest 2021-03-15 11:25:48 +03:00
Dmitriy Dolovov
aa196ae813 [Commonizer] Minor. Clean-up in ValueParameterCommonizerTest 2021-03-15 11:25:43 +03:00
Dmitriy Dolovov
0bd5fdb611 [Commonizer] Minor. Formatted 2021-03-15 11:25:37 +03:00
Dmitriy Dolovov
ed98d878df [Commonizer] Minor. Reorganize CirClass.supertypes 2021-03-15 11:25:32 +03:00
Mikhael Bogdanov
cdb2dd6661 Advance bootstrap to 1.5.20-dev-2613 2021-03-15 07:10:03 +01:00
Ilmir Usmanov
64abb2501f Minor. Add FIR_IDENTICAL directive 2021-03-15 06:19:22 +01:00
Ilmir Usmanov
c9f41a2440 Minor. Ignore tests on WASM 2021-03-15 06:14:44 +01:00
Ilmir Usmanov
149064803d JVM_IR: Do not unbox Result argument inside java SAM adapters
#KT-45259
2021-03-15 06:14:42 +01:00
Ilmir Usmanov
4099dfc7e0 JVM_IR: Do not unbox Result argument inside SAM adapters
#KT-45259 Fixed
2021-03-15 06:14:40 +01:00
Mikhael Bogdanov
6fab1305e9 Fix compilation after @JvmDefault deprecation
Suppress could be removed after switch to -Xjvm-default=all
2021-03-13 08:24:18 +00:00
Mikhail Bogdanov
95654bb9bc Deprecate @JvmDefault
#KT-40392 Fixed

(cherry picked from commit c11f38688e)
2021-03-13 08:24:17 +00:00
Abduqodiri Qurbonzoda
77c263fcc4 Mark kt45410.kt with TARGET_BACKEND: JVM 2021-03-13 02:30:24 +03:00
Alexander Shabalin
391458c355 Fix CompileToBitcode's llvm-link invocation
Porting https://github.com/jetbrains/kotlin-native/pull/4536 which got
lost in c85c3ac123
2021-03-12 16:53:47 +00:00
Ilmir Usmanov
d3b42709fd Revert "Value Classes: Forbid var properties with value class receivers"
This reverts commit f43899086a.
2021-03-12 17:51:24 +01:00
Ilmir Usmanov
6429ac17d8 Revert "Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error"
This reverts commit bad197e075.
2021-03-12 17:51:21 +01:00
Roman Artemev
050db6d454 [KLIB] Add box test for generic annotations 2021-03-12 19:03:04 +03:00
Roman Artemev
0d8fff7186 [KLIB] Fix annotation type deserialization
Instead of hardcoded `Unit` restore it basing on annotation class and
constructor's type arguments
2021-03-12 19:03:04 +03:00
Roman Artemev
607a598f1a [IR] Add irText test for generic annotations 2021-03-12 19:02:29 +03:00
Roman Artemev
79935e29de [IR] Support type arguments in psi2ir 2021-03-12 19:02:29 +03:00
Roman Artemev
b60ebc0975 [IR] Support type arguments on annotations in IR render 2021-03-12 19:00:11 +03:00
Roman Artemev
ab8f64a3ee [FIR] Mute failing tests 2021-03-12 18:47:34 +03:00
Roman Artemev
92eac7e124 [IR] Fix irText test runner
Do not ignore compilation errors if they are existed
2021-03-12 18:36:33 +03:00
Anton Lakotka
d023f09bd4 Don't add common compiler plugin artifacts to native targets
Make native plugin configuration be non-transitive
2021-03-12 18:28:26 +03:00
Ilya Kirillov
f339748f5b FIR IDE: fix origin of synthetic functional interfaces
^KT-45312 fixed
2021-03-12 15:17:33 +01:00
Ilya Kirillov
41d1ef22b6 FIR: specify BODY_RESOLVE for synthetic functional interface 2021-03-12 15:15:32 +01:00
Alexander Likhachev
6b774b07e0 [Gradle, K/N] Fix broken iOS, watchOS, tvOS tests
They were broken in 2a8e2613a2
2021-03-12 16:36:18 +03:00
Alexander Likhachev
aedd8a104d [Gradle, K/N] Fix native test execution test on Macs 2021-03-12 15:56:03 +03:00
Mads Ager
8588412a56 [JVM IR] Support break in do-while condition.
This breaks from the loop itself which is inconsistent with
what happens for breaks in while conditions.

Also, the frontend will report that code after the loop is
unreachable, which it isn't. :-\

However, those issues are covered in
https://youtrack.jetbrains.com/issue/KT-17728, so for now
we follow the old backend to not "break" anyone. :)

Fixes KT-44412
2021-03-12 13:46:27 +01:00
Dmitry Petrov
d0d3b57366 Minor: mute test in FIR 2021-03-12 15:08:24 +03:00
Victor Petukhov
91d2f32a57 Don't lose upper non-expected type constraints to include them to intersection type during finding the result type of the fixing type variable 2021-03-12 14:36:54 +03:00
Victor Petukhov
b87c2a15b5 Don't stop constraints processing if all type variables have proper equality constraints
Those type variable may have other constraints after incorporation into which, the constraint error may appear

^KT-42042 Fixed
2021-03-12 14:36:54 +03:00
Victor Petukhov
7f7bb70596 Don't fix a type variable into the intersection type if there is an explicit expected type
^KT-43303 Fixed
^KT-42396 Fixed
^KT-42472 Fixed
2021-03-12 14:36:53 +03:00
pyos
e06bacafad JVM: fix inline cycle detection
1. use the correct descriptor in the old backend;
 2. clear the temporary variables for arguments in the IR backend.

 #KT-45292 Fixed
2021-03-12 11:49:42 +01:00
Ilya Kirillov
4e98d1b857 FIR IDE: update lazy resolve tests testdata 2021-03-12 11:44:00 +01:00
Ilya Kirillov
f8828abeba FIR: fix declaration phase updating in FirContractResolveTransformer 2021-03-12 11:44:00 +01:00
Ilya Kirillov
4dc040b91a FIR: update enum entry resolve phase in body resolve transformers 2021-03-12 11:44:00 +01:00
Ilya Kirillov
d49913944c FIR: add tests which checks that every declaration in file has body resolve phase after resolving the fiile 2021-03-12 11:44:00 +01:00
Ilya Kirillov
0dd18006e8 FIR: do not update phase from IMPLICIT_TYPES_BODY_RESOLVE to BODY_RESOLVE
This is not needed as such declarations are now marked with body resolve phase
2021-03-12 11:44:00 +01:00
Ilya Kirillov
fe207492b7 FIR: mark declarations resolved to BODY_RESOLVE with BODY_RESOLVE phase in implicit body transformer 2021-03-12 11:43:59 +01:00
Ilya Kirillov
ded234074d FIR: render value parameter/lambda/accessor resolve phase if RenderMode.renderDeclarationResolvePhase is enabled 2021-03-12 11:43:59 +01:00
Alexander Udalov
869a153327 Enable -Werror for buildSrc 2021-03-12 11:19:07 +01:00
Alexander Udalov
848b08a475 Minor, suppress 1.3 language version warnings 2021-03-12 11:18:57 +01:00
Ilya Goncharov
ead0b50107 [JS IR] In file:JsModule top level with fresh names 2021-03-12 12:57:56 +03:00
Ilya Kirillov
600e1725cb Do not run wizard project importing tests in TC
They will be run only in kotlin-ide plugin
2021-03-12 10:56:41 +01:00
Igor Yakovlev
023b7fbb8f [ULC] Fix invalid primitive type annotating
Fixed #KT-45417
2021-03-12 10:35:37 +01:00
Abduqodiri Qurbonzoda
ff5b2404af Introduce firstNotNullOf and firstNotNullOfOrNull #KT-12109 2021-03-12 09:27:14 +03:00
Abduqodiri Qurbonzoda
d4b3ae92cb [K/N] Strict version of String.toBoolean() #KT-42071 2021-03-12 09:26:58 +03:00
Abduqodiri Qurbonzoda
09ad5ca602 Strict version of String.toBoolean() #KT-42071 2021-03-12 09:26:55 +03:00
Abduqodiri Qurbonzoda
5f4a4fd8ae Introduce assertContentEquals in kotlin-test #KT-32996 2021-03-12 09:24:15 +03:00
Dmitry Petrov
44e6483090 JVM_IR Spill stack on array constructor call
KT-42932
2021-03-12 09:18:35 +03:00
Alexander Likhachev
dbfe45993a [Build] Fix test distribution plugin applying condition 2021-03-12 08:02:44 +03:00
Anton Lakotka
99ce047733 Add separate Plugin Classpaths per compilation
Make them extend the common CP for sake of backward compatibility
^KT-45020 Fixed
2021-03-11 22:34:21 +01:00
Tianyu Geng
9476175cc2 FIR: add mapping to partially resolved arg list
Initially I tried adding `mapping` field to `FirArgumentList` but it
seems to be very difficult to make it flexible enough to do what I want.

So instead, I am creating a `FirPartialResolvedArgumentList`, which
seems to be very simple.
2021-03-11 22:57:58 +03:00
Mikhail Glukhikh
5d3afbad54 Rename: BadNamedArgumentsTarget -> ForbiddenNamedArgumentsTarget 2021-03-11 22:57:57 +03:00
Tianyu Geng
be0dd84a06 FIR: check NAMED_ARGUMENTS_NOT_ALLOWED
The check has already been partially implemented in
org.jetbrains.kotlin.fir.resolve.calls.FirCallArgumentsProcessor. This
change completes the missing piece that determines if a `FirFunction`
has stable parameter names.
2021-03-11 22:57:57 +03:00
Tianyu Geng
0d4e9ca0b9 FIR: allow reporting multiple FirDiagnostics from a ConeDiagnostic 2021-03-11 22:57:57 +03:00
Mikhail Glukhikh
1f15ce2d26 FIR diagnostics: extract mapUnsafeCallError 2021-03-11 22:57:57 +03:00
Mark Punzalan
bb790195a2 FIR IDE: Enable ChangeVariableMutabilityFix for MUST_BE_INITIALIZED. 2021-03-11 16:31:40 +01:00
Ilya Chernikov
09fb2cd746 [minor] disable implicits test on IR, see added comments for details 2021-03-11 15:50:33 +01:00
Ilya Chernikov
e05c8ac57b Add script metedata flag 2021-03-11 15:50:33 +01:00
Ilya Chernikov
7c63105bb7 Mark script result expression as used to avoid coercion to unit 2021-03-11 15:50:32 +01:00
Ilya Chernikov
7d07010785 Fix handling of lambdas in top-level destructuring declarations 2021-03-11 15:50:32 +01:00
Ilya Chernikov
22f1814911 Fix CFA for destructuring declarations in scripts
in particular without the fix, the CFA skipped marking of the used
result values in lambdas and they were coerced to unit in IR
2021-03-11 15:50:31 +01:00
Ilya Chernikov
10567d9a37 [minor] fix scripting test dependencies 2021-03-11 15:50:31 +01:00
Ilya Chernikov
9c786a9cd9 [minor] uncomment 2 scripting tests:
Tests were failing before, but now fixed, most likely by switching to
default target 1.8 and some changes in scripting IR support.
#KT-44471 fixed
2021-03-11 15:50:31 +01:00
Ilya Chernikov
ef01411d20 [minor] fix script util tests 2021-03-11 15:50:30 +01:00
Ilya Chernikov
375441832e Implement REPL support in IR scripting 2021-03-11 15:50:30 +01:00
Ilya Chernikov
c066b7843c Fix provided properties generation in ir scripting 2021-03-11 15:50:07 +01:00
Ilya Chernikov
bc6c17d4b2 Enable IR in jvm scripting host tests 2021-03-11 15:50:06 +01:00
Ilya Chernikov
e9da385f7c Implement property for passing argumens to isolated script compiler 2021-03-11 15:50:06 +01:00
Ilya Chernikov
43d7536a28 Protect scripts compilation from passing -Xuse-ir via configuration
as well as other options that require changes in the compilation setup
before compiler options from the configuration could be processed
2021-03-11 15:50:06 +01:00
Ilya Chernikov
bac6a7346e Extend GeneratorExtensions with previous script, implemt it for JS REPL
also refactor JS REPL for better compatibility with the generic
REPL/scripting infrastructure
2021-03-11 15:50:01 +01:00
Ilya Chernikov
83da5f61fd [minor] Implement in-process test for main.kts cache
mainly to ease debugging
2021-03-11 15:49:46 +01:00
Ilya Chernikov
4dc228a0a3 Implement proper call to the base class ctor in ir script lowering 2021-03-11 15:49:46 +01:00
Ilya Chernikov
32d0c99289 Implement metadata handling for IR scripts 2021-03-11 15:49:45 +01:00
Ilya Chernikov
4c6b5ff0b8 Implement IR backend support in scripting tests, enable for some tests 2021-03-11 15:49:44 +01:00
Alexander Likhachev
d1ee05c7f6 Revert "[Build] Fix configuration cache issues with install task"
This reverts commit 078849d1
2021-03-11 17:22:37 +03:00
Yahor Berdnikau
543ab3fa2a Fix issues in Android test projects setup. 2021-03-11 16:36:54 +03:00
Yahor Berdnikau
590bab82e2 Remove not-needed test task validation.
Now all test 'install' dependencies are added via centralized 'dependsOnKotlinGradlePluginInstall()' method.
2021-03-11 16:36:53 +03:00
Yahor Berdnikau
3f953bcdfc Use lazy query for KGP test SourceSet output. 2021-03-11 16:36:52 +03:00
Yahor Berdnikau
7e7552bf5d Use JUnit 5 platform to run KGP tests.
Enabled vintage engine, so existing tests could run without any
modification.

^KT-45353 In Progress
2021-03-11 16:36:50 +03:00
Tianyu Geng
9bdae40ad8 FIR IDE: check generated primary constructor
Currently the IDE skips checking the delegated constructor call because
the primary constructor is generated if it's declared with the class.
2021-03-11 14:30:54 +01:00
Svyatoslav Scherbina
2b994e1b66 Native: fix links in RELEASE_NOTES.md 2021-03-11 13:25:42 +00:00
Jinseong Jeon
55561fad37 FIR CFG: correct target and label for rethrow in try expression
^KT-45385 Fixed
2021-03-11 16:19:16 +03:00
Jinseong Jeon
4f20d2dccf Reproduce KT-45385: false positive MUST_BE_INITIALIZED_* after rethrow 2021-03-11 16:19:15 +03:00
Alexander Udalov
f4c63c8ba2 Update public API dump for stdlib 2021-03-11 14:17:33 +01:00
Michael Hoisie
83383ab9e5 Make kotlin.jvm.internal.DefaultConstructorMarker public
DefaultConstructorMarker is used as a marker to ensure that a
constructor is unique for companion objects. Prior to this change,
DefaultConstructorMarker was package private.

Being package private worked when calling the
DefaultConstructorMarker-marked constsructor using `invokespecial`,
likely because the JVM may not perform strict access checks in this
situation.

However, when access checks are performed, trying to call a
DefaultConstructorMarker-marked constructor will fail. This could happen
if the constructor was called using reflection or the MethodHandle API.
These APIs may be used by tools that perform bytecode instrumentation
on Kotlin JVM bytecode, such as Robolectric. It also caused problems
when using ByteBuddy validation.

Fixes https://youtrack.jetbrains.com/issue/KT-20869
2021-03-11 14:17:33 +01:00
Alexander Likhachev
78ed758704 [Gradle, K/N] Rework environment input on test tasks
Provide method `trackEnvironment` to track environment variables. Use only tracked environment variables as task input.
#KT-44059 Fixed
2021-03-11 15:44:37 +03:00
Alexander Likhachev
c5a9f20a6f [Gradle, K/N] Don't add unsupported targets to default fat frameworks task 2021-03-11 15:37:36 +03:00
Alexander Udalov
bc5fc122c5 JVM, JVM IR: report error if not all parts of multifile class are @JvmSynthetic
#KT-41884 Fixed
2021-03-11 13:33:25 +01:00
Alexander Udalov
75850a618c Minor, move bytecodeListing tests on JvmMultifileClass 2021-03-11 13:33:25 +01:00
Steven Schäfer
057ead358c JVM: Add FILE target to the JvmSynthetic annotation (#4149) 2021-03-11 13:33:07 +01:00
Victor Petukhov
b45d5abeb1 [jspecify] Change annotations' package from org.jspecify.annotations to org.jspecify.nullness, and DefaultNonNull to NullMarked
^KT-45409 Fixed
2021-03-11 15:32:14 +03:00
Alexander Likhachev
2ae7740c46 Set explicit lang version 1.3 for kotlin-native-utils & kotlin-util-io
Without explicit version we cannot use those modules in buildscripts with Gradle 6.8+ because Gradle doesn't set flag `skipPrereleaseCheck` (previously was named `skipMetadataVersionCheck`). This way we make it compatible with all supported versions of Gradle.
2021-03-11 14:12:38 +03:00
Alexander Likhachev
875cf1acf9 [Build] Add https://nodejs.org/dist to cache redirector
https://nodejs.org/dist repository is being added by Gradle Node plugin (com.github.node-gradle.node) at configuration phase in project.afterEvaluate so we need to wrap it once more to setup redirection later than repository is added
2021-03-11 14:12:37 +03:00
Alexander Likhachev
35df00e071 [Build] Apply :idea:idea-gradle classpath modification on JPS build only
This modification is incompatible with Gradle configuration cache
Relates to #KT-44611
2021-03-11 14:12:37 +03:00
Alexander Likhachev
57f5939f5e [Build] Fix configuration cache issues (part 7)
* Read system property "disable.verification.tasks" using Gradle provider
* Fix compileTestKotlin tasks with instrumented classes
* Read Gradle property "kotlin.test.maxParallelForks" using Gradle provider
* Change :idea:performanceTests jackson version to fixed ones
Relates to #KT-44611
2021-03-11 14:12:37 +03:00
Alexander Likhachev
6bd44df861 [Build] Fix configuration cache issues (part 6)
Make DexMethodCountStats task class, tasks :examples:kotlin-jsr223-daemon-local-eval-example:test,:idea:idea-fir:test, :idea:idea-fir-performance-tests:test, :idea:idea-frontend-fir:test, :idea:idea-frontend-fir:idea-fir-low-level-api:test, :kotlin-compiler-client-embeddable:test, :kotlin-compiler-embeddable:test, :kotlin-stdlib-js-ir:compileTestKotlinJs, :plugins:android-extensions-compiler:test, :plugins:parcelize:parcelize-compiler:test, :compiler:test compatible with configuration cache
Relates to #KT-44611
2021-03-11 14:12:36 +03:00
Alexander Likhachev
1751b5182b [Build] Apply test distribution plugin conditionally only if it's needed
This buildscript logic change is motivated by configuration cache incompatibility of the plugin
Relates to #KT-44611
2021-03-11 14:12:36 +03:00
Alexander Likhachev
9be06da045 [Build] Make Gradle IT buildscript property reads via Gradle providers
Relates to #KT-44611
2021-03-11 14:12:36 +03:00
Alexander Likhachev
ca7dfe02b2 [Build] Replace deprecated configurations usage :tools:kotlinp 2021-03-11 14:12:36 +03:00
Alexander Likhachev
078849d133 [Build] Fix configuration cache issues with install task
* `install` task provided by `maven` plugin doesn't support configuration cache so replace `maven` plugin with `maven-publish` and use task that is subtype of PublishToMavenRepository. `maven-publish` partially support configuration cache, see https://github.com/gradle/gradle/issues/13468
* Apply `signing` plugin only if it really needed. The plugin doesn't support configuration cache. See https://github.com/gradle/gradle/issues/13470
Relates to #KT-44611
2021-03-11 14:12:35 +03:00
Alexander Likhachev
46b056c929 [Build] Fix configuration cache issues (part 5)
Make Project.configureFormInstrumentation and Task.useAndroidConfiguration extensions, :dependencies:android-sdk unzip tasks compatible with configuration cache

Relates to #KT-44611
2021-03-11 14:12:35 +03:00
Alexander Likhachev
da6544ae3c [Build] Make projectTest() extension compatible with configuration cache
Relates to #KT-44611
2021-03-11 14:12:35 +03:00
Alexander Likhachev
ce49664366 [Build] Bump test-retry plugin version to 1.2.0 to support conf cache
Relates to #KT-44611
2021-03-11 14:12:34 +03:00
Alexander Likhachev
74ab5c21a8 [Build] Fix configuration cache issues (part 4)
Make :kotlin-stdlib-js:prepareComparableSource, :kotlin-stdlib-js:prepareBuiltinsSources, :kotlin-stdlib-js:compileJs, :kotlin-stdlib-js:compileJs, :prepare:build.version:writeBuildNumber, :kotlin-compiler:distKotlinc compatible with configuration cache

Relates to #KT-44611
2021-03-11 14:12:34 +03:00
Alexander Likhachev
5f10c98a38 [Build] Fix configuration cache issues (part 3)
* Make IntelliJInstrumentCodeTask compatible with configuration cache
* Make CoreXmlShadingTransformer compatible with configuration cache
* Make :kotlin-reflect:relocateCoreSources compatible with configuration cache
* Copy some properties to not capture it's owning object into lambda to support configuration cache
Relates to #KT-44611
2021-03-11 14:12:34 +03:00
Alexander Likhachev
0e4e90dc13 [Build] Bump gradle-node-plugin version to 3.0.1 to support conf cache
:kotlin-test:kotlin-test-js:kotlin-test-js-it will still have old version as integration test run logic cannot be fully refactored to the new version (approximately till 3.1)
Relates to #KT-44611
2021-03-11 14:12:34 +03:00
Alexander Likhachev
89a78a02d4 [Build] Make generatePom tasks compatible with configuration cache
Relates to #KT-44611
2021-03-11 14:12:33 +03:00
Alexander Likhachev
2a49dcab47 [Build] Bump shadow plugin version to 6.1.0 to support configuration cache
Relates to #KT-44611
2021-03-11 14:12:33 +03:00
Alexander Likhachev
faf9600ff0 [Build] Fix configuration cache issues (part 2)
* Make WriteCopyrightToFile task compatible with configuration cache
* Configure shadowJar task in compatible with configuration cache way
* Configure compileJava9Java task in compatible with configuration cache way
* Make :js:js.tests buildscript compatible with configuration cache
Relates to #KT-44611
2021-03-11 14:12:33 +03:00
Alexander Likhachev
ce19063e43 [Build] Disable reporters when configuration cache is enabled
Relates to #KT-44611
2021-03-11 14:12:32 +03:00
Alexander Likhachev
27956adf3f [Build] Fix configuration cache issues (part 1)
* Make `clean` task compatible with configuration cache
* Make Java compile instrumentation compatible with configuration cache
* Make settings.gradle compatible with configuration cache
* Initial work on making IntelliJInstrumentCodeTask compatible with configuration cache
* Make writeStdlibVersion task compatible with configuration cache
* Copy some properties to not capture it's owning object into lambda to support configuration cache

Relates to #KT-44611
2021-03-11 14:12:28 +03:00
Mikhail Glukhikh
111e67dc8d Use DECLARATION_NAME strategy for FirErrors.PRIMARY_CONSTRUCTOR_REQUIRED 2021-03-11 13:25:52 +03:00
Tianyu Geng
6e8bad6ef6 FIR: Implement data class constructor checker 2021-03-11 13:25:51 +03:00
Jinseong Jeon
d2da15e039 FIR checker: report (expected|unnecessary) lateinit 2021-03-11 13:25:51 +03:00
Dmitriy Novozhilov
815e40620c [FIR-IDE] Update testdata after previous changes about java nullability enhancement 2021-03-11 13:10:05 +03:00
Dmitriy Novozhilov
dceb8b2991 [FIR] Don't render ! at the end of ConeFlexibleType 2021-03-11 13:10:05 +03:00
Dmitriy Novozhilov
932eed2c14 [FIR] Fix determining nullability of arguments during enhancement 2021-03-11 13:10:05 +03:00
Dmitriy Novozhilov
65ea4e184a [FIR] Fix enhancement of FlexibleNullability and EnhancedNullability
- Add utilities to add new attribute to ConeAttributes
- Get rid of FlexibleNullability attribute (it can be easily inferred
    for any flexible type at any moment)
- Fix determining of EnhancedNullability attribute
2021-03-11 13:10:04 +03:00
Dmitriy Novozhilov
0108f8a1b4 [FIR2IR] Don't create implicit not null cast on IrGetEnumValue 2021-03-11 13:10:04 +03:00
Dmitriy Novozhilov
01e8019c4c [FIR] Properly handle friend modules in modularized and full-pipeline tests 2021-03-11 13:10:04 +03:00
Dmitriy Novozhilov
f82c7c4678 [FIR] Cleanup session creation utils 2021-03-11 13:10:04 +03:00
Dmitriy Novozhilov
f1edca8ca8 Move default gradle run configurations to separate folders 2021-03-11 13:10:03 +03:00
Dmitriy Novozhilov
8995fe36f3 Add .idea/csv-plugin.xml to .gitignore 2021-03-11 13:10:03 +03:00
Vladimir Dolzhenko
fbe18164b4 Filter KtAnnotated on-the-fly diagnostic elements
Relates to #KTIJ-1760
Relates to #KT-45254
2021-03-11 08:43:36 +00:00
Dmitriy Novozhilov
cba63f2c12 Regenerate tests 2021-03-11 00:58:26 +03:00
Dmitriy Novozhilov
74118930b4 [FE] Don't fail with exception if ESVisitor tries to visit ESLambda
#KT-45243 Fixed
2021-03-11 00:58:24 +03:00
Mikhail Glukhikh
f3135baba9 FIR: eliminate replaceSource usages in transformTypeToArrayType 2021-03-10 22:23:21 +03:00
Dmitry Petrov
0cca07fa19 Bump d8 used in box tests to 2.1.75 2021-03-10 21:04:12 +03:00
Dmitry Petrov
737fbe271f JVM_IR Do not generate generic signatures for lifted lambda methods 2021-03-10 21:04:11 +03:00
Dmitry Petrov
00a335129b JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+ 2021-03-10 21:04:08 +03:00
Alexander Udalov
bf844aa8e4 JVM IR: prevent behavior change with operator dot calls on literals
#KT-42321 Fixed
2021-03-10 18:46:30 +01:00
Alexander Udalov
c7498dd74d Remove one layer of nested exceptions in JVM backend 2021-03-10 18:44:11 +01:00
Igor Chevdar
6608ca5795 [K/N][IR] Fixed bug with parents setting
Fixes IR_VALIDATION warning as a side effect
2021-03-10 21:29:11 +05:00
Andrey Zinovyev
d941d41776 [KAPT] Fix broken incremental test 2021-03-10 17:30:10 +03:00
Alexander Udalov
a3a745e7a5 Fix ParallelBuildTest for Windows
Enclose file paths in raw strings. Otherwise in the string
"C:\Users\...", "\U" was detected as an illegal escape which led to an
error.
2021-03-10 14:25:06 +01:00
Roman Golyshev
5d0760c685 KT-44756 Ignore annotations on value parameters if metadata says so
There is a `gradle-api-impldep.jar` created by Gradle which contains
our nullability annotations, but relocated in the
`org.gradle.internal.impldep` package

In the deserialization process we use a `HAS_ANNOTATIONS` flag, and
if it is present on the declaration, we do not try to build annotations
for it, even when they are actually present and even when they are
relocated
(see usages of Flags.HAS_ANNOTATIONS in org.jetbrains.kotlin.serialization.deserialization.MemberDeserializer)

In the stubs builder we also use this HAS_ANNOTATIONS flag, but we did
not use it for the value parameters. This commit fixes that - now, if
the `org.jetbrains.annotations` packages are relocated, it should not
cause `Stub Mismatch Error` for the value parameters

Lets consider two possible cases:

1. If the value parameter has a user-defined annotation,
it will be marked as having annotations (HAS_ANNOTATIONS == true), and
both stubs and deserialized descriptors will have to
use all available annotations (even a relocated ones)

2. If, for example, the value parameter is of non-nullable type, it will
have a `@NotNull` annotation on it, but will be marked as having
no annotations at all (HAS_ANNOTATIONS == false), since `NotNull` is
considered as auxiliary by the compiler. Because of the flag, both stubs
and descriptors will ignore all present annotations (even if they were
relocated)

In the both cases, the stubs and the descriptors will completely match

^KT-44756 Fixed

See IDEA-262971 about fixing the Gradle jar and the details

N.B. This does not fixes the cases when `kotlin.Metadata` and similar
annotations are relocated (e.g. KT-25709)
2021-03-10 11:53:33 +00:00
Elena Lepilkina
f7099d34d4 [K/N] Fixed build of performance server project 2021-03-10 11:49:39 +00:00
Dmitriy Dolovov
cd2f55ea2f [Commonizer] Minor. Remove unused utility functions 2021-03-10 13:50:00 +03:00
Dmitriy Dolovov
c1848a26c3 [Commonizer] Use more compact interner based on THashSet 2021-03-10 13:49:54 +03:00
Dmitriy Dolovov
7a11c722c6 [Commonizer] Introduce CirProvided.ExportedForwardDeclarationClass
To represent classifiers that are actually exported forward declarations
2021-03-10 13:49:48 +03:00
Dmitriy Dolovov
76d93b6dca [Commonizer] Read exported forward declarations for every C-interop module 2021-03-10 13:49:41 +03:00
Ilya Gorbunov
a7fda66fa1 Suggest duration static factories instead of number extension properties
Introduce Duration companion functions to convert numbers to Duration.
Deprecate number extension properties and propose to use these
new functions instead.
2021-03-10 13:23:32 +03:00
Ilya Gorbunov
ca99fc4fed Make more lambda-taking functions in kotlin-test inline-only
So that the lambda can contain non-local control flow, such as suspend
calls. Inline-only helps preserving line numbers in the failed assertion
stack traces.

KT-44717
2021-03-10 12:15:45 +03:00
Mikhael Bogdanov
66a29c70bf Use compatibility accessors only in compatibility stubs 2021-03-10 09:09:10 +00:00
Mikhael Bogdanov
efceb89b98 Don't generate private members in compatibility mode in DefaultImpls 2021-03-10 09:09:09 +00:00
Mikhael Bogdanov
f648d86d2b Generate stubs for private function with default arguments as public in interfaces 2021-03-10 09:09:08 +00:00
Andrey Zinovyev
7edbf79b4b [KAPT] Don't fail on empty InsnList
Fix failing on empty methods inline methods (after light generation)

#KT-45032 Fixed
2021-03-10 10:58:35 +03:00
Dmitry Petrov
02b5b931d4 Revert "JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+"
This reverts commit 679756ad
2021-03-10 07:39:29 +03:00
Vasily Levchenko
ba3f27b5ce [performance] performace includes kotlinx.cli compositelly 2021-03-09 20:21:25 +00:00
Vasily Levchenko
8f97ba97f2 [kotlinx.cli] dually depends on kotlin artifacts
- in kotlin build this is project dependency
- in performace build this is artifact dependency
2021-03-09 20:21:25 +00:00
Vasily Levchenko
f159a424f5 [build][plugin] kotlin native benchmarking plugin adds dependency kotlinx.cli as project dependency 2021-03-09 20:21:24 +00:00
Vasily Levchenko
0858a92b12 [build-tools] util to substitute dependency notation as artifact or project dependency 2021-03-09 20:21:23 +00:00
Vasily Levchenko
3935c290a9 [performance] prerequisite checks added 2021-03-09 20:21:23 +00:00
Vasily Levchenko
72bb1f5b30 [kotlin-native][performance][plugin] clean up 2021-03-09 20:21:22 +00:00
Sergey Bogolepov
eb54689801 Update coverage sample documentation.
We need to invoke `llvm-profdata` tool from
the same toolchain as Clang (on macOS we use the one from Xcode).

(cherry picked from commit 91665b36af68b7fb3a56c0e7ed7ebb7d819adfb2)
2021-03-09 20:19:37 +00:00
Alexander Shabalin
e53c8ba6ca Add FinalizerQueue to ObjectFactory (#4725)
(cherry picked from commit af70866594c31c81dfcc41b2e8b33c7a0cdc38f5)
2021-03-09 20:19:36 +00:00
Sergey Bogolepov
f840b45ae1 Add hack for kotlinx-datetime:0.1.1 linkage
Provide a `std::system_category` wrapper with
the same mangling as in GCC 4.8.5

(cherry picked from commit ec5828a1f375a74a09aa49182571201e1f67b4fa)
2021-03-09 20:19:35 +00:00
LepilkinaElena
fcbb921194 [LEGACY MM] Escape making extra increments and decrements during coping to the same array (#4731)
(cherry picked from commit 8b601d8e2c6bc772386ebd88d303a032a6f54237)
2021-03-09 20:19:34 +00:00
Igor Chevdar
f9f948fea6 [IR] Fixed problems with nested inline classes
Fixes https://youtrack.jetbrains.com/issue/KT-45139 as well

(cherry picked from commit 44916e39bfa69325a9ab73cb4533bd2612fb4e56)
2021-03-09 20:19:34 +00:00
Sergey Bogolepov
f5f7e976f6 Fix #KT-45094
Rebuild linux toolchains with an older OS.

(cherry picked from commit 1d249ad7b592573dc4478f0f6cefe2766c323e12)
2021-03-09 20:19:33 +00:00
Sergey Bogolepov
357f2be14e [Toolchain] Archive versioning
Allow toolchain builder to add a suffix to toolchain name.
It is useful for rebuilding the same toolchain in different environment.

(cherry picked from commit 83148fc5bb4e8bcc5afcf119df53ec1bc854be17)
2021-03-09 20:19:32 +00:00
Florian Kistner
bd614aba0b Retain typed generics in ObjC export stubs (#4727)
* Add ObjC export test with disabled generics
* Retain typed generics in ObjC export stubs
* Introduce ObjC variance enum to decouple stubs from Kotlin variance

(cherry picked from commit 4d7c78b952a467ca3318c8c49d36b768fdc1ef9c)
2021-03-09 20:19:31 +00:00
LepilkinaElena
6641b4f029 [LEGACY MM] Fixed types in messages for tracing GC (#4729)
(cherry picked from commit 2f34b0f98e77226f02809a685a96ebb683a69e9d)
2021-03-09 20:19:30 +00:00
Dmitry Petrov
679756ad07 JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+ 2021-03-09 23:16:11 +03:00
Alexander Udalov
8294aed40c IR: add descriptor to "unbound symbols not allowed" message
This will help in diagnosing problems such as KT-45236.
2021-03-09 21:07:53 +01:00
Alexander Udalov
e3dc112c5f Add original KotlinType to rendered IrErrorType
Also improve an error message in `IrType.erasedUpperBound`, which seems
like a frequent first place where the JVM IR backend crashes in case an
error type has made it past psi2ir.

This will help in diagnosing problems such as KT-45016.
2021-03-09 21:07:53 +01:00
Alexander Udalov
cd9463ae8d Minor, add toString for GeneratedFile 2021-03-09 21:07:53 +01:00
Alexander Udalov
bdaeaca5ae Psi2ir: do not generate default accessor body for expect properties
Because generateDefaultGetterBody/generateDefaultSetterBody reference
the property's backing field, which in case of extension properties
leads to an error "Unbound symbols not allowed" because extension
property cannot have a backing field.

In some way, this check is similar to the `isExpect` check in
`generatePrimaryConstructor`.
2021-03-09 20:51:02 +01:00
Alexander Udalov
5fc9f3bc17 Minor, add box test for unreachable uninitialized property
#KT-44496
2021-03-09 20:50:39 +01:00
Alexander Udalov
247efb220c Do not require backing fields for extension properties
This has no effect on correct code because extension properties cannot
have a backing field anyway and that is checked separately. But this
function is used in psi2ir to determine whether or not to create a
backing field for a property, and in case the code where the property is
declared is unreachable like in KT-44496 and has no explicit getter or
setter, it would previously return true for extension properties, which
on JVM would result in an actual field in the class file, which made no
sense.

After this change, the compiler will actually crash with an exception in
the IR validaton step because the symbol for the field is unbound. That
is a bit better than proceeding to generate potentially invalid
bytecode, but of course a proper fix would be to report an error in the
frontend.

 #KT-44496
2021-03-09 20:50:39 +01:00
Ilya Kirillov
81baf4fae5 FIR IDE: collect diagnostics under read lock 2021-03-09 18:30:35 +01:00
Ilya Kirillov
770468c78e FIR IDE: refactor designated lazy transformers 2021-03-09 18:30:35 +01:00
Pavel Kirpichenkov
4bc019736b [MPP] Add KotlinSDK to the set of predefined test SDKs
^KT-45145 Fixed
2021-03-09 20:05:32 +03:00
Ilya Kirillov
d8a3dacdc5 FIR: return back supertypeRefs list recreation 2021-03-09 15:41:42 +01:00
Pavel Punegov
efa43052db Fix Kotlin/Native dist path setting in Klib tests 2021-03-09 14:38:59 +00:00
Vladimir Ivanov
fd02802028 [Native] Export KDoc into generated native header 2021-03-09 16:50:23 +03:00
Jinseong Jeon
6427117a35 FIR CFG: correct edge label from a node that returns Nothing
If it's not within a try/catch/finally, that should be an uncaught
exception path.

^KT-45327 Fixed
2021-03-09 14:44:42 +03:00
Jinseong Jeon
d8fb54c6bd Reproduce KT-45327: false positive MUST_INITIALIZED_OR_BE_ABSTRACT after conditional exitProcess 2021-03-09 14:44:42 +03:00
Alexander Udalov
628d75c7cd JVM: fix EnclosingMethod information for SAMs in inline lambdas
Pass parentContext to SamWrapperCodegen from the outside instead of
using the one from parentCodegen. The difference is that in case of an
inline lambda, we're creating an InlineLambdaContext whose parent is a
ClosureContext, but the codegen for that lambda has that latter
ClosureContext as its context. So the getNonInlineOuterContext call in
SamWrapperCodegen.generateInnerClassInformation wasn't able to identify
that this is a context of a lambda that needs to be skipped, and
generated it as EnclosingMethod, which caused Java reflection to fail
because once that lambda was inlined, it was removed and thus didn't
make it to runtime.

 #KT-44827 Fixed
2021-03-09 11:43:11 +01:00
Nikolay Krasko
9e5bf7e05c Increase amount of memory for Gradle Importing Tests
We have OOM in recent tests executions
2021-03-09 13:32:27 +03:00
Dmitriy Dolovov
1a3515dbab [Commonizer] Use Flag.Class.IS_VALUE instead of Flag.Class.IS_INLINE
Also: Rename CirClass.isInline to CirClass.isValue
2021-03-09 13:13:30 +03:00
Dmitriy Dolovov
0fb99f1bf2 [Commonizer] Rename: entityBuilders.kt to CirSerializers.kt 2021-03-09 13:13:24 +03:00
Dmitriy Dolovov
b41cc57ff7 [Commonizer] Rename: Cir<Entity>.build<Entity> to Cir<Entity>.serialize<Entity> 2021-03-09 13:13:18 +03:00
Dmitriy Dolovov
010ea39417 [Commonizer] Rename: MetadataBuilder -> CirTreeSeralizer 2021-03-09 13:13:13 +03:00
Dmitriy Dolovov
4f33abf5e4 [Commonizer] Minor. Rename: CirTypeProjectionImpl -> CirRegularTypeProjection 2021-03-09 13:13:06 +03:00
Dmitriy Dolovov
6b0f080ed8 [Commonizer] Rename: TypeParameterResolver -> CirTypeParameterResolver 2021-03-09 13:12:59 +03:00
Dmitriy Dolovov
d07ede7305 [Commonizer] Move all CIR deserialization logic to CirDeserializers.kt 2021-03-09 13:12:53 +03:00
Dmitriy Dolovov
1737bdd4d4 [Commonizer] Extract CirTypeResolver to a separate file 2021-03-09 13:12:47 +03:00
Dmitriy Dolovov
6697c4d197 [Commonizer] Put all CIR utils to a single file 2021-03-09 13:12:42 +03:00
Dmitriy Dolovov
20ab88c001 [Commonizer] Extract CirStandardTypes from CirTypeFactory 2021-03-09 13:12:37 +03:00
Dmitriy Dolovov
298b595826 [Commonizer] Move TA expander to 'commonizer.metadata' package 2021-03-09 13:12:32 +03:00
Dmitriy Dolovov
82589c0898 [Commonizer] Move recursion markers to 'commonizer.cir' package 2021-03-09 13:12:26 +03:00
Dmitriy Dolovov
f0669c752f [Commonizer] Extract creation of CirProperty from CirPropertyFactory 2021-03-09 13:12:21 +03:00
Dmitriy Dolovov
3778d1d631 [Commonizer] Extract creation of CirFunction from CirFunctionFactory 2021-03-09 13:12:15 +03:00
Dmitriy Dolovov
d3c60ab72e [Commonizer] Extract creation of CirClass from CirClassFactory 2021-03-09 13:12:09 +03:00
Dmitriy Dolovov
fa9285aac7 [Commonizer] Extract creation of CirTypeAlias from CirTypeAliasFactory 2021-03-09 13:12:04 +03:00
Dmitriy Dolovov
52d0250dc6 [Commonizer] Extract creation of CirClassConstructor from CirClassConstructorFactory 2021-03-09 13:11:59 +03:00
Dmitriy Dolovov
cdba0d029e [Commonizer] Extract creation of CirExtensionReceiver from CirExtensionReceiverFactory 2021-03-09 13:11:52 +03:00
Dmitriy Dolovov
885026f6db [Commonizer] Extract creation of CirTypeParameter from CirTypeParameterFactory 2021-03-09 13:11:47 +03:00
Dmitriy Dolovov
b30ebe2842 [Commonizer] Drop CirPackageFactory 2021-03-09 13:11:41 +03:00
Dmitriy Dolovov
bfe0623837 [Commonizer] Drop CirModuleFactory 2021-03-09 13:11:35 +03:00
Dmitriy Dolovov
1f17d238f8 [Commonizer] Drop CirRootFactory 2021-03-09 13:11:30 +03:00
Dmitriy Dolovov
d7ed8ff804 [Commonizer] Encapsulate interning inside of CIR entities: CirTypeAliasType 2021-03-09 13:11:24 +03:00
Dmitriy Dolovov
36294352ef [Commonizer] Encapsulate interning inside of CIR entities: CirClassType 2021-03-09 13:11:19 +03:00
Dmitriy Dolovov
c6d8cddcd9 [Commonizer] Encapsulate interning inside of CIR entities: CirTypeParameterType 2021-03-09 13:11:14 +03:00
Dmitriy Dolovov
3012839f49 [Commonizer] Encapsulate interning inside of CIR entities: CirAnnotation 2021-03-09 13:11:08 +03:00
Dmitriy Dolovov
f7d977d7c4 [Commonizer] Encapsulate interning inside of CIR entities: CirPropertySetter 2021-03-09 13:11:02 +03:00
Dmitriy Dolovov
f1739980d3 [Commonizer] Encapsulate interning inside of CIR entities: CirPropertyGetter 2021-03-09 13:10:57 +03:00
Dmitriy Dolovov
ec1e4fb26e [Commonizer] Encapsulate interning inside of CIR entities: CirFunctionModifiers 2021-03-09 13:10:51 +03:00
Dmitriy Dolovov
5e41a7c66b [Commonizer] Encapsulate interning inside of CIR entities: CirValueParameter 2021-03-09 13:10:46 +03:00
Dmitriy Dolovov
f43626d545 [Commonizer] Drop no more necessary logic for forward declarations 2021-03-09 13:10:40 +03:00
Dmitriy Dolovov
12be9c99ca [Commonizer] Replace DescriptorVisibilit[y,ies] by Visibilit[y,ies] 2021-03-09 13:10:35 +03:00
Dmitriy Dolovov
7bdbc893a0 [Commonizer] Move test-specific logic to 'tests' module 2021-03-09 13:10:30 +03:00
Dmitriy Dolovov
a0baecc6e4 [Commonizer] Rename: CirTreeMergerV2 -> CirTreeMerger 2021-03-09 13:10:24 +03:00
Dmitriy Dolovov
126b634529 [Commonizer] Drop support of descriptors, part 2 2021-03-09 13:10:18 +03:00
Dmitriy Dolovov
607568fb73 [Commonizer] Rework mocks for tests to drop descriptors 2021-03-09 13:10:13 +03:00
Dmitriy Dolovov
e96dd3b301 [Commonizer] Drop support of descriptors, part 1 2021-03-09 13:10:07 +03:00
Dmitriy Dolovov
eddeef1d51 [Commonizer] Build CIR tree directly from metadata 2021-03-09 13:10:01 +03:00
sebastian.sellmair
3d6893e518 [Commonizer] Implement safe SharedCommonizerTarget factory function
Do not try to instantiate SharedCommonizerTarget with no leaves
^KT-45350 Verification Pending
2021-03-09 10:02:00 +00:00
sebastian.sellmair
6527452143 [Commonizer] Add CommonizerIT test for ^KT-45350
Adding a test project containing commonization targets for
ios, linux and windows to test behaviour if at least one commonizer group
is fully not supported.
2021-03-09 10:02:00 +00:00
Mads Ager
7dbb0c7d20 [IR] Make IrGetObjectValue copyable to avoid duplicate IR nodes.
Fixes KT-45170
2021-03-09 09:48:16 +03:00
Ilmir Usmanov
e79c9a3618 Extend LVT record of alive variables to end of next suspension point
Otherwise, arguments of suspend call become invisible in async stack
trace
 #KT-44714
2021-03-08 23:56:40 +01:00
Ilmir Usmanov
b6bb8a576e Make start label of LVT record the point where variable becomes alive
Otherwise, there will be overlapping LVT records, which leads to
removal of the whole LVT by R8.
 #KT-44714 Fixed
2021-03-08 23:56:39 +01:00
Ilmir Usmanov
e17b7f01b6 Do not remove dead variables' LVT records
Also, extend liveness of alive variable to nearest suspension points
 #KT-44714
2021-03-08 23:56:36 +01:00
Alexander Udalov
ee11202db5 Add Flag.IS_VALUE for value classes to kotlinx-metadata-jvm
#KT-44783 Fixed
2021-03-08 21:22:40 +01:00
Alexander Udalov
6ddca4a592 Add KClass.isValue to kotlin-reflect
#KT-44782 Fixed
2021-03-08 21:22:40 +01:00
Mikhael Bogdanov
4d51d71699 Fix EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE message 2021-03-08 17:52:52 +00:00
Mikhael Bogdanov
3568eba1b2 Use actual implementation instead of inherited one in -Xjvm-default diagnostics 2021-03-08 17:52:52 +00:00
Mikhael Bogdanov
71c134e54f Fix checker for -Xjvm-defaults 2021-03-08 17:52:51 +00:00
Alexander Udalov
8b8262096c Fix testKt44814 by adding an IR dump
It's supposedly needed because of the `// DUMP_IR` directive.
2021-03-08 17:32:13 +01:00
Alexander Udalov
9970851684 Restore writing bytecode version to metadata for LV < 1.5
#KT-45323 Fixed
2021-03-08 11:18:54 +01:00
Alexander Udalov
a2200b5386 Revert "Do not write bytecode version to class file"
This reverts commit c6f5ce6837.

 #KT-45323
2021-03-08 11:18:54 +01:00
Ilya Kirillov
7c11dde2cf FIR IDE: add support of FirStatement in getKtExpressionType 2021-03-07 19:48:08 +01:00
Ilya Kirillov
d311fe21f8 FIR IDE: add additional tests for expression types 2021-03-07 19:48:08 +01:00
Ilya Kirillov
8a28175302 FIR IDE: fix CCE in getKtExpressionType on loops 2021-03-07 19:48:08 +01:00
Ilya Kirillov
0130ecd21d FIR IDE: fix CCE in getKtExpressionType on assignment target 2021-03-07 19:48:08 +01:00
Andrey Uskov
b7e13d677d Fixed loading Gradle script templates located on WSL2
#KT-45042 Fixed
2021-03-07 19:40:13 +03:00
Andrey Uskov
63925ee018 Implemented collecting projectId from Gradle
#KT-45337 Fixed
2021-03-07 19:40:08 +03:00
Abduqodiri Qurbonzoda
4401589974 [K/N] Fix @SinceKotlin in Common titlecase and titlecaseChar functions 2021-03-07 07:38:05 +03:00
Abduqodiri Qurbonzoda
e7a45bba91 Fix @SinceKotlin in Common titlecase and titlecaseChar functions 2021-03-07 07:38:04 +03:00
Abduqodiri Qurbonzoda
aa5874e073 [K/N] Mark with @SinceKotlin("1.5") the Common char category API 2021-03-07 07:37:47 +03:00
Abduqodiri Qurbonzoda
10b0d147af Mark with @SinceKotlin("1.5") the Common char category API 2021-03-07 07:37:46 +03:00
Yahor Berdnikau
5db71209b2 Run Gradle advanced tests against 7.0-milestone-2 Gradle release.
^KT-44949 Fixed
2021-03-06 19:43:50 +01:00
Yahor Berdnikau
58564a7b89 Distinguish outputs of JS IR tasks.
Now JS IR link and sync tasks will output produced artifacts based on
compilation name, binary name and binary mode. This will remove
Gradle 7 error about missing task dependencies, which should not depend
on each other.

^KT-44949 In Progress
2021-03-06 19:43:50 +01:00
Yahor Berdnikau
2e1c1cd154 Fix test expects slightly different variant selection error message.
Error message was slightly changed on Gradle 7.

^KT-44949 In Progress
2021-03-06 19:43:50 +01:00
Yahor Berdnikau
c96c50a73c Update AGP tests.
Bump AGP version in some tests and ignore AGP 3.4 tests on Gradle 7.
AGP 3.4 is not compatible with Gradle 7.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
e17aa5efaa Change source jar duplication error to warning.
For now Gradle 7 will print warnings on publishing sources jar containing
duplicate files.

Duplicates are coming from SourceSets SourceSet added to sources jar
task depends on. Such approach should be rethought.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
c072c8200b Fix test was using removed publication plugin.
Replace usage of removed 'maven' plugin with 'maven-publish'.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
2042508df0 Fix test project uses removed configuration for dependencies.
^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
d78f579a42 Link task producing jar with sources to dukat tasks.
This required by Gradle 7 task validation.
Though in some cases sourcesJar task should not depend in some cases on Dukat tasks.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
2a8e2613a2 Split klib and cinterop outputs.
So Gradle 7 will not complain that some tasks using klib or cinterop
should depend on both tasks producing klib and cinterop, while they
don't need both.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
2ed98ee732 Fix test was using old KMM dependency notation.
^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Yahor Berdnikau
db2d6c7e0a Ensure compilation task depends on friend artifact producer task.
Without it Gradle 7.0 tasks dependency validation will fail.

Fix JS tasks are not cacheable due to friends inputs change.

^KT-44949 In Progress
2021-03-06 19:43:49 +01:00
Cedric Champeau
0340a89045 Fix File as input of an artifact transform
Using `File` as input of an artifact transform was deprecated.
With Gradle 7, this becomes an error. This commit fixes the
problem by using the proper replacement:

   Provider<FileSystemLocation>
2021-03-06 15:46:07 +03:00
scaventz
9a7ef11043 Report a readable diagnostic on empty -J argument in CLI 2021-03-06 03:14:11 -08:00
scaventz
81a495b494 Fix the NullPointerException when pathname does not name a parent. 2021-03-06 01:50:40 -08:00
Abduqodiri Qurbonzoda
1c1492da3d Optimize K/N ArrayList.toArray #KT-42720 2021-03-06 11:15:08 +03:00
Abduqodiri Qurbonzoda
421cb6971d Optimized toArray method for ArrayDeque and ListBuilder #KT-42720 2021-03-06 11:14:50 +03:00
Abduqodiri Qurbonzoda
c2f6a2cb96 [K/N] Commonize and generalize JVM-only String.contentEquals #KT-42840 2021-03-06 11:14:32 +03:00
Abduqodiri Qurbonzoda
ed57bcb3b1 Commonize and generalize JVM-only String.contentEquals #KT-42840 2021-03-06 11:14:30 +03:00
Mikhail Glukhikh
037505d9f2 FIR IDE: regenerate diagnostics 2021-03-06 09:22:35 +03:00
Mikhail Glukhikh
7eb9b1188f FIR: implement helpers for diagnostic suppression on elements children 2021-03-06 09:22:35 +03:00
Mikhail Glukhikh
15c3269e38 FIR: don't report error on inline nested classes 2021-03-06 09:22:35 +03:00
Mikhail Glukhikh
1e4d7ff690 Fix LightTreePositioningStrategies.DECLARATION_NAME 2021-03-06 09:22:35 +03:00
eugenpolytechnic
f6e564ffa6 FIR: introduce inline classes checks 2021-03-06 09:22:34 +03:00
Ilya Gorbunov
9cc8f44390 Support mod and floorDiv extensions in constant evaluator
Ignore evaluation tests for floorDiv and mod with FIR for now.
2021-03-05 23:46:57 +03:00
Ilya Gorbunov
58e6f775bb Rename test of rem operator evaluation 2021-03-05 23:46:57 +03:00
Ilya Gorbunov
3da3f0e653 Advance bootstrap to 1.5.20-dev-2378 2021-03-05 23:46:56 +03:00
Mads Ager
e5631addf3 [IR] Move annotations from original to new constructor declarations.
LocalDeclarationsLowering did not move annotations when creating
a new constructor declaration, thereby losing the annotations.

Fixes KT-45298
2021-03-05 12:24:38 -08:00
Mads Ager
965c118521 [JVM IR] Make upper bounds check recursive for ieee Equals.
Fixes KT-44402
2021-03-05 12:22:54 -08:00
Alexander Udalov
566f97ae3e JVM IR: remove dependency of 'backend.jvm' on 'psi2ir', 'ir.serialization.jvm'
Add a new module 'backend.jvm.entrypoint' which depends on psi2ir and
contains code that runs psi2ir + JVM IR backend with serialization
implementations.

Hopefully this will allow to compile these modules in parallel and
reduce the build time.
2021-03-05 20:46:33 +01:00
Alexander Udalov
5e0860ca14 IR: move PsiSourceManager, PsiErrorBuilder to ir.backend.common 2021-03-05 20:46:33 +01:00
Alexander Udalov
bec4d1903b IR: move PsiFileEntry to ir.tree, rename to PsiIrFileEntry 2021-03-05 20:46:33 +01:00
Alexander Udalov
1f8de46b3c JVM IR: do not depend on StubGeneratorExtensions in backend
Move most of the implementation from JvmGeneratorExtensions to
JvmGeneratorExtensionsImpl. The latter implements
StubGeneratorExtensions from psi2ir, and doing so helps to remove direct
dependency on this part of psi2ir from backend.
2021-03-05 20:46:33 +01:00
Alexander Udalov
22d269a0a8 Minor, rename JvmGeneratorExtensions.kt -> JvmGeneratorExtensionsImpl.kt
To keep git history for this file after the subsequent commit, where
most of the implementation is moved to JvmGeneratorExtensionsImpl.
2021-03-05 20:46:33 +01:00
Alexander Udalov
f332192de8 IR: remove SourceManager, make PsiSourceManager a singleton 2021-03-05 20:46:33 +01:00
Mikhael Bogdanov
8ff0b1e243 Reports warning on super calls in public-api inline functions 2021-03-05 18:45:07 +00:00
Alexander Udalov
027df41740 Add test which runs Kotlin compiler in parallel
This will be useful in diagnosing issues like KT-45007 in the future.

 #KT-45007
2021-03-05 17:58:42 +01:00
Alexander Udalov
e7e17cdaa9 Revert "Fix KotlinCoreEnvironment projectCount disposable"
This reverts commit 99a6bdeec7.

 #KT-45007 Fixed
2021-03-05 17:40:39 +01:00
Vladimir Dolzhenko
36ff952a0f Ignore when failed to get file text
Relates to #KTIJ-706
2021-03-05 17:12:56 +01:00
Andrei Klunnyi
a0b901b23a Revert "[FIR]: sealed hierarchy processor for IDE"
This reverts commit e6ccdff2
2021-03-05 16:37:47 +01:00
Dmitriy Novozhilov
4ed341b152 Advance bootstrap to 1.5.20-dev-1608 2021-03-05 17:23:29 +03:00
Ilya Kirillov
1d42c70056 FIR IDE: generate diagnostics 2021-03-05 15:04:07 +01:00
Igor Yakovlev
b744f41c0d [ULC] Fix annotations invalid parents
Fixed #KT-45287
2021-03-05 14:33:10 +01:00
Igor Yakovlev
179cf303da [ULC] Fix annotations with no site for ctor
Fixed #KT-45291
2021-03-05 14:33:10 +01:00
Yahor Berdnikau
297aa17b6e Fix Jvm target tries to use removed configuration.
KT-44949 In Progress
KT-44957 Fixed
2021-03-05 16:28:03 +03:00
Yahor Berdnikau
117cfc763a Fix JS target configuration triggers task creation too early.
This raised the problem that task, compilation task depends on, has not
been yet created and Gradle fails the build with exception.

KT-44949 In Progress
2021-03-05 16:28:01 +03:00
Yahor Berdnikau
d06ec61b79 Migrate to the actual workers api available from Gradle 5.6.
Old api was removed in Gradle 7 and causes build crashes.

KT-44949 In Progress
2021-03-05 16:28:00 +03:00
Tianyu Geng
8158a07063 FIR IDE: add quickfix for NESTED_CLASS_NOT_ALLOWED 2021-03-05 13:27:36 +01:00
Svyatoslav Scherbina
27904c0fb9 Native compiler source: replace inline classes by value classes
The former are deprecated.
2021-03-05 12:15:22 +00:00
Svyatoslav Scherbina
b45de517c4 Native stdlib build: fix using OptionalExpectation in Interop/Runtime
Current build for kotlin-native/Interop/Runtime sources is not truly
MPP, so explicit -Xcommon-sources flags are required for the compiler
to allow using OptionalExpectation annotations.
2021-03-05 12:15:22 +00:00
Bingran
03df752e8e Update min supported gradle version to 6.1
This PR also updates the min agp version we test with because older agp
versions are using gradle apis which doesn't exist in gradle 6.0+.

GH PR: #4155
2021-03-05 14:11:10 +03:00
Roman Artemev
9bdfbc948c [KLIB] Support assignable value parameters in deserializer
- fix KT-44945
2021-03-05 13:47:07 +03:00
Andrei Klunnyi
e6ccdff2f7 [FIR]: sealed hierarchy processor for IDE
From now on sealed declarations get resolved with the help of
FirIdeSealedHierarchyProcessor. This change entails correct IDE side
check for sealed when exhaustiveness.
2021-03-05 10:20:19 +00:00
Dmitriy Novozhilov
aa829c2321 [FIR2IR] Fix using default values of annotation arguments 2021-03-05 13:00:12 +03:00
Dmitriy Novozhilov
ca26c193ae Make all hierarchies of JavaAnnotationArgument sealed 2021-03-05 13:00:12 +03:00
Dmitriy Novozhilov
1f6ce874a1 Don't fail on unsupported default values of java annotations 2021-03-05 13:00:12 +03:00
Dmitriy Novozhilov
745aa620d0 Reformat annotationArgumentsImpl.kt 2021-03-05 13:00:11 +03:00
Dmitriy Novozhilov
bd7689d381 [FIR] Properly compute default arguments of java annotations 2021-03-05 13:00:11 +03:00
Dmitriy Novozhilov
8324f499cd [FIR] Fix serializing annotation metadata on setters value parameters 2021-03-05 13:00:11 +03:00
Vasily Levchenko
ee1bc45bd6 [performance] disable fat framework compilation 2021-03-05 09:53:27 +00:00
Vasily Levchenko
ab68bb6ddb [performance] enable "swift run" 2021-03-05 09:53:26 +00:00
Jinseong Jeon
8368812432 Minor cleanup: avoid vague util names 2021-03-05 10:06:22 +03:00
Jinseong Jeon
8b24f4b5c6 Minor cleanup: place modifier strategies close to each other 2021-03-05 10:06:22 +03:00
Jinseong Jeon
1ba943eb4a Minor cleanup: prefer actual body with return statement 2021-03-05 10:06:22 +03:00
Ilya Gorbunov
7e2c365b79 Generate docs for floorDiv and mod and improve docs for div and rem
Refactor operator documentation generation for primitives and unsigned
types so that it is easier to specialize it.

Manually sync docs of numeric types in js-ir stdlib.

 KT-26234
2021-03-05 07:32:16 +03:00
Ilya Gorbunov
50d4979531 Floor division and remainder for numeric types KT-26234
- floorDiv/mod for unsigned types
- floorDiv/mod for signed types
- mod for floating point types

- mod return type: same as divisor for integer types

- Update JS API dump
- Avoid triggering division overflow in tests due to K/N
- Workaround failing test in JS-legacy
2021-03-05 07:32:16 +03:00
Ilya Gorbunov
284e6f5bb3 Add runtime dependency on junit-jupiter-engine to kotlin-test-junit5
It is required to run tests authored with kotlin-test, so it seems
convenient to have it as a runtime dependency of kotlin-test-junit5
variant.

Depend on the version 5.6.0, which is approx. one year old.
Can be upgraded in the consumer project if necessary.

Also upgrade junit-jupiter-api dependency to 5.6.0, so that users could
use more recent JUnit functionality in JVM tests,
but continue compiling the artifact against 5.0.0 to leave a
possibility to downgrade JUnit platform dependency if needed.

KT-45107
2021-03-05 02:22:24 +03:00
scaventz
28452fc38e Kotlinc: catch FileNotFoundException caused by problematic destination. 2021-03-04 11:25:35 -08:00
Dmitriy Dolovov
149282a888 [Commonizer] Fix: Stats not logged for "native-dist-commonize" CLI task 2021-03-04 22:24:11 +03:00
Dmitriy Dolovov
1c06972ec6 [Commonizer] Minor. Formatted 2021-03-04 22:24:05 +03:00
Dmitriy Dolovov
d6961a6e60 [Commonizer] Rework MetadataDeclarationsComparator API
1. Formalize all possible variants of entities where mismatch could happen via sealed interface MetadataDeclarationsComparator.EntityKind
2. Track the path to the place of mismatch in terms of MetadataDeclarationsComparator.PathElement
2021-03-04 22:23:57 +03:00
Alexander Likhachev
70d434e992 Update tests after compiler properties rework
#KT-43605 Fixed
2021-03-04 19:36:18 +03:00
Alexander Likhachev
3537c699b5 [Gradle] Read system properties at configuration time using Gradle providers
The change is a step to fully support Gradle configuration cache.
Relates to #KT-43605
Relates to #KT-44611
2021-03-04 19:36:11 +03:00
1530 changed files with 27303 additions and 10334 deletions

3
.gitignore vendored
View File

@@ -54,6 +54,7 @@ build/
.idea/artifacts/kotlin_test_js_ir_*
.idea/artifacts/kotlin_stdlib_wasm_*
.idea/jarRepositories.xml
.idea/csv-plugin.xml
kotlin-ultimate/
node_modules/
.rpt2_cache/
@@ -63,4 +64,4 @@ buildSrcTmp/
distTmp/
outTmp/
/test.output
/kotlin-native/dist
/kotlin-native/dist

View File

@@ -1,8 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="kotlinx.cli-jvm-1.5.255-SNAPSHOT">
<output-path>$PROJECT_DIR$/kotlin-native/endorsedLibraries/kotlinx.cli/build/libs</output-path>
<root id="archive" name="kotlinx.cli-jvm-1.5.255-SNAPSHOT.jar">
<element id="module-output" name="kotlin.kotlin-native.endorsedLibraries.kotlinx.cli.jvmMain" />
</root>
<root id="archive" name="kotlinx.cli-jvm-1.5.255-SNAPSHOT.jar" />
</artifact>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate All Tests" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Generate All Tests" type="GradleRunConfiguration" factoryName="Gradle" folderName="Generators">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate Compiler Tests" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Generate Compiler Tests" type="GradleRunConfiguration" factoryName="Gradle" folderName="Generators">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/compiler" />

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate FIR Checker Components and FIR/IDE Diagnostics" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Generate FIR Checker Components and FIR/IDE Diagnostics" type="GradleRunConfiguration" factoryName="Gradle" folderName="Generators">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -21,4 +21,4 @@
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate standard library sources" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Generate standard library sources" type="GradleRunConfiguration" factoryName="Gradle" folderName="Stdlib">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/libraries/tools/kotlin-stdlib-gen" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA" type="GradleRunConfiguration" factoryName="Gradle" singleton="true">
<configuration default="false" name="IDEA" type="GradleRunConfiguration" factoryName="Gradle" singleton="true" folderName="IDEA">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA Ultimate" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="IDEA Ultimate" type="GradleRunConfiguration" factoryName="Gradle" folderName="IDEA">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA Ultimate (No ProcessCanceledException) " type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="IDEA Ultimate (No ProcessCanceledException) " type="GradleRunConfiguration" factoryName="Gradle" folderName="IDEA">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="GradleRunConfiguration" factoryName="Gradle" folderName="IDEA">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="IDEA (Not Internal)" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="IDEA (Not Internal)" type="GradleRunConfiguration" factoryName="Gradle" folderName="IDEA">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -16,4 +16,4 @@
<option name="vmOptions" value="" />
</ExternalSystemSettings>
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test: KMM" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Test: KMM" type="GradleRunConfiguration" factoryName="Gradle" folderName="Tests">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -17,4 +17,4 @@
</ExternalSystemSettings>
<method v="2" />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test: public API binary compatibility validator, overwrite results" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Test: public API binary compatibility validator, overwrite results" type="GradleRunConfiguration" factoryName="Gradle" folderName="Stdlib">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/libraries/tools/binary-compatibility-validator" />
@@ -18,4 +18,4 @@
</ExternalSystemSettings>
<method />
</configuration>
</component>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test: stdlib-js public kotlin api test, overwrite results" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="Test: stdlib-js public kotlin api test, overwrite results" type="GradleRunConfiguration" factoryName="Gradle" folderName="Stdlib">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -19,4 +19,4 @@
<GradleScriptDebugEnabled>false</GradleScriptDebugEnabled>
<method v="2" />
</configuration>
</component>
</component>

View File

@@ -92,18 +92,16 @@ benchmark {
}
}
tasks.named("classes") {
doLast {
tasks.named("mainBenchmarkJar", Zip::class.java) {
isZip64 = true
archiveName = "benchmarks.jar"
}
listOf("mainBenchmark", "mainFirBenchmark", "mainNiBenchmark").forEach {
tasks.named(it, JavaExec::class.java) {
systemProperty("idea.home.path", intellijRootDir().canonicalPath)
}
}
}
tasks.matching { it is Zip && it.name == "mainBenchmarkJar" }.configureEach {
this as Zip
isZip64 = true
archiveFileName.set("benchmarks.jar")
}
val benchmarkTasks = listOf("mainBenchmark", "mainFirBenchmark", "mainNiBenchmark")
tasks.matching { it is JavaExec && it.name in benchmarkTasks }.configureEach {
this as JavaExec
systemProperty("idea.home.path", intellijRootDir().canonicalPath)
}
tasks.register<JavaExec>("runBenchmark") {

View File

@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.context.withProject
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
import org.jetbrains.kotlin.fir.createSession
import org.jetbrains.kotlin.fir.createSessionForTests
import org.jetbrains.kotlin.fir.java.FirJavaElementFinder
import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl
@@ -150,7 +150,7 @@ abstract class AbstractSimpleFileBenchmark {
private fun analyzeGreenFileIr(bh: Blackhole) {
val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
val session = createSession(env, scope)
val session = createSessionForTests(env, scope)
val firProvider = session.firProvider as FirProviderImpl
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider)

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.build
import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
/**

View File

@@ -26,11 +26,13 @@ open class GeneratedFile(
val outputFile: File
) {
val sourceFiles = sourceFiles.sortedBy { it.path }
override fun toString(): String = "${this::class.java.simpleName}: $outputFile"
}
class GeneratedJvmClass (
sourceFiles: Collection<File>,
outputFile: File
class GeneratedJvmClass(
sourceFiles: Collection<File>,
outputFile: File
) : GeneratedFile(sourceFiles, outputFile) {
val outputClass = LocalFileKotlinClass.create(outputFile).sure {
"Couldn't load KotlinClass from $outputFile; it may happen because class doesn't have valid Kotlin annotations"

View File

@@ -182,7 +182,7 @@ extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.1.3"
extra["versions.r8"] = "2.0.88"
extra["versions.r8"] = "2.1.75"
val immutablesVersion = "0.3.1"
extra["versions.kotlinx-collections-immutable"] = immutablesVersion
extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
@@ -242,6 +242,7 @@ extra["compilerModules"] = arrayOf(
":compiler:ir.psi2ir",
":compiler:ir.backend.common",
":compiler:backend.jvm",
":compiler:backend.jvm:backend.jvm.entrypoint",
":compiler:backend.js",
":compiler:backend.wasm",
":compiler:ir.serialization.common",
@@ -564,10 +565,13 @@ allprojects {
}
}
gradle.buildFinished {
val taskGraph = gradle?.taskGraph
if (taskGraph != null) {
taskGraph.allTasks
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 {
@@ -577,6 +581,7 @@ gradle.buildFinished {
}
}
}
}
}
}
@@ -620,17 +625,12 @@ val ideaPlugin by task<Task> {
}
tasks {
named("clean") {
doLast {
delete("$buildDir/repo")
delete(distDir)
}
named<Delete>("clean") {
delete += setOf("$buildDir/repo", distDir)
}
register("cleanupArtifacts") {
doLast {
delete(artifactsDir)
}
register<Delete>("cleanupArtifacts") {
delete = setOf(artifactsDir)
}
listOf("clean", "assemble", "install").forEach { taskName ->
@@ -729,10 +729,12 @@ tasks {
register("scriptingTest") {
dependsOn("dist")
dependsOn(":kotlin-script-util:test")
dependsOn(":kotlin-scripting-compiler-embeddable:test")
dependsOn(":kotlin-scripting-compiler:test")
dependsOn(":kotlin-scripting-compiler:testWithIr")
dependsOn(":kotlin-scripting-common:test")
dependsOn(":kotlin-scripting-jvm:test")
dependsOn(":kotlin-scripting-jvm-host-test:test")
dependsOn(":kotlin-scripting-jvm-host-test:testWithIr")
dependsOn(":kotlin-scripting-dependencies:test")
dependsOn(":kotlin-scripting-dependencies-maven:test")
dependsOn(":kotlin-scripting-jsr223-test:test")
@@ -740,6 +742,7 @@ tasks {
// dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
dependsOn(":kotlin-main-kts-test:test")
dependsOn(":kotlin-main-kts-test:testWithIr")
dependsOn(":kotlin-scripting-ide-services-test:test")
dependsOn(":kotlin-scripting-ide-services-test:embeddableTest")
dependsOn(":kotlin-scripting-js-test:test")
@@ -891,17 +894,11 @@ tasks {
if (Ide.IJ()) {
dependsOn(
":libraries:tools:new-project-wizard:test",
":libraries:tools:new-project-wizard:new-project-wizard-cli:test",
":idea:idea-new-project-wizard:test" // Temporary here. Remove after enabling builds for ideaIntegrationsTests
":libraries:tools:new-project-wizard:new-project-wizard-cli:test"
)
}
}
register("ideaIntegrationsTests") {
if (Ide.IJ()) {
dependsOn(":idea:idea-new-project-wizard:test")
}
}
register("kaptIdeTest") {
dependsOn(":kotlin-annotation-processing:test")
@@ -1208,7 +1205,8 @@ val Jar.outputFile: File
val Project.sourceSetsOrNull: SourceSetContainer?
get() = convention.findPlugin(JavaPluginConvention::class.java)?.sourceSets
val disableVerificationTasks = System.getProperty("disable.verification.tasks") == "true"
val disableVerificationTasks = providers.systemProperty("disable.verification.tasks")
.forUseAtConfigurationTime().orNull?.toBoolean() ?: false
if (disableVerificationTasks) {
gradle.taskGraph.whenReady {
allTasks.forEach {

View File

@@ -161,7 +161,7 @@ dependencies {
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.5")
implementation("org.gradle:test-retry-gradle-plugin:1.1.9")
implementation("org.gradle:test-retry-gradle-plugin:1.2.0")
implementation("com.gradle.enterprise:test-distribution-gradle-plugin:1.2.1")
compileOnly(gradleApi())
@@ -199,6 +199,7 @@ java {
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.allWarningsAsErrors = true
kotlinOptions.freeCompilerArgs += listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xskip-runtime-version-check",
@@ -262,4 +263,4 @@ gradlePlugin {
implementationClass = "org.jetbrains.kotlin.NativeInteropPlugin"
}
}
}
}

View File

@@ -0,0 +1,51 @@
import org.gradle.api.Action
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withGroovyBuilder
/*
* 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.
*/
class InstrumentJava(@Transient val javaInstrumentator: Configuration, @Transient val sourceSet: SourceSet) : Action<Task> {
private val instrumentatorClasspath: String by lazy {
javaInstrumentator.asPath
}
private val srcDirs: FileCollection by lazy {
sourceSet.allJava.sourceDirectories
}
override fun execute(task: Task) {
require(task is JavaCompile) { "$task is not of type JavaCompile!" }
task.doLast {
task.ant.withGroovyBuilder {
"taskdef"(
"name" to "instrumentIdeaExtensions",
"classpath" to instrumentatorClasspath,
"loaderref" to "java2.loader",
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
)
}
val javaSourceDirectories = srcDirs.filter { it.exists() }
task.ant.withGroovyBuilder {
javaSourceDirectories.forEach { directory ->
"instrumentIdeaExtensions"(
"srcdir" to directory,
"destdir" to task.destinationDir,
"classpath" to task.classpath.asPath,
"includeantruntime" to false,
"instrumentNotNull" to true
)
}
}
}
}
}

View File

@@ -25,7 +25,6 @@ import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.Upload
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.jvm.tasks.Jar
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer
import plugins.KotlinBuildPublishingPlugin

View File

@@ -8,48 +8,37 @@ package tasks
import groovy.util.Node
import groovy.util.XmlParser
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import java.io.File
import java.util.*
open class WriteCopyrightToFile : DefaultTask() {
abstract class WriteCopyrightToFile : DefaultTask() {
@InputFile
var path = project.file("${project.rootDir}/.idea/copyright/apache.xml")
val path = project.file("${project.rootDir}/.idea/copyright/apache.xml")
@OutputFile
var outputFile: File? = null
@get:OutputFile
abstract val outputFile: RegularFileProperty
@Input
var commented: Boolean = true
@get:Input
val commented: Property<Boolean> = project.objects.property(Boolean::class.java).convention(true)
@TaskAction
fun write() {
if (commented) {
outputFile!!.writeText(project.readCopyrightCommented())
} else {
outputFile!!.writeText(project.readCopyright())
}
val file = outputFile.asFile.get()
file.writeText(if (commented.get()) readCopyrightCommented() else readCopyright())
}
fun Project.readCopyright(): String {
val file = rootDir.resolve(".idea/copyright/apache.xml")
assert(file.exists()) {
"File $file with copyright not found"
private fun readCopyright(): String {
assert(path.exists()) {
"File $path with copyright not found"
}
val xmlParser = XmlParser()
val node = xmlParser.parse(file)
val node = xmlParser.parse(path)
assert(node.attribute("name") == "CopyrightManager") {
"Format changed occasionally?"
}
@@ -59,7 +48,7 @@ open class WriteCopyrightToFile : DefaultTask() {
return noticeNode.attribute("value").toString().replace("&#36;today.year", GregorianCalendar()[Calendar.YEAR].toString())
}
fun Project.readCopyrightCommented(): String {
private fun readCopyrightCommented(): String {
return "/*\n" + readCopyright().prependIndent(" * ") + "\n */"
}
}

View File

@@ -128,7 +128,6 @@ fun Project.rewriteDepsToShadedJar(
archiveClassifier.set("original")
}
val compilerDummyJarFile by lazy { configurations.getAt("compilerDummyJar").singleFile }
shadowJarTask.configure {
dependsOn(originalJarTask)
@@ -136,7 +135,8 @@ fun Project.rewriteDepsToShadedJar(
// When Gradle traverses the inputs, reject the shaded compiler JAR,
// which leads to the content of that JAR being excluded as well:
exclude { it.file == compilerDummyJarFile }
val compilerDummyJarFile = project.provider { configurations.getByName("compilerDummyJar").singleFile }
exclude { it.file == compilerDummyJarFile.get() }
archiveClassifier.set("original")
body()

View File

@@ -21,15 +21,18 @@ import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.internal.ConventionTask
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.tasks.*
import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.kotlin.dsl.*
import java.io.File
import javax.inject.Inject
fun Project.configureFormInstrumentation() {
plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all {
plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.configureEach {
// When we change the output classes directory, Gradle will automatically configure
// the test compile tasks to use the instrumented classes. Normally this is fine,
// however, it causes problems for Kotlin projects:
@@ -42,31 +45,36 @@ fun Project.configureFormInstrumentation() {
// This fails when we change the classes dir. The easiest fix is to prepend the
// classes from the "friendly directory" to the compile classpath.
val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile?
testCompile?.doFirst {
val originalClassesDirs = files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))
if (!tasks.names.contains("compileTestKotlin")) return@configureEach
testCompile.classpath = (testCompile.classpath
- mainSourceSet.output.classesDirs
+ originalClassesDirs)
tasks.named<AbstractCompile>("compileTestKotlin") {
val objects = project.objects
val classesDirs = project.mainSourceSet.output.classesDirs
val classesDirsCopy = project.provider { (mainSourceSet as ExtensionAware).extra.get("classesDirsCopy") }
doFirst {
val originalClassesDirs = objects.fileCollection().from(classesDirsCopy)
// Since Kotlin 1.3.60, the friend paths available to the test compile task are calculated as the main source set's
// output.classesDirs. Since the classesDirs are excluded from the classpath (replaced by the originalClassesDirs),
// in order to be able to access the internals of 'main', tests need to receive the original classes dirs as a
// -Xfriend-paths compiler argument as well.
fun addFreeCompilerArgs(kotlinCompileTask: AbstractCompile, vararg args: String) {
val getKotlinOptions = kotlinCompileTask::class.java.getMethod("getKotlinOptions")
val kotlinOptions = getKotlinOptions(kotlinCompileTask)
classpath = (classpath
- classesDirs
+ originalClassesDirs)
val getFreeCompilerArgs = kotlinOptions::class.java.getMethod("getFreeCompilerArgs")
val freeCompilerArgs = getFreeCompilerArgs(kotlinOptions) as List<*>
// Since Kotlin 1.3.60, the friend paths available to the test compile task are calculated as the main source set's
// output.classesDirs. Since the classesDirs are excluded from the classpath (replaced by the originalClassesDirs),
// in order to be able to access the internals of 'main', tests need to receive the original classes dirs as a
// -Xfriend-paths compiler argument as well.
fun addFreeCompilerArgs(kotlinCompileTask: AbstractCompile, vararg args: String) {
val getKotlinOptions = kotlinCompileTask::class.java.getMethod("getKotlinOptions")
val kotlinOptions = getKotlinOptions(kotlinCompileTask)
val setFreeCompilerArgs = kotlinOptions::class.java.getMethod("setFreeCompilerArgs", List::class.java)
setFreeCompilerArgs(kotlinOptions, freeCompilerArgs + args)
val getFreeCompilerArgs = kotlinOptions::class.java.getMethod("getFreeCompilerArgs")
val freeCompilerArgs = getFreeCompilerArgs(kotlinOptions) as List<*>
val setFreeCompilerArgs = kotlinOptions::class.java.getMethod("setFreeCompilerArgs", List::class.java)
setFreeCompilerArgs(kotlinOptions, freeCompilerArgs + args)
}
addFreeCompilerArgs(this as AbstractCompile, "-Xfriend-paths=" + originalClassesDirs.joinToString(",") { it.absolutePath })
}
addFreeCompilerArgs(testCompile, "-Xfriend-paths=" + originalClassesDirs.joinToString(",") { it.absolutePath })
}
}
val instrumentationClasspathCfg = configurations.create("instrumentationClasspath")
@@ -76,7 +84,7 @@ fun Project.configureFormInstrumentation() {
}
afterEvaluate {
sourceSets.all { sourceSetParam ->
sourceSets.forEach { sourceSetParam ->
// This copy will ignore filters, but they are unlikely to be used.
val classesDirs = (sourceSetParam.output.classesDirs as ConfigurableFileCollection).from as Collection<Any>
@@ -88,66 +96,82 @@ fun Project.configureFormInstrumentation() {
(sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir)
val instrumentTask =
project.tasks.register(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java) {
dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty }
sourceSet = sourceSetParam
instrumentationClasspath = instrumentationClasspathCfg
originalClassesDirs = classesDirsCopy
output = instrumentedClassesDir
outputs.dir(instrumentedClassesDir)
dependsOn(sourceSetParam.classesTaskName)
compileClasspath.from(sourceSetParam.compileClasspath)
sourceDirs.from(project.files({ sourceSetParam.allSource.srcDirs.filter { !sourceSetParam.resources.contains(it) && it.exists() } }))
instrumentationClasspathConfiguration = instrumentationClasspathCfg
originalClassesDirs.from(classesDirsCopy)
output.set(instrumentedClassesDir)
}
// Ensure that our task is invoked when the source set is built
sourceSetParam.compiledBy(instrumentTask)
@Suppress("UNUSED_EXPRESSION")
true
}
}
}
@CacheableTask
open class IntelliJInstrumentCodeTask : ConventionTask() {
abstract class IntelliJInstrumentCodeTask : ConventionTask() {
companion object {
private const val FILTER_ANNOTATION_REGEXP_CLASS = "com.intellij.ant.ClassFilterAnnotationRegexp"
private const val LOADER_REF = "java2.loader"
}
@Classpath
var instrumentationClasspath: Configuration? = null
@Transient
@Internal
lateinit var instrumentationClasspathConfiguration: Configuration
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
var originalClassesDirs: FileCollection? = null
@get:Classpath
val instrumentationClasspath: String by lazy {
instrumentationClasspathConfiguration.asPath
}
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:SkipWhenEmpty
abstract val originalClassesDirs: ConfigurableFileCollection
@get:Input
var instrumentNotNull: Boolean = false
@Internal
var sourceSet: SourceSet? = null
@get:InputFiles
@get:Classpath
abstract val compileClasspath: ConfigurableFileCollection
// Instrumentation needs to have access to sources of forms for inclusion
private val depSourceDirectorySets by lazy {
project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
}
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
val sourceDirs: FileCollection
get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() })
abstract val sourceDirs: ConfigurableFileCollection
@get:OutputDirectory
lateinit var output: File
abstract val output: RegularFileProperty
@get:Inject
abstract val fs: FileSystemOperations
@TaskAction
fun instrumentClasses() {
logger.info(
"input files are: ${originalClassesDirs?.joinToString(
"; ",
transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)"}" })}"
"input files are: ${
originalClassesDirs.joinToString(
"; ",
transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)"}" })
}"
)
output.deleteRecursively()
output.asFile.get().deleteRecursively()
copyOriginalClasses()
val classpath = instrumentationClasspath!!
val classpath = instrumentationClasspath
ant.withGroovyBuilder {
"taskdef"(
"name" to "instrumentIdeaExtensions",
"classpath" to classpath.asPath,
"classpath" to classpath,
"loaderref" to LOADER_REF,
"classname" to "com.intellij.ant.InstrumentIdeaExtensions"
)
@@ -155,14 +179,14 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
logger.info("Compiling forms and instrumenting code with nullability preconditions")
if (instrumentNotNull) {
prepareNotNullInstrumenting(classpath.asPath)
prepareNotNullInstrumenting(classpath)
}
instrumentCode(sourceDirs, instrumentNotNull)
}
private fun copyOriginalClasses() {
project.copy {
fs.copy {
from(originalClassesDirs)
into(output)
}
@@ -181,12 +205,10 @@ open class IntelliJInstrumentCodeTask : ConventionTask() {
private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) {
val headlessOldValue = System.setProperty("java.awt.headless", "true")
val output = output.get().asFile
// Instrumentation needs to have access to sources of forms for inclusion
val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java)
.map { p -> p.dependencyProject.mainSourceSet.allSource.sourceDirectories }
val instrumentationClasspath =
depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also {
depSourceDirectorySets.fold(compileClasspath as FileCollection) { acc, v -> acc + v }.asPath.also {
logger.info("Using following dependency source dirs: $it")
}

View File

@@ -64,6 +64,9 @@ private fun createMavenMarkerPublication(
): MavenPublication {
return publications.create<MavenPublication>(declaration.name.toString() + "PluginMarkerMaven") {
val pluginId: String = declaration.id
val cGroupId = coordinates.groupId
val cArtifactId = coordinates.artifactId
val cVersion = coordinates.version
artifactId = pluginId + PLUGIN_MARKER_SUFFIX
groupId = pluginId
pom.withXml {
@@ -72,11 +75,11 @@ private fun createMavenMarkerPublication(
val dependencies = root.appendChild(document.createElement("dependencies"))
val dependency = dependencies.appendChild(document.createElement("dependency"))
val groupId = dependency.appendChild(document.createElement("groupId"))
groupId.textContent = coordinates.groupId
groupId.textContent = cGroupId
val artifactId = dependency.appendChild(document.createElement("artifactId"))
artifactId.textContent = coordinates.artifactId
artifactId.textContent = cArtifactId
val version = dependency.appendChild(document.createElement("version"))
version.textContent = coordinates.version
version.textContent = cVersion
}
pom.name.set(declaration.displayName)

View File

@@ -6,12 +6,15 @@
import com.jakewharton.dex.*
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.jvm.tasks.Jar
import java.io.File
@CacheableTask
open class DexMethodCount : DefaultTask() {
abstract class DexMethodCount : DefaultTask() {
data class Counts(
val total: Int,
@@ -24,16 +27,18 @@ open class DexMethodCount : DefaultTask() {
@Classpath
lateinit var jarFile: File
@Optional
@Input
var ownPackages: List<String>? = null
@get:Optional
@get:Input
abstract val ownPackages: ListProperty<String>
@Internal
var artifactName: String? = null
private val projectName = project.name
@get:Input
val artifactOrArchiveName: String
get() = artifactName ?: project.name
get() = artifactName ?: projectName
fun from(jar: Jar) {
jarFile = jar.archiveFile.get().asFile
@@ -45,8 +50,9 @@ open class DexMethodCount : DefaultTask() {
lateinit var counts: Counts
@get:OutputFile
val detailOutputFile: File
get() = project.buildDir.resolve("$artifactOrArchiveName-method-count.txt")
val detailOutputFile: File by lazy {
project.buildDir.resolve("$artifactOrArchiveName-method-count.txt")
}
@TaskAction
fun invoke() {
@@ -59,9 +65,9 @@ open class DexMethodCount : DefaultTask() {
val byPackage = this.groupingBy { it.`package` }.eachCount()
val byClass = this.groupingBy { it.declaringType }.eachCount()
val ownPackages = ownPackages?.map { "$it." }
val byOwnPackages = if (ownPackages != null) {
this.partition { method -> ownPackages.any { method.declaringType.startsWith(it) } }.let {
val ownPackages = ownPackages.map { list -> list.map { "$it." } }
val byOwnPackages = if (ownPackages.isPresent) {
this.partition { method -> ownPackages.get().any { method.declaringType.startsWith(it) } }.let {
it.first.size to it.second.size
}
} else (null to null)
@@ -78,7 +84,7 @@ open class DexMethodCount : DefaultTask() {
private fun outputDetails(counts: Counts) {
detailOutputFile.printWriter().use { writer ->
writer.println("${counts.total.padRight()}\tTotal methods")
ownPackages?.let { packages ->
ownPackages.orNull?.let { packages ->
writer.println("${counts.totalOwnPackages?.padRight()}\tTotal methods from packages ${packages.joinToString { "$it.*" }}")
writer.println("${counts.totalOtherPackages?.padRight()}\tTotal methods from other packages")
}
@@ -96,23 +102,24 @@ open class DexMethodCount : DefaultTask() {
}
}
open class DexMethodCountStats : DefaultTask() {
@Internal
lateinit var from: TaskProvider<DexMethodCount>
abstract class DexMethodCountStats : DefaultTask() {
@get:InputFile
internal val inputFile
get() = from.get().detailOutputFile
internal abstract val inputFile: RegularFileProperty
@get:Input
internal abstract val artifactOrArchiveName: Property<String>
@get:Input
@get:Optional
internal abstract val ownPackages: ListProperty<String>
@TaskAction
private fun printStats() {
val artifactOrArchiveName = from.get().artifactOrArchiveName
inputFile.reader().useLines { lines ->
val artifactOrArchiveName = artifactOrArchiveName.get()
inputFile.get().asFile.reader().useLines { lines ->
fun String.getStatValue() = substringBefore("\t").trim()
val ownPackages = from.get().ownPackages
val statsLineCount = if (ownPackages == null) 1 else 3
val statsLineCount = if (!ownPackages.isPresent) 1 else 3
val stats = lines.take(statsLineCount).map { it.getStatValue() }.toList()
val total = stats[0]
@@ -122,7 +129,7 @@ open class DexMethodCountStats : DefaultTask() {
println("##teamcity[buildStatisticValue key='DexMethodCount_${artifactOrArchiveName}' value='$total']")
}
ownPackages?.let { packages ->
ownPackages.map { packages ->
val totalOwnPackages = stats[1]
val totalOtherPackages = stats[2]
@@ -141,7 +148,9 @@ open class DexMethodCountStats : DefaultTask() {
fun Project.printStats(dexMethodCount: TaskProvider<DexMethodCount>) {
val dexMethodCountStats = tasks.register("dexMethodCountStats", DexMethodCountStats::class.java) {
dependsOn(dexMethodCount)
from = dexMethodCount
inputFile.set(dexMethodCount.flatMap { objects.fileProperty().apply { set(it.detailOutputFile) } })
artifactOrArchiveName.set(dexMethodCount.map { it.artifactOrArchiveName })
ownPackages.set(dexMethodCount.flatMap { it.ownPackages })
}
dexMethodCount.configure {

View File

@@ -9,11 +9,14 @@
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.tasks.TaskProvider
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import org.gradle.kotlin.dsl.support.serviceOf
import java.io.File
import java.lang.Character.isLowerCase
import java.lang.Character.isUpperCase
@@ -80,129 +83,141 @@ fun Project.projectTest(
shortenTempRootName: Boolean = false,
jUnit5Enabled: Boolean = false,
body: Test.() -> Unit = {}
): TaskProvider<Test> = getOrCreateTask(taskName) {
doFirst {
val commandLineIncludePatterns = (filter as? DefaultTestFilter)?.commandLineIncludePatterns ?: mutableSetOf()
val patterns = filter.includePatterns + commandLineIncludePatterns
if (patterns.isEmpty() || patterns.any { '*' in it }) return@doFirst
patterns.forEach { pattern ->
var isClassPattern = false
val maybeMethodName = pattern.substringAfterLast('.')
val maybeClassFqName = if (maybeMethodName.isFirstChar(::isLowerCase)) {
pattern.substringBeforeLast('.')
} else {
isClassPattern = true
pattern
}
if (!maybeClassFqName.substringAfterLast('.').isFirstChar(::isUpperCase)) {
return@forEach
}
val classFileNameWithoutExtension = maybeClassFqName.replace('.', '/')
val classFileName = "$classFileNameWithoutExtension.class"
if (isClassPattern) {
val innerClassPattern = "$pattern$*"
if (pattern in commandLineIncludePatterns) {
commandLineIncludePatterns.add(innerClassPattern)
(filter as? DefaultTestFilter)?.setCommandLineIncludePatterns(commandLineIncludePatterns)
} else {
filter.includePatterns.add(innerClassPattern)
}
}
val parentNames = if (jUnit5Enabled) {
/*
* If we run test from inner test class with junit 5 we need
* to include all containing classes of our class
*/
val nestedNames = classFileNameWithoutExtension.split("$")
mutableListOf(nestedNames.first()).also {
for (s in nestedNames.subList(1, nestedNames.size)) {
it += "${it.last()}\$$s"
}
}
} else emptyList()
include { treeElement ->
val path = treeElement.path
if (treeElement.isDirectory) {
classFileNameWithoutExtension.startsWith(path)
} else {
if (jUnit5Enabled) {
path == classFileName || (path.endsWith(".class") && parentNames.any { path.startsWith(it) })
} else {
path == classFileName || (path.endsWith(".class") && path.startsWith("$classFileNameWithoutExtension$"))
}
}
}
}
): TaskProvider<Test> {
val shouldInstrument = project.providers.gradleProperty("kotlin.test.instrumentation.disable")
.forUseAtConfigurationTime().orNull?.toBoolean() != true
if (shouldInstrument) {
evaluationDependsOn(":test-instrumenter")
}
if (project.findProperty("kotlin.test.instrumentation.disable")?.toString()?.toBoolean() != true) {
return getOrCreateTask<Test>(taskName) {
doFirst {
val agent = tasks.findByPath(":test-instrumenter:jar")!!.outputs.files.singleFile
val args = project.findProperty("kotlin.test.instrumentation.args")?.let { "=$it" }.orEmpty()
jvmArgs("-javaagent:$agent$args")
}
dependsOn(":test-instrumenter:jar")
}
val commandLineIncludePatterns = (filter as? DefaultTestFilter)?.commandLineIncludePatterns ?: mutableSetOf()
val patterns = filter.includePatterns + commandLineIncludePatterns
if (patterns.isEmpty() || patterns.any { '*' in it }) return@doFirst
patterns.forEach { pattern ->
var isClassPattern = false
val maybeMethodName = pattern.substringAfterLast('.')
val maybeClassFqName = if (maybeMethodName.isFirstChar(::isLowerCase)) {
pattern.substringBeforeLast('.')
} else {
isClassPattern = true
pattern
}
jvmArgs(
"-ea",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:+UseCodeCacheFlushing",
"-XX:ReservedCodeCacheSize=256m",
"-Djna.nosys=true"
)
if (!maybeClassFqName.substringAfterLast('.').isFirstChar(::isUpperCase)) {
return@forEach
}
maxHeapSize = "1600m"
systemProperty("idea.is.unit.test", "true")
systemProperty("idea.home.path", intellijRootDir().canonicalPath)
systemProperty("java.awt.headless", "true")
environment("NO_FS_ROOTS_ACCESS_CHECK", "true")
environment("PROJECT_CLASSES_DIRS", testSourceSet.output.classesDirs.asPath)
environment("PROJECT_BUILD_DIR", buildDir)
systemProperty("jps.kotlin.home", rootProject.extra["distKotlinHomeDir"]!!)
systemProperty("kotlin.ni", if (rootProject.hasProperty("newInferenceTests")) "true" else "false")
systemProperty("org.jetbrains.kotlin.skip.muted.tests", if (rootProject.hasProperty("skipMutedTests")) "true" else "false")
val classFileNameWithoutExtension = maybeClassFqName.replace('.', '/')
val classFileName = "$classFileNameWithoutExtension.class"
if (Platform[202].orHigher()) {
systemProperty("idea.ignore.disabled.plugins", "true")
}
if (isClassPattern) {
val innerClassPattern = "$pattern$*"
if (pattern in commandLineIncludePatterns) {
commandLineIncludePatterns.add(innerClassPattern)
(filter as? DefaultTestFilter)?.setCommandLineIncludePatterns(commandLineIncludePatterns)
} else {
filter.includePatterns.add(innerClassPattern)
}
}
var subProjectTempRoot: Path? = null
doFirst {
val teamcity = rootProject.findProperty("teamcity") as? Map<*, *>
val systemTempRoot =
// TC by default doesn't switch `teamcity.build.tempDir` to 'java.io.tmpdir' so it could cause to wasted disk space
// Should be fixed soon on Teamcity side
(teamcity?.get("teamcity.build.tempDir") as? String)
?: System.getProperty("java.io.tmpdir")
systemTempRoot.let {
val prefix = (project.name + "Project_" + taskName + "_").takeUnless { shortenTempRootName }
subProjectTempRoot = Files.createTempDirectory(File(systemTempRoot).toPath(), prefix)
systemProperty("java.io.tmpdir", subProjectTempRoot.toString())
}
}
val parentNames = if (jUnit5Enabled) {
/*
* If we run test from inner test class with junit 5 we need
* to include all containing classes of our class
*/
val nestedNames = classFileNameWithoutExtension.split("$")
mutableListOf(nestedNames.first()).also {
for (s in nestedNames.subList(1, nestedNames.size)) {
it += "${it.last()}\$$s"
}
}
} else emptyList()
doLast {
subProjectTempRoot?.let {
try {
delete(it)
} catch (e: Exception) {
project.logger.warn("Can't delete test temp root folder $it", e.printStackTrace())
include { treeElement ->
val path = treeElement.path
if (treeElement.isDirectory) {
classFileNameWithoutExtension.startsWith(path)
} else {
if (jUnit5Enabled) {
path == classFileName || (path.endsWith(".class") && parentNames.any { path.startsWith(it) })
} else {
path == classFileName || (path.endsWith(".class") && path.startsWith("$classFileNameWithoutExtension$"))
}
}
}
}
}
}
if (parallel && !jUnit5Enabled) {
maxParallelForks =
project.findProperty("kotlin.test.maxParallelForks")?.toString()?.toInt()
?: (Runtime.getRuntime().availableProcessors() / if (kotlinBuildProperties.isTeamcityBuild) 2 else 4).coerceAtLeast(1)
}
body()
if (shouldInstrument) {
val instrumentationArgsProperty = project.providers.gradleProperty("kotlin.test.instrumentation.args")
val testInstrumenterOutputs = project.tasks.findByPath(":test-instrumenter:jar")!!.outputs.files
doFirst {
val agent = testInstrumenterOutputs.singleFile
val args = instrumentationArgsProperty.orNull?.let { "=$it" }.orEmpty()
jvmArgs("-javaagent:$agent$args")
}
dependsOn(":test-instrumenter:jar")
}
jvmArgs(
"-ea",
"-XX:+HeapDumpOnOutOfMemoryError",
"-XX:+UseCodeCacheFlushing",
"-XX:ReservedCodeCacheSize=256m",
"-Djna.nosys=true"
)
maxHeapSize = "1600m"
systemProperty("idea.is.unit.test", "true")
systemProperty("idea.home.path", project.intellijRootDir().canonicalPath)
systemProperty("java.awt.headless", "true")
environment("NO_FS_ROOTS_ACCESS_CHECK", "true")
environment("PROJECT_CLASSES_DIRS", project.testSourceSet.output.classesDirs.asPath)
environment("PROJECT_BUILD_DIR", project.buildDir)
systemProperty("jps.kotlin.home", project.rootProject.extra["distKotlinHomeDir"]!!)
systemProperty("kotlin.ni", if (project.rootProject.hasProperty("newInferenceTests")) "true" else "false")
systemProperty("org.jetbrains.kotlin.skip.muted.tests", if (project.rootProject.hasProperty("skipMutedTests")) "true" else "false")
if (Platform[202].orHigher()) {
systemProperty("idea.ignore.disabled.plugins", "true")
}
var subProjectTempRoot: Path? = null
val projectName = project.name
val teamcity = project.rootProject.findProperty("teamcity") as? Map<*, *>
doFirst {
val systemTempRoot =
// TC by default doesn't switch `teamcity.build.tempDir` to 'java.io.tmpdir' so it could cause to wasted disk space
// Should be fixed soon on Teamcity side
(teamcity?.get("teamcity.build.tempDir") as? String)
?: System.getProperty("java.io.tmpdir")
systemTempRoot.let {
val prefix = (projectName + "Project_" + taskName + "_").takeUnless { shortenTempRootName }
subProjectTempRoot = Files.createTempDirectory(File(systemTempRoot).toPath(), prefix)
systemProperty("java.io.tmpdir", subProjectTempRoot.toString())
}
}
val fs = project.serviceOf<FileSystemOperations>()
doLast {
subProjectTempRoot?.let {
try {
fs.delete {
delete(it)
}
} catch (e: Exception) {
logger.warn("Can't delete test temp root folder $it", e.printStackTrace())
}
}
}
if (parallel && !jUnit5Enabled) {
maxParallelForks =
project.providers.gradleProperty("kotlin.test.maxParallelForks").forUseAtConfigurationTime().orNull?.toInt()
?: (Runtime.getRuntime().availableProcessors() / if (project.kotlinBuildProperties.isTeamcityBuild) 2 else 4).coerceAtLeast(1)
}
}.apply { configure(body) }
}
private inline fun String.isFirstChar(f: (Char) -> Boolean) = isNotEmpty() && f(first())
@@ -229,18 +244,25 @@ private fun Task.useAndroidConfiguration(systemPropertyName: String, configName:
val configuration = with(project) {
configurations.getOrCreate(configName)
.also {
dependencies.add(
configName,
dependencies.project(":dependencies:android-sdk", configuration = configName)
)
if (it.allDependencies.matching { dep ->
dep is ProjectDependency &&
dep.targetConfiguration == configName &&
dep.dependencyProject.path == ":dependencies:android-sdk"
}.count() == 0) {
dependencies.add(
configName,
dependencies.project(":dependencies:android-sdk", configuration = configName)
)
}
}
}
dependsOn(configuration)
if (this is Test) {
val androidFilePath = configuration.singleFile.canonicalPath
doFirst {
systemProperty(systemPropertyName, configuration.singleFile.canonicalPath)
systemProperty(systemPropertyName, androidFilePath)
}
}
}

View File

@@ -9,13 +9,13 @@ import org.gradle.internal.os.OperatingSystem
fun Test.configureTestDistribution(configure: TestDistributionExtension.() -> Unit = {}) {
if (extensions.findByType(TestDistributionExtension::class.java) == null) return
val isTeamcityBuild = project.kotlinBuildProperties.isTeamcityBuild
val testDistributionEnabled = project.findProperty("kotlin.build.test.distribution.enabled")?.toString()?.toBoolean()
?: isTeamcityBuild
useJUnitPlatform()
extensions.configure(TestDistributionExtension::class.java) {
enabled.set(testDistributionEnabled)
enabled.set(true)
maxRemoteExecutors.set(20)
if (isTeamcityBuild) {
requirements.set(setOf("os=${OperatingSystem.current().familyName}"))

View File

@@ -116,6 +116,12 @@ object AbstractTypeMapper {
return asmType
}
typeConstructor.isScript() -> {
val asmType = AsmTypes.JAVA_CLASS_TYPE
with(context) { sw?.writeGenericType(type, asmType, mode) }
return asmType
}
typeConstructor.isTypeParameter() -> {
val typeParameter = typeConstructor as TypeParameterMarker
return mapType(context, typeParameter.representativeUpperBound(), mode, null).also { asmType ->

View File

@@ -51,7 +51,6 @@ interface BaseExpressionCodegen {
fun consumeReifiedOperationMarker(typeParameter: TypeParameterMarker)
@JvmDefault
fun putReifiedOperationMarkerIfTypeIsReifiedParameter(type: KotlinTypeMarker, operationKind: OperationKind) {
with(typeSystem) {
val (typeParameter, second) = extractReificationArgument(type) ?: return

View File

@@ -88,6 +88,7 @@ import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContextImpl;
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS;
import org.jetbrains.kotlin.types.model.KotlinTypeMarker;
import org.jetbrains.kotlin.types.model.TypeParameterMarker;
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
import org.jetbrains.kotlin.util.OperatorNameConventions;
@@ -5532,4 +5533,11 @@ The "returned" value of try expression with no finally is either the last expres
parentCodegen.getReifiedTypeParametersUsages().addUsedReifiedParameter(typeParameterDescriptor.getName().asString());
}
}
@Override
public void putReifiedOperationMarkerIfTypeIsReifiedParameter(
@NotNull KotlinTypeMarker type, @NotNull ReifiedTypeInliner.OperationKind operationKind
) {
BaseExpressionCodegen.DefaultImpls.putReifiedOperationMarkerIfTypeIsReifiedParameter(this, type, operationKind);
}
}

View File

@@ -1152,8 +1152,10 @@ public class FunctionCodegen {
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
// $default methods are never protected to be accessible from subclass nested classes
// TODO: maybe best to generate private default in interface as private
int visibilityFlag =
DescriptorVisibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
(!isInterface(functionDescriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS) &&
(DescriptorVisibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor))
? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
if (!(functionDescriptor instanceof ConstructorDescriptor &&
@@ -1689,7 +1691,7 @@ public class FunctionCodegen {
return (kind != OwnerKind.DEFAULT_IMPLS && !isSyntheticInCompatibilityOrJvmDefault) ||
(kind == OwnerKind.DEFAULT_IMPLS &&
(isSyntheticInCompatibilityOrJvmDefault ||
(mode.isCompatibility() && !JvmAnnotationUtilKt.hasJvmDefaultNoCompatibilityAnnotation(containingDeclaration))));
(mode.isCompatibility() && !JvmAnnotationUtilKt.hasJvmDefaultNoCompatibilityAnnotation(containingDeclaration))) && !DescriptorVisibilities.isPrivate(memberDescriptor.getVisibility()));
} else {
switch (kind) {
case DEFAULT_IMPLS: return true;

View File

@@ -34,9 +34,13 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtTypeAlias
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClassPart
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
@@ -125,8 +129,19 @@ class MultifileClassCodegenImpl(
val superClassForFacade = if (shouldGeneratePartHierarchy) partInternalNamesSorted.last() else J_L_OBJECT
state.factory.newVisitor(MultifileClass(files.firstOrNull(), actualPackageFragment), facadeClassType, files).apply {
var attributes = FACADE_CLASS_ATTRIBUTES
val nonJvmSyntheticParts = files.filterNot { it.isJvmSynthetic() }
if (nonJvmSyntheticParts.isEmpty()) {
attributes = attributes or Opcodes.ACC_SYNTHETIC
} else if (nonJvmSyntheticParts.size < files.size) {
for (part in nonJvmSyntheticParts) {
state.diagnostics.report(ErrorsJvm.NOT_ALL_MULTIFILE_CLASS_PARTS_ARE_JVM_SYNTHETIC.on(part.packageDirective ?: part))
}
}
defineClass(
singleSourceFile, state.classFileVersion, FACADE_CLASS_ATTRIBUTES,
singleSourceFile, state.classFileVersion, attributes,
facadeClassType.internalName, null, superClassForFacade, emptyArray()
)
if (singleSourceFile != null) {
@@ -146,6 +161,13 @@ class MultifileClassCodegenImpl(
}
}
private fun KtFile.isJvmSynthetic(): Boolean {
return annotationEntries.any { entry ->
val descriptor = state.bindingContext[BindingContext.ANNOTATION, entry]
descriptor?.annotationClass?.let(DescriptorUtils::getFqNameSafe) == JVM_SYNTHETIC_ANNOTATION_FQ_NAME
}
}
override fun generate() {
assert(delegateGenerationTasks.isEmpty()) { "generate() is called twice for facade class $facadeFqName" }

View File

@@ -36,14 +36,16 @@ class SamWrapperClasses(private val state: GenerationState) {
expressionCodegen: ExpressionCodegen,
contextDescriptor: CallableMemberDescriptor
): Type {
val isInsideInline = InlineUtil.isInlineOrContainingInline(expressionCodegen.context.contextDescriptor) ||
isInsideInlineLambdaContext(expressionCodegen.context, state)
val parentContext = expressionCodegen.context
val isInsideInline = InlineUtil.isInlineOrContainingInline(parentContext.contextDescriptor) ||
isInsideInlineLambdaContext(parentContext, state)
return samInterfaceToWrapperClass.getOrPut(WrapperKey(samType, file, isInsideInline)) {
SamWrapperCodegen(state, samType, expressionCodegen.parentCodegen, isInsideInline).genWrapper(file, contextDescriptor)
SamWrapperCodegen(state, samType, expressionCodegen.parentCodegen, parentContext, isInsideInline)
.genWrapper(file, contextDescriptor)
}
}
private fun isInsideInlineLambdaContext(context: CodegenContext<*>, state: GenerationState):Boolean {
private fun isInsideInlineLambdaContext(context: CodegenContext<*>, state: GenerationState): Boolean {
var parent: CodegenContext<*>? = context
while (parent != null && parent != state.rootContext) {
if (parent is InlineLambdaContext) return true

View File

@@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.backend.common.CodegenUtil;
import org.jetbrains.kotlin.codegen.context.ClassContext;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.LanguageFeature;
@@ -64,6 +63,7 @@ public class SamWrapperCodegen {
private final KotlinTypeMapper typeMapper;
private final SamType samType;
private final MemberCodegen<?> parentCodegen;
private final CodegenContext<?> parentContext;
private final int visibility;
private final int classFlags;
public static final String SAM_WRAPPER_SUFFIX = "$0";
@@ -72,6 +72,7 @@ public class SamWrapperCodegen {
@NotNull GenerationState state,
@NotNull SamType samType,
@NotNull MemberCodegen<?> parentCodegen,
@NotNull CodegenContext<?> parentContext,
boolean isInsideInline
) {
this.state = state;
@@ -79,6 +80,7 @@ public class SamWrapperCodegen {
this.typeMapper = state.getTypeMapper();
this.samType = samType;
this.parentCodegen = parentCodegen;
this.parentContext = parentContext;
visibility = isInsideInline ? ACC_PUBLIC : NO_FLAG_PACKAGE_PRIVATE;
int synth = state.getLanguageVersionSettings().supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic) ? ACC_SYNTHETIC : 0;
classFlags = visibility | ACC_FINAL | ACC_SUPER | synth;
@@ -170,7 +172,6 @@ public class SamWrapperCodegen {
private void generateInnerClassInformation(@NotNull KtFile file, Type asmType, ClassBuilder cv) {
parentCodegen.addSyntheticAnonymousInnerClass(new SyntheticInnerClassInfo(asmType.getInternalName(), classFlags));
FieldOwnerContext<?> parentContext = parentCodegen.context;
CodegenContext<?> outerContext = MemberCodegen.getNonInlineOuterContext(parentContext);
assert outerContext != null :
"Outer context for SAM wrapper " + asmType.getInternalName() + " is null, parentContext:" + parentContext;

View File

@@ -1217,6 +1217,27 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
fun isAlive(insnIndex: Int, variableIndex: Int): Boolean =
liveness[insnIndex].isAlive(variableIndex)
fun nextSuspensionPointEndLabel(insn: AbstractInsnNode): LabelNode {
val suspensionPoint =
InsnSequence(insn, method.instructions.last).firstOrNull { isAfterSuspendMarker(it) } ?: method.instructions.last
return suspensionPoint as? LabelNode ?: suspensionPoint.findNextOrNull { it is LabelNode } as LabelNode
}
fun nextSuspensionPointStartLabel(insn: AbstractInsnNode): LabelNode {
val suspensionPoint =
InsnSequence(insn, method.instructions.last).firstOrNull { isBeforeSuspendMarker(it) } ?: method.instructions.last
return suspensionPoint as? LabelNode ?: suspensionPoint.findPreviousOrNull { it is LabelNode } as LabelNode
}
fun min(a: LabelNode, b: LabelNode): LabelNode =
if (method.instructions.indexOf(a) < method.instructions.indexOf(b)) a else b
fun max(a: LabelNode, b: LabelNode): LabelNode =
if (method.instructions.indexOf(a) < method.instructions.indexOf(b)) b else a
fun containsSuspensionPoint(a: LabelNode, b: LabelNode): Boolean =
InsnSequence(min(a, b), max(a, b)).none { isBeforeSuspendMarker(it) }
val oldLvt = arrayListOf<LocalVariableNode>()
for (record in method.localVariables) {
oldLvt += record
@@ -1237,23 +1258,35 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
// No variable in LVT -> do not add one
val lvtRecord = oldLvt.findRecord(insnIndex, variableIndex) ?: continue
if (lvtRecord.name == CONTINUATION_VARIABLE_NAME) continue
val endLabel = insn as? LabelNode ?: insn.findNextOrNull { it is LabelNode } as? LabelNode ?: continue
// Extend lvt record to the next suspension point
val endLabel = min(lvtRecord.end, nextSuspensionPointEndLabel(insn))
// startLabel can be null in case of parameters
@Suppress("NAME_SHADOWING") val startLabel = startLabel ?: lvtRecord.start
// Attempt to extend existing local variable node corresponding to the record in
// the original local variable table.
var recordToExtend: LocalVariableNode? = oldLvtNodeToLatestNewLvtNode[lvtRecord]
if (recordToExtend != null && InsnSequence(recordToExtend.end, startLabel).none { isBeforeSuspendMarker(it) }) {
val recordToExtend: LocalVariableNode? = oldLvtNodeToLatestNewLvtNode[lvtRecord]
if (recordToExtend != null && containsSuspensionPoint(recordToExtend.end, startLabel)) {
recordToExtend.end = endLabel
} else {
val node = LocalVariableNode(lvtRecord.name, lvtRecord.desc, lvtRecord.signature, startLabel, endLabel, lvtRecord.index)
method.localVariables.add(node)
if (lvtRecord !in oldLvtNodeToLatestNewLvtNode) {
method.localVariables.add(node)
}
oldLvtNodeToLatestNewLvtNode[lvtRecord] = node
}
}
}
}
val deadVariables = arrayListOf<Int>()
outer@for (variableIndex in start until method.maxLocals) {
if (oldLvt.none { it.index == variableIndex }) continue
for (insnIndex in 0 until (method.instructions.size() - 1)) {
if (isAlive(insnIndex, variableIndex)) continue@outer
}
deadVariables += variableIndex
}
for (variable in oldLvt) {
// $continuation and $result are dead, but they are used by debugger, as well as fake inliner variables
// For example, $continuation is used to create async stack trace
@@ -1262,10 +1295,26 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
isFakeLocalVariableForInline(variable.name)
) {
method.localVariables.add(variable)
continue
}
// this acts like $continuation for lambdas. For example, it is used by debugger to create async stack trace. Keep it.
if (variable.name == "this" && !isForNamedFunction) {
method.localVariables.add(variable)
continue
}
// Shrink LVT records of dead variables to the next suspension point
if (variable.index in deadVariables) {
method.localVariables.add(
LocalVariableNode(
variable.name,
variable.desc,
variable.signature,
variable.start,
nextSuspensionPointStartLabel(variable.start),
variable.index
)
)
}
}
}

View File

@@ -108,11 +108,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
)
}
protected fun generateStub(resolvedCall: ResolvedCall<*>?, codegen: BaseExpressionCodegen) {
protected fun generateStub(text: String, codegen: BaseExpressionCodegen) {
leaveTemps()
assert(resolvedCall != null)
val message = "Call is part of inline cycle: " + resolvedCall!!.call.callElement.text
AsmUtil.genThrow(codegen.v, "java/lang/UnsupportedOperationException", message)
AsmUtil.genThrow(codegen.v, "java/lang/UnsupportedOperationException", "Call is part of inline cycle: $text")
}
protected fun endCall(result: InlineResult, registerLineNumberAfterwards: Boolean) {

View File

@@ -60,8 +60,8 @@ class PsiInlineCodegen(
callDefault: Boolean,
codegen: ExpressionCodegen
) {
if (!state.globalInlineContext.enterIntoInlining(resolvedCall?.resultingDescriptor, resolvedCall?.call?.callElement)) {
generateStub(resolvedCall, codegen)
if (!state.globalInlineContext.enterIntoInlining(functionDescriptor, resolvedCall?.call?.callElement)) {
generateStub(resolvedCall?.call?.callElement?.text ?: "<no source>", codegen)
return
}
try {

View File

@@ -61,7 +61,7 @@ class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequ
}
}
fun InsnList.asSequence() = InsnSequence(this)
fun InsnList.asSequence(): Sequence<AbstractInsnNode> = if (size() == 0) emptySequence() else InsnSequence(this)
fun MethodNode.prepareForEmitting() {
stripOptimizationMarkers()

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.codegen.optimization.transformer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.jetbrains.org.objectweb.asm.tree.MethodNode;
import org.jetbrains.org.objectweb.asm.tree.analysis.*;
@@ -31,7 +32,7 @@ public abstract class MethodTransformer {
return analyzer.analyze(internalClassName, node);
}
catch (AnalyzerException e) {
throw new RuntimeException(e);
throw ExceptionUtilsKt.rethrow(e);
}
}

View File

@@ -213,13 +213,13 @@ class GenerationState private constructor(
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS)
if (fromConfig != null && target >= fromConfig.minJvmTarget)
fromConfig
else {
// TODO wait for KT-44844 (properly support 'invokedynamic' in JPS incremental compilation)
// Use JvmClosureGenerationScheme.INDY if
// JVM target is at least JVM_1_8 &&
// SamWrapperClassesAreSynthetic language feature is supported
else if (
target >= JvmClosureGenerationScheme.INDY.minJvmTarget &&
languageVersionSettings.supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic)
)
JvmClosureGenerationScheme.INDY
else
JvmClosureGenerationScheme.CLASS
}
}
val lambdasScheme = run {

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.org.objectweb.asm.AnnotationVisitor
@@ -31,6 +32,9 @@ fun writeKotlinMetadata(
) {
val av = cb.newAnnotation(JvmAnnotationNames.METADATA_DESC, true)
av.visit(JvmAnnotationNames.METADATA_VERSION_FIELD_NAME, state.metadataVersion.toArray())
if (!state.metadataVersion.isAtLeast(1, 5, 0)) {
av.visit("bv", JvmBytecodeBinaryVersion.INSTANCE.toArray())
}
av.visit(JvmAnnotationNames.KIND_FIELD_NAME, kind.id)
var flags = extraFlags
if (state.languageVersionSettings.isPreRelease()) {

View File

@@ -103,8 +103,11 @@ projectTest(parallel = true) {
workingDir = rootDir
systemProperty("kotlin.test.script.classpath", testSourceSet.output.classesDirs.joinToString(File.pathSeparator))
val antLauncherJarPathProvider = project.provider {
antLauncherJar.asPath
}
doFirst {
systemProperty("kotlin.ant.classpath", antLauncherJar.asPath)
systemProperty("kotlin.ant.classpath", antLauncherJarPathProvider.get())
systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main")
}
}

View File

@@ -52,6 +52,10 @@ while [ $# -gt 0 ]; do
;;
-J*)
java_args=("${java_args[@]}" "${1:2}")
if [ "x${1:2}" = "x" ]; then
echo "error: empty -J argument"
exit 1
fi
shift
;;
*)

View File

@@ -28,6 +28,10 @@ set _arg=%~1
if "%_arg%" == "" goto loopend
if "%_arg:~0,2%"=="-J" (
if "%_arg:~2%"=="" (
echo error: empty -J argument
goto error
)
set JAVA_OPTS=%JAVA_OPTS% "%_arg:~2%"
) else (
if "%_arg:~0,2%"=="-D" (
@@ -67,7 +71,6 @@ if "!_KOTLIN_RUNNER!"=="1" (
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
)
exit /b %ERRORLEVEL%
goto end
rem ##########################################################################
@@ -103,5 +106,8 @@ rem Needs to be executed in the EnableDelayedExpansion mode.
)
goto :eof
:error
set ERRORLEVEL=1
:end
endlocal
exit /b %ERRORLEVEL%

View File

@@ -12,6 +12,7 @@ dependencies {
compile(project(":compiler:backend-common"))
compile(project(":compiler:backend"))
compile(project(":compiler:backend.jvm"))
implementation(project(":compiler:backend.jvm:backend.jvm.entrypoint"))
compile(project(":compiler:ir.backend.common"))
compile(project(":compiler:light-classes"))
compile(project(":compiler:serialization"))

View File

@@ -16,8 +16,54 @@
package org.jetbrains.kotlin.cli.common
val KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY = "kotlin.environment.keepalive"
import com.intellij.util.LineSeparator
import java.util.*
enum class CompilerSystemProperties(val property: String) {
COMPILE_DAEMON_ENABLED_PROPERTY("kotlin.daemon.enabled"),
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY("kotlin.daemon.jvm.options"),
COMPILE_DAEMON_OPTIONS_PROPERTY("kotlin.daemon.options"),
COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY("kotlin.daemon.client.options"),
COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY("kotlin.daemon.client.alive.path"),
COMPILE_DAEMON_LOG_PATH_PROPERTY("kotlin.daemon.log.path"),
COMPILE_DAEMON_REPORT_PERF_PROPERTY("kotlin.daemon.perf"),
COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY("kotlin.daemon.verbose"),
COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY("kotlin.daemon.startup.timeout"),
JAVA_RMI_SERVER_HOSTNAME("java.rmi.server.hostname"),
DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY("kotlin.daemon.socket.backlog.size"),
DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY("kotlin.daemon.socket.connect.attempts"),
DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY("kotlin.daemon.socket.connect.interval"),
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")
;
var value
get() = systemPropertyGetter(property)
set(value) {
systemPropertySetter(property, value!!)
}
fun clear(): String? = systemPropertyCleaner(property)
companion object {
var systemPropertyGetter: (String) -> String? = {
System.getProperty(it)
}
var systemPropertySetter: (String, String) -> String? = { key, value ->
System.setProperty(key, value)
}
var systemPropertyCleaner: (String) -> String? = { key ->
System.clearProperty(key)
}
}
}
val isWindows: Boolean
get() = CompilerSystemProperties.OS_NAME.value!!.toLowerCase(Locale.ENGLISH).startsWith("windows")
fun String?.toBooleanLenient(): Boolean? = when (this?.toLowerCase()) {
null -> false

View File

@@ -205,8 +205,8 @@ abstract class CLITool<A : CommonToolArguments> {
if (System.getProperty("java.awt.headless") == null) {
System.setProperty("java.awt.headless", "true")
}
if (System.getProperty(PlainTextMessageRenderer.KOTLIN_COLORS_ENABLED_PROPERTY) == null) {
System.setProperty(PlainTextMessageRenderer.KOTLIN_COLORS_ENABLED_PROPERTY, "true")
if (CompilerSystemProperties.KOTLIN_COLORS_ENABLED_PROPERTY.value == null) {
CompilerSystemProperties.KOTLIN_COLORS_ENABLED_PROPERTY.value = "true"
}
setupIdeaStandaloneExecution()

View File

@@ -16,13 +16,13 @@
package org.jetbrains.kotlin.cli.common.messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.LineSeparator;
import kotlin.text.StringsKt;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.internal.CLibrary;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties;
import org.jetbrains.kotlin.cli.common.PropertiesKt;
import org.jetbrains.kotlin.util.capitalizeDecapitalize.CapitalizeDecapitalizeKt;
import java.util.EnumSet;
@@ -31,13 +31,12 @@ import java.util.Set;
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*;
public abstract class PlainTextMessageRenderer implements MessageRenderer {
public static final String KOTLIN_COLORS_ENABLED_PROPERTY = "kotlin.colors.enabled";
public static final boolean COLOR_ENABLED;
static {
boolean colorEnabled = false;
// TODO: investigate why ANSI escape codes on Windows only work in REPL for some reason
if (!SystemInfo.isWindows && "true".equals(System.getProperty(KOTLIN_COLORS_ENABLED_PROPERTY))) {
if (!PropertiesKt.isWindows() && "true".equals(CompilerSystemProperties.KOTLIN_COLORS_ENABLED_PROPERTY.getValue())) {
try {
// AnsiConsole doesn't check isatty() for stderr (see https://github.com/fusesource/jansi/pull/35).
colorEnabled = CLibrary.isatty(CLibrary.STDERR_FILENO) != 0;
@@ -49,7 +48,7 @@ public abstract class PlainTextMessageRenderer implements MessageRenderer {
COLOR_ENABLED = colorEnabled;
}
private static final String LINE_SEPARATOR = LineSeparator.getSystemLineSeparator().getSeparatorString();
private static final String LINE_SEPARATOR = System.lineSeparator();
private static final Set<CompilerMessageSeverity> IMPORTANT_MESSAGE_SEVERITIES = EnumSet.of(EXCEPTION, ERROR, STRONG_WARNING, WARNING);

View File

@@ -23,13 +23,24 @@ 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 java.io.File
import java.io.FileNotFoundException
fun OutputFileCollection.writeAll(outputDir: File, report: ((file: OutputFile, sources: List<File>, output: File) -> Unit)?) {
for (file in asList()) {
val sources = file.sourceFiles
val output = File(outputDir, file.relativePath)
report?.invoke(file, sources, output)
FileUtil.writeToFile(output, file.asByteArray())
try {
FileUtil.writeToFile(output, file.asByteArray())
} catch (e: FileNotFoundException) {
if (outputDir.isDirectory) {
// output directory exists
throw NoPermissionException("error while writing $output (Permission denied)", e)
}
// Failed to create directory, possibly due to lack of write permission or clash with existing file.
// In both cases, the directory will not exist, so for the sake of simplicity, we treat them same way.
throw e
}
}
}
@@ -38,8 +49,16 @@ fun OutputFileCollection.writeAllTo(outputDir: File) {
}
fun OutputFileCollection.writeAll(outputDir: File, messageCollector: MessageCollector, reportOutputFiles: Boolean) {
if (!reportOutputFiles) writeAllTo(outputDir)
else writeAll(outputDir) { _, sources, output ->
messageCollector.report(CompilerMessageSeverity.OUTPUT, OutputMessageUtil.formatOutputMessage(sources, output))
try {
if (!reportOutputFiles) writeAllTo(outputDir)
else writeAll(outputDir) { _, sources, output ->
messageCollector.report(CompilerMessageSeverity.OUTPUT, OutputMessageUtil.formatOutputMessage(sources, output))
}
} catch (e: NoPermissionException) {
messageCollector.report(CompilerMessageSeverity.ERROR, e.message!!)
} catch (e: FileNotFoundException) {
messageCollector.report(CompilerMessageSeverity.ERROR, "directory not found: $outputDir")
}
}
private class NoPermissionException(message: String, cause: Throwable?) : IllegalStateException(message, cause)

View File

@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.output.OutputFile;
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity;
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
import org.jetbrains.kotlin.cli.common.modules.ModuleChunk;
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser;
@@ -104,16 +105,26 @@ public class CompileEnvironmentUtil {
}
public static void writeToJar(
File jarPath, boolean jarRuntime, boolean noReflect, boolean resetJarTimestamps, FqName mainClass, OutputFileCollection outputFiles
File jarPath,
boolean jarRuntime,
boolean noReflect,
boolean resetJarTimestamps,
FqName mainClass,
OutputFileCollection outputFiles,
MessageCollector messageCollector
) {
FileOutputStream outputStream = null;
try {
// we should try to create the output dir first
if (jarPath.getParentFile() != null) {
jarPath.getParentFile().mkdirs();
}
outputStream = new FileOutputStream(jarPath);
doWriteToJar(outputFiles, outputStream, mainClass, jarRuntime, noReflect, resetJarTimestamps);
outputStream.close();
}
catch (FileNotFoundException e) {
throw new CompileEnvironmentException("Invalid jar path " + jarPath, e);
messageCollector.report(CompilerMessageSeverity.ERROR, "Invalid jar path: " + jarPath, null);
}
catch (IOException e) {
throw ExceptionUtilsKt.rethrow(e);

View File

@@ -58,7 +58,7 @@ import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.CliModuleVisibilityManagerImpl
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.config.ContentRoot
import org.jetbrains.kotlin.cli.common.config.KotlinSourceRoot
import org.jetbrains.kotlin.cli.common.config.kotlinSourceRoots
@@ -498,16 +498,13 @@ class KotlinCoreEnvironment private constructor(
}
// Disposing of the environment is unsafe in production then parallel builds are enabled, but turning it off universally
// breaks a lot of tests, therefore it is disabled for production and enabled for tests
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY).toBooleanLenient() != true) {
if (CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value.toBooleanLenient() != true) {
// JPS may run many instances of the compiler in parallel (there's an option for compiling independent modules in parallel in IntelliJ)
// All projects share the same ApplicationEnvironment, and when the last project is disposed, the ApplicationEnvironment is disposed as well
@Suppress("ObjectLiteralToLambda") // Disposer tree depends on identity of disposables.
Disposer.register(parentDisposable, object : Disposable {
override fun dispose() {
synchronized(APPLICATION_LOCK) {
if (--ourProjectCount <= 0) {
disposeApplicationEnvironment()
}
Disposer.register(parentDisposable, Disposable {
synchronized(APPLICATION_LOCK) {
if (--ourProjectCount <= 0) {
disposeApplicationEnvironment()
}
}
})

View File

@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensions
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensionsImpl
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.backend.jvm.jvmPhases
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
@@ -57,9 +57,7 @@ import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendExtension
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
import org.jetbrains.kotlin.fir.session.FirJvmModuleInfo
import org.jetbrains.kotlin.fir.session.FirSessionFactory
import org.jetbrains.kotlin.fir.createSessionWithDependencies
import org.jetbrains.kotlin.ir.backend.jvm.jvmResolveLibraries
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
@@ -88,7 +86,7 @@ object KotlinToJVMBytecodeCompiler {
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
val noReflect = configuration.get(JVMConfigurationKeys.NO_REFLECT, false)
val resetJarTimestamps = !configuration.get(JVMConfigurationKeys.NO_RESET_JAR_TIMESTAMPS, false)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, noReflect, resetJarTimestamps, mainClassFqName, outputFiles)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, noReflect, resetJarTimestamps, mainClassFqName, outputFiles, messageCollector)
if (reportOutputFiles) {
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
messageCollector.report(OUTPUT, message)
@@ -318,25 +316,26 @@ object KotlinToJVMBytecodeCompiler {
if (!checkKotlinPackageUsage(environment, ktFiles)) return false
val moduleConfiguration = projectConfiguration.applyModuleProperties(module, buildFile)
val scope = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
val sourceScope = GlobalSearchScope.filesScope(project, ktFiles.map { it.virtualFile })
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
val provider = FirProjectSessionProvider()
val librariesModuleInfo = FirJvmModuleInfo.createForLibraries()
val librariesScope = ProjectScope.getLibrariesScope(project)
FirSessionFactory.createLibrarySession(
librariesModuleInfo, provider, librariesScope,
project, environment.createPackagePartProvider(librariesScope)
)
val moduleInfo = FirJvmModuleInfo(module, listOf(librariesModuleInfo))
val session = FirSessionFactory.createJavaModuleBasedSession(moduleInfo, provider, scope, project) {
val languageVersionSettings = moduleConfiguration.languageVersionSettings
val session = createSessionWithDependencies(
module,
project,
languageVersionSettings,
sourceScope,
librariesScope,
environment::createPackagePartProvider
) {
if (extendedAnalysisMode) {
registerExtendedCommonCheckers()
}
}
val firAnalyzerFacade = FirAnalyzerFacade(session, moduleConfiguration.languageVersionSettings, ktFiles)
val firAnalyzerFacade = FirAnalyzerFacade(session, languageVersionSettings, ktFiles)
firAnalyzerFacade.runResolution()
val firDiagnostics = firAnalyzerFacade.runCheckers().values.flatten()
@@ -353,8 +352,8 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyGenerationStarted()
performanceManager?.notifyIRTranslationStarted()
val extensions = JvmGeneratorExtensions()
val (moduleFragment, symbolTable, sourceManager, components) = firAnalyzerFacade.convertToIr(extensions)
val extensions = JvmGeneratorExtensionsImpl()
val (moduleFragment, symbolTable, components) = firAnalyzerFacade.convertToIr(extensions)
performanceManager?.notifyIRTranslationFinished()
@@ -390,12 +389,11 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyIRLoweringStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, sourceManager, extensions, FirJvmBackendExtension(session, components),
{
performanceManager?.notifyIRLoweringFinished()
performanceManager?.notifyIRGenerationStarted()
}
)
generationState, moduleFragment, symbolTable, extensions, FirJvmBackendExtension(session, components)
) {
performanceManager?.notifyIRLoweringFinished()
performanceManager?.notifyIRGenerationStarted()
}
CodegenFactory.doCheckCancelled(generationState)
generationState.factory.done()

View File

@@ -74,6 +74,7 @@ internal class K2MetadataKlibSerializer(private val metadataVersion: BuiltInsBin
configuration.languageVersionSettings,
metadataVersion,
project,
exportKDoc = false,
skipExpects = false,
includeOnlyModuleContent = true
).serializeModule(module)

View File

@@ -1,6 +1,3 @@
import org.gradle.jvm.tasks.Jar
description = "Compiler runner + daemon client"
plugins {

View File

@@ -25,8 +25,9 @@ tasks.withType<JavaCompile> {
}
tasks.named<ProcessResources>("processResources") {
inputs.property("compilerVersion", kotlinVersion)
val kotlinVersionLocal = kotlinVersion
inputs.property("compilerVersion", kotlinVersionLocal)
filesMatching("META-INF/compiler.version") {
filter<ReplaceTokens>("tokens" to mapOf("snapshot" to kotlinVersion))
filter<ReplaceTokens>("tokens" to mapOf("snapshot" to kotlinVersionLocal))
}
}

View File

@@ -10,6 +10,7 @@ import kotlinx.coroutines.Deferred
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.daemon.client.CompileServiceSessionAsync
@@ -44,13 +45,13 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
val DAEMON_DEFAULT_STARTUP_TIMEOUT_MS = 10000L
val DAEMON_CONNECT_CYCLE_ATTEMPTS = 3
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
val verboseReporting = CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value != null
private val log = Logger.getLogger("KotlinCompilerClient")
override fun getOrCreateClientFlagFile(daemonOptions: DaemonOptions): File =
// for jps property is passed from IDEA to JPS in KotlinBuildProcessParametersProvider
System.getProperty(COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY.value
?.let(String::trimQuotes)
?.takeUnless(String::isBlank)
?.let(::File)
@@ -210,8 +211,6 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
}
}
val COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY: String = "kotlin.daemon.client.options"
data class ClientOptions(
var stop: Boolean = false
) : OptionsGroup {
@@ -220,11 +219,11 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
}
private fun configureClientOptions(opts: ClientOptions): ClientOptions {
System.getProperty(COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY)?.let {
CompilerSystemProperties.COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY.value?.let {
val unrecognized = it.trimQuotes().split(",").filterExtractProps(opts.mappers, "")
if (unrecognized.any())
throw IllegalArgumentException(
"Unrecognized client options passed via property $COMPILE_DAEMON_OPTIONS_PROPERTY: " + unrecognized.joinToString(" ") +
"Unrecognized client options passed via property ${CompilerSystemProperties.COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY.property}: " + unrecognized.joinToString(" ") +
"\nSupported options: " + opts.mappers.joinToString(", ", transform = { it.names.first() })
)
}
@@ -456,11 +455,11 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
reportingTargets: DaemonReportingTargets
): Boolean {
val javaExecutable = File(File(System.getProperty("java.home"), "bin"), "java")
val serverHostname = System.getProperty(JAVA_RMI_SERVER_HOSTNAME) ?: error("$JAVA_RMI_SERVER_HOSTNAME is not set!")
val serverHostname = CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value ?: error("${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property} is not set!")
val platformSpecificOptions = listOf(
// hide daemon window
"-Djava.awt.headless=true",
"-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname"
"-D${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property}=$serverHostname"
)
val args = listOf(
javaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)
@@ -509,13 +508,13 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
}
try {
// trying to wait for process
val daemonStartupTimeout = System.getProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)?.let {
val daemonStartupTimeout = CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value?.let {
try {
it.toLong()
} catch (e: Exception) {
reportingTargets.report(
DaemonReportCategory.INFO,
"unable to interpret $COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY property ('$it'); using default timeout $DAEMON_DEFAULT_STARTUP_TIMEOUT_MS ms"
"unable to interpret ${CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.property} property ('$it'); using default timeout $DAEMON_DEFAULT_STARTUP_TIMEOUT_MS ms"
)
null
}

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.daemon.client
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.daemon.common.*
@@ -48,11 +49,11 @@ object KotlinCompilerClient {
val DAEMON_DEFAULT_STARTUP_TIMEOUT_MS = 10000L
val DAEMON_CONNECT_CYCLE_ATTEMPTS = 3
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
val verboseReporting = CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value != null
fun getOrCreateClientFlagFile(daemonOptions: DaemonOptions): File =
// for jps property is passed from IDEA to JPS in KotlinBuildProcessParametersProvider
System.getProperty(COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY.value
?.let(String::trimQuotes)
?.takeUnless(String::isBlank)
?.let(::File)
@@ -211,7 +212,6 @@ object KotlinCompilerClient {
).get()
}
val COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY: String = "kotlin.daemon.client.options"
data class ClientOptions(
var stop: Boolean = false
) : OptionsGroup {
@@ -220,11 +220,11 @@ object KotlinCompilerClient {
}
private fun configureClientOptions(opts: ClientOptions): ClientOptions {
System.getProperty(COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY)?.let {
CompilerSystemProperties.COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY.value?.let {
val unrecognized = it.trimQuotes().split(",").filterExtractProps(opts.mappers, "")
if (unrecognized.any())
throw IllegalArgumentException(
"Unrecognized client options passed via property $COMPILE_DAEMON_OPTIONS_PROPERTY: " + unrecognized.joinToString(" ") +
"Unrecognized client options passed via property ${CompilerSystemProperties.COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY.property}: " + unrecognized.joinToString(" ") +
"\nSupported options: " + opts.mappers.joinToString(", ", transform = { it.names.first() }))
}
return opts
@@ -369,11 +369,11 @@ object KotlinCompilerClient {
private fun startDaemon(compilerId: CompilerId, daemonJVMOptions: DaemonJVMOptions, daemonOptions: DaemonOptions, reportingTargets: DaemonReportingTargets): Boolean {
val javaExecutable = File(File(System.getProperty("java.home"), "bin"), "java")
val serverHostname = System.getProperty(JAVA_RMI_SERVER_HOSTNAME) ?: error("$JAVA_RMI_SERVER_HOSTNAME is not set!")
val serverHostname = CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value ?: error("${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property} is not set!")
val platformSpecificOptions = listOf(
// hide daemon window
"-Djava.awt.headless=true",
"-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname")
"-D$${CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.property}=$serverHostname")
val javaVersion = System.getProperty("java.specification.version")?.toIntOrNull()
val javaIllegalAccessWorkaround =
if (javaVersion != null && javaVersion >= 16)
@@ -424,12 +424,12 @@ object KotlinCompilerClient {
}
try {
// trying to wait for process
val daemonStartupTimeout = System.getProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)?.let {
val daemonStartupTimeout = CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value?.let {
try {
it.toLong()
}
catch (e: Exception) {
reportingTargets.report(DaemonReportCategory.INFO, "unable to interpret $COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY property ('$it'); using default timeout $DAEMON_DEFAULT_STARTUP_TIMEOUT_MS ms")
reportingTargets.report(DaemonReportCategory.INFO, "unable to interpret ${CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.property} property ('$it'); using default timeout $DAEMON_DEFAULT_STARTUP_TIMEOUT_MS ms")
null
}
} ?: DAEMON_DEFAULT_STARTUP_TIMEOUT_MS

View File

@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import java.io.File
import java.io.Serializable
import java.lang.management.ManagementFactory
@@ -24,53 +24,47 @@ import java.security.MessageDigest
import java.util.*
import kotlin.reflect.KMutableProperty1
const val COMPILER_JAR_NAME: String = "kotlin-compiler.jar"
const val COMPILER_SERVICE_RMI_NAME: String = "KotlinJvmCompilerService"
const val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.daemon.KotlinCompileDaemon"
const val COMPILE_DAEMON_FIND_PORT_ATTEMPTS: Int = 10
const val COMPILE_DAEMON_PORTS_RANGE_START: Int = 17001
const val COMPILE_DAEMON_PORTS_RANGE_END: Int = 18000
const val COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX: String = "--daemon-"
const val COMPILE_DAEMON_DEFAULT_FILES_PREFIX: String = "kotlin-daemon"
const val COMPILE_DAEMON_TIMEOUT_INFINITE_S: Int = 0
const val COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S: Int = 7200 // 2 hours
const val COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S: Int = 60
const val COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS: Long = 1000L // 1 sec
const val COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE: Long = 0L
const val COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS: Long = 10000L // 10 secs
const val COMPILE_DAEMON_TIMEOUT_INFINITE_MS: Long = 0L
const val COMPILE_DAEMON_IS_READY_MESSAGE = "Kotlin compile daemon is ready"
val COMPILER_JAR_NAME: String = "kotlin-compiler.jar"
val COMPILER_SERVICE_RMI_NAME: String = "KotlinJvmCompilerService"
val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.daemon.KotlinCompileDaemon"
val COMPILE_DAEMON_FIND_PORT_ATTEMPTS: Int = 10
val COMPILE_DAEMON_PORTS_RANGE_START: Int = 17001
val COMPILE_DAEMON_PORTS_RANGE_END: Int = 18000
val COMPILE_DAEMON_ENABLED_PROPERTY: String = "kotlin.daemon.enabled"
val COMPILE_DAEMON_JVM_OPTIONS_PROPERTY: String = "kotlin.daemon.jvm.options"
val COMPILE_DAEMON_OPTIONS_PROPERTY: String = "kotlin.daemon.options"
val COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY: String = "kotlin.daemon.client.alive.path"
val COMPILE_DAEMON_LOG_PATH_PROPERTY: String = "kotlin.daemon.log.path"
val COMPILE_DAEMON_REPORT_PERF_PROPERTY: String = "kotlin.daemon.perf"
val COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY: String = "kotlin.daemon.verbose"
val COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX: String = "--daemon-"
val COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY: String = "kotlin.daemon.startup.timeout"
val COMPILE_DAEMON_DEFAULT_FILES_PREFIX: String = "kotlin-daemon"
val COMPILE_DAEMON_TIMEOUT_INFINITE_S: Int = 0
val COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S: Int = 7200 // 2 hours
val COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S: Int = 60
val COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS: Long = 1000L // 1 sec
val COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE: Long = 0L
val COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS: Long = 10000L // 10 secs
val COMPILE_DAEMON_TIMEOUT_INFINITE_MS: Long = 0L
val COMPILE_DAEMON_IS_READY_MESSAGE = "Kotlin compile daemon is ready"
val COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS: String = "kotlin.daemon.custom.run.files.path.for.tests"
val COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH: String get() =
System.getProperty(COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS)
?: FileSystem.getRuntimeStateFilesPath("kotlin", "daemon")
val COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH: String
get() = CompilerSystemProperties.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS.value ?: FileSystem.getRuntimeStateFilesPath(
"kotlin",
"daemon"
)
val CLASSPATH_ID_DIGEST = "MD5"
open class PropMapper<C, V, out P : KMutableProperty1<C, V>>(val dest: C,
val prop: P,
val names: List<String> = listOf(prop.name),
val fromString: (String) -> V,
val toString: ((V) -> String?) = { it.toString() },
val skipIf: ((V) -> Boolean) = { false },
val mergeDelimiter: String? = null) {
open class PropMapper<C, V, out P : KMutableProperty1<C, V>>(
val dest: C,
val prop: P,
val names: List<String> = listOf(prop.name),
val fromString: (String) -> V,
val toString: ((V) -> String?) = { it.toString() },
val skipIf: ((V) -> Boolean) = { false },
val mergeDelimiter: String? = null
) {
open fun toArgs(prefix: String = COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX): List<String> =
when {
skipIf(prop.get(dest)) -> listOf<String>()
mergeDelimiter != null -> listOf(listOfNotNull(prefix + names.first(), toString(prop.get(dest))).joinToString(mergeDelimiter))
else -> listOfNotNull(prefix + names.first(), toString(prop.get(dest)))
}
when {
skipIf(prop.get(dest)) -> listOf<String>()
mergeDelimiter != null -> listOf(listOfNotNull(prefix + names.first(), toString(prop.get(dest))).joinToString(mergeDelimiter))
else -> listOfNotNull(prefix + names.first(), toString(prop.get(dest)))
}
open fun apply(s: String) = prop.set(dest, fromString(s))
}
@@ -255,7 +249,7 @@ data class CompilerId(
}
fun isDaemonEnabled(): Boolean = System.getProperty(COMPILE_DAEMON_ENABLED_PROPERTY) != null
fun isDaemonEnabled(): Boolean = CompilerSystemProperties.COMPILE_DAEMON_ENABLED_PROPERTY.value != null
fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
vararg additionalParams: String,
@@ -289,16 +283,16 @@ fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
if (inheritOtherJvmOptions) {
opts.jvmParams.addAll(
otherArgs.filterNot {
it.startsWith("agentlib") ||
it.startsWith("D" + COMPILE_DAEMON_LOG_PATH_PROPERTY) ||
it.startsWith("D" + KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY) ||
it.startsWith("D" + COMPILE_DAEMON_JVM_OPTIONS_PROPERTY) ||
it.startsWith("D" + COMPILE_DAEMON_OPTIONS_PROPERTY)
})
otherArgs.filterNot {
it.startsWith("agentlib") ||
it.startsWith("D" + CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property) ||
it.startsWith("D" + CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.property) ||
it.startsWith("D" + CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property) ||
it.startsWith("D" + CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property)
})
}
}
System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)?.let {
CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.value?.let {
opts.jvmParams.addAll(
it.trimQuotes()
.split("(?<!\\\\),".toRegex()) // using independent non-capturing group with negative lookahead zero length assertion to split only on non-escaped commas
@@ -311,8 +305,8 @@ fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
opts.jvmParams.addAll(additionalParams)
if (inheritAdditionalProperties) {
System.getProperty(COMPILE_DAEMON_LOG_PATH_PROPERTY)?.let { opts.jvmParams.add("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"$it\"") }
System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY)?.let { opts.jvmParams.add("D$KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY") }
CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.value?.let { opts.jvmParams.add("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"$it\"") }
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value?.let { opts.jvmParams.add("D${CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.property}") }
}
if (opts.jvmParams.none { it.matches(jvmAssertArgsRegex) }) {
@@ -338,15 +332,15 @@ fun configureDaemonJVMOptions(
)
fun configureDaemonOptions(opts: DaemonOptions): DaemonOptions {
System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)?.let {
CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.value?.let {
val unrecognized = it.trimQuotes().split(",").filterExtractProps(opts.mappers, "")
if (unrecognized.any())
throw IllegalArgumentException(
"Unrecognized daemon options passed via property $COMPILE_DAEMON_OPTIONS_PROPERTY: " + unrecognized.joinToString(" ") +
"Unrecognized daemon options passed via property ${CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property}: " + unrecognized.joinToString(" ") +
"\nSupported options: " + opts.mappers.joinToString(", ", transform = { it.names.first() }))
}
System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY)?.let { opts.verbose = true }
System.getProperty(COMPILE_DAEMON_REPORT_PERF_PROPERTY)?.let { opts.reportPerf = true }
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value?.let { opts.verbose = true }
CompilerSystemProperties.COMPILE_DAEMON_REPORT_PERF_PROPERTY.value?.let { opts.reportPerf = true }
return opts
}

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import java.io.IOException
import java.io.Serializable
import java.net.*
@@ -26,12 +27,7 @@ import java.rmi.server.RMIClientSocketFactory
import java.rmi.server.RMIServerSocketFactory
import java.util.*
const val SOCKET_ANY_FREE_PORT = 0
const val JAVA_RMI_SERVER_HOSTNAME = "java.rmi.server.hostname"
const val DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY = "kotlin.daemon.socket.backlog.size"
const val DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY = "kotlin.daemon.socket.connect.attempts"
const val DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY = "kotlin.daemon.socket.connect.interval"
const val SOCKET_ANY_FREE_PORT = 0
const val DEFAULT_SERVER_SOCKET_BACKLOG_SIZE = 50
const val DEFAULT_SOCKET_CONNECT_ATTEMPTS = 3
const val DEFAULT_SOCKET_CONNECT_INTERVAL_MS = 10L
@@ -43,9 +39,9 @@ object LoopbackNetworkInterface {
// size of the requests queue for daemon services, so far seems that we don't need any big numbers here
// but if we'll start getting "connection refused" errors, that could be the first place to try to fix it
val SERVER_SOCKET_BACKLOG_SIZE by lazy { System.getProperty(DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY)?.toIntOrNull() ?: DEFAULT_SERVER_SOCKET_BACKLOG_SIZE }
val SOCKET_CONNECT_ATTEMPTS by lazy { System.getProperty(DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY)?.toIntOrNull() ?: DEFAULT_SOCKET_CONNECT_ATTEMPTS }
val SOCKET_CONNECT_INTERVAL_MS by lazy { System.getProperty(DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY)?.toLongOrNull() ?: DEFAULT_SOCKET_CONNECT_INTERVAL_MS }
val SERVER_SOCKET_BACKLOG_SIZE by lazy { CompilerSystemProperties.DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY.value?.toIntOrNull() ?: DEFAULT_SERVER_SOCKET_BACKLOG_SIZE }
val SOCKET_CONNECT_ATTEMPTS by lazy { CompilerSystemProperties.DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY.value?.toIntOrNull() ?: DEFAULT_SOCKET_CONNECT_ATTEMPTS }
val SOCKET_CONNECT_INTERVAL_MS by lazy { CompilerSystemProperties.DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY.value?.toLongOrNull() ?: DEFAULT_SOCKET_CONNECT_INTERVAL_MS }
val serverLoopbackSocketFactory by lazy { ServerLoopbackSocketFactory() }
val clientLoopbackSocketFactory by lazy { ClientLoopbackSocketFactory() }
@@ -125,7 +121,7 @@ fun findPortAndCreateRegistry(attempts: Int, portRangeStart: Int, portRangeEnd:
* which may be slow and can cause a timeout when there is a network problem/misconfiguration.
*/
fun ensureServerHostnameIsSetUp() {
if (System.getProperty(JAVA_RMI_SERVER_HOSTNAME) == null) {
System.setProperty(JAVA_RMI_SERVER_HOSTNAME, LoopbackNetworkInterface.loopbackInetAddressName)
if (CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value == null) {
CompilerSystemProperties.JAVA_RMI_SERVER_HOSTNAME.value = LoopbackNetworkInterface.loopbackInetAddressName
}
}

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.daemon
import com.intellij.openapi.application.ApplicationManager
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
@@ -127,7 +128,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
val logFile: Path = createTempFile("kotlin-daemon-test.", ".log")
val daemonJVMOptions = configureDaemonJVMOptions("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"",
val daemonJVMOptions = configureDaemonJVMOptions("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
val jar = tmpdir.absolutePath + File.separator + "hello.jar"
@@ -167,7 +168,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
val logFile: Path = createTempFile("kotlin-daemon-test.", ".log")
val daemonJVMOptions = configureDaemonJVMOptions("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"",
val daemonJVMOptions = configureDaemonJVMOptions("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false)
try {
val (code, outputs) = compileOnDaemon(

View File

@@ -20,6 +20,7 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.io.FileUtilRt
import junit.framework.TestCase
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
@@ -109,7 +110,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun makeTestDaemonJvmOptions(logFile: File? = null, xmx: Int = 384, args: Iterable<String> = listOf()): DaemonJVMOptions {
val additionalArgs = arrayListOf<String>()
if (logFile != null) {
additionalArgs.add("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"")
additionalArgs.add("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"")
}
args.forEach { additionalArgs.add(it) }
val baseOpts = if (xmx > 0) DaemonJVMOptions(maxMemory = "${xmx}m") else DaemonJVMOptions()
@@ -160,16 +161,16 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun testDaemonJvmOptionsParsing() {
val backupJvmOptions = System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
val backupJvmOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy")
val opts = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("200m", opts.maxMemory)
assertEquals("10k", opts.maxMetaspaceSize)
assertEquals("100", opts.reservedCodeCacheSize)
assertEquals(arrayListOf("aaa", "bbb,ccc", "ddd", "xxx,yyy", "ea"), opts.jvmParams)
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
val opts2 = configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
assertEquals( -1, DaemonJVMOptionsMemoryComparator().compare(opts, opts2))
@@ -178,14 +179,14 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)
val myXmxVal = myXmxParam.substring(4)
System.clearProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
System.clearProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
val opts3 = configureDaemonJVMOptions(inheritMemoryLimits = true,
inheritOtherJvmOptions = true,
inheritAdditionalProperties = false)
assertEquals(myXmxVal, opts3.maxMemory)
}
finally {
restoreSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backupJvmOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backupJvmOptions)
}
}
@@ -215,12 +216,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
private fun withDaemonJvmOptionsSetTo(newValue: String?, fn: () -> Unit) {
val backup = getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, newValue)
val backup = getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, newValue)
try {
fn()
} finally {
getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backup)
getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backup)
}
}
@@ -237,15 +238,15 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun testDaemonOptionsParsing() {
val backupOptions = System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)
val backupOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
val opts = configureDaemonOptions(DaemonOptions(shutdownDelayMilliseconds = 1))
assertEquals("abcd", opts.runFilesPath)
assertEquals(1111, opts.autoshutdownIdleSeconds)
}
finally {
restoreSystemProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, backupOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, backupOptions)
}
}
@@ -518,12 +519,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val daemonOptions = makeTestDaemonOptions(getTestName(true))
val jar = testTempDir.absolutePath + File.separator + "hello.jar"
val args = listOf(
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D$COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClient::class.qualifiedName!!) +
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D${CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property}",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClient::class.qualifiedName!!) +
daemonOptions.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } +
compilerId.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } +
File(getHelloAppBaseDir(), "hello.kt").absolutePath +
@@ -651,16 +652,16 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
}
System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "true")
System.setProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY, "100000")
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value = "true"
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value = "100000"
val succeeded = try {
(1..ParallelStartParams.threads).forEach { connectThread(it - 1) }
doneLatch.await(PARALLEL_WAIT_TIMEOUT_S, TimeUnit.SECONDS)
}
finally {
System.clearProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)
System.clearProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.clear()
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.clear()
}
Thread.sleep(100) // Wait for processes to finish and close log files

View File

@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.daemon.experimental.integration
import com.intellij.openapi.application.ApplicationManager
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
@@ -217,7 +218,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
log.info("creating daemonJVMOptions")
val daemonJVMOptions = configureDaemonJVMOptions(
"D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${externalLogFile.loggerCompatiblePath}\"",
"D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${externalLogFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false,
inheritOtherJvmOptions = false,
inheritAdditionalProperties = false
@@ -278,7 +279,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() {
reportPerf = true
)
val daemonJVMOptions = configureDaemonJVMOptions(
"D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${externalLogFile.loggerCompatiblePath}\"",
"D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${externalLogFile.loggerCompatiblePath}\"",
inheritMemoryLimits = false, inheritOtherJvmOptions = false, inheritAdditionalProperties = false
)
try {

View File

@@ -11,6 +11,7 @@ import junit.framework.TestCase
import kotlinx.coroutines.*
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
@@ -173,7 +174,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun makeTestDaemonJvmOptions(logFile: File? = null, xmx: Int = 384, args: Iterable<String> = listOf()): DaemonJVMOptions {
val additionalArgs = arrayListOf<String>()
if (logFile != null) {
additionalArgs.add("D$COMPILE_DAEMON_LOG_PATH_PROPERTY=\"${logFile.loggerCompatiblePath}\"")
additionalArgs.add("D${CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.property}=\"${logFile.loggerCompatiblePath}\"")
}
args.forEach { additionalArgs.add(it) }
val baseOpts = if (xmx > 0) DaemonJVMOptions(maxMemory = "${xmx}m") else DaemonJVMOptions()
@@ -230,10 +231,10 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun ignore_testDaemonJvmOptionsParsing() {
val backupJvmOptions = System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
val backupJvmOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
try {
System.setProperty(
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY,
CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property,
"-aaa,-bbb\\,ccc,-ddd,-Xmx200m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100,-xxx\\,yyy"
)
val opts =
@@ -243,7 +244,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
assertEquals("100", opts.reservedCodeCacheSize)
assertEquals(arrayListOf("aaa", "bbb,ccc", "ddd", "xxx,yyy", "ea"), opts.jvmParams)
System.setProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, "-Xmx300m,-XX:MaxMetaspaceSize=10k,-XX:ReservedCodeCacheSize=100")
val opts2 =
configureDaemonJVMOptions(inheritMemoryLimits = false, inheritAdditionalProperties = false, inheritOtherJvmOptions = false)
assertEquals("300m", opts2.maxMemory)
@@ -253,7 +254,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val myXmxParam = ManagementFactory.getRuntimeMXBean().inputArguments.first { it.startsWith("-Xmx") }
TestCase.assertNotNull(myXmxParam)
val myXmxVal = myXmxParam.substring(4)
System.clearProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)
System.clearProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property)
val opts3 = configureDaemonJVMOptions(
inheritMemoryLimits = true,
inheritOtherJvmOptions = true,
@@ -262,7 +263,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
assertEquals(myXmxVal, opts3.maxMemory)
} finally {
restoreSystemProperty(
COMPILE_DAEMON_JVM_OPTIONS_PROPERTY,
CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property,
backupJvmOptions
)
}
@@ -294,12 +295,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
private fun withDaemonJvmOptionsSetTo(newValue: String?, fn: () -> Unit) {
val backup = getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, newValue)
val backup = getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, newValue)
try {
fn()
} finally {
getAndSetSystemProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY, backup)
getAndSetSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_JVM_OPTIONS_PROPERTY.property, backup)
}
}
@@ -316,14 +317,14 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
fun ignore_testDaemonOptionsParsing() {
val backupOptions = System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)
val backupOptions = System.getProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property)
try {
System.setProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
System.setProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, "runFilesPath=abcd,autoshutdownIdleSeconds=1111")
val opts = configureDaemonOptions(DaemonOptions(shutdownDelayMilliseconds = 1))
assertEquals("abcd", opts.runFilesPath)
assertEquals(1111, opts.autoshutdownIdleSeconds)
} finally {
restoreSystemProperty(COMPILE_DAEMON_OPTIONS_PROPERTY, backupOptions)
restoreSystemProperty(CompilerSystemProperties.COMPILE_DAEMON_OPTIONS_PROPERTY.property, backupOptions)
}
}
@@ -746,7 +747,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
val args = listOf(
File(File(System.getProperty("java.home"), "bin"), "java").absolutePath,
"-Xmx256m",
"-D$COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY",
"-D${CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.property}",
"-cp",
daemonClientClassPath.joinToString(File.pathSeparator) { it.absolutePath },
KotlinCompilerClientInstance::class.qualifiedName!!
@@ -946,15 +947,15 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
}
runBlocking {
System.setProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY, "true")
System.setProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY, "100000")
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.value = "true"
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.value = "100000"
val succeeded = try {
(1..ParallelStartParams.threads).forEach { connectThread(it - 1) }
doneLatch.await(PARALLEL_WAIT_TIMEOUT_S, TimeUnit.SECONDS)
} finally {
System.clearProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)
System.clearProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY)
CompilerSystemProperties.COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY.clear()
CompilerSystemProperties.COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY.clear()
}
delay(1000) // Wait for processes to finish and close log files

View File

@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.RemoteBuildReporter
import org.jetbrains.kotlin.build.report.RemoteReporter
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.arguments.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -102,7 +102,7 @@ abstract class CompileServiceImplBase(
protected val log by lazy { Logger.getLogger("compiler") }
init {
System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true")
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value = "true"
}
// wrapped in a class to encapsulate alive check logic

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.daemon
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
import org.jetbrains.kotlin.cli.js.K2JSCompiler
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
@@ -60,7 +61,7 @@ abstract class KotlinCompileDaemonBase {
init {
val logTime: String = SimpleDateFormat("yyyy-MM-dd.HH-mm-ss-SSS").format(Date())
val (logPath: String, fileIsGiven: Boolean) =
System.getProperty(COMPILE_DAEMON_LOG_PATH_PROPERTY)?.trimQuotes()?.let { Pair(it, File(it).isFile) } ?: Pair("%t", false)
CompilerSystemProperties.COMPILE_DAEMON_LOG_PATH_PROPERTY.value?.trimQuotes()?.let { Pair(it, File(it).isFile) } ?: Pair("%t", false)
val cfg: String =
"handlers = java.util.logging.FileHandler\n" +
"java.util.logging.FileHandler.level = ALL\n" +

View File

@@ -16,7 +16,7 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import org.jetbrains.kotlin.cli.common.repl.ReplCompileResult
@@ -402,7 +402,7 @@ class CompileServiceServerSideImpl(
scheduler = CompileServiceTaskScheduler(log)
// assuming logically synchronized
System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true")
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value = "true"
// TODO UNCOMMENT THIS : this.toRMIServer(daemonOptions, compilerId) // also create RMI server in order to support old clients
// rmiServer = this.toRMIServer(daemonOptions, compilerId)

View File

@@ -601,6 +601,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/tryInLambda.kt");
}
@TestMetadata("typeMismatchOnExpectedJavaMap.kt")
public void testTypeMismatchOnExpectedJavaMap() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/typeMismatchOnExpectedJavaMap.kt");
}
@TestMetadata("untouchedReturnInIf.kt")
public void testUntouchedReturnInIf() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/untouchedReturnInIf.kt");
@@ -2394,6 +2399,34 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineClasses extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInInlineClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inlineClasses"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("inlineClassConstructor.kt")
public void testInlineClassConstructor() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassConstructor.kt");
}
@TestMetadata("inlineClassDeclaration.kt")
public void testInlineClassDeclaration() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassDeclaration.kt");
}
@TestMetadata("inlineClassMembers.kt")
public void testInlineClassMembers() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/inlineClasses/inlineClassMembers.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/innerClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -38,7 +38,7 @@ abstract class AbstractFirLoadCompiledKotlin : AbstractFirLoadBinariesTest() {
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
prepareProjectExtensions(environment.project)
val sessionWithDependency = createSession(environment, GlobalSearchScope.EMPTY_SCOPE)
val sessionWithDependency = createSessionForTests(environment, GlobalSearchScope.EMPTY_SCOPE)
val testDataDirectoryPath =
"compiler/fir/analysis-tests/testData/loadCompiledKotlin/" +

View File

@@ -18,7 +18,7 @@ class BuiltInsDeserializationForFirTestCase : AbstractFirLoadBinariesTest() {
fun testBuiltInPackagesContent() {
val moduleDescriptor = BuiltinsTestUtils.compileBuiltinsModule(environment)
val session = createSession(environment, GlobalSearchScope.allScope(project))
val session = createSessionForTests(environment, GlobalSearchScope.allScope(project))
for (packageFqName in BuiltinsTestUtils.BUILTIN_PACKAGE_NAMES) {
val path = "compiler/fir/analysis-tests/testData/builtIns/" + packageFqName.asString().replace('.', '-') + ".txt"
checkPackageContent(session, packageFqName, moduleDescriptor, path)

View File

@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.fir.FirRenderer
import org.jetbrains.kotlin.fir.createSession
import org.jetbrains.kotlin.fir.createSessionForTests
import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass
import org.jetbrains.kotlin.fir.resolve.symbolProvider
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirCompositeSymbolProvider
@@ -131,7 +131,7 @@ abstract class AbstractFirTypeEnhancementTest : KtUsefulTestCase() {
val scope = GlobalSearchScope.filesScope(project, virtualFiles)
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
val session = createSession(environment, scope)
val session = createSessionForTests(environment, scope)
val topPsiClasses = psiFiles.flatMap { it.getChildrenOfType<PsiClass>().toList() }

View File

@@ -1,5 +1,5 @@
public/*package*/ open class ArraysUtilJVM : R|kotlin/Any| {
public/*package*/ open static fun <T : R|ft<@FlexibleNullability kotlin/Any, kotlin/Any?>!|> asList(p0: T[]): java.util.List<T>
public/*package*/ open static fun <T : R|ft<kotlin/Any, kotlin/Any?>|> asList(p0: T[]): java.util.List<T>
public/*package*/ constructor(): R|kotlin/collections/ArraysUtilJVM|
@@ -304,4 +304,3 @@ public abstract class ShortIterator : R|kotlin/collections/Iterator<kotlin/Short
public constructor(): R|kotlin/collections/ShortIterator|
}

View File

@@ -3,9 +3,9 @@
}
public open class NonNullNever : R|kotlin/Any| {
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) public open field field: R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) public open field field: R|@EnhancedNullability kotlin/String?|
@R|MyNullable|() public open fun foo(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) x: R|@FlexibleNullability kotlin/String?|, @R|MyNullable|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String?|
@R|MyNullable|() public open fun foo(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) x: R|@EnhancedNullability kotlin/String?|, @R|MyNullable|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String?|
public constructor(): R|NonNullNever|

View File

@@ -1,7 +1,7 @@
public open class Simple : R|kotlin/Any| {
@R|javax/annotation/Nullable|() public open field field: R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open field field: R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun foo(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun foo(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|

View File

@@ -1,7 +1,7 @@
public open class Strange : R|kotlin/Any| {
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.UNKNOWN|()) public open field field: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.UNKNOWN|()) public open field field: R|ft<kotlin/String, kotlin/String?>|
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.MAYBE|()) public open fun foo(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.ALWAYS|()) x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.MAYBE|()) public open fun foo(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.ALWAYS|()) x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.NEVER|()) y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|

View File

@@ -1,9 +1,9 @@
@R|FieldsAreNullable|() public open class A : R|kotlin/Any| {
public open field field: R|@FlexibleNullability kotlin/String?|
public open field field: R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nonnull|() public open field nonNullField: R|@EnhancedNullability kotlin/String|
public open fun foo(q: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun foo(q: R|ft<kotlin/String, kotlin/String?>|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|ft<kotlin/String, kotlin/String?>|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|

View File

@@ -1,7 +1,7 @@
@R|spr/NonNullApi|() public open class A : R|kotlin/Any| {
public open fun foo(x: R|@FlexibleNullability kotlin/String|, @R|spr/Nullable|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String|
public open fun foo(x: R|@EnhancedNullability kotlin/String|, @R|spr/Nullable|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String|
@R|spr/ForceFlexibility|() public open fun bar(x: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|javax/annotation/Nonnull|() y: R|@EnhancedNullability kotlin/CharSequence|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
@R|spr/ForceFlexibility|() public open fun bar(x: R|ft<kotlin/String, kotlin/String?>|, @R|javax/annotation/Nonnull|() y: R|@EnhancedNullability kotlin/CharSequence|): R|ft<kotlin/String, kotlin/String?>|
public constructor(): R|A|

View File

@@ -1,11 +1,11 @@
@R|spr/NonNullApi|() public open class A : R|kotlin/Any|, R|B| {
@R|spr/ForceFlexibility|() public open fun foo(x: R|@FlexibleNullability kotlin/String|): R|kotlin/Unit|
@R|spr/ForceFlexibility|() public open fun foo(x: R|@EnhancedNullability kotlin/String|): R|kotlin/Unit|
public open fun bar(@R|spr/ForceFlexibility|() x: R|@FlexibleNullability kotlin/String|): R|kotlin/Unit|
public open fun bar(@R|spr/ForceFlexibility|() x: R|@EnhancedNullability kotlin/String|): R|kotlin/Unit|
public open fun baz(@R|spr/UnknownNullability|() x: R|@FlexibleNullability kotlin/String|): R|kotlin/Unit|
public open fun baz(@R|spr/UnknownNullability|() x: R|@EnhancedNullability kotlin/String|): R|kotlin/Unit|
public open fun foobar(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.UNKNOWN|()) x: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public open fun foobar(@R|javax/annotation/Nonnull|(R|javax/annotation/meta/When.UNKNOWN|()) x: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Unit|
public constructor(): R|A|

View File

@@ -1,55 +1,55 @@
@R|NonNullApi|() public open class A : R|kotlin/Any| {
public open fun foo1(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo1(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public open fun foo2(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo2(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public open fun foo3(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo3(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
@R|javax/annotation/Nullable|() public open fun bar1(@R|javax/annotation/Nullable|() x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun bar1(@R|javax/annotation/Nullable|() x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun bar2(@R|javax/annotation/Nullable|() x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun bar2(@R|javax/annotation/Nullable|() x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/String?|
public open fun baz(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun baz(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public constructor(): R|A|
}
@R|NonNullApi|() public abstract interface AInt : R|kotlin/Any| {
public abstract fun foo1(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/CharSequence|
public abstract fun foo1(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/CharSequence|
public abstract fun foo2(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/CharSequence|
public abstract fun foo2(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/CharSequence|
public abstract fun foo3(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/CharSequence|
public abstract fun foo3(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/CharSequence|
@R|javax/annotation/Nullable|() public abstract fun bar1(@R|javax/annotation/Nullable|() x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/CharSequence?|
@R|javax/annotation/Nullable|() public abstract fun bar1(@R|javax/annotation/Nullable|() x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/CharSequence?|
@R|javax/annotation/Nullable|() public abstract fun bar2(@R|javax/annotation/Nullable|() x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/CharSequence?|
@R|javax/annotation/Nullable|() public abstract fun bar2(@R|javax/annotation/Nullable|() x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/CharSequence?|
public abstract fun baz(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@FlexibleNullability kotlin/CharSequence|
public abstract fun baz(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/CharSequence|
}
@R|NullableApi|() public open class B : R|A|, R|AInt| {
public open fun foo1(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo1(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
@R|javax/annotation/Nonnull|() public open fun foo2(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public open fun bar1(x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/String?|
public open fun bar1(x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/String?|
public open fun baz(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun baz(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public constructor(): R|B|
}
@R|NonNullApi|() public open class C : R|A|, R|AInt| {
public open fun foo1(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo1(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public open fun foo2(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun foo2(@R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public open fun bar1(x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/String?|
public open fun bar1(x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun bar2(@R|javax/annotation/Nullable|() x: R|@FlexibleNullability kotlin/String?|): R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open fun bar2(@R|javax/annotation/Nullable|() x: R|@EnhancedNullability kotlin/String?|): R|@EnhancedNullability kotlin/String?|
public open fun baz(x: R|@FlexibleNullability kotlin/String|): R|@FlexibleNullability kotlin/String|
public open fun baz(x: R|@EnhancedNullability kotlin/String|): R|@EnhancedNullability kotlin/String|
public constructor(): R|C|

View File

@@ -1,13 +1,13 @@
@R|NonNullApi|() public open class A : R|kotlin/Any| {
public open field field: R|@FlexibleNullability kotlin/String|
public open field field: R|@EnhancedNullability kotlin/String|
public open fun foo(x: R|@FlexibleNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String|
public open fun foo(x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String|
@R|NullableApi|() public open fun foobar(x: R|@FlexibleNullability kotlin/String?|, @R|NonNullApi|() y: R|@FlexibleNullability kotlin/CharSequence|): R|@FlexibleNullability kotlin/String?|
@R|NullableApi|() public open fun foobar(x: R|@EnhancedNullability kotlin/String?|, @R|NonNullApi|() y: R|@EnhancedNullability kotlin/CharSequence|): R|@EnhancedNullability kotlin/String?|
public open fun bar(): R|@FlexibleNullability kotlin/String|
public open fun bar(): R|@EnhancedNullability kotlin/String|
@R|javax/annotation/Nullable|() public open fun baz(): R|ft<@FlexibleNullability kotlin/collections/MutableList<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?, kotlin/collections/List<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?>?|
@R|javax/annotation/Nullable|() public open fun baz(): R|ft<@EnhancedNullability kotlin/collections/MutableList<ft<kotlin/String, kotlin/String?>>?, @EnhancedNullability kotlin/collections/List<ft<kotlin/String, kotlin/String?>>?>|
public constructor(): R|A|

View File

@@ -1,7 +1,7 @@
@R|javax/annotation/ParametersAreNonnullByDefault|() public open class A : R|kotlin/Any| {
@R|javax/annotation/Nullable|() public open field field: R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open field field: R|@EnhancedNullability kotlin/String?|
public open fun foo(q: R|@FlexibleNullability kotlin/String|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun foo(q: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|ft<kotlin/String, kotlin/String?>|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|

View File

@@ -1,7 +1,7 @@
public open class A : R|kotlin/Any| {
@R|javax/annotation/Nullable|() public open field field: R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open field field: R|@EnhancedNullability kotlin/String?|
public open fun foo(q: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun foo(q: R|ft<kotlin/String, kotlin/String?>|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|ft<kotlin/String, kotlin/String?>|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|
@@ -9,9 +9,9 @@ public open class A : R|kotlin/Any| {
}
public open class A2 : R|kotlin/Any| {
@R|javax/annotation/Nullable|() public open field field: R|@FlexibleNullability kotlin/String?|
@R|javax/annotation/Nullable|() public open field field: R|@EnhancedNullability kotlin/String?|
public open fun foo(q: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun foo(q: R|ft<kotlin/String, kotlin/String?>|, @R|javax/annotation/Nonnull|() x: R|@EnhancedNullability kotlin/String|, @R|javax/annotation/CheckForNull|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|ft<kotlin/String, kotlin/String?>|
@R|javax/annotation/Nonnull|() public open fun bar(): R|@EnhancedNullability kotlin/String|

View File

@@ -1,11 +1,11 @@
@R|spr/NonNullApi|() public open class A : R|kotlin/Any| {
public open field field: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open field field: R|ft<kotlin/String, kotlin/String?>|
public open fun foo(x: R|@FlexibleNullability kotlin/String|, @R|spr/Nullable|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|@FlexibleNullability kotlin/String|
public open fun foo(x: R|@EnhancedNullability kotlin/String|, @R|spr/Nullable|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|@EnhancedNullability kotlin/String|
public open fun bar(): R|@FlexibleNullability kotlin/String|
public open fun bar(): R|@EnhancedNullability kotlin/String|
@R|spr/Nullable|() public open fun baz(): R|ft<@FlexibleNullability kotlin/collections/MutableList<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?, kotlin/collections/List<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?>?|
@R|spr/Nullable|() public open fun baz(): R|ft<@EnhancedNullability kotlin/collections/MutableList<ft<kotlin/String, kotlin/String?>>?, @EnhancedNullability kotlin/collections/List<ft<kotlin/String, kotlin/String?>>?>|
public constructor(): R|A|

View File

@@ -1,11 +1,11 @@
public open class A : R|kotlin/Any| {
public open field field: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open field field: R|ft<kotlin/String, kotlin/String?>|
public open fun foo(x: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|spr/Nullable|() y: R|@FlexibleNullability kotlin/CharSequence?|): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun foo(x: R|ft<kotlin/String, kotlin/String?>|, @R|spr/Nullable|() y: R|@EnhancedNullability kotlin/CharSequence?|): R|ft<kotlin/String, kotlin/String?>|
public open fun bar(): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public open fun bar(): R|ft<kotlin/String, kotlin/String?>|
@R|spr/Nullable|() public open fun baz(): R|ft<@FlexibleNullability kotlin/collections/MutableList<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?, kotlin/collections/List<ft<@FlexibleNullability kotlin/String, kotlin/String?>!>?>?|
@R|spr/Nullable|() public open fun baz(): R|ft<@EnhancedNullability kotlin/collections/MutableList<ft<kotlin/String, kotlin/String?>>?, @EnhancedNullability kotlin/collections/List<ft<kotlin/String, kotlin/String?>>?>|
public constructor(): R|test/A|

View File

@@ -1,4 +1,4 @@
public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap<ft<@FlexibleNullability kotlin/String, kotlin/String?>!, ft<@FlexibleNullability kotlin/String, kotlin/String?>!>| {
public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap<ft<kotlin/String, kotlin/String?>, ft<kotlin/String, kotlin/String?>>| {
public constructor(): R|AbstractMap|
}

View File

@@ -1,6 +1,5 @@
public final fun array(a: R|kotlin/Array<kotlin/Int>|): R|ft<kotlin/Array<ft<kotlin/Int, kotlin/Int?>!>, kotlin/Array<out ft<kotlin/Int, kotlin/Int?>!>?>!|
public final fun array(a: R|kotlin/Array<kotlin/Int>|): R|ft<kotlin/Array<ft<kotlin/Int, kotlin/Int?>>, kotlin/Array<out ft<kotlin/Int, kotlin/Int?>>?>|
public final fun list(): R|ft<kotlin/collections/MutableList<ft<kotlin/String, kotlin/String?>!>, kotlin/collections/List<ft<kotlin/String, kotlin/String?>!>?>!|
public final fun printStream(): R|ft<java/io/PrintStream, java/io/PrintStream?>!|
public final fun list(): R|ft<kotlin/collections/MutableList<ft<kotlin/String, kotlin/String?>>, kotlin/collections/List<ft<kotlin/String, kotlin/String?>>?>|
public final fun printStream(): R|ft<java/io/PrintStream, java/io/PrintStream?>|

View File

@@ -1,4 +1,4 @@
FILE: main.kt
public final fun test(list: R|kotlin/collections/List<kotlin/String>|, string: R|kotlin/String|): R|kotlin/Unit| {
R|/Matchers.assertThat|<R|ft<kotlin/collections/List<kotlin/String>, kotlin/collections/List<kotlin/String>?>!|>(R|<local>/list|, R|/Matchers.hasItem|<R|ft<kotlin/String, kotlin/String?>!|>(R|<local>/string|))
R|/Matchers.assertThat|<R|ft<kotlin/collections/List<kotlin/String>, kotlin/collections/List<kotlin/String>?>|>(R|<local>/list|, R|/Matchers.hasItem|<R|ft<kotlin/String, kotlin/String?>|>(R|<local>/string|))
}

View File

@@ -7,7 +7,7 @@ FILE: main.kt
public abstract interface PsiClass : R|kotlin/Any| {
}
public final fun test(): R|kotlin/Unit| {
lval processor: R|AdapterProcessor<ft<PsiMethod, PsiMethod?>!, ft<PsiClass, PsiClass?>!>| = R|/AdapterProcessor.AdapterProcessor|<R|ft<PsiMethod, PsiMethod?>!|, R|ft<PsiClass, PsiClass?>!|>(R|/Function|<R|ft<PsiMethod, PsiMethod?>!|, R|PsiClass?|>(<L> = Function@fun <anonymous>(method: R|PsiMethod?|): R|PsiClass?| {
lval processor: R|AdapterProcessor<ft<PsiMethod, PsiMethod?>, ft<PsiClass, PsiClass?>>| = R|/AdapterProcessor.AdapterProcessor|<R|ft<PsiMethod, PsiMethod?>|, R|ft<PsiClass, PsiClass?>|>(R|/Function|<R|ft<PsiMethod, PsiMethod?>|, R|PsiClass?|>(<L> = Function@fun <anonymous>(method: R|PsiMethod?|): R|PsiClass?| {
^ R|<local>/method|?.{ $subj$.R|/PsiMethod.containingClass| }
}
))

View File

@@ -0,0 +1,4 @@
FILE: main.kt
public final fun <T> test(executor: R|BuildActionExecuter<T>|, modelType: R|java/lang/Class<T>|, env: R|kotlin/collections/Map<kotlin/String, kotlin/String>|): R|kotlin/Unit| {
lval model: R|ft<BuildActionExecuter<ft<T, T?>>, BuildActionExecuter<ft<T, T?>>?>| = R|<local>/executor|.R|SubstitutionOverride</BuildActionExecuter.setEnvironmentVariables: R|ft<BuildActionExecuter<ft<T, T?>>, BuildActionExecuter<ft<T, T?>>?>|>|(R|<local>/env|)
}

View File

@@ -0,0 +1,26 @@
// FULL_JDK
// FILE: LongRunningOperation.java
import java.util.Map;
import org.jetbrains.annotations.Nullable;
public interface LongRunningOperation {
LongRunningOperation setEnvironmentVariables(@Nullable Map<String, String> envVariables);
}
// FILE: ConfigurableLauncher.java
import java.util.Map;
public interface ConfigurableLauncher<T extends ConfigurableLauncher<T>> extends LongRunningOperation {
@Override
T setEnvironmentVariables(Map<String, String> envVariables);
}
// FILE: BuildActionExecuter.java
public interface BuildActionExecuter<T> extends ConfigurableLauncher<BuildActionExecuter<T>> {}
// FILE: main.kt
fun <T> test(executor: BuildActionExecuter<T>, modelType: Class<T>, env: Map<String, String>) {
val model = executor.setEnvironmentVariables(env)
}

View File

@@ -84,7 +84,7 @@ digraph initBlock_kt {
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {28};
23 -> {28} [label=onUncaughtException];
23 -> {24} [style=dotted];
24 -> {25} [style=dotted];
25 -> {26} [style=dotted];

View File

@@ -72,7 +72,7 @@ digraph jumps_kt {
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {29};
18 -> {29} [label=onUncaughtException];
18 -> {19} [style=dotted];
19 -> {20} [style=dotted];
20 -> {21} [style=dotted];

View File

@@ -63,7 +63,7 @@ digraph lambdaReturningObject_kt {
}
13 -> {14};
14 -> {15};
15 -> {20};
15 -> {20} [label=onUncaughtException];
15 -> {16} [style=dotted];
16 -> {17} [style=dotted];
17 -> {20 18} [style=dotted];

View File

@@ -107,7 +107,7 @@ digraph propertiesAndInitBlocks_kt {
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {47};
44 -> {47} [label=onUncaughtException];
44 -> {45} [style=dotted];
45 -> {46} [style=dotted];
46 -> {47} [style=dotted];
@@ -138,7 +138,7 @@ digraph propertiesAndInitBlocks_kt {
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {58};
54 -> {58} [label=onUncaughtException];
54 -> {55} [style=dotted];
55 -> {56} [style=dotted];
56 -> {57} [style=dotted];
@@ -199,7 +199,7 @@ digraph propertiesAndInitBlocks_kt {
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {76};
73 -> {76} [label=onUncaughtException];
73 -> {74} [style=dotted];
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
@@ -246,7 +246,7 @@ digraph propertiesAndInitBlocks_kt {
28 -> {48 34} [color=green];
28 -> {48 34} [style=dashed];
29 -> {30};
30 -> {81};
30 -> {81} [label=onUncaughtException];
30 -> {31} [style=dotted];
31 -> {32} [style=dotted];
32 -> {33} [style=dotted];

View File

@@ -204,7 +204,8 @@ digraph returnValuesFromLambda_kt {
57 -> {65} [style=dashed];
58 -> {60} [style=dotted];
59 -> {60} [style=dotted];
60 -> {64 61} [style=dotted];
60 -> {61} [style=dotted];
60 -> {64} [style=dotted] [label=onUncaughtException];
61 -> {62} [style=dotted];
62 -> {63} [style=dotted];
63 -> {64} [style=dotted];

View File

@@ -20,13 +20,13 @@ FILE: main.kt
}
public final fun test_1(): R|kotlin/Unit| {
lval map: R|util/HashMap<ft<kotlin/Int, kotlin/Int?>!, ft<kotlin/Int, kotlin/Int?>!>| = R|util/HashMap.HashMap|<R|ft<kotlin/Int, kotlin/Int?>!|, R|ft<kotlin/Int, kotlin/Int?>!|>()
lval map: R|util/HashMap<ft<kotlin/Int, kotlin/Int?>, ft<kotlin/Int, kotlin/Int?>>| = R|util/HashMap.HashMap|<R|ft<kotlin/Int, kotlin/Int?>|, R|ft<kotlin/Int, kotlin/Int?>|>()
}
public final fun test_2(): R|kotlin/Unit| {
lval set: R|util/HashSet<kotlin/Int>| = R|util/HashSet.HashSet|<R|kotlin/Int|>()
}
public final fun test_3(): R|kotlin/Unit| {
lval list: R|foo/ArrayList<ft<kotlin/Int, kotlin/Int?>!>| = R|foo/ArrayList.ArrayList|<R|ft<kotlin/Int, kotlin/Int?>!|>()
lval list: R|foo/ArrayList<ft<kotlin/Int, kotlin/Int?>>| = R|foo/ArrayList.ArrayList|<R|ft<kotlin/Int, kotlin/Int?>|>()
}
public final fun test_4(): R|kotlin/Unit| {
lval list: R|foo/LinkedList<kotlin/Int>| = R|foo/LinkedList.LinkedList|<R|kotlin/Int|>()

View File

@@ -1,9 +1,9 @@
data class A {}
data <!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>class A<!> {}
<!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>data class B {
data <!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>class B<!> {
constructor()
}<!>
}
<!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>data class C {
data <!PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS!>class C<!> {
constructor(x: Int)
}<!>
}

View File

@@ -5,7 +5,7 @@ FILE: KotlinImporterComponent.kt
}
public final class State : R|kotlin/Any| {
public constructor(directories: R|kotlin/collections/List<kotlin/String>| = R|java/util/ArrayList.ArrayList|<R|ft<kotlin/String, kotlin/String?>!|>()): R|simulation/KotlinImporterComponent.State| {
public constructor(directories: R|kotlin/collections/List<kotlin/String>| = R|java/util/ArrayList.ArrayList|<R|ft<kotlin/String, kotlin/String?>|>()): R|simulation/KotlinImporterComponent.State| {
super<R|kotlin/Any|>()
}

View File

@@ -15,7 +15,7 @@ FILE: main.kt
}
public final fun test_1(): R|kotlin/Unit| {
lval e: R|ft<@FlexibleNullability E, E?>!| = Q|Utils|.R|/Utils.getEnum|()
lval e: R|ft<E, E?>| = Q|Utils|.R|/Utils.getEnum|()
lval s: R|kotlin/String| = when (R|<local>/e|) {
==($subj$, Null(null)) -> {
^test_1 Unit
@@ -34,7 +34,7 @@ FILE: main.kt
R|<local>/s|.R|kotlin/String.length|
}
public final fun test_2(): R|kotlin/Unit| {
lval e: R|ft<@FlexibleNullability E, E?>!| = Q|Utils|.R|/Utils.getEnum|()
lval e: R|ft<E, E?>| = Q|Utils|.R|/Utils.getEnum|()
lval s: R|kotlin/String| = when (R|<local>/e|) {
==($subj$, Q|E|.R|/E.A|) -> {
String()

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