Compare commits

..

139 Commits

Author SHA1 Message Date
Stanislav Erokhin
8ad07bb0a0 Fix 1.4-M2 ChangeLog.md 2020-07-02 22:05:37 +03:00
Lilia
e2296a3784 Add changelog for 1.4-M2 2020-06-03 18:05:14 +02:00
Stanislav Erokhin
ea347c8a23 Update kotlin version used in wizard
Unfortunately there is some test data that checks that it was
dev version, not eap version, so I picked an dev version instead.
2020-06-01 19:35:16 +03:00
Stanislav Erokhin
fa19c059b9 Advance kotlin version for wizard testing
Previous version was dropped from bintray
(because it is a kotlin-dev repo).
This is temporary fix for 1.4-M2
2020-06-01 14:59:09 +03:00
Pavel Punegov
acb1da1bb8 Update Kotlin/Native compiler to 1.4-M2 2020-05-29 15:06:12 +00:00
Ilmir Usmanov
45a5d0a01c Fix bugs with capturing rhs into EXACTLY_ONCE lambda
There are multiple ways to declare a named variable-like entity in
Kotlin:
1. val/var variable declaration
2. destructuring declaration
3. parameter of a function
4. parameter of a lambda
5. destructured lambda parameter
6. for-loop's variable declaration
7. catch block exception declaration
8. val in when
9. field declaration

Out of them, only variable and field can be assignable, in other words,
they can be on the left hand side of an assignment.
Val/var variable declarations were already supported.
So, we needed to just support field initialization and tell the backend
that other ways are prohibited. Function and lambda parameters were
already been supported. So, the only thing to explain to the backend are
remaining ways.
 #KT-39113 Fixed
 #KT-34048 Fixed
2020-05-29 15:13:31 +02:00
Vyacheslav Gerasimov
66ec576308 as41: Build against AS 4.1 C10 2020-05-29 13:54:48 +03:00
Vyacheslav Gerasimov
14a15a76cc as41: Setup bunch config and compatibility dsl for AS 4.1
(cherry picked from commit 097b93cb2a)
2020-05-29 09:10:37 +03:00
Vyacheslav Gerasimov
27a237ef5b Build: Remove bunch files with intellijUltimateEnabled=false for AS
(cherry picked from commit d6011103e2)
2020-05-29 09:10:34 +03:00
Dmitry Savvinov
2722cb984d Allow specific native targets to depend on unspecified native target
^KT-38769 Fixed
2020-05-26 10:50:48 +03:00
Dmitriy Dolovov
1bf6a047e7 [Commonizer] Add Gradle property to pass JVM args
^KT-39094
2020-05-22 16:11:52 +07:00
Ilya Goncharov
8abc86a9ba [Gradle, JS] Add isMpp property
#KT-38592 fixed

(cherry picked from commit 22f5d3b134)

[Gradle, JS] Define fake configuration for single js plugin to publish as common

#KT-38592 fixed

(cherry picked from commit 4f747072f4)

[Gradle, JS] Add fake common usage context for single js plugin publish

#KT-38592 fixed

(cherry picked from commit a6812e5d6a)

[Gradle, JS] Add test on hmpp with both js

#KT-38592 fixed

(cherry picked from commit 79984b6e04)

[Gradle, JS] Fix for JsIrTarget in mixed mode

#KT-38592 fixed

(cherry picked from commit d089bbe14a)

[Gradle, JS] Fix naming of test and test data

#KT-38592 fixed

(cherry picked from commit bed7b23d6c)

[Gradle, JS] Fix hmpp on only js

#KT-38592 fixed

(cherry picked from commit 985623eac5)

[Gradle, JS] Add test on local project dependency

#KT-38592 fixed

(cherry picked from commit 3c9207a2cd)
2020-05-22 11:02:45 +03:00
Sergey Igushkin
641b6a5e43 Fix KT-39063 by not adding extendsFrom with metadata configurations
Issue #KT-39063 Fixed

(cherry picked from commit 38fd9c3d1a)
2020-05-20 17:07:35 +03:00
Dmitry Savvinov
3ca79a052e Check for common klibs builtins_platform properly
Actually, common klibs don't have a corresponding record (and abscence
of that record should be treated as platform COMMON).

^KT-38769 Fixed
2020-05-17 19:17:18 +03:00
Ilya Kirillov
1236b9a1e7 Wizard: use correct version of react libraries
#KT-38929 fixed
2020-05-15 16:37:03 +03:00
Dmitriy Dolovov
dae56958e5 [Commonizer] Added README.md 2020-05-14 17:36:18 +07:00
Andrey Uskov
bb2f43945e Fixed import of MPP modules with single artifacts
#KT-38037 Fixed
2020-05-14 00:54:42 +03:00
Mikhael Bogdanov
d755bd9692 Call visit method on ClassWriter in IC caching in proper order
(cherry picked from commit 9fdb1ff4f8)
2020-05-13 18:13:51 +02:00
Mikhail Bogdanov
ba47666dea Call missed visit method on ClassWriter in IC caching
Otherwise ASM fails with error on invalid frames because bytecode version is 0

(cherry picked from commit 3134832396)
2020-05-13 18:13:37 +02:00
Anton Yalyshev
ea8de74cda Bump Gradle (6.3) and Android-build-tools (3.6.3) versions in new project wizards
(cherry picked from commit 37e676a4a6)
2020-05-07 16:28:32 +03:00
Sergey Igushkin
d0b9d48d9b Fix falsely skipped shared-native source sets in HMPP (KT-38746)
Issue #KT-38746 Fixed

(cherry picked from commit 292563451c)
2020-05-07 16:13:12 +03:00
Mikhail Bogdanov
e42d05b40c Postpone JvmDefault deprecation. Revert "Deprecate @JvmDefault"
This reverts commit c11f3868

(cherry picked from commit 4f7599076c)
2020-05-05 13:49:21 +02:00
Dmitry Savvinov
5d2507bf85 Make KotlinNativeTasks.konanTargetsForManifest non-nullable, otherwise Gradle fails 2020-05-03 10:35:02 +03:00
Dmitry Savvinov
f1150101d7 Collect and pass to K2Native actual targets of native-shared compilation
^KT-38658 Fixed
2020-04-30 20:03:16 +03:00
Sergey Igushkin
185f42c953 Kotlin/Native 1.4-M2-eap-49 2020-04-30 01:01:25 +03:00
Dmitriy Dolovov
9e9111a15a HMPP: Backward-compatible Kotlin facet serialization
^KT-38634
2020-04-29 19:49:32 +07:00
Ilya Goncharov
53cbb8e454 [Gradle, JS] No create target on import if no target in DSL
#KT-38469 fixed

(cherry picked from commit 1f40a71cbe)
2020-04-29 13:48:53 +03:00
Andrey Uskov
04475aa7f1 Fixed collecting MPP targets in gradle statistics
(cherry picked from commit 55934ff63a)
2020-04-29 13:42:16 +03:00
Andrey Uskov
8585407da2 Fixed import of JS source sets with Both mode
Added flag indicating that source set naming contract is violated. In this case disambiguition classifier is ignored in IDE.
#KT-37562 Fixed

(cherry picked from commit 96887d6e9f)
2020-04-29 13:42:12 +03:00
Ilya Kirillov
1c92db8f91 Wizard: remove copyrights from iOS template 2020-04-29 12:03:22 +03:00
Ilya Kirillov
6081aa1d3e Wizard: fix not created by default xcode framework in shared module
the runForXcode task is not generating xcode framework
if there is no source files in shared module
2020-04-29 12:03:21 +03:00
Ilya Kirillov
c91ff19fa4 Wizard: fix android project template
It was not able to be built as lint task required com.android.tools.build:gradle
in classpath to work

#KT-38579 fixed
2020-04-29 12:03:20 +03:00
Ilya Kirillov
a5e9bf7c4f Wizard: do not run whole JPS project importing in write action 2020-04-29 12:03:19 +03:00
Ilya Kirillov
c3fce0e3d2 Wizard: always allow user to choose project JDK 2020-04-29 12:03:18 +03:00
Ilya Kirillov
1739a0a397 Wizard: fix kotlin and resources directory names in Android module
#KT-38428 fixed
2020-04-29 12:03:16 +03:00
Ilya Kirillov
0c49cf6c0e Wizard: minor, move message to bundle 2020-04-29 12:03:14 +03:00
Ilya Kirillov
b43e8db2ab Wizard: add common target to FullStackWebApplicationProjectTemplate 2020-04-29 12:03:13 +03:00
Ilya Kirillov
3c51abc9e0 Wizard: validate project path for emptiness
#KT-38567 fixed
2020-04-29 12:03:11 +03:00
Ilya Kirillov
897596b3b5 Wizard: reduce buildsystem buttons sizes 2020-04-29 12:03:04 +03:00
Ilya Kirillov
0ed2dd84cb Wizard: do not create project with snapshot version 2020-04-29 12:03:00 +03:00
Ilya Kirillov
8dc7fa1f2a Wizard: add arrows for module selection popup 2020-04-29 12:02:55 +03:00
Ilya Kirillov
9623102fb9 Wizard: use new api from gradle to import project on >= 193 2020-04-29 12:02:54 +03:00
Ilya Kirillov
2df2f37026 Wizard: run Gradle wrapper task in background
#KT-38225 fixed

(cherry picked from commit 9c156c1a93)
2020-04-29 12:02:30 +03:00
Dmitriy Dolovov
e70663f94b [Commonizer] Capitalize messages to be printed at console 2020-04-29 13:28:37 +07:00
Dmitriy Dolovov
e988a95e93 [Commonizer] Don't fail when one of targets is not supported at the host
^KMM-214
2020-04-29 13:28:31 +07:00
Leonid Startsev
40fc072c22 Use AssociatedObjects on JS too
because JS IR now supports them

(cherry picked from commit 52933e161e)
2020-04-29 01:32:07 +03:00
Anton Bannykh
6e7aef6936 JS IR: fix findAssociatedObjects for primitive type KClass'es
(cherry picked from commit 2992d49a1d)
2020-04-28 19:22:39 +03:00
Anton Bannykh
e4b4d237bc JS IR: hide runtime helpers from users
(cherry picked from commit e8a6ddceaa)
2020-04-28 17:33:06 +03:00
Sergey Igushkin
c07043c166 Kotlin/Native 1.4-M2-eap-31 2020-04-28 14:22:57 +03:00
Sergey Igushkin
b0a7fde66d Drop Gradle < 6.0 support for Kotlin MPP Gradle plugin
This is required due to issues with dependency resolution of the
kotlinx library modules published in a way that their root MPP module
contains the JVM artifacts so that consumers that can't read Gradle
module metadata get the JVM JAR and POM. Gradle 6.0+ fails to resolve
those modules in a variant-aware way, always choosing the JVM artifacts.

To avoid issues on the consumer side when these dependencies are used,
we decided to drop support for Gradle < 6.0 in the MPP plugin.

Issue #KMM-233 Fixed

(cherry picked from commit e3d33cdc10)
2020-04-28 14:21:49 +03:00
Dmitry Savvinov
14d76ddfb1 Fallback to M2-implementation of dependsOn in AS + M3
^KT-33809
2020-04-28 10:43:58 +03:00
Dmitriy Dolovov
3fc3921897 Add test for overloading expect MemberDescriptors discrimination
Issue #KT-38298
2020-04-28 14:24:07 +07:00
Dmitriy Dolovov
483507af58 Discriminate overloading expect MemberDescriptors
Issue #KT-38298
2020-04-28 14:24:01 +07:00
Ilya Goncharov
f86d0aa367 [Gradle, JS] Remove propagation moduleName from legacy to ir target
#KT-38614 fixed

(cherry picked from commit 6b5b23f37b)
2020-04-27 18:48:32 +03:00
Abduqodiri Qurbonzoda
a3c7d9fbe9 Remove String.format with non-null locale
Introducing new overloads with @SinceKotlin(1.4) annotation
and marking the old ones @LowPriorityInOverloadResolution breaks
all code that uses the format(locale, args) overload with
-api-version 1.3. Because the low priority of the non-1.4 version makes
format(args) preferable in all cases.
For example, "%02X".format(Locale.ROOT, 1) throws
IllegalFormatConversionException: x != java.util.Locale.

(cherry picked from commit 2307692064)
2020-04-27 18:38:06 +03:00
Anton Bannykh
f500243930 IR JS: support findAssociatedObject feature (KT-37418 fixed)
(cherry picked from commit 442331acc9)
2020-04-27 17:56:16 +03:00
Konstantin Tskhovrebov
deecbe586a Get first platform from platformCompilations instead host platform.
Fixed #KMM-234

(cherry picked from commit 6d7e428d89)
2020-04-27 17:44:36 +03:00
Vladimir Ilmov
cf99351b9c (CoroutineDebugger) SkipCoroutineStackFrameProxy logic added 2020-04-27 16:13:12 +02:00
Vladimir Ilmov
f077b350cb (CoroutineDebugger) Tests added for no creation stack frame information 2020-04-27 16:13:11 +02:00
Vladimir Ilmov
f4aae0c33f (CoroutineDebugger) Exception if no creationStackTrace available
#KT-38484 Fixed
2020-04-27 16:13:11 +02:00
Vladimir Ilmov
26ccf81b1b (CoroutineDebugger) Minor issued fixed, log level adjusted for missing classes in JVM. 2020-04-27 16:13:10 +02:00
Vladimir Ilmov
46f5ff7ea1 (CoroutineDebugger) Unneccesary log record removed. 2020-04-27 16:13:10 +02:00
Vladimir Ilmov
57611995a5 (CoroutineDebugger) Unstable tests muted 2020-04-27 16:13:09 +02:00
Vladimir Ilmov
26a684c017 (CoroutineDebugger) Minor fixes, kotlinx.coroutines version fix 2020-04-27 16:13:06 +02:00
Vladimir Ilmov
e25c0b75b3 (CoroutineDebugger) negative frames removed from coroutine stack 2020-04-27 16:12:26 +02:00
Vladimir Ilmov
746eb1f064 (CoroutineDebugger) kotlinx.coroutines.core:1.3.5 support / dynamicProxy(interface) classes 2020-04-27 16:12:25 +02:00
Vladimir Ilmov
0c8ea17028 (CoroutineDebugger) kotlinx.coroutines compatibility version fix 2020-04-27 16:12:25 +02:00
Vladimir Ilmov
7d5be60e5e (CoroutineDebugger) Added setting to disable coroutine agent 2020-04-27 16:12:24 +02:00
Vladimir Ilmov
923f34fd73 (CoroutineDebugger) kotlinx-coroutines-core:1.3.5 support 2020-04-27 16:12:24 +02:00
Vladimir Ilmov
5ffdc4b96e (CoroutineDebugger) PreflightFrame support in tests via CoroutineAsync 2020-04-27 16:12:24 +02:00
Vladimir Ilmov
39b16b0dd0 (CoroutineDebugger) Fixed CombinedContext information, default group renamed to empty dispatcher 2020-04-27 16:12:23 +02:00
Vladimir Ilmov
d720d9362e (CoroutineDebugger) unused classes removed / code cleanup 2020-04-27 16:12:23 +02:00
Vladimir Ilmov
59e5052175 (CoroutineDebugger) Stack printing logic extracted to the single place
for DebugMetadata and CoroutinePanel, some corner cases fixed, test
cases added.
Added:
 - external maven dependencies in test scenarios
 - comparing stack traces + variables on breakpoint
