Compare commits

...

138 Commits

Author SHA1 Message Date
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
554 changed files with 13855 additions and 13670 deletions

3
.bunch
View File

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

10547
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)

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

@@ -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

@@ -52,7 +52,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.load.kotlin.MethodSignatureMappingKt;
import org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt;
import org.jetbrains.kotlin.name.Name;

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

@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;

View File

@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.JvmDefaultMode;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.java.JavaVisibilities;
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.DescriptorUtils;

View File

@@ -8,6 +8,7 @@ dependencies {
compile(project(":compiler:config"))
compile(project(":compiler:config.jvm"))
compile(project(":js:js.config"))
compile(project(":native:kotlin-native-utils"))
compileOnly(project(":kotlin-reflect-api"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }

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)
@@ -357,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

@@ -55,9 +55,11 @@ private fun <From : Any, To : Any> copyProperties(
): To {
if (from == to) return to
val toMemberProperties = to::class.memberProperties.associateBy { it.name }
for (fromProperty in propertiesToCopy) {
@Suppress("UNCHECKED_CAST")
val toProperty = to::class.memberProperties.firstOrNull { it.name == fromProperty.name } as? KMutableProperty1<To, Any?>
val toProperty = toMemberProperties[fromProperty.name] as? KMutableProperty1<To, Any?>
?: continue
val fromValue = fromProperty.get(from)
if (filter != null && !filter(fromProperty, fromValue)) continue

View File

@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.platform.js.JsPlatforms.defaultJsPlatform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.allJvmPlatforms
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.unspecifiedJvmPlatform
import org.jetbrains.kotlin.platform.konan.NativePlatforms.allNativePlatforms
import org.jetbrains.kotlin.platform.konan.NativePlatforms.defaultNativePlatform
import org.jetbrains.kotlin.platform.konan.NativePlatforms.unspecifiedNativePlatform
@Suppress("DEPRECATION_ERROR")
object CommonPlatforms {
@@ -23,7 +23,7 @@ object CommonPlatforms {
setOf(
unspecifiedJvmPlatform.single(),
defaultJsPlatform.single(),
defaultNativePlatform.single()
unspecifiedNativePlatform.single()
)
), org.jetbrains.kotlin.analyzer.common.CommonPlatform {
override val platformName: String

View File

@@ -5,33 +5,69 @@
package org.jetbrains.kotlin.platform.konan
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.platform.SimplePlatform
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.toTargetPlatform
abstract class NativePlatform : SimplePlatform("Native") {
sealed class NativePlatform : SimplePlatform("Native") {
override val oldFashionedDescription: String
get() = "Native "
get() = toString() + " "
}
object NativePlatformUnspecifiedTarget : NativePlatform() {
override val targetName: String
get() = "general"
}
data class NativePlatformWithTarget(val target: KonanTarget) : NativePlatform() {
override fun toString() = super.toString() // override the method generated for data class
override val targetName: String
get() = target.visibleName
}
@Suppress("DEPRECATION_ERROR")
object NativePlatforms {
private object DefaultSimpleNativePlatform : NativePlatform()
private val predefinedNativeTargetToSimpleNativePlatform: Map<KonanTarget, NativePlatformWithTarget> =
KonanTarget.predefinedTargets.values.associateWith { NativePlatformWithTarget(it) }
private val predefinedNativeTargetToNativePlatform: Map<KonanTarget, TargetPlatform> =
predefinedNativeTargetToSimpleNativePlatform.mapValues { (_, simplePlatform) -> simplePlatform.toTargetPlatform() }
val unspecifiedNativePlatform: TargetPlatform
get() = CompatNativePlatform
val allNativePlatforms: List<TargetPlatform> = listOf(unspecifiedNativePlatform) + predefinedNativeTargetToNativePlatform.values
fun nativePlatformBySingleTarget(target: KonanTarget): TargetPlatform =
predefinedNativeTargetToNativePlatform[target] ?: unspecifiedNativePlatform
fun nativePlatformByTargets(targets: Collection<KonanTarget>): TargetPlatform {
val simplePlatforms = targets.mapNotNullTo(HashSet()) { predefinedNativeTargetToSimpleNativePlatform[it] }
return when (simplePlatforms.size) {
0 -> unspecifiedNativePlatform
1 -> nativePlatformBySingleTarget(simplePlatforms.first().target)
else -> TargetPlatform(simplePlatforms)
}
}
fun nativePlatformByTargetNames(targets: Collection<String>): TargetPlatform =
nativePlatformByTargets(targets.mapNotNull { KonanTarget.predefinedTargets[it] })
@Deprecated(
message = "Should be accessed only by compatibility layer, other clients should use 'defaultNativePlatform'",
message = "Should be accessed only by compatibility layer, other clients should use 'unspecifiedNativePlatform'",
level = DeprecationLevel.ERROR
)
object CompatNativePlatform : TargetPlatform(setOf(DefaultSimpleNativePlatform)),
object CompatNativePlatform : TargetPlatform(setOf(NativePlatformUnspecifiedTarget)),
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform {
override val platformName: String
get() = "Native"
}
val defaultNativePlatform: TargetPlatform
get() = CompatNativePlatform
val allNativePlatforms: List<TargetPlatform> = listOf(defaultNativePlatform)
}
fun TargetPlatform?.isNative(): Boolean = this?.singleOrNull() is NativePlatform
fun TargetPlatform?.isNative(): Boolean = this?.isNotEmpty() == true && all { it is NativePlatform }
private val legacyNativePlatformUnspecifiedTargetSerializedRepresentation = "${NativePlatformUnspecifiedTarget.platformName} []"
fun NativePlatformUnspecifiedTarget.legacySerializeToString(): String = legacyNativePlatformUnspecifiedTargetSerializedRepresentation

View File

@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
@Deprecated(
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
replaceWith = ReplaceWith("NativePlatforms.defaultNativePlatform", "org.jetbrains.kotlin.platform.konan.NativePlatforms"),
replaceWith = ReplaceWith("NativePlatforms.unspecifiedNativePlatform", "org.jetbrains.kotlin.platform.konan.NativePlatforms"),
level = DeprecationLevel.ERROR
)
interface KonanPlatform : TargetPlatform {

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

@@ -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

@@ -61,14 +61,16 @@ class JdkPlatform(val targetVersion: JvmTarget) : JvmPlatform() {
get() = targetVersion
// TODO(dsavvinov): temporarily conservative measure; make JdkPlatform data class later
// Explanation: previously we had only one JvmPlatform, and all 'TargetPlatform's had an
// equality (actually, identity, because each platform had only one instance). This lead
// to common pattern of putting them in map (e.g., see KotlinCacheServiceImpl.globalFacadesPerPlatformAndSdk).
//
// If we start distinguishing JvmPlatforms with different JvmTarget right now, it may accidentally
// break some clients (in particular, we'll create global facade for *each* JvmTarget, which is a bad idea)
// Explanation: previously we had only one JvmPlatform, and all 'TargetPlatform's had an
// equality (actually, identity, because each platform had only one instance). This lead
// to common pattern of putting them in map (e.g., see KotlinCacheServiceImpl.globalFacadesPerPlatformAndSdk).
// .
// If we start distinguishing JvmPlatforms with different JvmTarget right now, it may accidentally
// break some clients (in particular, we'll create global facade for *each* JvmTarget, which is a bad idea)
override fun equals(other: Any?): Boolean = other is JdkPlatform
override fun hashCode(): Int = JdkPlatform::class.hashCode()
}
fun TargetPlatform?.isJvm(): Boolean = this?.singleOrNull() is JvmPlatform
// TODO: temporarily conservative implementation; use the same approach as for TargetPlatform?.isNative()
// when JdkPlatform becomes a data class
fun TargetPlatform?.isJvm(): Boolean = this?.singleOrNull() is JvmPlatform

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

@@ -9154,11 +9154,26 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/typeParameterBounds.kt");
}
@TestMetadata("unsafeVarianceInAliasedFunctionalType.kt")
public void testUnsafeVarianceInAliasedFunctionalType() throws Exception {
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/unsafeVarianceInAliasedFunctionalType.kt");
}
@TestMetadata("unsafeVarianceOnInputTypeOfFunctionalType.kt")
public void testUnsafeVarianceOnInputTypeOfFunctionalType() throws Exception {
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/unsafeVarianceOnInputTypeOfFunctionalType.kt");
}
@TestMetadata("unsafeVarianceStar.kt")
public void testUnsafeVarianceStar() throws Exception {
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/unsafeVarianceStar.kt");
}
@TestMetadata("unsafeVarianceWithRecursiveGenerics.kt")
public void testUnsafeVarianceWithRecursiveGenerics() throws Exception {
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/unsafeVarianceWithRecursiveGenerics.kt");
}
@TestMetadata("varargs.kt")
public void testVarargs() throws Exception {
runTest("compiler/testData/diagnostics/tests/generics/projectionsScope/varargs.kt");

View File

@@ -2403,6 +2403,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
public void testKt9820_javaFunctionTypeInheritor() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.kt");
}
@TestMetadata("kt-37497.kt")
public void testKt_37497() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt-37497.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/reified")

View File

@@ -4974,10 +4974,45 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/contracts/constructorArgument.kt");
}
@TestMetadata("destructuredVariable.kt")
public void testDestructuredVariable() throws Exception {
runTest("compiler/testData/codegen/box/contracts/destructuredVariable.kt");
}
@TestMetadata("exactlyOnceNotInline.kt")
public void testExactlyOnceNotInline() throws Exception {
runTest("compiler/testData/codegen/box/contracts/exactlyOnceNotInline.kt");
}
@TestMetadata("exception.kt")
public void testException() throws Exception {
runTest("compiler/testData/codegen/box/contracts/exception.kt");
}
@TestMetadata("field.kt")
public void testField() throws Exception {
runTest("compiler/testData/codegen/box/contracts/field.kt");
}
@TestMetadata("forLoop.kt")
public void testForLoop() throws Exception {
runTest("compiler/testData/codegen/box/contracts/forLoop.kt");
}
@TestMetadata("functionParameter.kt")
public void testFunctionParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
}
@TestMetadata("valInWhen.kt")
public void testValInWhen() throws Exception {
runTest("compiler/testData/codegen/box/contracts/valInWhen.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/controlStructures")
@@ -11029,6 +11064,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/funInterface/receiverEvaluatedOnce.kt");
}
@TestMetadata("samConstructorExplicitInvocation.kt")
public void testSamConstructorExplicitInvocation() throws Exception {
runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt");
}
@TestMetadata("suspendFunInterfaceConversionCodegen.kt")
public void testSuspendFunInterfaceConversionCodegen() throws Exception {
runTest("compiler/testData/codegen/box/funInterface/suspendFunInterfaceConversionCodegen.kt");
@@ -12100,6 +12140,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception {
runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");
}
@TestMetadata("unsafeVarianceCodegen.kt")
public void testUnsafeVarianceCodegen() throws Exception {
runTest("compiler/testData/codegen/box/inference/unsafeVarianceCodegen.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses")

View File

@@ -17,106 +17,23 @@
package org.jetbrains.kotlin.load.java.sam;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
import org.jetbrains.kotlin.resolve.sam.SamConversionOracle;
import org.jetbrains.kotlin.resolve.sam.SamConversionResolver;
import org.jetbrains.kotlin.resolve.sam.SamConversionResolverImplKt;
import org.jetbrains.kotlin.resolve.sam.*;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.SimpleType;
import org.jetbrains.kotlin.types.TypeSubstitutor;
import org.jetbrains.kotlin.types.Variance;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class JavaSingleAbstractMethodUtils {
private JavaSingleAbstractMethodUtils() {
}
@NotNull
public static SamConstructorDescriptor createSamConstructorFunction(
@NotNull DeclarationDescriptor owner,
@NotNull ClassDescriptor samInterface,
@NotNull SamConversionResolver samResolver,
@NotNull SamConversionOracle samConversionOracle
) {
assert SamConversionResolverImplKt.getSingleAbstractMethodOrNull(samInterface) != null : samInterface;
SamConstructorDescriptorImpl result = new SamConstructorDescriptorImpl(owner, samInterface);
List<TypeParameterDescriptor> samTypeParameters = samInterface.getTypeConstructor().getParameters();
SimpleType unsubstitutedSamType = samInterface.getDefaultType();
initializeSamConstructorDescriptor(samInterface, result, samTypeParameters, unsubstitutedSamType, samResolver, samConversionOracle);
return result;
}
private static void initializeSamConstructorDescriptor(
@NotNull ClassDescriptor samInterface,
@NotNull SimpleFunctionDescriptorImpl samConstructor,
@NotNull List<TypeParameterDescriptor> samTypeParameters,
@NotNull KotlinType unsubstitutedSamType,
@NotNull SamConversionResolver samResolver,
@NotNull SamConversionOracle samConversionOracle
) {
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samTypeParameters, samConstructor);
KotlinType parameterTypeUnsubstituted =
SamConversionResolverImplKt.getFunctionTypeForSamType(unsubstitutedSamType, samResolver, samConversionOracle);
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + unsubstitutedSamType;
KotlinType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
", substitutor = " + typeParameters.substitutor;
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
samConstructor, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("function"), parameterType,
/* declaresDefaultValue = */ false,
/* isCrossinline = */ false,
/* isNoinline = */ false,
null, SourceElement.NO_SOURCE);
KotlinType returnType = typeParameters.substitutor.substitute(unsubstitutedSamType, Variance.OUT_VARIANCE);
assert returnType != null : "couldn't substitute type: " + unsubstitutedSamType +
", substitutor = " + typeParameters.substitutor;
samConstructor.initialize(
null,
null,
typeParameters.descriptors,
Collections.singletonList(parameter),
returnType,
Modality.FINAL,
samInterface.getVisibility()
);
}
public static SamConstructorDescriptor createTypeAliasSamConstructorFunction(
@NotNull TypeAliasDescriptor typeAliasDescriptor,
@NotNull SamConstructorDescriptor underlyingSamConstructor,
@NotNull SamConversionResolver samResolver,
@NotNull SamConversionOracle samConversionOracle
) {
SamTypeAliasConstructorDescriptorImpl result = new SamTypeAliasConstructorDescriptorImpl(typeAliasDescriptor, underlyingSamConstructor);
ClassDescriptor samInterface = underlyingSamConstructor.getBaseDescriptorForSynthetic();
List<TypeParameterDescriptor> samTypeParameters = typeAliasDescriptor.getTypeConstructor().getParameters();
SimpleType unsubstitutedSamType = typeAliasDescriptor.getExpandedType();
initializeSamConstructorDescriptor(samInterface, result, samTypeParameters, unsubstitutedSamType, samResolver, samConversionOracle);
return result;
}
public static boolean isSamClassDescriptor(@NotNull ClassDescriptor descriptor) {
if (descriptor.isFun()) return true;
if (descriptor instanceof LazyJavaClassDescriptor && descriptor.getDefaultFunctionTypeForSamInterface() != null) return true;
@@ -197,12 +114,17 @@ public class JavaSingleAbstractMethodUtils {
@NotNull SamConversionResolver samResolver,
@NotNull SamConversionOracle samConversionOracle
) {
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
SamConstructorTypeParameters typeParameters;
if (adapter instanceof SamAdapterClassConstructorDescriptor) {
typeParameters = new SamConstructorTypeParameters(original.getTypeParameters(), TypeSubstitutor.EMPTY);
} else {
typeParameters = SamConstructorUtilsKt.recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
}
KotlinType returnTypeUnsubstituted = original.getReturnType();
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
TypeSubstitutor substitutor = typeParameters.substitutor;
TypeSubstitutor substitutor = typeParameters.getSubstitutor();
KotlinType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted +
", substitutor = " + substitutor;
@@ -211,7 +133,7 @@ public class JavaSingleAbstractMethodUtils {
List<ValueParameterDescriptor> valueParameters =
createValueParametersForSamAdapter(original, adapter, substitutor, samResolver, samConversionOracle);
initializer.initialize(typeParameters.descriptors, valueParameters, returnType);
initializer.initialize(typeParameters.getDescriptors(), valueParameters, returnType);
return adapter;
}
@@ -245,45 +167,6 @@ public class JavaSingleAbstractMethodUtils {
return valueParameters;
}
@NotNull
private static TypeParameters recreateAndInitializeTypeParameters(
@NotNull List<TypeParameterDescriptor> originalParameters,
@Nullable DeclarationDescriptor newOwner
) {
if (newOwner instanceof SamAdapterClassConstructorDescriptor) {
return new TypeParameters(originalParameters, TypeSubstitutor.EMPTY);
}
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> traitToFunTypeParameters =
JavaResolverUtils.recreateTypeParametersAndReturnMapping(originalParameters, newOwner);
TypeSubstitutor typeParametersSubstitutor = JavaResolverUtils.createSubstitutorForTypeParameters(traitToFunTypeParameters);
for (Map.Entry<TypeParameterDescriptor, TypeParameterDescriptorImpl> mapEntry : traitToFunTypeParameters.entrySet()) {
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
for (KotlinType upperBound : traitTypeParameter.getUpperBounds()) {
KotlinType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
funTypeParameter.addUpperBound(upperBoundSubstituted);
}
funTypeParameter.setInitialized();
}
List<TypeParameterDescriptor> typeParameters = new ArrayList<>(traitToFunTypeParameters.values());
return new TypeParameters(typeParameters, typeParametersSubstitutor);
}
private static class TypeParameters {
public final List<TypeParameterDescriptor> descriptors;
public final TypeSubstitutor substitutor;
private TypeParameters(List<TypeParameterDescriptor> descriptors, TypeSubstitutor substitutor) {
this.descriptors = descriptors;
this.substitutor = substitutor;
}
}
private static abstract class FunctionInitializer {
public abstract void initialize(
@NotNull List<TypeParameterDescriptor> typeParameters,
@@ -291,6 +174,4 @@ public class JavaSingleAbstractMethodUtils {
@NotNull KotlinType returnType
);
}
}

View File

@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.load.java.sam;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.synthetic.FunctionInterfaceAdapterDescriptor;
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
public interface SamAdapterDescriptor<D extends FunctionDescriptor>

View File

@@ -1,74 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.jvm;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.SourceElement;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.types.TypeConstructor;
import org.jetbrains.kotlin.types.TypeProjection;
import org.jetbrains.kotlin.types.TypeProjectionImpl;
import org.jetbrains.kotlin.types.TypeSubstitutor;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class JavaResolverUtils {
private JavaResolverUtils() {
}
public static Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> recreateTypeParametersAndReturnMapping(
@NotNull List<TypeParameterDescriptor> originalParameters,
@Nullable DeclarationDescriptor newOwner
) {
// LinkedHashMap to save the order of type parameters
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result = new LinkedHashMap<>();
for (TypeParameterDescriptor typeParameter : originalParameters) {
result.put(typeParameter,
TypeParameterDescriptorImpl.createForFurtherModification(
newOwner == null ? typeParameter.getContainingDeclaration() : newOwner,
typeParameter.getAnnotations(),
typeParameter.isReified(),
typeParameter.getVariance(),
typeParameter.getName(),
typeParameter.getIndex(),
SourceElement.NO_SOURCE,
typeParameter.getStorageManager()
)
);
}
return result;
}
@NotNull
public static TypeSubstitutor createSubstitutorForTypeParameters(
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters
) {
Map<TypeConstructor, TypeProjection> typeSubstitutionContext = new HashMap<>();
for (Map.Entry<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameter : originalToAltTypeParameters.entrySet()) {
typeSubstitutionContext.put(originalToAltTypeParameter.getKey().getTypeConstructor(),
new TypeProjectionImpl(originalToAltTypeParameter.getValue().getDefaultType()));
}
// TODO: Use IndexedParametersSubstitution here instead of map creation
return TypeSubstitutor.create(typeSubstitutionContext);
}
}

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
import org.jetbrains.kotlin.resolve.sam.SamConversionOracle
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
import org.jetbrains.kotlin.resolve.scopes.synthetic.FunInterfaceConstructorsSyntheticScope
import org.jetbrains.kotlin.storage.StorageManager
class JavaSyntheticScopes(
@@ -69,7 +70,10 @@ class JavaSyntheticScopes(
)
)
scopes = listOf(javaSyntheticPropertiesScope, samAdapterFunctionsScope) + scopesFromExtensions
val funInterfaceConstructorsScopes =
FunInterfaceConstructorsSyntheticScope(storageManager, lookupTracker, samConventionResolver, samConversionOracle)
scopes = listOf(javaSyntheticPropertiesScope, samAdapterFunctionsScope, funInterfaceConstructorsScopes) + scopesFromExtensions
if (samConversionPerArgumentIsEnabled) {
val forceEnabledSamAdapterFunctionsScope = SamAdapterFunctionsScope(

View File

@@ -29,16 +29,14 @@ import org.jetbrains.kotlin.incremental.record
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
import org.jetbrains.kotlin.load.java.sam.JavaSingleAbstractMethodUtils
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.components.isVararg
import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitution
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
import org.jetbrains.kotlin.resolve.sam.SAM_LOOKUP_NAME
import org.jetbrains.kotlin.resolve.sam.SamConversionOracle
import org.jetbrains.kotlin.resolve.sam.SamConversionResolver
import org.jetbrains.kotlin.resolve.sam.*
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
import org.jetbrains.kotlin.resolve.scopes.SyntheticScope
@@ -74,9 +72,8 @@ class SamAdapterFunctionsScope(
}
private val samConstructorForClassifier =
storageManager.createMemoizedFunction<ClassDescriptor, SamConstructorDescriptor> { classifier ->
JavaSingleAbstractMethodUtils
.createSamConstructorFunction(classifier.containingDeclaration, classifier, samResolver, samConversionOracle)
storageManager.createMemoizedFunction<JavaClassDescriptor, SamConstructorDescriptor> { classifier ->
createSamConstructorFunction(classifier.containingDeclaration, classifier, samResolver, samConversionOracle)
}
private val samConstructorForJavaConstructor =
@@ -261,17 +258,16 @@ class SamAdapterFunctionsScope(
return getTypeAliasSamConstructor(classifier)
}
if (classifier !is ClassDescriptor) return null
if (!JavaSingleAbstractMethodUtils.isSamClassDescriptor(classifier)) return null
if (classifier !is LazyJavaClassDescriptor || classifier.defaultFunctionTypeForSamInterface == null) return null
return samConstructorForClassifier(classifier)
}
private fun getTypeAliasSamConstructor(classifier: TypeAliasDescriptor): SamConstructorDescriptor? {
val classDescriptor = classifier.classDescriptor ?: return null
if (!JavaSingleAbstractMethodUtils.isSamClassDescriptor(classDescriptor)) return null
if (classDescriptor !is LazyJavaClassDescriptor || classDescriptor.defaultFunctionTypeForSamInterface == null) return null
return JavaSingleAbstractMethodUtils.createTypeAliasSamConstructorFunction(
return createTypeAliasSamConstructorFunction(
classifier, samConstructorForClassifier(classDescriptor), samResolver, samConversionOracle
)
}

View File

@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue

View File

@@ -160,6 +160,8 @@ class CommonResolverForModuleFactory(
val moduleDescriptor = resolver.descriptorForModule(moduleInfo)
dependenciesContainer?.registerDependencyForAllModules(moduleInfo, moduleDescriptor)
val container = resolver.resolverForModule(moduleInfo).componentProvider
container.get<LazyTopDownAnalyzer>().analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, files)
@@ -174,6 +176,11 @@ interface CommonDependenciesContainer {
fun moduleDescriptorForModuleInfo(moduleInfo: ModuleInfo): ModuleDescriptor
fun registerDependencyForAllModules(
moduleInfo: ModuleInfo,
descriptorForModule: ModuleDescriptorImpl
)
fun packageFragmentProviderForModuleInfo(moduleInfo: ModuleInfo): PackageFragmentProvider?
val friendModuleInfos: List<ModuleInfo>
val refinesModuleInfos: List<ModuleInfo>

View File

@@ -179,6 +179,7 @@ public interface BindingContext {
WritableSlice<KtElement, Boolean> USED_AS_RESULT_OF_LAMBDA = Slices.createSimpleSetSlice();
WritableSlice<VariableDescriptor, CaptureKind> CAPTURED_IN_CLOSURE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<PropertyDescriptor, Boolean> FIELD_CAPTURED_IN_EXACLY_ONCE_CLOSURE = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<KtDeclaration, PreliminaryDeclarationVisitor> PRELIMINARY_VISITOR = new BasicWritableSlice<>(DO_NOTHING);
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();

View File

@@ -178,7 +178,8 @@ class DelegationResolver<T : CallableMemberDescriptor> private constructor(
it == overriddenDescriptor || OverridingUtil.overrides(
it,
overriddenDescriptor,
it.module.isTypeRefinementEnabled()
it.module.isTypeRefinementEnabled(),
true
)
}
}

View File

@@ -10,10 +10,13 @@ import org.jetbrains.kotlin.contracts.description.CallsEffectDeclaration
import org.jetbrains.kotlin.contracts.description.ContractProviderKey
import org.jetbrains.kotlin.contracts.description.InvocationKind
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContext.CAPTURED_IN_CLOSURE
import org.jetbrains.kotlin.resolve.BindingContext.FIELD_CAPTURED_IN_EXACLY_ONCE_CLOSURE
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
@@ -23,6 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
import org.jetbrains.kotlin.types.expressions.CaptureKind
class CapturingInClosureChecker : CallChecker {
@@ -40,8 +44,16 @@ class CapturingInClosureChecker : CallChecker {
if (isCapturedVariable(variableParent, scopeContainer)) {
if (trace.get(CAPTURED_IN_CLOSURE, variable) != CaptureKind.NOT_INLINE) {
trace.record(CAPTURED_IN_CLOSURE, variable, getCaptureKind(trace.bindingContext, scopeContainer, variableParent, variable))
return
}
}
// Check whether a field is captured in EXACTLY_ONCE contract
if (variable !is PropertyDescriptor || scopeContainer !is AnonymousFunctionDescriptor) return
val scopeDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(scopeContainer) as? KtFunction ?: return
if (scopeContainer.containingDeclaration !is ConstructorDescriptor) return
if (isExactlyOnceContract(trace.bindingContext, scopeDeclaration)) {
trace.record(FIELD_CAPTURED_IN_EXACLY_ONCE_CLOSURE, variable)
}
}
private fun isCapturedVariable(variableParent: DeclarationDescriptor, scopeContainer: DeclarationDescriptor): Boolean {
@@ -75,10 +87,52 @@ class CapturingInClosureChecker : CallChecker {
) CaptureKind.INLINE_ONLY else CaptureKind.NOT_INLINE
}
val exactlyOnceContract = isExactlyOnceContract(context, scopeDeclaration)
// We cannot box arguments.
val isArgument = variable is ValueParameterDescriptor && variableParent is CallableDescriptor
if (!exactlyOnceContract) return CaptureKind.NOT_INLINE
// We cannot box function/lambda arguments, destructured lambda arguments, for-loop index variables,
// exceptions inside catch blocks ans vals in when
return if (isArgument(variable, variableParent) ||
isDestructuredVariable(variable, variableParent) ||
isForLoopParameter(variable) ||
isCatchBlockParameter(variable) ||
isValInWhen(variable)
) {
CaptureKind.NOT_INLINE
} else {
CaptureKind.EXACTLY_ONCE_EFFECT
}
}
private fun isArgument(variable: VariableDescriptor, variableParent: DeclarationDescriptor): Boolean =
variable is ValueParameterDescriptor && variableParent is CallableDescriptor
&& variableParent.valueParameters.contains(variable)
return if (exactlyOnceContract && !isArgument) CaptureKind.EXACTLY_ONCE_EFFECT else CaptureKind.NOT_INLINE
private fun isDestructuredVariable(variable: VariableDescriptor, variableParent: DeclarationDescriptor): Boolean =
variable is LocalVariableDescriptor && variableParent is AnonymousFunctionDescriptor &&
variableParent.valueParameters.any {
it is ValueParameterDescriptorImpl.WithDestructuringDeclaration && it.destructuringVariables.contains(variable)
}
private fun isValInWhen(variable: VariableDescriptor): Boolean {
val psi = ((variable as? LocalVariableDescriptor)?.source as? KotlinSourceElement)?.psi ?: return false
return (psi.parent as? KtWhenExpression)?.let { it.subjectVariable == psi } == true
}
private fun isCatchBlockParameter(variable: VariableDescriptor): Boolean {
val psi = ((variable as? LocalVariableDescriptor)?.source as? KotlinSourceElement)?.psi ?: return false
return psi.parent.parent.let { it is KtCatchClause && it.parameterList?.parameters?.contains(psi) == true }
}
private fun isForLoopParameter(variable: VariableDescriptor): Boolean {
val psi = ((variable as? LocalVariableDescriptor)?.source as? KotlinSourceElement)?.psi ?: return false
if (psi.parent is KtForExpression) {
val forExpression = psi.parent as KtForExpression
return forExpression.loopParameter == psi
} else if (psi.parent is KtDestructuringDeclaration) {
val parameter = psi.parent.parent as? KtParameter ?: return false
val forExpression = parameter.parent as? KtForExpression ?: return false
return forExpression.loopParameter == parameter
}
return false
}
private fun isExactlyOnceParameter(function: DeclarationDescriptor, parameter: VariableDescriptor): Boolean {

View File

@@ -65,7 +65,7 @@ class KotlinResolutionStatelessCallbacksImpl(
descriptor,
(kotlinCall as? PSIKotlinCall)?.psiCall,
(resolutionCallbacks as? KotlinResolutionCallbacksImpl)?.trace?.bindingContext,
isSuperOrDelegatingConstructorCall(kotlinCall),
kotlinCall is PSIKotlinCallImpl && kotlinCall.psiCall.isCallWithSuperReceiver(),
)
override fun isSuperExpression(receiver: SimpleKotlinCallArgument?): Boolean =

View File

@@ -601,7 +601,8 @@ internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResol
return PreviousResolutionError(level)
}
private val BasicCallResolutionContext.isSuperCall: Boolean get() = call.explicitReceiver is SuperCallReceiverValue
internal fun Call.isCallWithSuperReceiver(): Boolean = explicitReceiver is SuperCallReceiverValue
private val BasicCallResolutionContext.isSuperCall: Boolean get() = call.isCallWithSuperReceiver()
internal fun reportResolvedUsingDeprecatedVisibility(
call: Call,

View File

@@ -8,8 +8,10 @@ package org.jetbrains.kotlin.ir.backend.js
import org.jetbrains.kotlin.backend.common.ir.isMemberOfOpenClass
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.backend.js.export.isExported
import org.jetbrains.kotlin.ir.backend.js.utils.associatedObject
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
import org.jetbrains.kotlin.ir.backend.js.utils.getJsNameOrKotlinName
import org.jetbrains.kotlin.ir.backend.js.utils.isAssociatedObjectAnnotatedAnnotation
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
@@ -78,8 +80,19 @@ private fun removeUselessDeclarations(module: IrModuleFragment, usefulDeclaratio
process(declaration)
}
private fun IrConstructorCall.shouldKeepAnnotation(): Boolean {
associatedObject()?.let { obj ->
if (obj !in usefulDeclarations) return false
}
return true
}
override fun visitClass(declaration: IrClass) {
process(declaration)
// Remove annotations for `findAssociatedObject` feature, which reference objects eliminated by the DCE.
// Otherwise `JsClassGenerator.generateAssociatedKeyProperties` will try to reference the object factory (which is removed).
// That will result in an error from the Namer. It cannot generate a name for an absent declaration.
declaration.annotations = declaration.annotations.filter { it.shouldKeepAnnotation() }
}
// TODO bring back the primary constructor fix
@@ -118,6 +131,10 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
val contagiousReachableDeclarations = hashSetOf<IrOverridableDeclaration<*>>()
val constructedClasses = hashSetOf<IrClass>()
val classesWithObjectAssociations = hashSetOf<IrClass>()
val referencedJsClasses = hashSetOf<IrDeclaration>()
val referencedJsClassesFromExpressions = hashSetOf<IrClass>()
fun IrDeclaration.enqueue(
from: IrDeclaration?,
description: String?,
@@ -211,6 +228,14 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
}
}
}
declaration.annotations.forEach {
val annotationClass = it.symbol.owner.constructedClass
if (annotationClass.isAssociatedObjectAnnotatedAnnotation) {
classesWithObjectAssociations += declaration
annotationClass.enqueue("@AssociatedObject annotated annotation class")
}
}
}
if (declaration is IrSimpleFunction && declaration.isFakeOverride) {
@@ -268,7 +293,13 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
constructor.enqueue("intrinsic: jsBoxIntrinsic")
}
context.intrinsics.jsClass -> {
(expression.getTypeArgument(0)!!.classifierOrFail.owner as IrDeclaration).enqueue("intrinsic: jsClass")
val ref = expression.getTypeArgument(0)!!.classifierOrFail.owner as IrDeclaration
ref.enqueue("intrinsic: jsClass")
referencedJsClasses += ref
}
context.intrinsics.jsGetKClassFromExpression -> {
val ref = expression.getTypeArgument(0)?.classOrNull ?: context.irBuiltIns.anyClass
referencedJsClassesFromExpressions += ref.owner
}
context.intrinsics.jsObjectCreate.symbol -> {
val classToCreate = expression.getTypeArgument(0)!!.classifierOrFail.owner as IrClass
@@ -314,6 +345,21 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
return null
}
// Handle objects, constructed via `findAssociatedObject` annotation
referencedJsClassesFromExpressions += constructedClasses.filterDescendantsOf(referencedJsClassesFromExpressions) // Grow the set of possible results of instance::class expression
for (klass in classesWithObjectAssociations) {
if (klass !in referencedJsClasses && klass !in referencedJsClassesFromExpressions) continue
for (annotation in klass.annotations) {
val annotationClass = annotation.symbol.owner.constructedClass
if (annotationClass !in referencedJsClasses) continue
annotation.associatedObject()?.let { obj ->
context.mapping.objectToGetInstanceFunction[obj]?.enqueue(klass, "associated object factory")
}
}
}
for (klass in constructedClasses) {
// TODO a better way to support inverse overrides.
for (declaration in ArrayList(klass.declarations)) {
@@ -369,3 +415,29 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
return result
}
private fun Collection<IrClass>.filterDescendantsOf(bases: Collection<IrClass>): Collection<IrClass> {
val visited = hashSetOf<IrClass>()
val baseDescendants = hashSetOf<IrClass>()
baseDescendants += bases
fun overridesAnyBase(klass: IrClass): Boolean {
if (klass in baseDescendants) return true
if (klass in visited) return false
visited += klass
klass.superTypes.forEach {
(it.classifierOrNull as? IrClassSymbol)?.owner?.let {
if (overridesAnyBase(it)) {
baseDescendants += klass
return true
}
}
}
return false
}
return this.filter { overridesAnyBase(it) }
}

View File

@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.backend.js.export.isExported
import org.jetbrains.kotlin.ir.backend.js.utils.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrClassReference
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.types.IrType
@@ -189,6 +190,8 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
metadataLiteral.propertyInitializers += generateSuperClasses()
metadataLiteral.propertyInitializers += generateAssociatedKeyProperties()
if (isCoroutineClass()) {
metadataLiteral.propertyInitializers += generateSuspendArity()
}
@@ -218,6 +221,31 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
)
)
}
private fun generateAssociatedKeyProperties(): List<JsPropertyInitializer> {
var result = emptyList<JsPropertyInitializer>()
context.getAssociatedObjectKey(irClass)?.let { key ->
result = result + JsPropertyInitializer(JsStringLiteral("associatedObjectKey"), JsIntLiteral(key))
}
val associatedObjects = irClass.annotations.mapNotNull { annotation ->
val annotationClass = annotation.symbol.owner.constructedClass
context.getAssociatedObjectKey(annotationClass)?.let { key ->
annotation.associatedObject()?.let { obj ->
context.staticContext.backendContext.mapping.objectToGetInstanceFunction[obj]?.let { factory ->
JsPropertyInitializer(JsIntLiteral(key), context.staticContext.getNameForStaticFunction(factory).makeRef())
}
}
}
}
if (associatedObjects.isNotEmpty()) {
result = result + JsPropertyInitializer(JsStringLiteral("associatedObjects"), JsObjectLiteral(associatedObjects))
}
return result
}
}
private val IrClassifierSymbol.isInterface get() = (owner as? IrClass)?.isInterface == true

View File

@@ -7,10 +7,11 @@ package org.jetbrains.kotlin.ir.backend.js.utils
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrClassReference
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.util.getAnnotation
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -45,4 +46,15 @@ fun IrDeclarationWithName.getJsNameOrKotlinName(): Name =
when (val jsName = getJsName()) {
null -> name
else -> Name.identifier(jsName)
}
}
private val associatedObjectKeyAnnotationFqName = FqName("kotlin.reflect.AssociatedObjectKey")
val IrClass.isAssociatedObjectAnnotatedAnnotation: Boolean
get() = isAnnotationClass && annotations.any { it.symbol.owner.constructedClass.fqNameWhenAvailable == associatedObjectKeyAnnotationFqName }
fun IrConstructorCall.associatedObject(): IrClass? {
if (!symbol.owner.constructedClass.isAssociatedObjectAnnotatedAnnotation) return null
val klass = ((getValueArgument(0) as? IrClassReference)?.symbol as? IrClassSymbol)?.owner ?: return null
return if (klass.isObject) klass else null
}

View File

@@ -22,4 +22,5 @@ interface IrNamer {
fun getNameForProperty(property: IrProperty): JsName
fun getRefForExternalClass(klass: IrClass): JsNameRef
fun getNameForLoop(loop: IrLoop): JsName?
fun getAssociatedObjectKey(irClass: IrClass): Int?
}

View File

@@ -73,4 +73,14 @@ class IrNamerImpl(private val newNameTables: NameTables) : IrNamer {
error("Unsupported external class parent $parent")
}
}
private val associatedObjectKeyMap = mutableMapOf<IrClass, Int>()
override fun getAssociatedObjectKey(irClass: IrClass): Int? {
if (irClass.isAssociatedObjectAnnotatedAnnotation) {
return associatedObjectKeyMap.getOrPut(irClass) { associatedObjectKeyMap.size }
}
return null
}
}

View File

@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.psi2ir.generators
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.synthetic.FunctionInterfaceAdapterDescriptor
import org.jetbrains.kotlin.descriptors.synthetic.FunctionInterfaceAdapterExtensionFunctionDescriptor
import org.jetbrains.kotlin.descriptors.synthetic.FunctionInterfaceConstructorDescriptor

View File

@@ -10,6 +10,7 @@ import com.intellij.psi.impl.PsiImplUtil
import com.intellij.psi.impl.PsiSuperMethodImplUtil
import com.intellij.psi.impl.light.LightMethodBuilder
import com.intellij.psi.impl.light.LightTypeParameterListBuilder
import com.intellij.psi.util.MethodSignature
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
import org.jetbrains.kotlin.asJava.builder.LightMemberOriginForDeclaration
@@ -113,6 +114,9 @@ internal abstract class KtUltraLightMethod(
override fun findSuperMethods(parentClass: PsiClass?): Array<out PsiMethod> =
PsiSuperMethodImplUtil.findSuperMethods(this, parentClass)
override fun getSignature(substitutor: PsiSubstitutor): MethodSignature =
MethodSignatureBackedByPsiMethod.create(this, substitutor)
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is KtUltraLightMethod) return false

View File

@@ -135,8 +135,8 @@ open class OverloadingConflictResolver<C : Any>(
if (DescriptorEquivalenceForOverrides.areCallableDescriptorsEquivalent(
me,
other,
isTypeRefinementEnabled,
ignoreReturnType
allowCopiesFromTheSameDeclaration = isTypeRefinementEnabled,
ignoreReturnType = ignoreReturnType
)
) {
continue@outerLoop

View File

@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.resolve.scopes.utils
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name

View File

@@ -6,10 +6,10 @@ public final class TestClass /* TestClass*/ {
private int hello;
@null()
public TestClass(int);
public TestClass(int);// .ctor(int)
public final int getHello();
public final int getHello();// getHello()
public final void setHello(@Anno() int);
public final void setHello(@Anno() int);// setHello(int)
}

View File

@@ -1,42 +1,42 @@
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface SimpleAnn /* SimpleAnn*/ {
@null()
public abstract java.lang.String value();
public abstract java.lang.String value();// value()
}
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
public abstract @interface Ann /* Ann*/ {
@null()
public abstract SimpleAnn[] t();
public abstract SimpleAnn[] t();// t()
@null()
public abstract java.lang.Class<?> z();
public abstract java.lang.Class<?> z();// z()
@null()
public abstract java.lang.Class<?>[] e();
public abstract java.lang.Class<?>[] e();// e()
@null()
public abstract java.lang.String y();
public abstract java.lang.String y();// y()
@null()
public abstract kotlin.DeprecationLevel depr();
public abstract kotlin.DeprecationLevel depr();// depr()
public abstract int x();
public abstract int x();// x()
}
public abstract interface Base /* Base*/ {
@Ann(x = 1, y = "134", z = String::class, e = {Int::class, Double::class}, depr = DeprecationLevel.WARNING, t = {@SimpleAnn(value = "243"), @SimpleAnn(value = "4324")})
public abstract void foo(@Ann(x = 2, y = "324", z = Ann::class, e = {Byte::class, Base::class}, depr = DeprecationLevel.WARNING, t = {@SimpleAnn(value = "687"), @SimpleAnn(value = "78")}) @org.jetbrains.annotations.NotNull() java.lang.String);
public abstract void foo(@Ann(x = 2, y = "324", z = Ann::class, e = {Byte::class, Base::class}, depr = DeprecationLevel.WARNING, t = {@SimpleAnn(value = "687"), @SimpleAnn(value = "78")}) @org.jetbrains.annotations.NotNull() java.lang.String);// foo(java.lang.String)
}
public final class Derived /* Derived*/ implements Base {
@Ann(x = 1, y = "134", z = java.lang.String.class, e = {int.class, double.class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value="243"), @SimpleAnn(value="4324")})
public void foo(@Ann(x = 2, y = "324", z = Ann.class, e = {byte.class, Base.class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value="687"), @SimpleAnn(value="78")}) @org.jetbrains.annotations.NotNull() java.lang.String);
public void foo(@Ann(x = 2, y = "324", z = Ann.class, e = {byte.class, Base.class}, depr = kotlin.DeprecationLevel.WARNING, t = {@SimpleAnn(value="687"), @SimpleAnn(value="78")}) @org.jetbrains.annotations.NotNull() java.lang.String);// foo(java.lang.String)
@null()
public Derived(@org.jetbrains.annotations.NotNull() Base);
public Derived(@org.jetbrains.annotations.NotNull() Base);// .ctor(Base)
}

View File

@@ -1,14 +1,14 @@
public final class Foo /* c.b.a.Foo*/ {
@null()
public Foo();
public Foo();// .ctor()
public final void bar();
public final void bar();// bar()
}
public static final class A$B /* null*/ {
@null()
public A$B();
public A$B();// .ctor()
class $$$$$$$ ...
@@ -18,13 +18,13 @@ public static final class A$B /* null*/ {
public final class C$D /* null*/ {
@null()
public C$D();
public C$D();// .ctor()
}
public final class $$$$$$$ /* null*/ {
@null()
public $$$$$$$();
public $$$$$$$();// .ctor()
class G$G$ ...
@@ -32,6 +32,6 @@ public final class $$$$$$$ /* null*/ {
public final class G$G$ /* null*/ {
@null()
public G$G$();
public G$G$();// .ctor()
}

View File

@@ -2,12 +2,12 @@ public final class Prop /* Prop*/ {
private final java.lang.Object someProp;
@null()
public Prop();
public Prop();// .ctor()
}
final class null /* null*/ {
private ();
private ();// .ctor()
}
@@ -17,20 +17,20 @@ final class C /* C*/ {
private final kotlin.jvm.functions.Function0<java.lang.Object> initChild;
@null()
public C(int);
public C(int);// .ctor(int)
@org.jetbrains.annotations.NotNull()
public final kotlin.jvm.functions.Function0<java.lang.Object> getInitChild();
public final kotlin.jvm.functions.Function0<java.lang.Object> getInitChild();// getInitChild()
public final int getY();
public final int getY();// getY()
}
final class null /* null*/ {
@org.jetbrains.annotations.NotNull()
public java.lang.String toString();
public java.lang.String toString();// toString()
private ();
private ();// .ctor()
}
@@ -38,27 +38,27 @@ public final class ValidPublicSupertype /* ValidPublicSupertype*/ {
private final java.lang.Runnable x;
@null()
public ValidPublicSupertype();
public ValidPublicSupertype();// .ctor()
@org.jetbrains.annotations.NotNull()
public final java.lang.Runnable bar();
public final java.lang.Runnable bar();// bar()
@org.jetbrains.annotations.NotNull()
public final java.lang.Runnable getX();
public final java.lang.Runnable getX();// getX()
}
final class null /* null*/ implements java.lang.Runnable {
private ();
private ();// .ctor()
public void run();
public void run();// run()
}
final class null /* null*/ implements java.lang.Runnable {
private ();
private ();// .ctor()
public void run();
public void run();// run()
}
@@ -69,26 +69,26 @@ public final class InvalidPublicSupertype /* InvalidPublicSupertype*/ {
private final java.lang.Runnable x;
@null()
public InvalidPublicSupertype();
public InvalidPublicSupertype();// .ctor()
@org.jetbrains.annotations.NotNull()
public final java.lang.Runnable bar();
public final java.lang.Runnable bar();// bar()
@org.jetbrains.annotations.NotNull()
public final java.lang.Runnable getX();
public final java.lang.Runnable getX();// getX()
}
final class null /* null*/ implements I, java.lang.Runnable {
private ();
private ();// .ctor()
public void run();
public void run();// run()
}
final class null /* null*/ implements I, java.lang.Runnable {
private ();
private ();// .ctor()
public void run();
public void run();// run()
}

View File

@@ -4,21 +4,21 @@ public final class UInt /* UInt*/ {
public enum Foo /* Foo*/ {
;
public final int getX();
public final int getX();// getX()
}
public final class InlinedDelegate /* InlinedDelegate*/<T> {
@null()
public final T getNode();
public final T getNode();// getNode()
}
public final class InlineInheritance /* InlineInheritance*/ {
public final int getV();
public final int getV();// getV()
public int getX();
public int getX();// getX()
public int y();
public int y();// y()
}

View File

@@ -1,9 +1,9 @@
public final class X /* X*/ {
@null()
public X();
public X();// .ctor()
public final int getW();
public final int getW();// getW()
public final void setV(int);
public final void setV(int);// setV(int)
}

View File

@@ -1,19 +1,19 @@
public final class Boo /* Boo*/ {
@null()
public Boo();
public Boo();// .ctor()
public final void fooBar();
public final void fooBar();// fooBar()
}
public static final class LocalClassBase /* null*/ {
@null()
public LocalClassBase();
public LocalClassBase();// .ctor()
}
public static final class LocalClassDerived /* null*/ extends LocalClassBase {
@null()
public LocalClassDerived();
public LocalClassDerived();// .ctor()
}

View File

@@ -9,6 +9,7 @@ where advanced options include:
-Xir-dce-driven Perform a more experimental faster dead code elimination
-Xir-dce-print-reachability-info
Print declarations' reachability info to stdout during performing DCE
-Xir-module-name=<name> Specify a compilation module name for IR backend
-Xir-only Disables pre-IR backend
-Xir-produce-js Generates JS file using IR backend. Also disables pre-IR backend
-Xir-produce-klib-dir Generate unpacked KLIB into parent directory of output JS file.

View File

@@ -57,7 +57,6 @@ where advanced options include:
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)

View File

@@ -0,0 +1,26 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE, JS
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun ok(): String {
val res: String
val (o, _) = "OK" to "FAIL"
runOnce {
res = o
}
return res
}
fun box(): String {
return ok()
}

View File

@@ -0,0 +1,28 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun foo(): String {
var res = "FAIL"
try {
error("OK")
} catch(e: Exception) {
runOnce {
res = e.message!!
}
}
return res
}
fun box(): String {
return foo()
}

View File

@@ -0,0 +1,26 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
// IGNORE_LIGHT_ANALYSIS
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
class Foo {
val res: String
init {
runOnce {
res = "OK"
}
}
}
fun box(): String {
return Foo().res
}

View File

@@ -0,0 +1,61 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun test1(): String {
var res = ""
for (s in listOf("OK")) {
runOnce {
res += s
}
}
return res
}
fun test2(): String {
var res = ""
for (s: String in listOf("OK")) {
runOnce {
res += s
}
}
return res
}
fun test3(): String {
var res = ""
for ((s, _) in listOf("OK" to "FAIL")) {
runOnce {
res += s
}
}
return res
}
fun test4(): String {
var res = ""
for ((s: String, _) in listOf("OK" to "FAIL")) {
runOnce {
res += s
}
}
return res
}
fun box(): String {
test1().let { if (it != "OK") return "FAIL 1: $it" }
test2().let { if (it != "OK") return "FAIL 2: $it" }
test3().let { if (it != "OK") return "FAIL 3: $it" }
test4().let { if (it != "OK") return "FAIL 4: $it" }
return "OK"
}

View File

@@ -0,0 +1,24 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun foo(b: Boolean): String {
val res: String
runOnce {
b
res = "OK"
}
return res
}
fun box(): String {
return foo(true)
}

View File

@@ -0,0 +1,37 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun o(): String {
var res = "FAIL1 "
("O" to "").let { (a, _) ->
runOnce {
res = a
}
}
return res
}
fun k(): String {
val res: String
"K".let { b ->
runOnce {
res = b
}
}
return res
}
fun box(): String {
return o() + k()
}

View File

@@ -0,0 +1,26 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
import kotlin.contracts.*
fun runOnce(action: () -> Unit) {
contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE)
}
action()
}
fun ok(): String {
val res: String
when (val o = "OK") {
else -> runOnce {
res = o
}
}
return res
}
fun box(): String {
return ok()
}

View File

@@ -1,6 +1,6 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_DCE_DRIVEN
fun interface KRunnable {

View File

@@ -1,7 +1,7 @@
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// SKIP_DCE_DRIVEN
fun interface MyRunnable {
fun invoke()

View File

@@ -10,11 +10,37 @@ fun interface CharToAny {
fun invoke(c: Char): Any
}
fun foo(c: CharToAny): Any = c.invoke('O')
fun interface GenericToAny<T> {
fun invoke(t: T): Any
}
fun interface GenericCharToAny: GenericToAny<Char>
fun foo1(c: CharToAny): Any = c.invoke('1')
fun <T> foo2(t: T, g: GenericToAny<T>): Any = g.invoke(t)
fun foo3(c: GenericCharToAny) = c.invoke('3')
fun box(): String {
if (foo { it } !is Char) return "fail"
val c1 = foo1 { it }
if (c1 !is Char || c1 != '1') return "fail1"
val c2 = foo2<Char>('2') { it }
if (c2 !is Char || c2 != '2') return "fail2"
val c3 = foo3 { it }
if (c3 !is Char || c3 != '3') return "fail3"
val c4 = CharToAny { it }.invoke('4')
if (c4 !is Char || c4 != '4') return "fail4"
val c5 = GenericToAny<Char> { it }.invoke('5')
if (c5 !is Char || c5 != '5') return "fail5"
val c6 = GenericCharToAny { it }.invoke('6')
if (c6 !is Char || c6 != '6') return "fail6"
return "OK"
}

View File

@@ -0,0 +1,33 @@
// !LANGUAGE: +FunctionalInterfaceConversion
// IGNORE_BACKEND_FIR: JVM_IR
// SKIP_DCE_DRIVEN
fun interface S {
fun invoke(): String
}
fun interface G<T> {
fun foo(t: T): T
}
fun interface C: G<Char>
fun interface C2 {
fun bar(c: Char): Char
}
fun box(): String {
val g = G<Int> { it * 10 }
if (g.foo(2) != 20) return "fail1"
val g2 = G { a: Char -> a + 1 }
if (g2.foo('a') != 'b') return "fail2"
val c = C { it + 2 }
if (c.foo('A') != 'C') return "fail3"
val c2 = C2 { it + 3 }
if (c2.bar('0') != '3') return "fail4"
return S { "OK" }.invoke()
}

View File

@@ -0,0 +1,11 @@
class A<out K> {
fun foo(x: @UnsafeVariance K): K = x
}
fun test(a: A<*>): Any? {
return a.foo("OK")
}
fun box(): String {
return test(A<String>()) as String
}

View File

@@ -0,0 +1,13 @@
// FIR_IDENTICAL
class Foo<out T>(val baz: Baz<T>)
class Bar {
val foo: Foo<*> = TODO()
fun <T> bar(): Baz<T> {
return foo.baz
}
}
typealias Baz<T> = (@UnsafeVariance T) -> Unit

View File

@@ -0,0 +1,19 @@
package
public final class Bar {
public constructor Bar()
public final val foo: Foo<*>
public final fun </*0*/ T> bar(): Baz<T> /* = (@kotlin.UnsafeVariance T) -> kotlin.Unit */
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo</*0*/ out T> {
public constructor Foo</*0*/ out T>(/*0*/ baz: Baz<T> /* = (@kotlin.UnsafeVariance T) -> kotlin.Unit */)
public final val baz: Baz<T> /* = (@kotlin.UnsafeVariance T) -> kotlin.Unit */
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias Baz</*0*/ T> = (@kotlin.UnsafeVariance T) -> kotlin.Unit

View File

@@ -0,0 +1,22 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -REDUNDANT_PROJECTION
class FunctionHolder<out T : Any>(val f: (@UnsafeVariance T) -> Unit) {
fun f2(v: @UnsafeVariance T) {}
}
fun caller(
holder1: FunctionHolder<out Any>,
holder2: FunctionHolder<*>,
holder3: FunctionHolder<Any>,
a: Any
) {
holder1.f(a)
holder1.f2(a)
holder2.f(a)
holder2.f2(a)
holder3.f(a)
holder3.f2(a)
}

View File

@@ -0,0 +1,12 @@
package
public fun caller(/*0*/ holder1: FunctionHolder<out kotlin.Any>, /*1*/ holder2: FunctionHolder<*>, /*2*/ holder3: FunctionHolder<kotlin.Any>, /*3*/ a: kotlin.Any): kotlin.Unit
public final class FunctionHolder</*0*/ out T : kotlin.Any> {
public constructor FunctionHolder</*0*/ out T : kotlin.Any>(/*0*/ f: (@kotlin.UnsafeVariance T) -> kotlin.Unit)
public final val f: (@kotlin.UnsafeVariance T) -> kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun f2(/*0*/ v: @kotlin.UnsafeVariance T): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -1,10 +0,0 @@
// !WITH_NEW_INFERENCE
interface A<out K> {
fun foo(x: @UnsafeVariance K): Unit
}
fun test(a: A<*>) {
a.foo(null)
a.foo(Any())
}

View File

@@ -1,10 +1,10 @@
// !WITH_NEW_INFERENCE
// FIR_IDENTICAL
interface A<out K> {
fun foo(x: @UnsafeVariance K): Unit
}
fun test(a: A<*>) {
a.foo(<!NI;NULL_FOR_NONNULL_TYPE!>null<!>)
a.foo(<!NI;TYPE_MISMATCH!>Any()<!>)
a.foo(null)
a.foo(Any())
}

View File

@@ -0,0 +1,11 @@
interface UpdatableRendering<out T : UpdatableRendering<T>> {
fun canUpdateFrom(another: @UnsafeVariance T): Boolean
}
internal fun Any.matchesRendering(other: Any): Boolean {
return when {
this::class != other::class -> false
this !is UpdatableRendering<*> -> true
else -> this.<!INAPPLICABLE_CANDIDATE!>canUpdateFrom<!>(other as UpdatableRendering<*>)
}
}

View File

@@ -0,0 +1,11 @@
interface UpdatableRendering<out T : UpdatableRendering<T>> {
fun canUpdateFrom(another: @UnsafeVariance T): Boolean
}
internal fun Any.matchesRendering(other: Any): Boolean {
return when {
this::class != other::class -> false
this !is UpdatableRendering<*> -> true
else -> <!DEBUG_INFO_SMARTCAST!>this<!>.canUpdateFrom(other as UpdatableRendering<*>)
}
}

View File

@@ -0,0 +1,10 @@
package
internal fun kotlin.Any.matchesRendering(/*0*/ other: kotlin.Any): kotlin.Boolean
public interface UpdatableRendering</*0*/ out T : UpdatableRendering<T>> {
public abstract fun canUpdateFrom(/*0*/ another: @kotlin.UnsafeVariance T): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -0,0 +1,10 @@
fun interface Foo<T> {
fun invoke(): T
}
fun test() {
Foo { }
Foo<Unit> { }
Foo<String> <!TYPE_MISMATCH!>{ }<!>
Foo<String> { "" }
}

View File

@@ -0,0 +1,10 @@
package
public fun test(): kotlin.Unit
public fun interface Foo</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun invoke(): T
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -2,7 +2,7 @@
// !JVM_DEFAULT_MODE: enable
interface A<T> {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun test(p: T) {
}
}

View File

@@ -13,7 +13,7 @@ public interface JavaInterface {
// FILE: 1.kt
interface KotlinInterface : JavaInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
override fun test() {}
<!NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT!>override fun testForNonDefault()<!> {}
@@ -22,7 +22,7 @@ interface KotlinInterface : JavaInterface {
}
interface KotlinInterface2 : JavaInterface, KotlinInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
override fun test() {}
override fun testForNonDefault() {}
@@ -37,7 +37,7 @@ interface KotlinInterfaceForIndirect : JavaInterface {
interface KotlinInterfaceIndirectInheritance : KotlinInterfaceForIndirect {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
override fun test() {}
<!NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT!>override fun testForNonDefault()<!> {}
@@ -63,7 +63,7 @@ interface KotlinInterfaceX {
}
interface KotlinInterfaceManySuper: JavaInterface, KotlinInterfaceX {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
override fun test() {}
<!NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT!>override fun testForNonDefault()<!> {}

View File

@@ -1,7 +1,7 @@
// !JVM_TARGET: 1.8
interface A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!> {
}
}
@@ -28,7 +28,7 @@ class Bar2 : Foo(), A
class Bar3 : Foo(), B
open class BarWithJvmDefault : B {
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
override fun test() {
}
}

View File

@@ -2,12 +2,12 @@
// !JVM_TARGET: 1.8
public interface KInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun test(): String {
return "OK";
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val property: String
get() = "OK"
@@ -23,7 +23,7 @@ public interface KInterface {
// FILE: 1.kt
interface KotlinInterface : KInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun fooo() {
super.test()
super.property
@@ -42,7 +42,7 @@ interface KotlinInterface : KInterface {
}
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val propertyy: String
get() {
super.test()
@@ -105,7 +105,7 @@ interface KotlinInterface : KInterface {
}
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun foooo() {
super.test()
super.property
@@ -124,7 +124,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
}
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val propertyyy: String
get() {
super.test()

View File

@@ -15,7 +15,7 @@ public interface JavaInterface {
// FILE: 1.kt
interface KotlinInterface : JavaInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun fooo() {
super.test()
@@ -26,7 +26,7 @@ interface KotlinInterface : JavaInterface {
}
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val propertyy: String
get() {
super.test()
@@ -39,14 +39,14 @@ interface KotlinInterface : JavaInterface {
return ""
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
override fun testOverride(): String {
return "OK";
}
}
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun foooo() {
super.test()
@@ -57,7 +57,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
}
}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val propertyyy: String
get() {
super.test()

View File

@@ -2,27 +2,27 @@
interface B {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!> {}
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
abstract fun test2(s: String = "")<!>
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
abstract fun test3()<!>
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
abstract val prop: String<!>
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
abstract val prop2: String<!>
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
val prop3: String<!>
get() = ""
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
var prop4: String<!>
get() = ""
set(<!UNUSED_PARAMETER!>value<!>) {}

View File

@@ -2,21 +2,21 @@
abstract class A {
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
fun test() {}
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
abstract fun test2(s: String = "")
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
abstract fun test3()
}
object B {
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
fun test() {}
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_NOT_IN_INTERFACE!>@JvmDefault<!>
fun test2(<!UNUSED_PARAMETER!>s<!>: String = "") {}
}

View File

@@ -3,12 +3,12 @@
interface B {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val prop1: String
<!WRONG_ANNOTATION_TARGET!>@<!DEPRECATION!>JvmDefault<!><!> get() = ""
<!WRONG_ANNOTATION_TARGET!>@JvmDefault<!> get() = ""
var prop2: String
<!WRONG_ANNOTATION_TARGET!>@<!DEPRECATION!>JvmDefault<!><!> get() = ""
<!WRONG_ANNOTATION_TARGET!>@<!DEPRECATION!>JvmDefault<!><!> set(<!UNUSED_PARAMETER!>value<!>) {}
<!WRONG_ANNOTATION_TARGET!>@JvmDefault<!> get() = ""
<!WRONG_ANNOTATION_TARGET!>@JvmDefault<!> set(<!UNUSED_PARAMETER!>value<!>) {}
}

View File

@@ -2,7 +2,7 @@
// !JVM_DEFAULT_MODE: enable
interface A {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun test() {}
}

View File

@@ -2,7 +2,7 @@
// !JVM_DEFAULT_MODE: enable
interface A {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val test: String
get() = "OK"
}

View File

@@ -1,7 +1,7 @@
// !JVM_TARGET: 1.8
// FILE: 1.kt
interface A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!> {
}
}
@@ -12,7 +12,7 @@ interface <!JVM_DEFAULT_THROUGH_INHERITANCE!>B<!> : A {
}
interface C : B {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
override fun test()<!> {
super.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
}

View File

@@ -1,6 +1,6 @@
// !JVM_TARGET: 1.8
interface A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!> {
}
}
@@ -16,7 +16,7 @@ interface B{
interface C : A, B {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
override fun test()<!> {
super<B>.test()
super<A>.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()
@@ -24,7 +24,7 @@ interface C : A, B {
}
interface D : B, A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
override fun test()<!> {
super<B>.test()
super<A>.<!USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL!>test<!>()

View File

@@ -1,6 +1,6 @@
// !JVM_TARGET: 1.8
interface A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!>
}

View File

@@ -1,6 +1,6 @@
// !JVM_TARGET: 1.8
interface A {
<!JVM_DEFAULT_IN_DECLARATION!>@<!DEPRECATION!>JvmDefault<!>
<!JVM_DEFAULT_IN_DECLARATION!>@JvmDefault
fun test()<!> {
}

View File

@@ -2,27 +2,27 @@
interface B {
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
fun test() {}
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
abstract fun test2(s: String = "")
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
abstract fun test3()
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
abstract val prop: String
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
abstract val prop2: String
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
val prop3: String
get() = ""
<!JVM_DEFAULT_IN_JVM6_TARGET!>@<!DEPRECATION!>JvmDefault<!><!>
<!JVM_DEFAULT_IN_JVM6_TARGET!>@JvmDefault<!>
var prop4: String
get() = ""
set(<!UNUSED_PARAMETER!>value<!>) {}

View File

@@ -3,27 +3,27 @@
interface B {
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
fun test() {}
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
abstract fun test2(s: String = "")
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
abstract fun test3()
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
abstract val prop: String
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
abstract val prop2: String
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
val prop3: String
get() = ""
@<!DEPRECATION!>JvmDefault<!>
@JvmDefault
var prop4: String
get() = ""
set(<!UNUSED_PARAMETER!>value<!>) {}

View File

@@ -0,0 +1,18 @@
// FIR_IDENTICAL
// FULL_JDK
// Issue: KT-37497
import java.util.*
object Bug1 {
@JvmStatic
fun main(args: Array<String>) {
val list = object : ArrayList<String>(listOf("a")) {
override fun sort(c: Comparator<in String>?) {
super.sort(c)
println(c)
}
}
println(list)
}
}

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