2020-04-27 16:12:22 +02:00
Vladimir Ilmov
03cb79d156 (CoroutineDebugger) Added check if agent is not available in target jvm 2020-04-27 16:12:22 +02:00
Vladimir Ilmov
10c2d6f9f2 (CoroutineDebugger) Group coroutines by dispatcher
Kotlin Script support added.

 #KT-37917 fixed
2020-04-27 16:12:21 +02:00
Vladimir Ilmov
bb3aea8026 NPE fix in StackFrameInterceptor 2020-04-27 16:12:21 +02:00
Anton Yalyshev
68fd4cd1b9 Update group id for refactoring fus collector in 201 bunch
(cherry picked from commit f356ff36b4)
2020-04-24 21:22:07 +03:00
Dmitry Gridin
b87ab423ed i18n, MoveKotlinNestedClassesToUpperLevelDialog: add missing bundles for 201
#KT-38527 Fixed

(cherry picked from commit 60dc2f9674)
2020-04-24 17:13:53 +07:00
Dmitry Gridin
633f88c248 i18n, debugger: add missing bundles for 201
#KT-38487 Fixed

(cherry picked from commit 6524e2b764)
2020-04-24 17:13:17 +07:00
Dmitry Savvinov
6beb4e31d4 Allow dependencies to see internals from main module as well
^KT-38338 Fixed

(cherry picked from commit b07f89864e)
2020-04-24 12:57:14 +03:00
Sergey Igushkin
68fabac8eb fix testLanguageSettingsApplied
(cherry picked from commit af09cb0e57)
2020-04-24 12:57:10 +03:00
Sergey Igushkin
29d71087e7 Add Gradle integration tests running the IDE HMPP highlighting tests
(cherry picked from commit 60c49d26e3)
2020-04-24 12:57:08 +03:00
Sergey Igushkin
0ecd3ef070 Fix expect discrimination with actual typealias in deserialization
* For types encountered during deserialization, search for a classifier,
  not necessarily a class, across module dependencies (i.e. accept type
  aliases, returned when actual type alias discriminates an expect
  class).

* When the referenced type is a type alias, expand it, so that when
  the descriptor is compared to the expansion in other places,
  they match.

* Also, when resolving an abbreviation, don't expand the type aliases,
  as there are assumptions in the code base that an abbreviation is a
  type alias.

(cherry picked from commit 4b0da0688a)
2020-04-24 12:57:05 +03:00
Sergey Igushkin
3811b69f0e Support additional module descriptor dependencies in klib descriptors
(cherry picked from commit d4a0844a77)
2020-04-24 12:57:03 +03:00
Sergey Igushkin
9696e9b054 Fix wrong assumption in getHostSpecificSourceSets (KMM-225)
The assumption that each source set is already registered in at least
one compilation would break Android targets which are configured later
on the execution path, and also fail when there are unused source sets.

Issue #KMM-225 Fixed

(cherry picked from commit a9dd194383)
2020-04-24 12:57:00 +03:00
Sergey Igushkin
85f4d1dbb8 Add a dependency from all klib-originated modules to the main module
This is required, for instance, to properly resolve supertypes across
the modules.

Issue #KT-37832 Fixed

(cherry picked from commit 67f4b7e2b0)
2020-04-24 12:56:58 +03:00
Ilya Goncharov
df5356c6d7 [Gradle, JS] Add compiler type values on extension type
#KT-38519 fixed

(cherry picked from commit 9a3bf54d9d)

[Gradle, JS] Test check several ways to configure compiler type

#KT-38519 fixed

(cherry picked from commit f95ff049c6)
2020-04-24 10:54:09 +03:00
Ilya Matveev
5f174bc423 [Gradle] Use : as a separator for group and name in klib unique names 2020-04-24 10:27:48 +07:00
Ilya Matveev
4a88699d71 [Gradle, native] Make tests tolerate to stacktrace format changes
The K/N compiler changed the way in which inline functions are shown
in stacktraces. When an exception is thrown from an inline function,
the stacktrace refers to a line in the body of the inline function
while in 1.3.7x it referred to a line when the inline function is called.

This patch gets rid of inline functions in the corresponding test
to make it independent on such changes in the stacktrace format.
2020-04-24 10:27:47 +07:00
Ilya Matveev
7f1999f99a [Gradle, native] Improve logging in CacheBuilder 2020-04-24 10:27:47 +07:00
Ilya Matveev
dcfe23b2ca [Gradle, Native/JS] Specify FQ module name for klibs
By default, a unique name for a klibrary equals to a klib
file name. In the MPP plugin, the file name equals to a
Gradle project name. But the project name is not unique
enough. E.g. there is a situation when there are several projects
with the same simple name inside a single Gradle build. If
one of these projects depends on another, the compiler
will report a false cyclic dependency error.

This patch partially fixes this problem by specifying a custom
unique name for produced klibs based on project group and name.
We still can get a unique name clash in a case of equal groups
and project names. But in this case the cyclic dependency error
looks much more logical for user.

Also this patch specifies short names for native klibs to avoid
long declaration prefixes in framework headers.

Issue #KT-36721 Fixed
Issue #KT-38220 Fixed
2020-04-24 10:27:47 +07:00
Ilya Matveev
2dc5468b62 [JS IR] Support setting custom module name (= unique name)
Required for #KT-36721.
2020-04-24 10:27:47 +07:00
Ilya Matveev
2a1f3bd671 Update K/N: 1.4-M2-eap-14 2020-04-24 10:27:47 +07:00
Alexey Trilis
40543bc7e5 Introduce MSE and EME APIs to Kotlin/JS stdlib
#KT-37910 Fixed

(cherry picked from commit 3ad597ca5c)
2020-04-23 16:51:54 +03:00
Ilya Chernikov
bcab0d9ee5 Revert "Drop unnecessary dependency from embeddable compiler to daemon"
The commit breaks gradle plugin, because it relies on this dependency.
This reverts commit 2c889c2e
2020-04-23 15:47:50 +02:00
Ilya Goncharov
b53566a1c1 [Gradle, JS] Add string sompiler setting in js plugin
#KT-38485 fixed

(cherry picked from commit c7f7f2bcbb)

[Gradle, JS] Fix test

#KT-38485 fixed

(cherry picked from commit 47c27726b9)

[Gradle, JS] Change byArgument on byArgumentOrNull

#KT-38485 fixed

(cherry picked from commit 8e282e8aad)

[Gradle, JS] Remove copypaste in js compiler argument

#KT-38485 fixed

(cherry picked from commit ac11bc6710)
2020-04-23 15:03:43 +03:00
Abduqodiri Qurbonzoda
ec6bc50e01 Fix CharArray sort in JS IR-backend 2020-04-23 13:43:50 +03:00
Anton Bannykh
a991f7bd8d JS: fix JsName renamer (KT-36484 fixed)
The following code was treated incorrectly:
```
function (_) {

  function foo() {
      try {} catch (_) {}
      try {} catch (_) {}
  }

  // _ is linked to the catch parameter here
}
```

(cherry picked from commit de25d13f1a)
2020-04-22 19:33:15 +03:00
Igor Yakovlev
dde850e663 Fixed possible NPE in LightClasses
Fixed #EA-218014
2020-04-22 14:01:16 +03:00
Igor Yakovlev
00d9da53f5 Fix invalid signature for generic UL method
Fixed #KT-38348
2020-04-22 14:01:13 +03:00
Abduqodiri Qurbonzoda
86016f18ed Reverse range and sortDescending range #KT-36955
(cherry picked from commit d6472aa700)
2020-04-22 13:55:13 +03:00
Ilya Chernikov
2c889c2e75 Drop unnecessary dependency from embeddable compiler to daemon
(cherry picked from commit 86d47b496b)
2020-04-22 08:34:36 +02:00
Ilya Chernikov
a87ec06c6f Fix ThreadDeath exception on stopping daemon thread
#KT-30086 fixed

(cherry picked from commit c2eaa3d955)
2020-04-22 08:34:35 +02:00
Dmitriy Dolovov
c45b2438c4 IDE. Allow expect declarations in completion in shared native modules
Issue #KMM-218
2020-04-22 08:39:51 +07:00
Ilya Kirillov
5c663ba319 Wizard: enable new wizard by default in registry key
It was forgotten in 0e199ae94c

(cherry picked from commit bf97391c51)
2020-04-20 19:00:38 +03:00
Igor Chevdar
ae191da8c8 [box-tests] Turned on some tests on fun interfaces for JS & Native 2020-04-20 19:58:27 +05:00
Dmitry Gridin
0090f1c2ce i18n: fix text in AbstractKotlinInlineDialog
#KT-37822 Fixed

(cherry picked from commit 2d64ded3c7)
2020-04-20 19:16:12 +07:00
Vladimir Dolzhenko
06ffea298e Fix KotlinNativeABICompatibilityChecker.getLibrariesToNotifyAbout freeze
Get rid of O(n^2) in copyProperties
make ModuleProductionSourceInfo.stableName lazy
add checkCanceled in loops in IdeaModelInfosCache

#KT-38318 Fixed

(cherry picked from commit 86a02c07f6)
2020-04-20 11:35:09 +02:00
Vladimir Dolzhenko
f8b4bf1831 Do not search TODOs in non KT and non physical files
#KT-37896 Fixed
#EA-230407 Fixed

(cherry picked from commit 86a02c07f6)
2020-04-20 11:35:09 +02:00
Pavel Kirpichenkov
c54869d113 [NI] Fix expicit super receiver check
^KT-37497 Fixed
2020-04-20 12:12:01 +03:00
Ilya Matveev
6265a94f4d [klibs] Allow resolving klibs which names are not valid file names
Issue #KT-36721

Cherry-picked from 5f53986f47
2020-04-20 15:24:25 +07:00
Dmitriy Dolovov
8b73f939a6 [Commonizer] Generate correct TA types for callable descriptors
Issue #KMM-217
2020-04-20 13:22:08 +07:00
Dmitriy Dolovov
5a8e7d586d Minor. Add comments 2020-04-20 13:18:54 +07:00
Dmitriy Dolovov
b9c3440ea8 HMPP. Avoid leaking platform-specific dependencies into common libraries
Issue #KMM-217
2020-04-20 13:18:44 +07:00
Dmitriy Dolovov
9d8bad3e93 HMPP. Rewrite LibraryDependenciesCache on using LibraryInfo/SdkInfo
... instead of pure IJ Library/SDK.
2020-04-20 13:18:39 +07:00
Dmitriy Dolovov
ec6bc11b1c HMPP: Fix detection of NativePlatform in CompositeResolverForModuleFactory 2020-04-20 13:18:31 +07:00
Dmitriy Dolovov
ae18b563e4 HMPP: Evaluate exact TargetPlatform for each K/N KLIB library 2020-04-20 13:18:23 +07:00
Dmitriy Dolovov
d29c1fdea7 Minor. Specify explicit property types 2020-04-20 13:18:18 +07:00
Dmitriy Dolovov
5451cde862 HMPP: Fix serialization of TargetPlatform in tests 2020-04-20 13:18:12 +07:00
Dmitriy Dolovov
8530541a4d HMPP: Fix serialization of TargetPlatform in Kotlin facet 2020-04-20 13:18:06 +07:00
Dmitriy Dolovov
b161d45d7f Minor. Formatted 2020-04-20 13:18:00 +07:00
Dmitriy Dolovov
42d048e112 HMPP: Fix detection of PlatformDependentAnalyzerServices for TargetPlatform 2020-04-20 13:17:45 +07:00
Dmitriy Dolovov
31a7e3dd78 JVM, JS: Use faster checks in IdePlatformKind.supportsTargetPlatform() 2020-04-20 13:17:36 +07:00
Dmitriy Dolovov
ce5f10c1c1 HMPP: Avoid false positive detection of "common native" as "common" 2020-04-20 13:17:30 +07:00
Dmitriy Dolovov
92d909effa HMPP. Fix tests after parameterization of NativePlatform 2020-04-20 13:17:23 +07:00
Dmitriy Dolovov
dd727404fe HMPP: Parameterize NativePlatform with KonanTarget 2020-04-20 13:17:18 +07:00
Dmitriy Dolovov
35d9655aff HMPP: Propagate K/N flavor into each imported K/N module 2020-04-20 13:17:08 +07:00
Ilya Matveev
22d2adb071 [Gradle, native] Disable platform libraries generation by default
Since there are a lot of changes around klibs in 1.4-M2, it was
decided to postpone enabling user-side platform libraries generation
by default. This patch switches the default distribution type to
prebuilt.

It also slightly refactors the code allowing user to choose the
distribution type. Now, there are only two distribution types
available:

- prebuilt - the default type, contains prebuilt platform libs.
             A distribution archive has the "-prebuilt-" classifier.
- light    - doesn't contain platform libs in an archive and
             generates them at the user side. The archive has no
             classifier to avoid changes in the K/N build logic and
             TC configurations.

The same types are also available for 1.3 but with sightly different
convention:

- prebuilt - the default type, contains prebuilt platform libs.
             A distribution archive has no classifier.
- light    - aka "restricted" distribution, doesn't contain
             platform libs for Apple platforms. The archive has
             the "-restricted-" suffix. Doesn't have a facility
             to build the libraries at the user side.

Issue #KT-38174 Fixed
2020-04-19 12:21:09 +07:00
Ilya Matveev
a54c4b54fa [Gradle, native] Rename native distribution kind: regular -> light 2020-04-19 12:21:08 +07:00
Ilya Gorbunov
793e13c093 Introduce runningFold and runningReduce operations
runningFold is a synonym for scan,
runningReduce replaces scanReduce.

#KT-38060

(cherry picked from commit 893021f22b)
2020-04-16 19:26:11 +03:00
Ilya Gorbunov
abb4ba30fc Delegate properties to property references
#KT-8658

(cherry picked from commit ea1e16e309)
2020-04-16 19:26:09 +03:00
Mikhail Zarechenskiy
bef7e02781 [NI] Properly support UnsafeVariance annotation
#KT-38134 Fixed
 #KT-34433 Fixed
 #KT-31823 Fixed
2020-04-16 14:24:00 +03:00
Anton Bannykh
c1cf23b491 JS: support explicit SAM constructor invocation
(cherry picked from commit 81798282b9)
2020-04-15 21:18:10 +03:00
Mikhail Zarechenskiy
8cd7430cc1 Remove JavaResolverUtils.java as its usages were moved to core 2020-04-15 11:26:01 +03:00
Mikhail Zarechenskiy
7dab4c8bc6 Introduce synthetic scope for constructors of fun interfaces
#KT-37434 Fixed
2020-04-15 11:26:01 +03:00
Mikhail Zarechenskiy
2976a22436 Refactoring: move utils to create & initialize SAM constructors to core 2020-04-15 11:26:00 +03:00
Mikhail Zarechenskiy
20e942e104 Extract Java specific check from common method out
This is needed for further refactoring
2020-04-15 11:25:59 +03:00
Mikhail Zarechenskiy
a581c1c52e Move Sam(TypeAlias)ConstructorDescriptor to core 2020-04-15 11:25:59 +03:00
Mikhail Zarechenskiy
c38413b31f Move SyntheticMemberDescriptor.kt to core
This is a first part of unification SAM constructors for all platforms
2020-04-15 11:25:58 +03:00
1877 changed files with 19396 additions and 35981 deletions

3
.bunch
View File

@@ -4,4 +4,5 @@
191_192
as35_191_192
as36_192
as40
as40
as41_201

View File

@@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact build-on-make="true" name="dist_root">
<output-path>$PROJECT_DIR$/dist</output-path>
<root id="root">
<element id="artifact" artifact-name="dist" />
</root>
</artifact>
</component>

10660
ChangeLog.md

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.org.objectweb.asm.*
import java.io.File
@@ -476,8 +477,21 @@ open class IncrementalJvmCache(
if (inlineFunctions.isEmpty()) return emptyMap()
val result = HashMap<String, Long>()
var dummyVersion: Int = -1
ClassReader(bytes).accept(object : ClassVisitor(Opcodes.API_VERSION) {
override fun visit(
version: Int,
access: Int,
name: String?,
signature: String?,
superName: String?,
interfaces: Array<out String>?
) {
super.visit(version, access, name, signature, superName, interfaces)
dummyVersion = version
}
override fun visitMethod(
access: Int,
name: String,
@@ -485,7 +499,8 @@ open class IncrementalJvmCache(
signature: String?,
exceptions: Array<out String>?
): MethodVisitor? {
val dummyClassWriter = ClassWriter(Opcodes.API_VERSION)
val dummyClassWriter = ClassWriter(0)
dummyClassWriter.visit(dummyVersion, 0, "dummy", null, AsmTypes.OBJECT_TYPE.internalName, null)
return object : MethodVisitor(Opcodes.API_VERSION, dummyClassWriter.visitMethod(0, name, desc, null, exceptions)) {
override fun visitEnd() {
@@ -493,6 +508,7 @@ open class IncrementalJvmCache(
if (jvmName !in inlineFunctions) return
val dummyBytes = dummyClassWriter.toByteArray()!!
val hash = dummyBytes.md5()
result[jvmName] = hash
}

View File

@@ -181,7 +181,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.4-M2-dev-15123"
extra["versions.kotlin-native"] = "1.4-M2"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -365,7 +365,6 @@ allprojects {
"-Xread-deserialized-contracts",
"-Xjvm-default=compatibility",
"-Xno-optimized-callable-references",
"-Xno-kotlin-nothing-value-exception",
"-progressive".takeIf { hasProperty("test.progressive.mode") }
)
@@ -601,7 +600,6 @@ tasks {
// dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
dependsOn(":kotlin-main-kts-test:test")
dependsOn(":kotlin-scripting-ide-services-test:test")
}
register("compilerTest") {

View File

@@ -1,8 +0,0 @@
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m -Dfile.encoding=UTF-8
cacheRedirectorEnabled=true
#buildSrc.kotlin.repo=https://jcenter.bintray.com
#buildSrc.kotlin.version=1.1.50
intellijUltimateEnabled=false

View File

@@ -1,8 +0,0 @@
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m -Dfile.encoding=UTF-8
cacheRedirectorEnabled=true
#buildSrc.kotlin.repo=https://jcenter.bintray.com
#buildSrc.kotlin.version=1.1.50
intellijUltimateEnabled=false

View File

@@ -1,8 +0,0 @@
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m -Dfile.encoding=UTF-8
cacheRedirectorEnabled=true
#buildSrc.kotlin.repo=https://jcenter.bintray.com
#buildSrc.kotlin.version=1.1.50
intellijUltimateEnabled=false

View File

@@ -25,7 +25,7 @@ val androidStudioRelease = rootProject.findProperty("versions.androidStudioRelea
val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String?
val intellijSeparateSdks: Boolean by rootProject.extra
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
val installIntellijUltimate = intellijUltimateEnabled
val installIntellijUltimate = intellijUltimateEnabled && androidStudioRelease == null
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
if (intellijVersionDelimiterIndex == -1) {

View File

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

View File

@@ -1,7 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
isD8Enabled = project.findProperty('android.enableD8').toBoolean()
}
buildscript {
repositories {
google()
@@ -60,42 +58,21 @@ android {
resultsDir = "build/test/results"
}
if (isD8Enabled) {
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
flavorDimensions "box"
productFlavors {
common0 {
ktest0 {
dimension "box"
}
common1 {
ktest1 {
dimension "box"
}
common2 {
ktest2 {
dimension "box"
}
reflect0 {
dimension "box"
}
if (isD8Enabled) {
jvm80 {
dimension "box"
}
reflectjvm80 {
dimension "box"
}
}
}
}
@@ -103,9 +80,9 @@ android {
task jarTestFolders() {
println "Jar folders..."
new File("${projectDir}/libs/").listFiles().each { File file ->
if (file.isDirectory()) {
if (file.isDirectory() && !file.name.equals("test")) {
println "Jar '${file.name}' folder..."
ant.jar(basedir: "libs/${file.name}/", destfile: "libs/" + file.name + ".jar")
ant.jar(basedir: "libs/${file.name}/", destfile: "libs/test/" + file.name + ".jar")
}
}
}
@@ -115,18 +92,11 @@ tasks.withType(JavaCompile) {
}
dependencies {
implementation fileTree(dir: 'libs', include: ['kotlin-test.jar', 'kotlin-stdlib.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
android.applicationVariants.all { variant ->
variant.productFlavors.each {
def configuration = configurations.getByName(it.name + 'Implementation').name
add(configuration, project.fileTree(dir: 'libs', include: [it.name + ".jar"]))
if (it.name.startsWith("reflect")) {
add(configuration, project.fileTree(dir: 'libs', include: ['kotlin-reflect.jar']))
}
}
}
ktest0Implementation fileTree(dir: 'libs/test', include: ['libtest0.jar'])
ktest1Implementation fileTree(dir: 'libs/test', include: ['libtest1.jar'])
ktest2Implementation fileTree(dir: 'libs/test', include: ['libtest2.jar'])
}

View File

@@ -1,3 +1,3 @@
#don't try to download android specific tools within gradle: licence acceptance will be required
android.builder.sdkDownload=false
android.enableD8=true
android.enableD8=false

View File

@@ -52,16 +52,16 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
try {
emulator.waitEmulatorStart()
runTestsOnEmulator(gradleRunner, TestSuite("D8")).apply {
runTestsOnEmulator(gradleRunner, TestSuite("Dex")).apply {
rootSuite.addTest(this)
}
renameFlavorFolder()
enableD8(false)
runTestsOnEmulator(gradleRunner, TestSuite("DX")).apply {
enableD8(true)
runTestsOnEmulator(gradleRunner, TestSuite("D8")).apply {
(0 until this.countTestCases()).forEach {
val testCase = testAt(it) as TestCase
testCase.name += "_DX"
testCase.name += "_D8"
}
rootSuite.addTest(this)
}
@@ -102,14 +102,14 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
testCases.forEach { aCase -> suite.addTest(aCase) }
Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong())
}
} catch (e: Throwable) {
} catch (e: Exception) {
throw RuntimeException("Can't parse test results in $reportFolder\n$resultOutput", e)
}
}
private fun renameFlavorFolder() {
val reportFolder = File(flavorFolder())
reportFolder.renameTo(File(reportFolder.parentFile, reportFolder.name + "_d8"))
reportFolder.renameTo(File(reportFolder.parentFile, reportFolder.name + "_dex"))
}
private fun flavorFolder() = pathManager.tmpFolder + "/build/test/results/connected/flavors"

View File

@@ -52,8 +52,8 @@ public class PathManager {
return getAndroidSdkRoot() + "/emulator";
}
public String getOutputForCompiledFiles(String flavor) {
return tmpFolder + "/libs/" + flavor;
public String getOutputForCompiledFiles(int index) {
return tmpFolder + "/libs/libtest" + index;
}
public String getLibsFolderInAndroidTmpFolder() {

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.android.tests
import com.intellij.openapi.util.Ref
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -46,21 +47,18 @@ internal fun patchFilesAndAddTest(
val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_")
val oldPackage = Ref<FqName>()
val isJvmName = Ref<Boolean>(false)
val isSingle = testFiles.size == 1
val resultFiles = testFiles.map {
val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name
TestClassInfo(
fileName,
changePackage(newPackagePrefix, it.content, oldPackage, isJvmName),
changePackage(newPackagePrefix, it.content, oldPackage),
oldPackage.get(),
isJvmName.get(),
getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get())
)
}
val packages =
resultFiles.map { OldPackageAndNew(it.oldPackage, it.newPackagePartClassId.parent()) }
.sortedByDescending { it.oldFqName.asString().length }
resultFiles.map { OldPackageAndNew(it.oldPackage, it.newClassId.parent()) }.sortedByDescending { it.oldFqName.asString().length }
//If files contain any val or var declaration with same name as any package name
// then use old conservative renaming scheme, otherwise use aggressive one
@@ -97,7 +95,7 @@ internal fun patchFilesAndAddTest(
/*replace all Class.forName*/
resultFiles.forEach { file ->
file.content = resultFiles.fold(file.content) { r, param ->
patchClassForName(param.newPackagePartClassId, param.oldPackage, r, conservativeRenameScheme)
patchClassForName(param.newClassId, param.oldPackage, r, conservativeRenameScheme)
}
}
@@ -106,13 +104,6 @@ internal fun patchFilesAndAddTest(
file.content = file.content.patchSelfImports(file.newPackage)
}
//patch root package parts usages in strings
resultFiles.forEach { file ->
file.content = resultFiles.fold(file.content) { r, param ->
patchRootPartNamesInStrings(param.newPackagePartClassId, param.oldPackage, param.isJvmName, r)
}
}
val boxFiles = resultFiles.filter { hasBoxMethod(it.content) }
if (boxFiles.size != 1) {
println("Several box methods in $testFile")
@@ -120,22 +111,22 @@ internal fun patchFilesAndAddTest(
filesHolder.addTest(
resultFiles.filter { resultFile -> resultFile.name.endsWith(".kt") || resultFile.name.endsWith(".kts") },
TestInfo("", boxFiles.last().newPackagePartClassId, testFile)
TestInfo("", boxFiles.last().newClassId, testFile)
)
return boxFiles.last().newPackagePartClassId
return boxFiles.last().newClassId
}
private fun hasBoxMethod(text: String): Boolean {
return text.contains("fun box()")
}
class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val isJvmName: Boolean, val newPackagePartClassId: FqName) {
val newPackage = newPackagePartClassId.parent()
class TestClassInfo(val name: String, var content: String, val oldPackage: FqName, val newClassId: FqName) {
val newPackage = newClassId.parent()
}
private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref<FqName>, isJvmName: Ref<Boolean>): String {
private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Ref<FqName>): String {
val matcher = packagePattern.matcher(text)
if (matcher.find()) {
val oldPackageName = matcher.toMatchResult().group(1)
@@ -147,7 +138,6 @@ private fun changePackage(newPackagePrefix: String, text: String, oldPackage: Re
if (text.contains("@file:")) {
val index = text.lastIndexOf("@file:")
val packageDirectiveIndex = text.indexOf("\n", index)
isJvmName.set(true)
return text.substring(0, packageDirectiveIndex + 1) + packageDirective + text.substring(packageDirectiveIndex + 1)
} else {
return packageDirective + text
@@ -180,19 +170,6 @@ private fun patchClassForName(className: FqName, oldPackage: FqName, text: Strin
)
}
private fun patchRootPartNamesInStrings(
className: FqName,
oldPackage: FqName,
isJvmName: Boolean,
text: String
): String {
if (!oldPackage.isRoot || isJvmName) return text
return text.replace(
("\"" + oldPackage.child(className.shortName()).asString()).toRegex(),
"\"" + className.asString()
)
}
private fun patchPackages(newPackage: FqName, oldPackage: FqName, text: String): String {
if (oldPackage.isRoot) return text

View File

@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.android.tests
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.io.FileUtil
@@ -19,56 +18,35 @@ import org.jetbrains.kotlin.codegen.GenerationUtils
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.*
import org.junit.Assert
import org.junit.Ignore
import java.io.File
import java.io.FileWriter
import java.io.IOException
import kotlin.test.assertTrue
data class ConfigurationKey(val kind: ConfigurationKind, val jdkKind: TestJdkKind, val configuration: String)
class CodegenTestsOnAndroidGenerator private constructor(private val pathManager: PathManager) {
@Ignore
class CodegenTestsOnAndroidGenerator private constructor(private val pathManager: PathManager) : CodegenTestCase() {
private var writtenFilesCount = 0
private var currentModuleIndex = 1
private val pathFilter: String? = System.getProperties().getProperty("kotlin.test.android.path.filter")
private val pendingUnitTestGenerators = hashMapOf<String, UnitTestFileWriter>()
private val pendingUnitTestGenerators = hashMapOf<Int, UnitTestFileWriter>()
//keep it globally to avoid test grouping on TC
private val generatedTestNames = hashSetOf<String>()
private val COMMON = FlavorConfig("common", 3);
private val REFLECT = FlavorConfig("reflect", 1);
private val JVM8 = FlavorConfig("jvm8", 1);
private val JVM8REFLECT = FlavorConfig("reflectjvm8", 1);
class FlavorConfig(private val prefix: String, val limit: Int) {
private var writtenFilesCount = 0
fun printStatistics() {
println("FlavorTestCompiler: $prefix, generated file count: $writtenFilesCount")
}
fun getFlavorForNewFiles(newFilesCount: Int): String {
writtenFilesCount += newFilesCount
//2500 files per folder that would be used by flavor to avoid multidex usage,
// each folder would be jared by build.gradle script
val index = writtenFilesCount / 2500
return getFlavorName(index, prefix).also {
assertTrue("Please Add new flavor in build.gradle for $it") { index < limit }
}
}
private fun getFlavorName(index: Int, prefix: String): String {
return prefix + index
}
fun getFlavorUnitTestFilePath(index: Int): String {
return pathManager.srcFolderInAndroidTmpFolder + "/androidTestKtest$index/java/" + testClassPackage.replace(
".",
"/"
) + "/" + testClassName + "$index.java"
}
private fun prepareAndroidModuleAndGenerateTests(skipSdkDirWriting: Boolean) {
@@ -148,15 +126,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
holders.values.forEach {
it.writeFilesOnDisk()
}
COMMON.printStatistics()
REFLECT.printStatistics()
JVM8.printStatistics()
JVM8REFLECT.printStatistics()
}
internal inner class FilesWriter(
private val flavorConfig: FlavorConfig,
private val configuration: CompilerConfiguration
) {
private val rawFiles = arrayListOf<TestClassInfo>()
@@ -171,40 +143,38 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}
fun writeFilesOnDisk() {
val disposable = Disposer.newDisposable()
val disposable = TestDisposable()
val environment = KotlinCoreEnvironment.createForTests(
disposable,
configuration.copy().apply { put(CommonConfigurationKeys.MODULE_NAME, "android-module-" + currentModuleIndex++) },
EnvironmentConfigFiles.JVM_CONFIG_FILES
)
try {
writeFiles(
rawFiles.map {
try {
CodegenTestFiles.create(it.name, it.content, environment.project).psiFile
} catch (e: Throwable) {
throw RuntimeException("Error on processing ${it.name}:\n${it.content}", e)
}
}, environment, unitTestDescriptions
)
} finally {
rawFiles.clear()
unitTestDescriptions.clear()
Disposer.dispose(disposable)
}
writeFiles(
rawFiles.map {
try {
CodegenTestFiles.create(it.name, it.content, environment.project).psiFile
} catch (e: Throwable) {
throw RuntimeException("Error on processing ${it.name}:\n${it.content}", e)
}
}, environment
)
Disposer.dispose(disposable)
rawFiles.clear()
unitTestDescriptions.clear()
}
private fun writeFiles(
filesToCompile: List<KtFile>,
environment: KotlinCoreEnvironment,
unitTestDescriptions: ArrayList<TestInfo>
) {
private fun writeFiles(filesToCompile: List<KtFile>, environment: KotlinCoreEnvironment) {
if (filesToCompile.isEmpty()) return
val flavorName = flavorConfig.getFlavorForNewFiles(filesToCompile.size)
//2500 files per folder that would be used by flavor to avoid multidex usage,
// each folder would be jared by build.gradle script
writtenFilesCount += filesToCompile.size
val index = writtenFilesCount / 2500
val outputDir = File(pathManager.getOutputForCompiledFiles(index))
assertTrue("Add flavors for ktest$index", index < 3)
val outputDir = File(pathManager.getOutputForCompiledFiles(flavorName))
println("Generating ${filesToCompile.size} files into ${outputDir.name}, configuration: '${environment.configuration}'...")
val outputFiles = GenerationUtils.compileFiles(filesToCompile, environment).run { destroy(); factory }
@@ -213,10 +183,10 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
outputDir.mkdirs()
}
Assert.assertTrue("Cannot create directory for compiled files", outputDir.exists())
val unitTestFileWriter = pendingUnitTestGenerators.getOrPut(flavorName) {
val unitTestFileWriter = pendingUnitTestGenerators.getOrPut(index) {
UnitTestFileWriter(
getFlavorUnitTestFolder(flavorName),
flavorName,
getFlavorUnitTestFilePath(index),
index,
generatedTestNames
)
}
@@ -224,12 +194,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
outputFiles.writeAllTo(outputDir)
}
private fun getFlavorUnitTestFolder(flavourName: String): String {
return pathManager.srcFolderInAndroidTmpFolder +
"/androidTest${flavourName.capitalize()}/java/" +
testClassPackage.replace(".", "/") + "/"
}
fun addTest(testFiles: List<TestClassInfo>, info: TestInfo) {
rawFiles.addAll(testFiles)
unitTestDescriptions.add(info)
@@ -246,6 +210,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}
for (file in files) {
if (SpecialFiles.getExcludedFiles().contains(file.name)) {
continue
}
if (file.isDirectory) {
val listFiles = file.listFiles()
if (listFiles != null) {
@@ -258,9 +225,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
continue
}
if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file) ||
InTextDirectivesUtils.isIgnoredTarget(TargetBackend.ANDROID, file)
) {
if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file)) {
continue
}
@@ -276,32 +241,23 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
if (fullFileText.contains("@file:JvmPackageName(")) continue
// TODO: Support jvm assertions
if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue
val targets = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fullFileText, "// JVM_TARGET:")
.also { it.remove(JvmTarget.JVM_1_6.description) }
val isJvm8Target =
if (targets.isEmpty()) false
else if (targets.contains(JvmTarget.JVM_1_8.description) && targets.size == 1) true
else continue //TODO: support other targets on Android
// TODO: support JVM 8 test with D8
if (fullFileText.contains("// JVM_TARGET")) continue
// TODO: support SKIP_JDK6 on new platforms
if (fullFileText.contains("// SKIP_JDK6")) continue
if (hasBoxMethod(fullFileText)) {
val testFiles = createTestFiles(file, fullFileText)
val kind = KotlinBaseTest.extractConfigurationKind(testFiles)
val jdkKind = KotlinBaseTest.getTestJdkKind(testFiles)
val kind = extractConfigurationKind(testFiles)
val jdkKind = getTestJdkKind(testFiles)
val keyConfiguration = CompilerConfiguration()
CodegenTestCase.updateConfigurationByDirectivesInTestFiles(testFiles, keyConfiguration)
updateConfigurationByDirectivesInTestFiles(testFiles, keyConfiguration)
val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString())
val compiler = if (isJvm8Target) {
if (kind.withReflection) JVM8REFLECT else JVM8
} else if (kind.withReflection) REFLECT else COMMON
val filesHolder = holders.getOrPut(key) {
FilesWriter(compiler, KotlinTestUtils.newConfiguration(kind, jdkKind, KotlinTestUtils.getAnnotationsJar()).apply {
FilesWriter(KotlinTestUtils.newConfiguration(kind, jdkKind, KotlinTestUtils.getAnnotationsJar()).apply {
println("Creating new configuration by $key")
CodegenTestCase.updateConfigurationByDirectivesInTestFiles(testFiles, this)
updateConfigurationByDirectivesInTestFiles(testFiles, this)
})
}
@@ -311,8 +267,17 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}
}
private fun createTestFiles(file: File, expectedText: String): List<KotlinBaseTest.TestFile> =
CodegenTestCase.createTestFilesFromFile(file, expectedText, "kotlin.coroutines", false, TargetBackend.JVM)
private fun createTestFiles(file: File, expectedText: String): List<TestFile> =
TestFiles.createTestFiles(
file.name,
expectedText,
object : TestFiles.TestFileFactoryNoModules<TestFile>() {
override fun create(fileName: String, text: String, directives: Directives): TestFile {
return TestFile(fileName, text, directives)
}
}, false,
"kotlin.coroutines"
)
companion object {
const val GRADLE_VERSION = "5.6.4"
@@ -349,7 +314,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
val rootFolder = File("")
val pathManager = PathManager(rootFolder.absolutePath, tmpFolder.absolutePath)
generate(pathManager, true)
println("Android test project is generated into " + tmpFolder.absolutePath + " folder")
}
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.android.tests;
import java.util.HashSet;
import java.util.Set;
public class SpecialFiles {
private static final Set<String> excludedFiles = new HashSet<>();
static {
fillExcludedFiles();
}
public static Set<String> getExcludedFiles() {
return excludedFiles;
}
private static void fillExcludedFiles() {
// Reflection
excludedFiles.add("enclosing");
excludedFiles.add("kt10259.kt");
excludedFiles.add("simpleClassLiteral.kt");
//UnsatisfiedLinkError
excludedFiles.add("nativePropertyAccessors.kt");
excludedFiles.add("topLevel.kt");
//Test with no reflection at runtime
excludedFiles.add("noReflectAtRuntime");
excludedFiles.add("noReflect");
excludedFiles.add("functionNtoStringNoReflect.kt");
excludedFiles.add("getDelegateWithoutReflection.kt");
excludedFiles.add("toStringNoReflect.kt");
// "IOOBE: Invalid index 4, size is 4" for java.lang.reflect.ParameterizedType on Android
excludedFiles.add("innerGenericTypeArgument.kt");
// Cannot change package name
excludedFiles.add("kt6990.kt");
excludedFiles.add("typeParameters.kt");
excludedFiles.add("kt13133.kt");
// StackOverflow with StringBuilder (escape())
excludedFiles.add("kt684.kt");
// Wrong enclosing info or signature after package renaming
excludedFiles.add("enclosingInfo");
excludedFiles.add("signature");
// Some classes are not visible on android
excludedFiles.add("classpath.kt");
// Out of memory
excludedFiles.add("manyNumbers.kt");
// Native methods
excludedFiles.add("external");
// Additional nested class in 'Thread' class on Android
excludedFiles.add("nestedClasses.kt");
// KT-8120
excludedFiles.add("closureOfInnerLocalClass.kt");
excludedFiles.add("closureWithSelfInstantiation.kt");
excludedFiles.add("quotedClassName.kt");
//wrong function resolution after package renaming
excludedFiles.add("apiVersionAtLeast1.kt");
//special symbols in names
excludedFiles.add("nameWithWhitespace.kt");
//some classes are moved from stdlib to compatibility package
excludedFiles.add("suspendFunction_1_2.kt");
}
private SpecialFiles() {
}
}

View File

@@ -15,11 +15,7 @@ import java.io.FileWriter
class TestInfo(val name: String, val fqName: FqName, val file: File)
class UnitTestFileWriter(
private val flavourFolder: String,
private val flavourName: String,
private val generatedTestNames: MutableSet<String>
) {
class UnitTestFileWriter(private val fileName: String, private val index: Int, private val generatedTestNames: MutableSet<String>) {
private val infos = arrayListOf<TestInfo>()
fun addTests(info: List<TestInfo>) {
@@ -27,7 +23,7 @@ class UnitTestFileWriter(
}
fun generate() {
FileWriter(File(flavourFolder, flavourName.capitalize() + ".java").also { it.parentFile.mkdirs() }).use { suite ->
FileWriter(File(fileName).also { it.parentFile.mkdirs() }).use { suite ->
val p = Printer(suite)
p.println(
"""package ${CodegenTestsOnAndroidGenerator.testClassPackage};
@@ -35,7 +31,7 @@ class UnitTestFileWriter(
|import ${CodegenTestsOnAndroidGenerator.baseTestClassPackage}.${CodegenTestsOnAndroidGenerator.baseTestClassName};
|
|/* This class is generated by ${CodegenTestsOnAndroidGenerator.generatorName}. DO NOT MODIFY MANUALLY */
|public class ${flavourName.capitalize()} extends ${CodegenTestsOnAndroidGenerator.baseTestClassName} {
|public class ${CodegenTestsOnAndroidGenerator.testClassName}$index extends ${CodegenTestsOnAndroidGenerator.baseTestClassName} {
|
""".trimMargin()
)

View File

@@ -125,11 +125,16 @@ fun findImplementationFromInterface(descriptor: CallableMemberDescriptor): Calla
* The returned function should be called from TImpl-bridges generated for the given fake override.
*/
fun firstSuperMethodFromKotlin(
descriptor: CallableMemberDescriptor,
implementation: CallableMemberDescriptor
descriptor: CallableMemberDescriptor,
implementation: CallableMemberDescriptor
): CallableMemberDescriptor? {
return descriptor.overriddenDescriptors.firstOrNull { overridden ->
overridden.modality != Modality.ABSTRACT &&
(overridden == implementation || OverridingUtil.overrides(overridden, implementation, overridden.module.isTypeRefinementEnabled()))
(overridden == implementation || OverridingUtil.overrides(
overridden,
implementation,
overridden.module.isTypeRefinementEnabled(),
true
))
}
}

View File

@@ -1759,7 +1759,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!endsWithReturn(expr)) {
if (isLambdaVoidBody(expr, typeForExpression)) {
markLineNumber((KtFunctionLiteral) expr.getParent(), true);
} else if (!isLambdaBody(expr)){
}
else {
markLineNumber(expr, true);
}
@@ -1781,14 +1782,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
private static boolean isLambdaVoidBody(@NotNull KtElement bodyExpression, @NotNull Type returnType) {
return isLambdaBody(bodyExpression) && Type.VOID_TYPE.equals(returnType);
}
private static boolean isLambdaBody(@NotNull KtElement bodyExpression) {
if (bodyExpression instanceof KtBlockExpression) {
PsiElement parent = bodyExpression.getParent();
return parent instanceof KtFunctionLiteral;
if (parent instanceof KtFunctionLiteral) {
return Type.VOID_TYPE.equals(returnType);
}
}
return false;
}
@@ -2646,7 +2646,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
KotlinType returnType = resolvedCall.getResultingDescriptor().getReturnType();
if (returnType != null && KotlinBuiltIns.isNothing(returnType)) {
if (state.getUseKotlinNothingValueException()) {
if (state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_4) >= 0) {
v.anew(Type.getObjectType("kotlin/KotlinNothingValueException"));
v.dup();
v.invokespecial("kotlin/KotlinNothingValueException", "<init>", "()V", false);

View File

@@ -401,6 +401,14 @@ public class PropertyCodegen {
}
modifiers |= getVisibilityForBackingField(propertyDescriptor, isDelegate);
// If val is initialized in EXACTLY_ONCE closure, other class from the same package initializes it
// so, its visibility should be package private and not final
if (!propertyDescriptor.isVar() &&
bindingContext.get(BindingContext.FIELD_CAPTURED_IN_EXACLY_ONCE_CLOSURE, propertyDescriptor) != null
) {
modifiers &= ~(ACC_PRIVATE | ACC_FINAL);
}
if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) {
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
parentBodyCodegen.addCompanionObjectPropertyToCopy(propertyDescriptor, defaultValue);

View File

@@ -219,9 +219,6 @@ class GenerationState private constructor(
val generateOptimizedCallableReferenceSuperClasses =
languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 &&
!configuration.getBoolean(JVMConfigurationKeys.NO_OPTIMIZED_CALLABLE_REFERENCES)
val useKotlinNothingValueException =
languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 &&
!configuration.getBoolean(JVMConfigurationKeys.NO_KOTLIN_NOTHING_VALUE_EXCEPTION)
val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
val globalInlineContext: GlobalInlineContext = GlobalInlineContext(diagnostics)
val mappingsClassesForWhenByEnum: MappingsClassesForWhenByEnum = MappingsClassesForWhenByEnum(this)

View File

@@ -27,27 +27,9 @@ if "%_JAVACMD%"=="" set _JAVACMD=java
rem We use the value of the JAVA_OPTS environment variable if defined
if "%JAVA_OPTS%"=="" set JAVA_OPTS=-Xmx256M -Xms32M
rem Iterate through arguments and split them into java and kotlin ones
:loop
set _arg=%~1
if "%_arg%" == "" goto loopend
if "%_arg:~0,2%"=="-J" (
set JAVA_OPTS=%JAVA_OPTS% "%_arg:~2%"
) else (
if "%_arg:~0,2%"=="-D" (
set JAVA_OPTS=%JAVA_OPTS% "%_arg%"
) else (
set KOTLIN_OPTS=%KOTLIN_OPTS% "%_arg%"
)
)
shift
goto loop
:loopend
if "%_KOTLIN_RUNNER%"=="1" (
if not "%_KOTLIN_RUNNER%"=="" (
"%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
org.jetbrains.kotlin.runner.Main %*
) else (
SET _ADDITIONAL_CLASSPATH=
@@ -57,7 +39,7 @@ if "%_KOTLIN_RUNNER%"=="1" (
"%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar%_ADDITIONAL_CLASSPATH%" ^
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
%_KOTLIN_COMPILER% %*
)
exit /b %ERRORLEVEL%

View File

@@ -128,6 +128,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xir-only", description = "Disables pre-IR backend")
var irOnly: Boolean by FreezableVar(false)
@Argument(
value = "-Xir-module-name",
valueDescription = "<name>",
description = "Specify a compilation module name for IR backend"
)
var irModuleName: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xinclude",
valueDescription = "<path>",

View File

@@ -289,7 +289,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
Note that if interface delegation is used, all interface methods are delegated.
The only exception are methods annotated with the deprecated @JvmDefault annotation.
-Xjvm-default=disable Do not generate JVM default methods and prohibit @JvmDefault annotation usage.
The following modes are DEPRECATED:
-Xjvm-default=enable Allow usages of @JvmDefault; only generate the default method
for annotated method in the interface
(annotating an existing method can break binary compatibility)
@@ -347,12 +346,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var noOptimizedCallableReferences: Boolean by FreezableVar(false)
@Argument(
value = "-Xno-kotlin-nothing-value-exception",
description = "Do not use KotlinNothingValueException available since 1.4"
)
var noKotlinNothingValueException: Boolean by FreezableVar(false)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
@@ -363,12 +356,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
result[AnalysisFlags.ignoreDataFlowInAssert] = JVMAssertionsMode.fromString(assertionsMode) != JVMAssertionsMode.LEGACY
JvmDefaultMode.fromStringOrNull(jvmDefault)?.let {
result[JvmAnalysisFlags.jvmDefaultMode] = it
if (it == JvmDefaultMode.ENABLE || it == JvmDefaultMode.ENABLE_WITH_DEFAULT_IMPLS) {
collector.report(
CompilerMessageSeverity.WARNING,
"'-Xjvm-default=$jvmDefault' mode is deprecated. Please considering to switch to new modes: 'all' and 'all-compatibility'"
)
}
} ?: collector.report(
CompilerMessageSeverity.ERROR,
"Unknown @JvmDefault mode: $jvmDefault, " +

View File

@@ -19,12 +19,10 @@ package org.jetbrains.kotlin.cli.common.messages
import java.io.Serializable
data class CompilerMessageLocation private constructor(
val path: String,
val line: Int,
val column: Int,
val lineEnd: Int,
val columnEnd: Int,
val lineContent: String?
val path: String,
val line: Int,
val column: Int,
val lineContent: String?
) : Serializable {
override fun toString(): String =
path + (if (line != -1 || column != -1) " ($line:$column)" else "")
@@ -32,23 +30,12 @@ data class CompilerMessageLocation private constructor(
companion object {
@JvmStatic
fun create(path: String?): CompilerMessageLocation? =
create(path, -1, -1, null)
create(path, -1, -1, null)
@JvmStatic
fun create(path: String?, line: Int, column: Int, lineContent: String?): CompilerMessageLocation? =
if (path == null) null else CompilerMessageLocation(path, line, column, -1, -1, lineContent)
if (path == null) null else CompilerMessageLocation(path, line, column, lineContent)
@JvmStatic
fun create(
path: String?,
lineStart: Int,
columnStart: Int,
lineEnd: Int?,
columnEnd: Int?,
lineContent: String?
): CompilerMessageLocation? =
if (path == null) null else CompilerMessageLocation(path, lineStart, columnStart, lineEnd ?: -1, columnEnd ?: -1, lineContent)
private val serialVersionUID: Long = 8228357579L
private val serialVersionUID: Long = 8228357578L
}
}

View File

@@ -24,13 +24,16 @@ import kotlin.concurrent.write
data class LineId(override val no: Int, override val generation: Int, private val codeHash: Int) : ILineId, Serializable {
override fun compareTo(other: ILineId): Int = (other as? LineId)?.let { lineId ->
no.compareTo(lineId.no).takeIf { no -> no != 0 }
?: codeHash.compareTo(lineId.codeHash)
constructor(codeLine: ReplCodeLine): this(codeLine.no, codeLine.generation, codeLine.code.hashCode())
override fun compareTo(other: ILineId): Int = (other as? LineId)?.let {
no.compareTo(it.no).takeIf { it != 0 }
?: generation.compareTo(it.generation).takeIf { it != 0 }
?: codeHash.compareTo(it.codeHash)
} ?: -1 // TODO: check if it doesn't break something
companion object {
private const val serialVersionUID: Long = 8328354000L
private val serialVersionUID: Long = 8328353000L
}
}

View File

@@ -21,7 +21,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.write
open class GenericReplCompilingEvaluatorBase(
val compiler: ReplCompilerWithoutCheck,
val compiler: ReplCompiler,
val evaluator: ReplEvaluator,
private val fallbackScriptArgs: ScriptArgsWithTypes? = null
) : ReplFullEvaluator {
@@ -46,7 +46,7 @@ open class GenericReplCompilingEvaluatorBase(
}
ReplEvalResult.Error.CompileTime(compiled.message, compiled.location)
}
is ReplCompileResult.Incomplete -> ReplEvalResult.Incomplete(compiled.message)
is ReplCompileResult.Incomplete -> ReplEvalResult.Incomplete()
is ReplCompileResult.CompiledClasses -> {
val result = eval(state, compiled, scriptArgs, invokeWrapper)
when (result) {
@@ -75,6 +75,8 @@ open class GenericReplCompilingEvaluatorBase(
override fun eval(state: IReplStageState<*>, compileResult: ReplCompileResult.CompiledClasses, scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult =
evaluator.eval(state, compileResult, scriptArgs, invokeWrapper)
override fun check(state: IReplStageState<*>, codeLine: ReplCodeLine): ReplCheckResult = compiler.check(state, codeLine)
override fun compileToEvaluable(state: IReplStageState<*>, codeLine: ReplCodeLine, defaultScriptArgs: ScriptArgsWithTypes?): Pair<ReplCompileResult, Evaluable?> {
val compiled = compiler.compile(state, codeLine)
return when (compiled) {
@@ -94,7 +96,7 @@ open class GenericReplCompilingEvaluatorBase(
}
class GenericReplCompilingEvaluator(
compiler: ReplCompilerWithoutCheck,
compiler: ReplCompiler,
baseClasspath: Iterable<File>,
baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
fallbackScriptArgs: ScriptArgsWithTypes? = null,

View File

@@ -25,7 +25,7 @@ const val KOTLIN_SCRIPT_ENGINE_BINDINGS_KEY = "kotlin.script.engine"
abstract class KotlinJsr223JvmScriptEngineBase(protected val myFactory: ScriptEngineFactory) : AbstractScriptEngine(), ScriptEngine, Compilable {
protected abstract val replCompiler: ReplCompilerWithoutCheck
protected abstract val replCompiler: ReplCompiler
protected abstract val replEvaluator: ReplFullEvaluator
override fun eval(script: String, context: ScriptContext): Any? = compileAndEval(script, context)
@@ -72,7 +72,7 @@ abstract class KotlinJsr223JvmScriptEngineBase(protected val myFactory: ScriptEn
val result = replCompiler.compile(state, codeLine)
val compiled = when (result) {
is ReplCompileResult.Error -> throw ScriptException("Error${result.locationString()}: ${result.message}")
is ReplCompileResult.Incomplete -> throw ScriptException("Error: incomplete code; ${result.message}")
is ReplCompileResult.Incomplete -> throw ScriptException("error: incomplete code")
is ReplCompileResult.CompiledClasses -> result
}
return CompiledKotlinScript(this, codeLine, compiled)
@@ -103,7 +103,7 @@ abstract class KotlinJsr223JvmScriptEngineBase(protected val myFactory: ScriptEn
throw ScriptException(result.message, result.location.path, result.location.line, result.location.column)
else -> throw ScriptException(result.message)
}
is ReplEvalResult.Incomplete -> throw ScriptException("Error: incomplete code. ${result.message}")
is ReplEvalResult.Incomplete -> throw ScriptException("error: incomplete code")
is ReplEvalResult.HistoryMismatch -> throw ScriptException("Repl history mismatch at line: ${result.lineNo}")
}
}

View File

@@ -96,7 +96,7 @@ sealed class ReplCompileResult : Serializable {
companion object { private val serialVersionUID: Long = 2L }
}
class Incomplete(val message: String) : ReplCompileResult() {
class Incomplete : ReplCompileResult() {
companion object { private val serialVersionUID: Long = 1L }
}
@@ -110,9 +110,7 @@ sealed class ReplCompileResult : Serializable {
}
}
interface ReplCompilerWithoutCheck : ReplCompileAction, CreateReplStageStateAction
interface ReplCompiler : ReplCompilerWithoutCheck, ReplCheckAction
interface ReplCompiler : ReplCompileAction, ReplCheckAction, CreateReplStageStateAction
// --- eval
@@ -139,7 +137,7 @@ sealed class ReplEvalResult : Serializable {
companion object { private val serialVersionUID: Long = 1L }
}
class Incomplete(val message: String) : ReplEvalResult() {
class Incomplete : ReplEvalResult() {
companion object { private val serialVersionUID: Long = 1L }
}
@@ -177,7 +175,7 @@ interface ReplAtomicEvalAction {
invokeWrapper: InvokeWrapper? = null): ReplEvalResult
}
interface ReplAtomicEvaluator : ReplAtomicEvalAction
interface ReplAtomicEvaluator : ReplAtomicEvalAction, ReplCheckAction
interface ReplDelayedEvalAction {
fun compileToEvaluable(state: IReplStageState<*>,

View File

@@ -149,7 +149,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val outputFile = File(outputFilePath)
configurationJs.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile))
configurationJs.put(
CommonConfigurationKeys.MODULE_NAME,
arguments.irModuleName ?: FileUtil.getNameWithoutExtension(outputFile)
)
// TODO: in this method at least 3 different compiler configurations are used (original, env.configuration, jsConfig.configuration)
// Such situation seems a bit buggy...

View File

@@ -31,6 +31,6 @@ interface MessageCollectorBasedReporter : DiagnosticMessageReporter {
override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) = messageCollector.report(
AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity),
render,
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumnRange(diagnostic))
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumn(diagnostic))
)
}

View File

@@ -35,20 +35,18 @@ public class MessageUtil {
public static CompilerMessageLocation psiElementToMessageLocation(@Nullable PsiElement element) {
if (element == null) return null;
PsiFile file = element.getContainingFile();
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnRangeInPsiFile(file, element.getTextRange()));
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()));
}
@Nullable
public static CompilerMessageLocation psiFileToMessageLocation(
@NotNull PsiFile file,
@Nullable String defaultValue,
@NotNull PsiDiagnosticUtils.LineAndColumnRange range
@NotNull PsiDiagnosticUtils.LineAndColumn lineAndColumn
) {
VirtualFile virtualFile = file.getVirtualFile();
String path = virtualFile != null ? virtualFileToPath(virtualFile) : defaultValue;
PsiDiagnosticUtils.LineAndColumn start = range.getStart();
PsiDiagnosticUtils.LineAndColumn end = range.getEnd();
return CompilerMessageLocation.create(path, start.getLine(), start.getColumn(), end.getLine(), end.getColumn(), start.getLineContent());
return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn(), lineAndColumn.getLineContent());
}
@NotNull

View File

@@ -154,7 +154,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize)
put(JVMConfigurationKeys.EMIT_JVM_TYPE_ANNOTATIONS, arguments.emitJvmTypeAnnotations)
put(JVMConfigurationKeys.NO_OPTIMIZED_CALLABLE_REFERENCES, arguments.noOptimizedCallableReferences)
put(JVMConfigurationKeys.NO_KOTLIN_NOTHING_VALUE_EXCEPTION, arguments.noKotlinNothingValueException)
if (!JVMConstructorCallNormalizationMode.isSupportedValue(arguments.constructorCallNormalizationMode)) {
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(

View File

@@ -123,9 +123,9 @@ private class KlibMetadataDependencyContainer(
private class KlibModuleInfo(
override val name: Name,
val kotlinLibrary: KotlinLibrary,
private val dependOnKlibModules: List<ModuleInfo>
private val dependOnModules: List<ModuleInfo>
) : ModuleInfo {
override fun dependencies(): List<ModuleInfo> = dependOnKlibModules
override fun dependencies(): List<ModuleInfo> = dependOnModules
override fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns = ModuleInfo.DependencyOnBuiltIns.LAST
@@ -136,6 +136,12 @@ private class KlibMetadataDependencyContainer(
get() = CommonPlatformAnalyzerServices
}
private val mutableDependenciesForAllModuleDescriptors = mutableListOf<ModuleDescriptorImpl>().apply {
add(builtIns.builtInsModule)
}
private val mutableDependenciesForAllModules = mutableListOf<ModuleInfo>()
private val moduleDescriptorsForKotlinLibraries: Map<KotlinLibrary, ModuleDescriptorImpl> =
kotlinLibraries.keysToMap { library ->
val moduleHeader = parseModuleHeader(library.moduleHeaderData)
@@ -145,19 +151,20 @@ private class KlibMetadataDependencyContainer(
moduleName, storageManager, builtIns, moduleOrigin
)
}.also { result ->
val resultValues = result.values.toList()
val dependenciesForModuleDescriptors = resultValues + builtIns.builtInsModule
val resultValues = result.values
resultValues.forEach { module ->
module.setDependencies(dependenciesForModuleDescriptors)
module.setDependencies(mutableDependenciesForAllModuleDescriptors)
}
mutableDependenciesForAllModuleDescriptors.addAll(resultValues)
}
private val moduleInfosImpl: List<KlibModuleInfo> = mutableListOf<KlibModuleInfo>().apply {
addAll(
moduleDescriptorsForKotlinLibraries.map { (kotlinLibrary, moduleDescriptor) ->
KlibModuleInfo(moduleDescriptor.name, kotlinLibrary, this@apply)
KlibModuleInfo(moduleDescriptor.name, kotlinLibrary, mutableDependenciesForAllModules)
}
)
mutableDependenciesForAllModules.addAll(this@apply)
}
override val moduleInfos: List<ModuleInfo> get() = moduleInfosImpl
@@ -182,6 +189,14 @@ private class KlibMetadataDependencyContainer(
return moduleDescriptorsForKotlinLibraries.getValue(moduleInfo.kotlinLibrary)
}
override fun registerDependencyForAllModules(
moduleInfo: ModuleInfo,
descriptorForModule: ModuleDescriptorImpl
) {
mutableDependenciesForAllModules.add(moduleInfo)
mutableDependenciesForAllModuleDescriptors.add(descriptorForModule)
}
override fun packageFragmentProviderForModuleInfo(
moduleInfo: ModuleInfo
): PackageFragmentProvider? {

View File

@@ -119,7 +119,4 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> NO_OPTIMIZED_CALLABLE_REFERENCES =
CompilerConfigurationKey.create("Do not use optimized callable reference superclasses available from 1.4");
public static final CompilerConfigurationKey<Boolean> NO_KOTLIN_NOTHING_VALUE_EXCEPTION =
CompilerConfigurationKey.create("Do not use KotlinNothingValueException available since 1.4");
}

View File

@@ -8,12 +8,15 @@ package org.jetbrains.kotlin.daemon.client.experimental
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
import org.jetbrains.kotlin.daemon.client.KotlinRemoteReplCompilerClient
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.daemon.common.CompileServiceClientSide
import org.jetbrains.kotlin.daemon.common.experimental.findCallbackServerSocket
import org.jetbrains.kotlin.daemon.common.ReportCategory
import org.jetbrains.kotlin.daemon.common.ReportSeverity
import java.io.File
import java.util.concurrent.locks.ReentrantReadWriteLock
import org.jetbrains.kotlin.daemon.client.RemoteReplCompilerState
// TODO: reduce number of ports used then SOCKET_ANY_FREE_PORT is passed (same problem with other calls)

View File

@@ -388,28 +388,29 @@ object KotlinCompilerClient {
isEchoRead.acquire()
val stdoutThread =
thread {
try {
daemon.inputStream
.reader()
.forEachLine {
if (it == COMPILE_DAEMON_IS_READY_MESSAGE) {
reportingTargets.report(DaemonReportCategory.DEBUG, "Received the message signalling that the daemon is ready")
isEchoRead.release()
return@forEachLine
}
else {
reportingTargets.report(DaemonReportCategory.INFO, it, "daemon")
}
}
}
finally {
daemon.inputStream.close()
daemon.outputStream.close()
daemon.errorStream.close()
isEchoRead.release()
}
thread {
try {
daemon.inputStream
.reader()
.forEachLine {
if (Thread.currentThread().isInterrupted) return@forEachLine
if (it == COMPILE_DAEMON_IS_READY_MESSAGE) {
reportingTargets.report(DaemonReportCategory.DEBUG, "Received the message signalling that the daemon is ready")
isEchoRead.release()
return@forEachLine
} else {
reportingTargets.report(DaemonReportCategory.INFO, it, "daemon")
}
}
} catch (_: Throwable) {
// Ignore, assuming all exceptions as interrupt exceptions
} finally {
daemon.inputStream.close()
daemon.outputStream.close()
daemon.errorStream.close()
isEchoRead.release()
}
}
try {
// trying to wait for process
val daemonStartupTimeout = System.getProperty(COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY)?.let {
@@ -444,7 +445,7 @@ object KotlinCompilerClient {
// assuming that all important output is already done, the rest should be routed to the log by the daemon itself
if (stdoutThread.isAlive) {
// TODO: find better method to stop the thread, but seems it will require asynchronous consuming of the stream
stdoutThread.stop()
stdoutThread.interrupt()
}
reportingTargets.out?.flush()
}

View File

@@ -27,8 +27,8 @@ public final class Generic<T> : R|kotlin/Any| {
public final class InnerGeneric<A, B> : R|kotlin/Any| {
public constructor<A, B>(): R|test/InnerGeneric<A, B>|
public final inner class Inner<in C, D : R|A|, A, B> : R|kotlin/Any| {
public constructor<in C, D : R|A|>(): R|test/InnerGeneric.Inner<C, D, A, B>|
public final inner class Inner<in C, D : R|A|> : R|kotlin/Any| {
public constructor<in C, D : R|A|>(): R|test/InnerGeneric.Inner<C, D>|
}
@@ -38,4 +38,3 @@ public final class Simple : R|kotlin/Any| {
public constructor(): R|test/Simple|
}

View File

@@ -3,22 +3,21 @@ public final class Outer<E, F> : R|kotlin/Any| {
public constructor<E, F>(): R|test/Outer<E, F>|
public final inner class Inner<G, H, E, F> : R|kotlin/Any| {
public constructor<G, H>(): R|test/Outer.Inner<G, H, E, F>|
public final inner class Inner<G, H> : R|kotlin/Any| {
public constructor<G, H>(): R|test/Outer.Inner<G, H>|
public final inner class Inner3<I, G, H, E, F> : R|kotlin/Any| {
public final inner class Inner3<I> : R|kotlin/Any| {
public final fun foo(x: R|test/Outer.Inner<G, kotlin/Int, kotlin/String, F>|, y: R|test/Outer.Inner<E, kotlin/Double, E, F>|, z: R|test/Outer.Inner.Inner3<kotlin/Double, G, kotlin/Int, kotlin/String, F>|, w: R|test/Outer.Inner.Inner3<*, G, H, E, F>|): R|kotlin/Unit|
public constructor<I>(): R|test/Outer.Inner.Inner3<I, G, H, E, F>|
public constructor<I>(): R|test/Outer.Inner.Inner3<I>|
}
}
public final inner class Inner2<E, F> : R|kotlin/Any| {
public constructor(): R|test/Outer.Inner2<E, F>|
public final inner class Inner2 : R|kotlin/Any| {
public constructor(): R|test/Outer.Inner2|
}
}

View File

@@ -1,18 +1,18 @@
public final class A<TA> : R|kotlin/Any| {
public constructor<TA>(): R|test/A<TA>|
public final inner class B<TB, TA> : R|kotlin/Any| {
public constructor<TB>(): R|test/A.B<TB, TA>|
public final inner class B<TB> : R|kotlin/Any| {
public constructor<TB>(): R|test/A.B<TB>|
public final inner class C<TC, TB, TA> : R|kotlin/Any| {
public constructor<TC>(): R|test/A.B.C<TC, TB, TA>|
public final inner class C<TC> : R|kotlin/Any| {
public constructor<TC>(): R|test/A.B.C<TC>|
public final inner class D<TD, TC, TB, TA> : R|kotlin/Any| {
public final inner class D<TD> : R|kotlin/Any| {
public final fun bar(ta: R|TA|, tb: R|TB|, tc: R|TC|, td: R|TD|): R|test/A.B.C.D<TD, TC, TB, TA>|
public final fun <P1, P2, P3, P4> foo(p1: R|P1|, p2: R|P2|, p3: R|P3|, p4: R|P4|): R|kotlin/Nothing|
public constructor<TD>(): R|test/A.B.C.D<TD, TC, TB, TA>|
public constructor<TD>(): R|test/A.B.C.D<TD>|
}

View File

@@ -1,10 +1,9 @@
public final class InnerClassReferencesOuterTP<P> : R|kotlin/Any| {
public constructor<P>(): R|test/InnerClassReferencesOuterTP<P>|
public final inner class Inner<Q : R|P|, P> : R|kotlin/Any| {
public constructor<Q : R|P|>(): R|test/InnerClassReferencesOuterTP.Inner<Q, P>|
public final inner class Inner<Q : R|P|> : R|kotlin/Any| {
public constructor<Q : R|P|>(): R|test/InnerClassReferencesOuterTP.Inner<Q>|
}
}

View File

@@ -1,7 +1,7 @@
public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
public constructor<P>(): R|test/MembersReferenceOuterTP<P>|
public final inner class Inner<P> : R|kotlin/Any| {
public final inner class Inner : R|kotlin/Any| {
public final fun <Q : R|P|> f(): R|kotlin/Unit|
public final fun g(p: R|P|): R|P|
@@ -12,9 +12,8 @@ public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
public final val <Q : R|P|> R|Q|.w: R|Q|
public get(): R|Q|
public constructor(): R|test/MembersReferenceOuterTP.Inner<P>|
public constructor(): R|test/MembersReferenceOuterTP.Inner|
}
}

View File

@@ -19,11 +19,16 @@ FILE: constantValues.kt
public final val arrayNestedness: R|kotlin/Int| = R|<local>/arrayNestedness|
public get(): R|kotlin/Int|
public final fun component1(): R|ClassId|
public final fun component1(): R|ClassId| {
^component1 this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|
}
public final fun component2(): R|kotlin/Int|
public final fun component2(): R|kotlin/Int| {
^component2 this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|
}
public final fun copy(classId: R|ClassId| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|, arrayNestedness: R|kotlin/Int| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|): R|ClassLiteralValue|
public final fun copy(classId: R|ClassId| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|, arrayNestedness: R|kotlin/Int| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|): R|ClassLiteralValue| {
}
}
public final class ClassId : R|kotlin/Any| {
@@ -62,9 +67,12 @@ FILE: constantValues.kt
public final val arrayDimensions: R|kotlin/Int|
public get(): R|kotlin/Int|
public final fun component1(): R|ClassLiteralValue|
public final fun component1(): R|ClassLiteralValue| {
^component1 this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|
}
public final fun copy(value: R|ClassLiteralValue| = this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|): R|KClassValue.Value.NormalClass|
public final fun copy(value: R|ClassLiteralValue| = this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|): R|KClassValue.Value.NormalClass| {
}
}
@@ -76,9 +84,12 @@ FILE: constantValues.kt
public final val type: R|KotlinType| = R|<local>/type|
public get(): R|KotlinType|
public final fun component1(): R|KotlinType|
public final fun component1(): R|KotlinType| {
^component1 this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|
}
public final fun copy(type: R|KotlinType| = this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|): R|KClassValue.Value.LocalClass|
public final fun copy(type: R|KotlinType| = this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|): R|KClassValue.Value.LocalClass| {
}
}

View File

@@ -1,27 +0,0 @@
// FILE: AJava.java
public class AJava {
public AJava(String s) {}
}
// FILE: main.kt
class BJava : AJava, C {
constructor(s: String) : super(s)
}
open class AKt(val s: String)
class BKt : AKt, C {
constructor(s: String) : super(s)
}
interface C
typealias QQQ = AKt
typealias DDD = C
class CKt : QQQ, DDD {
constructor(s: String) : super(s)
}

View File

@@ -1,32 +0,0 @@
FILE: main.kt
public final class BJava : R|AJava|, R|C| {
public constructor(s: R|kotlin/String|): R|BJava| {
super<R|AJava|>(R|<local>/s|)
}
}
public open class AKt : R|kotlin/Any| {
public constructor(s: R|kotlin/String|): R|AKt| {
super<R|kotlin/Any|>()
}
public final val s: R|kotlin/String| = R|<local>/s|
public get(): R|kotlin/String|
}
public final class BKt : R|AKt|, R|C| {
public constructor(s: R|kotlin/String|): R|BKt| {
super<R|AKt|>(R|<local>/s|)
}
}
public abstract interface C : R|kotlin/Any| {
}
public final typealias QQQ = R|AKt|
public final typealias DDD = R|C|
public final class CKt : R|QQQ|, R|DDD| {
public constructor(s: R|kotlin/String|): R|CKt| {
super<R|QQQ|>(R|<local>/s|)
}
}

View File

@@ -10,11 +10,16 @@ FILE: copy.kt
public final val y: R|kotlin/String| = R|<local>/y|
public get(): R|kotlin/String|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/Some|.R|/Some.x|
}
public final fun component2(): R|kotlin/String|
public final fun component2(): R|kotlin/String| {
^component2 this@R|/Some|.R|/Some.y|
}
public final fun copy(x: R|kotlin/Int| = this@R|/Some|.R|/Some.x|, y: R|kotlin/String| = this@R|/Some|.R|/Some.y|): R|Some|
public final fun copy(x: R|kotlin/Int| = this@R|/Some|.R|/Some.x|, y: R|kotlin/String| = this@R|/Some|.R|/Some.y|): R|Some| {
}
}
public final fun test(some: R|Some|): R|kotlin/Unit| {

View File

@@ -8,7 +8,7 @@ FILE: LinkedList.kt
FILE: HashSet.kt
public final class HashSet<T> : R|java/util/HashSet<T>| {
public constructor<T>(): R|util/HashSet<T>| {
super<R|java/util/HashSet<T>|>()
super<R|kotlin/Any|>()
}
}

View File

@@ -51,9 +51,12 @@ FILE: incompatibleModifiers.kt
public final val i: R|kotlin/Int| = R|<local>/i|
public get(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/H|.R|/H.i|
}
public final fun copy(i: R|kotlin/Int| = this@R|/H|.R|/H.i|): R|H|
public final fun copy(i: R|kotlin/Int| = this@R|/H|.R|/H.i|): R|H| {
}
}
public sealed data class I : R|kotlin/Any| {
@@ -64,9 +67,12 @@ FILE: incompatibleModifiers.kt
public final val i: R|kotlin/Int| = R|<local>/i|
public get(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/I|.R|/I.i|
}
public final fun copy(i: R|kotlin/Int| = this@R|/I|.R|/I.i|): R|I|
public final fun copy(i: R|kotlin/Int| = this@R|/I|.R|/I.i|): R|I| {
}
}
public final data inline class J : R|kotlin/Any| {
@@ -77,9 +83,12 @@ FILE: incompatibleModifiers.kt
public final val i: R|kotlin/Int| = R|<local>/i|
public get(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/J|.R|/J.i|
}
public final fun copy(i: R|kotlin/Int| = this@R|/J|.R|/J.i|): R|J|
public final fun copy(i: R|kotlin/Int| = this@R|/J|.R|/J.i|): R|J| {
}
}
public abstract class K : R|kotlin/Any| {
@@ -119,9 +128,12 @@ FILE: incompatibleModifiers.kt
public final val i: R|kotlin/Int| = R|<local>/i|
public get(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/X.Y|.R|/X.Y.i|
}
public final fun copy(i: R|kotlin/Int| = this@R|/X.Y|.R|/X.Y.i|): R|X.Y|
public final fun copy(i: R|kotlin/Int| = this@R|/X.Y|.R|/X.Y.i|): R|X.Y| {
}
}

View File

@@ -10,7 +10,7 @@ FILE: notASupertype.kt
}
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
super<R|kotlin/Any|>()
}
public final fun g(): R|kotlin/Unit| {

View File

@@ -13,7 +13,7 @@ FILE: checkArguments.kt
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
super<R|kotlin/Any|>()
}
}

View File

@@ -1,7 +1,7 @@
FILE: test.kt
public final class MyDecorator : R|Decorator<LookupElement>| {
public constructor(): R|MyDecorator| {
super<R|Decorator<LookupElement>|>()
super<R|kotlin/Any|>()
}
public final override fun getLookupString(): R|kotlin/String| {

View File

@@ -4,8 +4,8 @@ FILE: complexTypes.kt
super<R|kotlin/Any|>()
}
public final inner class D<R, in P, T, out S> : R|kotlin/Any| {
public constructor<R, in P>(): R|a/b/C.D<R, P, T, S>| {
public final inner class D<R, in P> : R|kotlin/Any| {
public constructor<R, in P>(): R|a/b/C.D<R, P>| {
super<R|kotlin/Any|>()
}
@@ -13,7 +13,7 @@ FILE: complexTypes.kt
}
public abstract interface Test : R|kotlin/Any| {
public abstract val x: R|a/b/C.D<in kotlin/collections/List<*>, *, out kotlin/CharSequence, *>|
public get(): R|a/b/C.D<in kotlin/collections/List<*>, *, out kotlin/CharSequence, *>|
public abstract val x: R|a/b/C.D<out kotlin/CharSequence, *, in kotlin/collections/List<*>, *>|
public get(): R|a/b/C.D<out kotlin/CharSequence, *, in kotlin/collections/List<*>, *>|
}

View File

@@ -13,7 +13,7 @@ FILE: test.kt
public final class Extra : R|test/Test| {
public constructor(x: R|kotlin/Int|): R|test/Test.Extra| {
super<R|test/Test|>()
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int| = R|<local>/x|

View File

@@ -1,21 +0,0 @@
class Outer<T> {
inner class Inner<K>
}
class Boxed<Q> {
fun substitute() = Outer<Q>().Inner<Int>()
}
fun accept(p: Outer<String>.Inner<Int>) {}
val rr = Outer<String>().Inner<Int>()
val rrq = Boxed<String>().substitute()
fun check() {
<!INAPPLICABLE_CANDIDATE!>accept<!>(Outer<Int>().Inner<Int>()) // illegal
<!INAPPLICABLE_CANDIDATE!>accept<!>(Outer<String>().Inner<String>()) // illegal
accept(Outer<String>().Inner<Int>()) // ok
<!INAPPLICABLE_CANDIDATE!>accept<!>(Boxed<Int>().substitute()) // illegal
accept(Boxed<String>().substitute()) // ok
}

View File

@@ -1,37 +0,0 @@
FILE: innerTypes.kt
public final class Outer<T> : R|kotlin/Any| {
public constructor<T>(): R|Outer<T>| {
super<R|kotlin/Any|>()
}
public final inner class Inner<K, T> : R|kotlin/Any| {
public constructor<K>(): R|Outer.Inner<K, T>| {
super<R|kotlin/Any|>()
}
}
}
public final class Boxed<Q> : R|kotlin/Any| {
public constructor<Q>(): R|Boxed<Q>| {
super<R|kotlin/Any|>()
}
public final fun substitute(): R|Outer.Inner<kotlin/Int, Q>| {
^substitute R|/Outer.Outer|<R|Q|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>()
}
}
public final fun accept(p: R|Outer.Inner<kotlin/Int, kotlin/String>|): R|kotlin/Unit| {
}
public final val rr: R|Outer.Inner<kotlin/Int, kotlin/String>| = R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>()
public get(): R|Outer.Inner<kotlin/Int, kotlin/String>|
public final val rrq: R|Outer.Inner<kotlin/Int, kotlin/String>| = R|/Boxed.Boxed|<R|kotlin/String|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/Int, kotlin/String>|>|()
public get(): R|Outer.Inner<kotlin/Int, kotlin/String>|
public final fun check(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Outer.Outer|<R|kotlin/Int|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>())
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/String|>())
R|/accept|(R|/Outer.Outer|<R|kotlin/String|>().R|/Outer.Inner.Inner|<R|kotlin/Int|>())
<Inapplicable(INAPPLICABLE): [/accept]>#(R|/Boxed.Boxed|<R|kotlin/Int|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/Int, kotlin/Int>|>|())
R|/accept|(R|/Boxed.Boxed|<R|kotlin/String|>().R|FakeOverride</Boxed.substitute: R|Outer.Inner<kotlin/Int, kotlin/String>|>|())
}

View File

@@ -42,13 +42,20 @@ FILE: problems2.kt
public final val s: R|kotlin/String?| = R|<local>/s|
public get(): R|kotlin/String?|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|
}
public final fun component2(): R|kotlin/Array<kotlin/String>?|
public final fun component2(): R|kotlin/Array<kotlin/String>?| {
^component2 this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|
}
public final fun component3(): R|kotlin/String?|
public final fun component3(): R|kotlin/String?| {
^component3 this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|
}
public final fun copy(x: R|kotlin/Int| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|, arr: R|kotlin/Array<kotlin/String>?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|, s: R|kotlin/String?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|): R|Some.WithPrimary|
public final fun copy(x: R|kotlin/Int| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|, arr: R|kotlin/Array<kotlin/String>?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|, s: R|kotlin/String?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|): R|Some.WithPrimary| {
}
}

View File

@@ -1,9 +0,0 @@
fun Short.foo(): Int = 1
fun Int.foo(): Int = 2
fun testRef(f: () -> Int) {}
fun test() {
// should resolve to Int.foo
testRef(1::foo)
}

View File

@@ -1,12 +0,0 @@
FILE: integerLiteralInLhs.kt
public final fun R|kotlin/Short|.foo(): R|kotlin/Int| {
^foo Int(1)
}
public final fun R|kotlin/Int|.foo(): R|kotlin/Int| {
^foo Int(2)
}
public final fun testRef(f: R|() -> kotlin/Int|): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
R|/testRef|(Int(1)::R|/foo|)
}

View File

@@ -6,8 +6,8 @@ FILE: typeParameterVsNested.kt
super<R|kotlin/Any|>()
}
public final inner class T<T : R|test/Some|> : R|kotlin/Any| {
public constructor(): R|test/My.T<T>| {
public final inner class T : R|kotlin/Any| {
public constructor(): R|test/My.T| {
super<R|kotlin/Any|>()
}

View File

@@ -6,14 +6,14 @@ fun IB.extFun(x: IA) {}
fun test() {
val extFun1 = IA::extFun
val extFun2 = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun2 = IB::extFun
}
fun testWithExpectedType() {
// NB: should be resolved to kotlin/FunctionX, not kotlin/reflect/FunctionX
val extFun_AB_A: IA.(IB) -> Unit = IA::extFun
val extFun_AA_B: IA.(IA) -> Unit = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun_AA_B: IA.(IA) -> Unit = IB::extFun
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
val extFun_BB_B: IB.(IB) -> Unit = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
val extFun_BB_B: IB.(IB) -> Unit = IB::extFun
}

View File

@@ -9,12 +9,12 @@ FILE: moreSpecificAmbiguousExtensions.kt
}
public final fun test(): R|kotlin/Unit| {
lval extFun1: R|kotlin/reflect/KFunction2<IA, IB, kotlin/Unit>| = Q|IA|::R|/extFun|
lval extFun2: <ERROR TYPE REF: No result type for initializer> = Q|IB|::<Unresolved reference: extFun>#
lval extFun2: R|kotlin/reflect/KFunction2<IB, IB, kotlin/Unit>| = Q|IB|::R|/extFun|
}
public final fun testWithExpectedType(): R|kotlin/Unit| {
lval extFun_AB_A: R|IA.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun|
lval extFun_BB_A: R|IB.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
lval extFun_BA_B: R|IB.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun|
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::R|/extFun|
}

View File

@@ -10,11 +10,16 @@ FILE: components.kt
public final val y: R|kotlin/String| = R|<local>/y|
public get(): R|kotlin/String|
public final fun component1(): R|kotlin/Int|
public final fun component1(): R|kotlin/Int| {
^component1 this@R|/D|.R|/D.x|
}
public final fun component2(): R|kotlin/String|
public final fun component2(): R|kotlin/String| {
^component2 this@R|/D|.R|/D.y|
}
public final fun copy(x: R|kotlin/Int| = this@R|/D|.R|/D.x|, y: R|kotlin/String| = this@R|/D|.R|/D.y|): R|D|
public final fun copy(x: R|kotlin/Int| = this@R|/D|.R|/D.x|, y: R|kotlin/String| = this@R|/D|.R|/D.y|): R|D| {
}
}
public final fun foo(list: R|kotlin/collections/List<D>|): R|kotlin/Unit| {

View File

@@ -1,88 +0,0 @@
digraph atLeastOnce_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function inlineRun" style="filled" fillcolor=red];
2 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
1 [label="Exit function inlineRun" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {1};
subgraph cluster_1 {
color=red
3 [label="Enter function myRun" style="filled" fillcolor=red];
5 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
4 [label="Exit function myRun" style="filled" fillcolor=red];
}
3 -> {5};
5 -> {4};
subgraph cluster_2 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
8 [label="Variable declaration: lval x: R|kotlin/Int|"];
9 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
14 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
16 [label="Const: Int(1)"];
17 [label="Assignment: R|<local>/x|"];
15 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
10 [label="Postponed exit from lambda"];
11 [label="Function call: R|/inlineRun|(...)"];
12 [label="Access variable R|<local>/x|"];
13 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
7 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {8};
8 -> {9};
9 -> {14};
9 -> {10} [color=red];
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {7};
14 -> {16};
15 -> {14};
15 -> {10} [color=green];
16 -> {17};
17 -> {15};
subgraph cluster_4 {
color=red
18 [label="Enter function test_2" style="filled" fillcolor=red];
20 [label="Variable declaration: lval x: R|kotlin/Int|"];
21 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
28 [label="Const: Int(1)"];
29 [label="Assignment: R|<local>/x|"];
27 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
22 [label="Postponed exit from lambda"];
23 [label="Function call: R|/myRun|(...)"];
24 [label="Access variable R|<local>/x|"];
25 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
19 [label="Exit function test_2" style="filled" fillcolor=red];
}
18 -> {20};
20 -> {21};
21 -> {26};
21 -> {22} [color=red];
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {19};
26 -> {28};
27 -> {26};
27 -> {22} [color=green];
28 -> {29};
29 -> {27};
}

View File

@@ -1,33 +0,0 @@
// !DUMP_CFG
import kotlin.contracts.*
inline fun inlineRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
}
block()
}
fun myRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
}
block()
}
fun test_1() {
val x: Int
inlineRun {
x = 1
}
x.inc()
}
fun test_2() {
val x: Int
myRun {
x = 1
}
x.inc()
}

View File

@@ -1,35 +0,0 @@
FILE: atLeastOnce.kt
public final inline fun inlineRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, AT_LEAST_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun myRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, AT_LEAST_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_1(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/inlineRun|(<L> = inlineRun@fun <anonymous>(): R|kotlin/Unit| <kind=AT_LEAST_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/myRun|(<L> = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=AT_LEAST_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}

View File

@@ -1,86 +0,0 @@
digraph atMostOnce_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function inlineRun" style="filled" fillcolor=red];
2 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
1 [label="Exit function inlineRun" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {1};
subgraph cluster_1 {
color=red
3 [label="Enter function myRun" style="filled" fillcolor=red];
5 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
4 [label="Exit function myRun" style="filled" fillcolor=red];
}
3 -> {5};
5 -> {4};
subgraph cluster_2 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
8 [label="Variable declaration: lval x: R|kotlin/Int|"];
9 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
14 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
16 [label="Const: Int(1)"];
17 [label="Assignment: R|<local>/x|"];
15 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
10 [label="Postponed exit from lambda"];
11 [label="Function call: R|/inlineRun|(...)"];
12 [label="Access variable R|<local>/x|"];
13 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
7 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {8};
8 -> {9};
9 -> {14};
9 -> {10} [color=red];
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {7};
14 -> {15 16};
15 -> {10} [color=green];
16 -> {17};
17 -> {15};
subgraph cluster_4 {
color=red
18 [label="Enter function test_2" style="filled" fillcolor=red];
20 [label="Variable declaration: lval x: R|kotlin/Int|"];
21 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
28 [label="Const: Int(1)"];
29 [label="Assignment: R|<local>/x|"];
27 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
22 [label="Postponed exit from lambda"];
23 [label="Function call: R|/myRun|(...)"];
24 [label="Access variable R|<local>/x|"];
25 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
19 [label="Exit function test_2" style="filled" fillcolor=red];
}
18 -> {20};
20 -> {21};
21 -> {26};
21 -> {22} [color=red];
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {19};
26 -> {27 28};
27 -> {22} [color=green];
28 -> {29};
29 -> {27};
}

View File

@@ -1,33 +0,0 @@
// !DUMP_CFG
import kotlin.contracts.*
inline fun inlineRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
block()
}
fun myRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
}
block()
}
fun test_1() {
val x: Int
inlineRun {
x = 1
}
x.inc()
}
fun test_2() {
val x: Int
myRun {
x = 1
}
x.inc()
}

View File

@@ -1,35 +0,0 @@
FILE: atMostOnce.kt
public final inline fun inlineRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, AT_MOST_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun myRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, AT_MOST_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_1(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/inlineRun|(<L> = inlineRun@fun <anonymous>(): R|kotlin/Unit| <kind=AT_MOST_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/myRun|(<L> = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=AT_MOST_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}

View File

@@ -1,92 +0,0 @@
digraph exactlyOnce_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function inlineRun" style="filled" fillcolor=red];
2 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
1 [label="Exit function inlineRun" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {1};
subgraph cluster_1 {
color=red
3 [label="Enter function myRun" style="filled" fillcolor=red];
5 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
4 [label="Exit function myRun" style="filled" fillcolor=red];
}
3 -> {5};
5 -> {4};
subgraph cluster_2 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
8 [label="Variable declaration: lval x: R|kotlin/Int|"];
9 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
15 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
17 [label="Const: Int(1)"];
18 [label="Assignment: R|<local>/x|"];
16 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
12 [label="Call arguments union" style="filled" fillcolor=yellow];
10 [label="Postponed exit from lambda"];
11 [label="Function call: R|/inlineRun|(...)"];
13 [label="Access variable R|<local>/x|"];
14 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
7 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {8};
8 -> {9};
9 -> {15};
9 -> {10} [color=red];
10 -> {11} [color=green];
11 -> {13};
12 -> {11} [color=red];
13 -> {14};
14 -> {7};
15 -> {17};
16 -> {10} [color=green];
16 -> {12} [color=red];
17 -> {18};
18 -> {16};
subgraph cluster_4 {
color=red
19 [label="Enter function test_2" style="filled" fillcolor=red];
21 [label="Variable declaration: lval x: R|kotlin/Int|"];
22 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
28 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
30 [label="Const: Int(1)"];
31 [label="Assignment: R|<local>/x|"];
29 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
25 [label="Call arguments union" style="filled" fillcolor=yellow];
23 [label="Postponed exit from lambda"];
24 [label="Function call: R|/myRun|(...)"];
26 [label="Access variable R|<local>/x|"];
27 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
20 [label="Exit function test_2" style="filled" fillcolor=red];
}
19 -> {21};
21 -> {22};
22 -> {28};
22 -> {23} [color=red];
23 -> {24} [color=green];
24 -> {26};
25 -> {24} [color=red];
26 -> {27};
27 -> {20};
28 -> {30};
29 -> {23} [color=green];
29 -> {25} [color=red];
30 -> {31};
31 -> {29};
}

View File

@@ -1,33 +0,0 @@
// !DUMP_CFG
import kotlin.contracts.*
inline fun inlineRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
fun myRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
fun test_1() {
val x: Int
inlineRun {
x = 1
}
x.inc()
}
fun test_2() {
val x: Int
myRun {
x = 1
}
x.inc()
}

View File

@@ -1,35 +0,0 @@
FILE: exactlyOnce.kt
public final inline fun inlineRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, EXACTLY_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun myRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, EXACTLY_ONCE)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_1(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/inlineRun|(<L> = inlineRun@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/myRun|(<L> = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}

View File

@@ -1,88 +0,0 @@
digraph unknown_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function inlineRun" style="filled" fillcolor=red];
2 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
1 [label="Exit function inlineRun" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {1};
subgraph cluster_1 {
color=red
3 [label="Enter function myRun" style="filled" fillcolor=red];
5 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
4 [label="Exit function myRun" style="filled" fillcolor=red];
}
3 -> {5};
5 -> {4};
subgraph cluster_2 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
8 [label="Variable declaration: lval x: R|kotlin/Int|"];
9 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
14 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
16 [label="Const: Int(1)"];
17 [label="Assignment: R|<local>/x|"];
15 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
10 [label="Postponed exit from lambda"];
11 [label="Function call: R|/inlineRun|(...)"];
12 [label="Access variable R|<local>/x|"];
13 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
7 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {8};
8 -> {9};
9 -> {14};
9 -> {10} [color=red];
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {7};
14 -> {15 16};
15 -> {14};
15 -> {10} [color=green];
16 -> {17};
17 -> {15};
subgraph cluster_4 {
color=red
18 [label="Enter function test_2" style="filled" fillcolor=red];
20 [label="Variable declaration: lval x: R|kotlin/Int|"];
21 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
28 [label="Const: Int(1)"];
29 [label="Assignment: R|<local>/x|"];
27 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
22 [label="Postponed exit from lambda"];
23 [label="Function call: R|/myRun|(...)"];
24 [label="Access variable R|<local>/x|"];
25 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
19 [label="Exit function test_2" style="filled" fillcolor=red];
}
18 -> {20};
20 -> {21};
21 -> {26};
21 -> {22} [color=red];
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {19};
26 -> {27 28};
27 -> {26};
27 -> {22} [color=green];
28 -> {29};
29 -> {27};
}

View File

@@ -1,33 +0,0 @@
// !DUMP_CFG
import kotlin.contracts.*
inline fun inlineRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.UNKNOWN)
}
block()
}
fun myRun(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.UNKNOWN)
}
block()
}
fun test_1() {
val x: Int
inlineRun {
x = 1
}
x.inc()
}
fun test_2() {
val x: Int
myRun {
x = 1
}
x.inc()
}

View File

@@ -1,35 +0,0 @@
FILE: unknown.kt
public final inline fun inlineRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, UNKNOWN)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun myRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit|
[R|Contract description]
<
CallsInPlace(block, UNKNOWN)
>
{
[StubStatement]
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_1(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/inlineRun|(<L> = inlineRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|/myRun|(<L> = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}

View File

@@ -1,69 +0,0 @@
import kotlin.contracts.*
fun myRequire(b: Boolean) {
contract {
returns() implies (b)
}
if (!b) throw IllegalStateException()
}
fun myRequireAnd(b1: Boolean, b2: Boolean) {
contract {
returns() implies (b1 && b2)
}
if (!(b1 && b2)) throw IllegalStateException()
}
fun myRequireOr(b1: Boolean, b2: Boolean) {
contract {
returns() implies (b1 || b2)
}
if (!(b1 || b2)) throw IllegalStateException()
}
fun myRequireNot(b: Boolean) {
contract {
returns() implies (!b)
}
if (b) throw IllegalStateException()
}
// ----------------------------------------------------
interface A {
fun foo()
}
interface B : A {
fun bar()
}
interface C : A {
fun baz()
}
// ----------------------------------------------------
fun test_1(x: Any) {
myRequire(x is A)
x.foo()
}
fun test_2(x: Any) {
myRequireAnd(x is B, x is C)
x.foo()
x.bar()
x.baz()
}
fun test_3(x: Any) {
myRequireOr(x is B, x is C)
x.foo() // OK
x.<!UNRESOLVED_REFERENCE!>bar<!>() // Error
x.<!UNRESOLVED_REFERENCE!>baz<!>() // Error
}
fun test_4(x: Any) {
myRequireNot(x !is A)
x.foo()
}

View File

@@ -1,89 +0,0 @@
FILE: booleanOperators.kt
public final fun myRequire(b: R|kotlin/Boolean|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> b
>
{
[StubStatement]
when () {
R|<local>/b|.R|kotlin/Boolean.not|() -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun myRequireAnd(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> (b1) && (b2)
>
{
[StubStatement]
when () {
R|<local>/b1| && R|<local>/b2|.R|kotlin/Boolean.not|() -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun myRequireOr(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> (b1) || (b2)
>
{
[StubStatement]
when () {
R|<local>/b1| || R|<local>/b2|.R|kotlin/Boolean.not|() -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun myRequireNot(b: R|kotlin/Boolean|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> (!)b
>
{
[StubStatement]
when () {
R|<local>/b| -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface B : R|A| {
public abstract fun bar(): R|kotlin/Unit|
}
public abstract interface C : R|A| {
public abstract fun baz(): R|kotlin/Unit|
}
public final fun test_1(x: R|kotlin/Any|): R|kotlin/Unit| {
R|/myRequire|((R|<local>/x| is R|A|))
R|<local>/x|.R|/A.foo|()
}
public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| {
R|/myRequireAnd|((R|<local>/x| is R|B|), (R|<local>/x| is R|C|))
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|/C.baz|()
}
public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| {
R|/myRequireOr|((R|<local>/x| is R|B|), (R|<local>/x| is R|C|))
R|<local>/x|.R|/A.foo|()
R|<local>/x|.<Unresolved name: bar>#()
R|<local>/x|.<Unresolved name: baz>#()
}
public final fun test_4(x: R|kotlin/Any|): R|kotlin/Unit| {
R|/myRequireNot|((R|<local>/x| !is R|A|))
R|<local>/x|.R|/A.foo|()
}

View File

@@ -1,31 +0,0 @@
import kotlin.contracts.*
fun checkNotNull(x: Any?) {
contract {
returns(true) implies (x != null)
returns(false) implies (x == null)
}
return x != null
}
fun trickyRequireNotNull(x: Any?) {
contract {
returns() implies (!(x == null))
}
if (x == null) {
throw IllegalStateException()
}
}
fun test_1(x: String?) {
if (checkNotNull(x)) {
x.length // OK
} else {
x.<!INAPPLICABLE_CANDIDATE!>length<!> // Error
}
}
fun test_2(x: String?) {
trickyRequireNotNull(x)
x.length
}

View File

@@ -1,40 +0,0 @@
FILE: eqNotEq.kt
public final fun checkNotNull(x: R|kotlin/Any?|): R|kotlin/Unit|
[R|Contract description]
<
Returns(TRUE) -> x != null
Returns(FALSE) -> x == null
>
{
[StubStatement]
^checkNotNull !=(R|<local>/x|, Null(null))
}
public final fun trickyRequireNotNull(x: R|kotlin/Any?|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> !x == null
>
{
[StubStatement]
when () {
==(R|<local>/x|, Null(null)) -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun test_1(x: R|kotlin/String?|): R|kotlin/Unit| {
when () {
R|/checkNotNull|(R|<local>/x|) -> {
R|<local>/x|.R|kotlin/String.length|
}
else -> {
R|<local>/x|.<Inapplicable(WRONG_RECEIVER): [kotlin/String.length]>#
}
}
}
public final fun test_2(x: R|kotlin/String?|): R|kotlin/Unit| {
R|/trickyRequireNotNull|(R|<local>/x|)
R|<local>/x|.R|kotlin/String.length|
}

View File

@@ -1,29 +0,0 @@
import kotlin.contracts.*
fun foo(x: Any, y: Any) {
contract {
returns() implies (x is Int && y is String)
}
if (x !is Int || y !is String) {
throw IllegalStateException()
}
}
fun test_1(x: Any, y: Any) {
foo(x = x, y = y)
x.inc()
y.length
}
fun test_2(x: Any, y: Any) {
foo(x, y = y)
x.inc()
y.length
}
fun test_3(x: Any, y: Any) {
foo(y = y, x = x)
x.inc()
y.length
}

View File

@@ -1,30 +0,0 @@
FILE: namedArguments.kt
public final fun foo(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> x is kotlin/Int && y is kotlin/String
>
{
[StubStatement]
when () {
(R|<local>/x| !is R|kotlin/Int|) || (R|<local>/y| !is R|kotlin/String|) -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun test_1(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
R|/foo|(x = R|<local>/x|, y = R|<local>/y|)
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|kotlin/String.length|
}
public final fun test_2(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
R|/foo|(R|<local>/x|, y = R|<local>/y|)
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|kotlin/String.length|
}
public final fun test_3(x: R|kotlin/Any|, y: R|kotlin/Any|): R|kotlin/Unit| {
R|/foo|(y = R|<local>/y|, x = R|<local>/x|)
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|kotlin/String.length|
}

View File

@@ -1,30 +0,0 @@
import kotlin.contracts.*
interface A {
fun foo()
}
var Any?.isNotNull: Boolean
get() {
contract {
returns(true) implies (this@isNotNull != null)
}
return this != null
}
set(value) {
contract {
returns() implies (this@isNotNull != null)
require(this != null)
}
}
fun test_1(a: A?) {
if (a.isNotNull) {
a.foo()
}
}
fun test_2(a: A?) {
a.isNotNull = true
a.foo()
}

View File

@@ -1,35 +0,0 @@
FILE: propertyAccessors.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public final var R|kotlin/Any?|.isNotNull: R|kotlin/Boolean|
public get(): R|kotlin/Boolean|
[R|Contract description]
<
Returns(TRUE) -> this != null
>
{
[StubStatement]
^ !=(this@R|/isNotNull|, Null(null))
}
public set(value: R|kotlin/Boolean|): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> this != null
>
{
[StubStatement]
}
public final fun test_1(a: R|A?|): R|kotlin/Unit| {
when () {
R|<local>/a|.R|/isNotNull| -> {
R|<local>/a|.R|/A.foo|()
}
}
}
public final fun test_2(a: R|A?|): R|kotlin/Unit| {
R|<local>/a|.R|/isNotNull| = Boolean(true)
R|<local>/a|.R|/A.foo|()
}

View File

@@ -1,43 +0,0 @@
import kotlin.contracts.*
interface A
fun A.foo() {}
fun Any?.myRequireNotNull() {
contract {
returns() implies (this@myRequireNotNull != null)
}
if (this == null) throw IllegalStateException()
}
fun test_1(x: A?) {
x.myRequireNotNull()
x.foo()
}
fun test_2(x: A?) {
x.myRequireNotNull()
with(x) {
foo()
}
}
fun test_3(x: A?) {
with(x) {
myRequireNotNull()
}
x.<!INAPPLICABLE_CANDIDATE!>foo<!>()
}
fun test_4(x: A?) {
with(x) {
myRequireNotNull()
foo()
}
}
fun A?.test_5() {
myRequireNotNull()
foo()
}

View File

@@ -1,48 +0,0 @@
FILE: receivers.kt
public abstract interface A : R|kotlin/Any| {
}
public final fun R|A|.foo(): R|kotlin/Unit| {
}
public final fun R|kotlin/Any?|.myRequireNotNull(): R|kotlin/Unit|
[R|Contract description]
<
Returns(WILDCARD) -> this != null
>
{
[StubStatement]
when () {
==(this@R|/myRequireNotNull|, Null(null)) -> {
throw R|java/lang/IllegalStateException.IllegalStateException|()
}
}
}
public final fun test_1(x: R|A?|): R|kotlin/Unit| {
R|<local>/x|.R|/myRequireNotNull|()
R|<local>/x|.R|/foo|()
}
public final fun test_2(x: R|A?|): R|kotlin/Unit| {
R|<local>/x|.R|/myRequireNotNull|()
R|kotlin/with|<R|A|, R|kotlin/Unit|>(R|<local>/x|, <L> = with@fun R|A|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|/foo|()
}
)
}
public final fun test_3(x: R|A?|): R|kotlin/Unit| {
R|kotlin/with|<R|A?|, R|kotlin/Unit|>(R|<local>/x|, <L> = with@fun R|A?|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|/myRequireNotNull|()
}
)
R|<local>/x|.<Inapplicable(WRONG_RECEIVER): [/foo]>#()
}
public final fun test_4(x: R|A?|): R|kotlin/Unit| {
R|kotlin/with|<R|A?|, R|kotlin/Unit|>(R|<local>/x|, <L> = with@fun R|A?|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
this@R|special/anonymous|.R|/myRequireNotNull|()
this@R|special/anonymous|.R|/foo|()
}
)
}
public final fun R|A?|.test_5(): R|kotlin/Unit| {
this@R|/test_5|.R|/myRequireNotNull|()
this@R|/test_5|.R|/foo|()
}

View File

@@ -1,17 +0,0 @@
import kotlin.contracts.*
fun checkIsString(x: Any) {
contract {
returns(true) implies (x is String)
returns(false) implies (x !is String)
}
return x is String
}
fun test(x: Any) {
if (checkIsString(x)) {
x.length // OK
} else {
x.<!UNRESOLVED_REFERENCE!>length<!> // Error
}
}

View File

@@ -1,22 +0,0 @@
FILE: typePredicate.kt
public final fun checkIsString(x: R|kotlin/Any|): R|kotlin/Unit|
[R|Contract description]
<
Returns(TRUE) -> x is kotlin/String
Returns(FALSE) -> x !is kotlin/String
>
{
[StubStatement]
^checkIsString (R|<local>/x| is R|kotlin/String|)
}
public final fun test(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
R|/checkIsString|(R|<local>/x|) -> {
R|<local>/x|.R|kotlin/String.length|
}
else -> {
R|<local>/x|.<Unresolved name: length>#
}
}
}

View File

@@ -5,9 +5,9 @@ fun main(k: KSub, vString: SuperClass<String>.NestedInSuperClass, vInt: SuperCla
k.getImpl().nestedI(vString)
// TODO: Support parametrisized inner classes
k.getImpl().<!INAPPLICABLE_CANDIDATE!>nestedI<!>(vInt)
k.getNestedSubClass().nested("")
k.getNestedSubClass().<!INAPPLICABLE_CANDIDATE!>nested<!>(1)
k.getImpl().nestedI(vInt)
k.getNestedSubClass().<!INAPPLICABLE_CANDIDATE!>nested<!>("")
k.getNestedSubClass().nested(1)
}
// FILE: J1.java

View File

@@ -7,9 +7,9 @@ FILE: K1.kt
}
public final fun main(k: R|KSub|, vString: R|SuperClass.NestedInSuperClass<kotlin/String>|, vInt: R|SuperClass.NestedInSuperClass<kotlin/Int>|): R|kotlin/Unit| {
R|<local>/k|.R|/J1.getImpl|().R|FakeOverride</J1.NestedIImpl.nestedI: R|kotlin/Unit|>|(R|<local>/vString|)
R|<local>/k|.R|/J1.getImpl|().<Inapplicable(INAPPLICABLE): [/J1.NestedIImpl.nestedI]>#(R|<local>/vInt|)
R|<local>/k|.R|/J1.getNestedSubClass|().R|FakeOverride</J1.NestedSubClass.nested: R|kotlin/Unit|>|(String())
R|<local>/k|.R|/J1.getNestedSubClass|().<Inapplicable(INAPPLICABLE): [/J1.NestedSubClass.nested]>#(Int(1))
R|<local>/k|.R|/J1.getImpl|().R|FakeOverride</J1.NestedIImpl.nestedI: R|kotlin/Unit|>|(R|<local>/vInt|)
R|<local>/k|.R|/J1.getNestedSubClass|().<Inapplicable(INAPPLICABLE): [/SuperClass.NestedInSuperClass.nested]>#(String())
R|<local>/k|.R|/J1.getNestedSubClass|().R|/SuperClass.NestedInSuperClass.nested|(Int(1))
}
FILE: K2.kt
public open class KFirst : R|SuperClass<kotlin/String>|, R|SuperI<kotlin/Int>| {
@@ -24,8 +24,8 @@ FILE: K3.kt
super<R|kotlin/Any|>()
}
public open inner class NestedInSuperClass<T> : R|kotlin/Any| {
public constructor(): R|SuperClass.NestedInSuperClass<T>| {
public open inner class NestedInSuperClass : R|kotlin/Any| {
public constructor(): R|SuperClass.NestedInSuperClass| {
super<R|kotlin/Any|>()
}

View File

@@ -1,6 +1,6 @@
FILE: MapCompute.kt
public final fun <D> R|kotlin/collections/MutableMap<kotlin/String, kotlin/collections/MutableSet<D>>|.initAndAdd(key: R|kotlin/String|, value: R|D|): R|kotlin/Unit| {
this@R|/initAndAdd|.R|FakeOverride<kotlin/collections/MutableMap.compute: R|kotlin/collections/MutableSet<D>?|>|(R|<local>/key|, <L> = compute@fun <anonymous>(_: R|ft<kotlin/String, kotlin/String?>!|, maybeValues: R|ft<kotlin/collections/MutableSet<D>, kotlin/collections/MutableSet<D>?>!|): R|ft<kotlin/collections/MutableSet<D>, kotlin/collections/MutableSet<D>?>!| {
this@R|/initAndAdd|.R|FakeOverride<java/util/Map.compute: R|kotlin/collections/MutableSet<D>?|>|(R|<local>/key|, <L> = compute@fun <anonymous>(_: R|ft<kotlin/String, kotlin/String?>!|, maybeValues: R|ft<kotlin/collections/MutableSet<D>, kotlin/collections/MutableSet<D>?>!|): R|ft<kotlin/collections/MutableSet<D>, kotlin/collections/MutableSet<D>?>!| {
lval setOfValues: R|kotlin/collections/MutableSet<D>| = when (lval <elvis>: R|ft<kotlin/collections/MutableSet<D>, kotlin/collections/MutableSet<D>?>!| = R|<local>/maybeValues|) {
==($subj$, Null(null)) -> {
R|kotlin/collections/mutableSetOf|<R|D|>()

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