Compare commits

...

648 Commits

Author SHA1 Message Date
anastasiia.spaseeva
a6b7a38bc0 test 2 2021-04-19 17:18:27 +02:00
anastasiia.spaseeva
25386aa0e0 Merge branch '1.5.0-github-testing' of https://github.com/JetBrains/kotlin into 1.5.0-github-testing 2021-04-19 17:10:12 +02:00
anastasiia.spaseeva
e6ec318425 test 2021-04-19 17:09:48 +02:00
Stanislav Erokhin
3cdad07fe4 add file2 2021-04-19 17:08:56 +02:00
Stanislav Erokhin
572f93de06 add file 2021-04-19 16:59:48 +02:00
Ilmir Usmanov
d0fa40cc5f Generate return when generating continuation class for expression body
Otherwise, the function will return Unit instead of correct value.
 #KT-46007 Fixed
2021-04-19 09:57:31 +02:00
Ilmir Usmanov
bd2d6c8083 Add 'value' modifier to modifier order
Otherwise, there will be unfixable 'non-canonical modifier order'
warning
 #KT-46088
 #KTIJ-5636 Fixed
2021-04-19 09:55:26 +02:00
Dmitry Petrov
5b6a57be15 JVM_IR KT-45934 don't generate declaration stubs for delegates
(cherry picked from commit e89ab71bf8)
2021-04-16 12:28:41 +03:00
Dmitry Petrov
dd2a9e11c0 JVM_IR KT-46092 fix array spread operator in Kotlin->Java call
(cherry picked from commit cc415f62b5)
2021-04-16 12:28:41 +03:00
Dmitry Petrov
a7592b93f2 PSI2IR KT-46069 resolve IR-based type parameter descriptors to symbols
(cherry picked from commit f1eeb72c01)
2021-04-16 12:28:41 +03:00
Dmitry Petrov
d88bb951a4 JVM_IR KT-46060 'contains' operator without receiver is non-optimizable
(cherry picked from commit 531a0de399)
2021-04-16 12:28:41 +03:00
Dmitry Petrov
22e6c88fba JVM_IR KT-45187 use Arrays.copyOf to copy an array in spread operator
Creating a new array (and copying data into it with System.arraycopy)
doesn't work in generic case, because the actual array class depends on
call site.

(cherry picked from commit 7d62f0b5aa)
2021-04-16 12:28:40 +03:00
Dmitry Petrov
efa79b3519 JVM_IR KT-45853 include return type into Java method IdSignature
This is a hack required to accept [potentially] incorrect input
provided by the front-end; see KT-46042.

(cherry picked from commit 7e03f8ea80)
2021-04-16 12:28:40 +03:00
Dmitry Petrov
98aced50ef JVM_IR KT-45967 generate accessor for argument of indy intrinsic
TODO handle inaccessible constructors gracefully

(cherry picked from commit f59b49db68)
2021-04-16 12:28:40 +03:00
Dmitry Petrov
9c571af0d4 JVM_IR KT-45868 look for parent for delegating lambda in scope stack
(cherry picked from commit ed88aa43a4)
2021-04-16 12:28:40 +03:00
Dmitry Petrov
08bc150a56 JVM_IR KT-45920 don't add special bridge if it clashes with known method
(cherry picked from commit c2a5b0b6e2)
2021-04-16 12:28:39 +03:00
Ilya Gorbunov
8663fe580a Support Char.code in constant evaluator, KT-46036
But do not consider Char.code a pure integer constant.

(cherry picked from commit 8041c3aa1d)
2021-04-16 04:31:05 +03:00
Leonid Startsev
bba22e8330 Support new inline(value) class syntax in serialization plugin
Use .isInlineClass() instead of .isInline + .isValue

 #KT-45783 Fixed

(cherry picked from commit f94e8f95d1)
2021-04-15 14:32:04 +03:00
Andrei Klunnyi
892b597041 KT-46049 Java-Kotlin sealed inheritors inspection: refactoring
(cherry picked from commit 73d2e1a42d)
2021-04-15 13:28:24 +02:00
Andrei Klunnyi
ef6102565d KT-46049 Java-Kotlin sealed inheritors inspection: false positive for type parameter
^KT-46049 Fixed

(cherry picked from commit 2fce968de0)
2021-04-15 13:28:23 +02:00
Ilya Goncharov
60ef5b385a [Gradle, JS] Mark visited dependencies inside dependency graph traversing
(cherry picked from commit 266daed2cb)
2021-04-15 13:15:40 +03:00
Ilmir Usmanov
aa09f7ba03 Minor. Change warning message 2021-04-15 12:10:51 +02:00
Yahor Berdnikau
7514aced27 Fix plugin is using deprecated method that is removed in AGP 7.0.
^KT-45950 Fixed
2021-04-15 11:08:00 +02:00
Yahor Berdnikau
a118653e35 Set Android Gradle Plugin dependency version to 3.4.0.
This is required to get method deprecations and new proposed methods.
2021-04-15 11:07:56 +02:00
Nikolay Krasko
2cae6756ce Add dependencies verification for prepareSonatypeStaging.gradle
File is applied conditionally when sonatype publication is enabled.
2021-04-13 17:50:04 +03:00
Margarita Bobova
e84e667929 Add changelog for 1.5.0-RC 2021-04-13 16:31:26 +03:00
anastasiia.spaseeva
952f11287d Add changelog for 1.5.0-M2 2021-04-13 16:30:27 +03:00
Svyatoslav Scherbina
eea18585b9 Update Kotlin/Native: 1.5-rc1-41 2021-04-12 18:26:17 +03:00
Victor Petukhov
275f8fcf63 Avoid subtype checking between type variable of self type and captured star projection only for invariant positions
Subtyping with non-invariant positions may produce useful constraints

^KT-46001 Fixed
2021-04-12 13:40:21 +03:00
Svyatoslav Scherbina
8f80deefc3 Update Kotlin/Native: 1.5-rc1-17 2021-04-09 10:51:31 +03:00
Abduqodiri Qurbonzoda
7fe4eb767c Remove deprecated JQuery
(cherry picked from commit 46338224e1)
2021-04-08 19:35:12 +03:00
Abduqodiri Qurbonzoda
db7649d635 Migrate compiler and idea-completion testData 2021-04-08 18:32:21 +03:00
Abduqodiri Qurbonzoda
89d7383365 Migrate stdlib, tests and samples to new case conversion api 2021-04-08 18:32:20 +03:00
Abduqodiri Qurbonzoda
36c788b57c Deprecate old Char and String case conversion api #KT-43023 2021-04-08 18:32:20 +03:00
Abduqodiri Qurbonzoda
0a9d6ad30e Deprecate sumBy and sumByDouble with WARNING
(cherry picked from commit 33b44585c4)
2021-04-08 15:32:11 +03:00
Renee Vandervelde
cc23d0bad9 Add assertEquals and assertNotEquals for floating point numbers to kotlin-test #KT-8364
(cherry picked from commit d520c37454)
2021-04-08 14:39:04 +03:00
Abduqodiri Qurbonzoda
c57f367040 Introduce assertContains in kotlin-test #KT-45582
(cherry picked from commit ff59b1c2ef)
2021-04-08 14:39:02 +03:00
Ilya Gorbunov
2027fff626 Deprecate Char-to-Number conversions in stdlib (JVM and JS)
- Int.toChar was left non-deprecated because the replacement is not intrinsic yet.
- Number.toChar was left non-deprecated because otherwise the deprecation propagates to the override, Int.toChar.

KT-23451

(cherry picked from commit b64b96eee6)
2021-04-08 13:36:27 +03:00
Abduqodiri Qurbonzoda
aef884efe1 Disable Werror in the release branch
This is to avoid migrating all the usages that will become deprecated
 after the following changes.
2021-04-08 13:36:25 +03:00
Alexander Udalov
c81ce8637a Add kotlin.build.disable.werror to disable -Werror locally
This can be placed, for example, in `local.properties` to temporarily
disable `-Werror` in compiler/stdlib/plugin/test modules during
development.

(cherry picked from commit 496d857db1)
2021-04-08 13:07:33 +03:00
Ilya Gorbunov
52846e7722 Hide deprecated JS Math object from public API and rename to JsMath
KT-41318

- Rename Math to JsMath and remove unused functions
- Fix return types, remove duplicating JsMath from longjs.kt

Co-authored-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
(cherry picked from commit d70edeb38b)
2021-04-08 13:00:45 +03:00
Abduqodiri Qurbonzoda
1902be18a1 Mute a failing test of the old J2K, the old J2K is removed in master 2021-04-08 12:50:21 +03:00
Abduqodiri Qurbonzoda
97399e5269 Advance max/min(By/With) deprecation level to ERROR
(cherry picked from commit b0f1ddc91e)
2021-04-08 12:50:19 +03:00
Abduqodiri Qurbonzoda
8c2f1a5fc9 Advance deprecation level of mixed Int/FP overloads of ClosedRange.contains to HIDDEN KT-22423
(cherry picked from commit d9ab96126d)
2021-04-08 12:50:18 +03:00
Abduqodiri Qurbonzoda
ff223a4901 Advance String(CharArray) deprecation level to ERROR in Common and JS 2021-04-08 12:50:17 +03:00
Abduqodiri Qurbonzoda
44a18616b0 Remove deprecated Clock and ClockMark
(cherry picked from commit 29040d6f53)
2021-04-08 12:50:16 +03:00
Abduqodiri Qurbonzoda
a77ddbe6d8 Remove deprecated scanReduce and scanReduceIndexed
(cherry picked from commit abcc572b97)
2021-04-08 12:50:14 +03:00
Abduqodiri Qurbonzoda
6c7d4b1905 Remove DefaultAsserter() constructor-like function in kotlin-test
(cherry picked from commit c46d71d4ac)
2021-04-08 12:50:13 +03:00
Abduqodiri Qurbonzoda
6a2da4bb4b Advance deprecation level of FP to lesser than Int types to ERROR #KT-30360
(cherry picked from commit 968099fbec)
2021-04-08 12:50:12 +03:00
Abduqodiri Qurbonzoda
c62d099d60 Advance deprecation level of InputStream.readBytes(estimatedSize) to ERROR
(cherry picked from commit e8992c5d19)
2021-04-08 12:50:12 +03:00
Dmitriy Novozhilov
9e4ff58aac Support actualization of expect sealed class with typealias in CliSealedClassInheritorsProvider 2021-04-08 11:38:01 +03:00
Dmitriy Novozhilov
9e2a1a404d Refine expect classes in CliSealedClassInheritorsProvider
KT-45796 Fixed
2021-04-08 11:38:01 +03:00
Ilya Gorbunov
991afb382f Fix case-insensitive character-wise comparison KT-45496
- Step 1: add failing tests
- Step 2: fix common case insensitive Char.equals
- Step 3: fix case insensitive String.equals in K/JS
- Step 4: enable unicode case folding in K/JS Regexes and
  string replacement (KT-45928)

(cherry picked from commit 22ca412dd2)
2021-04-07 14:49:12 +03:00
Ilya Gorbunov
376b250482 Add description for kotlin.io.path package
(cherry picked from commit f1cdd0e2ed)
2021-04-06 14:34:10 +03:00
Ilya Gorbunov
28d469aeec Stabilize existing Path API and annotate with @Throws where appropriate
KT-45913

(cherry picked from commit 81f2aea316)
2021-04-06 14:34:09 +03:00
Ilya Gorbunov
4673fd1e90 Stabilize new string and char case conversion API KT-45873
(cherry picked from commit 35ae913a5e)
2021-04-06 14:33:19 +03:00
Ilya Gorbunov
ab24019e40 Support all digit chars in digitToInt on JVM KT-23451
(cherry picked from commit 256f634e61)
2021-04-06 14:32:53 +03:00
Ilya Gorbunov
a95d69a9a8 Stabilize Char-to-Int conversions KT-45874
(cherry picked from commit 8b85bae020)
2021-04-06 14:32:49 +03:00
Ilya Gorbunov
b273bc17fe Duration: inWholeUnits properties instead of inUnits
Introduce conversion properties returning Long values,
deprecate the old ones returning Doubles.

(cherry picked from commit 0e93924ff3)
2021-04-02 19:10:49 +03:00
Ilya Gorbunov
809e85f9b4 Make Duration storage ranges symmetric and non-overlapping
Increase accuracy of multiplication and division.

(cherry picked from commit 11d15f3343)
2021-04-02 19:10:46 +03:00
Ilya Gorbunov
dc7d6021b6 Advance TestTimeSource more precisely
Change durations in its test so that they hold precise number
of nanoseconds

(cherry picked from commit 4fd2254f3f)
2021-04-02 19:10:43 +03:00
Ilya Gorbunov
5c82d8cd33 Store Duration value as a multi-range Long
Now precision loss happens at bigger durations.

This changes the binary API due different underlying type of Duration.

(cherry picked from commit fa7460ba48)
2021-04-02 19:10:39 +03:00
Ilmir Usmanov
b3e556e662 Enable suspend in fun interfaces by default
#KT-45836 Fixed
2021-04-02 14:40:46 +02:00
Ilya Muradyan
c14039cd37 [Scripting] Fix Bintray-dependent test 2021-04-01 16:47:55 +03:00
Nikolay Krasko
58d5b1bd26 Update verification data with older versions 2021-04-01 16:20:28 +03:00
Nikolay Krasko
46c68b4d1e Disable verification in IDE bunches 2021-04-01 16:15:56 +03:00
Nikolay Krasko
c8dfb1d6f5 CodeConformanceTest for no Bintray except jcenter (KTI-528)
(cherry picked from commit 7f60cd81fe)
2021-04-01 16:06:04 +03:00
Nikolay Krasko
ee5d677b19 Drop scripts for uploading to plugin repository (KTI-528)
(cherry picked from commit b48ede4a62)
2021-04-01 16:05:39 +03:00
Nikolay Krasko
ea394f4de4 Bintray dukat -> Space kotlin/kotlin-dependencies (KTI-528)
(cherry picked from commit 35ad28c372)
2021-04-01 16:05:25 +03:00
Nikolay Krasko
86b9fbbc14 Drop Bintray from maven inspections tests (KTI-528)
(cherry picked from commit d10f4ad718)
2021-04-01 16:05:11 +03:00
Nikolay Krasko
81733beb6a Stop using Bintray in ignored test in MavenResolverTest (KTI-528)
(cherry picked from commit 03c0a81a33)
2021-04-01 16:04:56 +03:00
Nikolay Krasko
607742de8c Drop Bintray from wizards (KTI-528)
(cherry picked from commit c868116535)
2021-04-01 16:04:42 +03:00
Nikolay Krasko
01f095adbc Move testResolveDependencyOnMppInCustomConfiguration to library from maven central (KTI-528)
(cherry picked from commit c74a3bd2b1)
2021-04-01 16:04:30 +03:00
Nikolay Krasko
0e28db28f3 Drop bintray from Gradle inspections and fixes tests (KTI-528)
(cherry picked from commit 1547d4f516)
2021-04-01 16:04:16 +03:00
Nikolay Krasko
6de5c408ff Drop bootstrap mentioning from CodeConformanceTest
(cherry picked from commit 7a9c2c1d17)
2021-04-01 16:04:14 +03:00
Nikolay Krasko
f4b464c126 Drop custom private Bintray Android Studio repository (KTI-528)
(cherry picked from commit 529fc352b3)
2021-04-01 16:04:01 +03:00
Nikolay Krasko
8d06261a9d Drop bintray kotlin-dev (KTI-528)
(cherry picked from commit 5631481747)
2021-04-01 16:03:47 +03:00
Nikolay Krasko
c8e0f3399a Drop bintray jetbrains markdown (KTI-528)
(cherry picked from commit 1cedc7e93e)
2021-04-01 16:03:33 +03:00
Nikolay Krasko
31ae15d19b Replace intellij-third-party-dependencies repository (KTI-528)
(cherry picked from commit 832523e23f)
2021-04-01 16:03:30 +03:00
Nikolay Krasko
f4cb821f08 Rearrange list of repositories - move jcenter to the end
(cherry picked from commit 87d509a7aa)
2021-04-01 16:01:00 +03:00
Nikolay Krasko
59cd8c5c5d Update cache redirector for more complex aliases
For example:
"https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" to "https://cache-redirector.jetbrains.com/intellij-dependencies",

(cherry picked from commit 818855d6f0)
2021-04-01 16:00:57 +03:00
Nikolay Krasko
33eb57043e Fix build of benchmarks module
Fix after 998a65d1cb

(cherry picked from commit c680ee8525)
2021-04-01 15:58:54 +03:00
Nikolay Krasko
65b7365684 Move Bintray js-externals to Space (KTI-528)
(cherry picked from commit a5e445492f)
2021-04-01 15:58:29 +03:00
Nikolay Krasko
880c628a69 Drop kotin/kotlinx and kotlin/kotlinx.html bintray usages (KTI-528)
(cherry picked from commit b903f87704)
2021-04-01 15:58:14 +03:00
Nikolay Krasko
c56025572c Bump version of kotlinx.benchmark plugin 0.2.0-dev-7 -> 0.3.0 (KTI-528)
(cherry picked from commit 998a65d1cb)
2021-04-01 15:57:49 +03:00
Nikolay Krasko
712c79c270 Minor: investigate j2objc-annotations:1.1 verification trace
(cherry picked from commit 455773299b)
2021-04-01 15:57:45 +03:00
Nikolay Krasko
117a88f7ba Add dependency verification description to ReadMe.md
(cherry picked from commit ddc12834cb)
2021-04-01 15:57:42 +03:00
Nikolay Krasko
113ff90c5b Trust all module metadata till Gradle 6.8 update (KTI-493)
There's and issue with absent module files in the cache that leads to
"Artifact has been deleted from dependency cache" that can be resolved
by cleaning caches. It should be fixed in Gradle 6.8

https://github.com/gradle/gradle/issues/12713
(cherry picked from commit 1558bd7373)
2021-04-01 15:54:59 +03:00
Nikolay Krasko
7145b524bf Trust all poms till Gradle 6.8 update (KTI-493)
There's and issue with absent poms in the cache that leads to
"Artifact has been deleted from dependency cache" that can be resolved
by cleaning caches. It should be fixed in Gradle 6.8

https://github.com/gradle/gradle/issues/12713
(cherry picked from commit 73bc16896d)
2021-04-01 15:54:57 +03:00
Nikolay Krasko
d41652b42b Trust javadoc and sources artifacts as the shouldn't be used in builds (KTI-493)
(cherry picked from commit efcb071f24)
2021-04-01 15:54:44 +03:00
Nikolay Krasko
8f877b33ba Trust kotlin-native-prebuild-* (KTI-493)
Need more investigation for this artifact

(cherry picked from commit fd921f1dc0)
2021-04-01 15:54:38 +03:00
Nikolay Krasko
0cfbeffaeb Trust kotlin artifacts for bootstrapping (KTI-493)
Can't predict exact version after build

(cherry picked from commit fae1215881)
2021-04-01 15:54:36 +03:00
Nikolay Krasko
0bc77f90dd Trust ivy xml files as they are constantly regenerated (KTI-493)
(cherry picked from commit 4bbba74360)
2021-04-01 15:54:33 +03:00
Nikolay Krasko
fd9b5f8c27 Add dependencies lock with md5 and sha256 (KTI-493)
Initial commit without explicit check or cleanup.

Includes Kotlin Native dependencies.

(cherry picked from commit 8240f5e459)
2021-04-01 15:54:31 +03:00
Ilya Gorbunov
e9e62622b6 Stabilize unsigned types KT-45653
Deprecate specialized unsigned iterators for removal.

Fix compiler tests:
- drop unsignedLiteralsOn1_2 because apiVersion 1.2 is no longer supported
- drop experimental unsigned literals diagnostic test

(cherry picked from commit 94240f7b21)
2021-04-01 14:56:36 +03:00
Victor Petukhov
f45a471457 Assert that the separation of two annotations on function type during rendering it, is any whitespace-like symbol, not only whitespace itself
E.g. in quick doc mode (HTML), it may be line break

^KT-38747 Fixed
2021-04-01 14:33:39 +03:00
Yahor Berdnikau
9d5b1dcd7a Fix Gradle 7 deprecation on adding associated compilation dependencies.
^KT-45787 Fixed
2021-04-01 10:50:54 +02:00
pyos
73147a7422 JVM_IR: cast bound property receivers to original type
Because the receiver type is used for determining where to put
accessors, and the type of fake overrides' receivers is the same as for
the original declaration, casting to the type of the parameter leads to
assertion errors.

 #KT-44658 Fixed

(cherry picked from commit 85aa6383ad)
2021-04-01 10:48:58 +02:00
Svyatoslav Scherbina
86f8c2ec5d Update Kotlin/Native: 1.5-eap-4 2021-03-31 15:17:32 +03:00
pyos
68f1925726 JVM_IR: do not inline @JvmStatic into their static proxies
(cherry picked from commit 66429cfb43)
2021-03-31 14:09:42 +02:00
pyos
b116597fd7 JVM_IR: remap calls to protected @JvmStatic in companions
Protected functions on unrelated classes cannot be called from outside
the current package, so in general, we can only call the static proxy,
not the original companion method.

This has an ABI compatibility implication in that removing `@JvmStatic`
from a protected companion method will require recompiling Kotlin use
sites (of course, this is already source- and binary-incompatible from
Java perspective).

 #KT-12063 Fixed

(cherry picked from commit a518a9407d)
2021-03-31 14:09:40 +02:00
Pavel Kirpichenkov
40d6d16b96 [IDE] Optimize stdlib cache for non-JVM modules
Consider only dependencies of JVM modules.
Cache found/missing stdlib dependencies for modules.

As of now, non-JVM platforms use default builtins in IDE.
For any non-JVM module indexed stdlib dependency is guaranteed
to be missing, searching for it is useless and costly.

^KTIJ-5666 Fixed
See also KT-44552
2021-03-31 14:09:21 +03:00
Andrey Zinovyev
6a2a1d7472 [parcelize] Fix codegen for generic classes
Replace type arguments with star projection in static methods
Fix IR function generation

^KT-42652  Fixed
2021-03-31 13:53:21 +03:00
Victor Petukhov
488d2206ef Regenerate tests 2021-03-31 11:12:46 +03:00
Victor Petukhov
10ba85d8c8 Mark some tests 'fir identical' 2021-03-31 11:12:46 +03:00
Matthew Gharrity
68554a0e93 KT-45676: fix backing field annotation resolve
(cherry picked from commit 2cb9d1f287)
2021-03-31 11:12:45 +03:00
Victor Petukhov
f641288fbe Report resolution ambiguity on '+=' by taking into account full resolution result including post type checking for '+'
^KT-45503 Fixed

(cherry picked from commit 5d78b0a962)
2021-03-31 11:12:45 +03:00
Victor Petukhov
a2d90ba39b Do subtyping between self types with captured type in special way
(cherry picked from commit bbf5c4412e)
2021-03-31 11:12:45 +03:00
Victor Petukhov
6ed1fe28d0 Propagate input type position across incorporation properly
^KT-45719 Fixed

(cherry picked from commit 7f2c5cde55)
2021-03-31 11:12:45 +03:00
Victor Petukhov
3ccf8e5aa5 Approximate types when only input types check is done. Otherwise given types are inconsistent with types obtained by ResultTypeResolver
^KT-45714 Fixed

(cherry picked from commit d06031ece3)
2021-03-31 11:12:45 +03:00
Victor Petukhov
86cdbf2328 Remove NonStrictOnlyInputTypesChecks LF and introduce opposite – StrictOnlyInputTypesChecks, set default as strict
(cherry picked from commit cc1cb463b2)
2021-03-31 11:12:45 +03:00
Victor Petukhov
c0ca5160ed Turn only input type warning to error
^KT-45482 Fixed

(cherry picked from commit b60056f11e)
2021-03-31 11:12:45 +03:00
Victor Petukhov
55e3ea9cfd Add compiler flag to enable strict mode for improvements in the type enhancement
^KT-45674 Fixed

(cherry picked from commit 9c38db754e)
2021-03-31 11:12:44 +03:00
Victor Petukhov
8b36ad6132 Rename LV ImprovementsAroundTypeEnhancement into TypeEnhancementImprovementsInStrictMode
(cherry picked from commit 731e3ebae1)
2021-03-31 11:12:44 +03:00
Victor Petukhov
91cd685616 Don't generate tests on top-down completion of the builder inference for WASM
(cherry picked from commit 4f1ed2f112)
2021-03-31 11:12:44 +03:00
Victor Petukhov
eacbe16965 Proper taking top level trace to pass it into completion
(cherry picked from commit 178910a2e5)
2021-03-31 11:12:44 +03:00
Victor Petukhov
36859d7eb1 Do updating calls for all nested builder inference sessions including at the same level
(cherry picked from commit e0a8e9a664)
2021-03-31 11:12:44 +03:00
Victor Petukhov
953b4880d5 Introduce hierarchy of inference sessions
(cherry picked from commit 999d1f982e)
2021-03-31 11:12:44 +03:00
Victor Petukhov
007e78100f Don't lose inference session in all the possible locations
(cherry picked from commit 80ac62864d)
2021-03-31 11:12:43 +03:00
Victor Petukhov
e33ecf0126 Rename CoroutineInferenceSession to BuilderInferenceSession
(cherry picked from commit b5d3f9ee31)
2021-03-31 11:12:43 +03:00
Victor Petukhov
25cb98e0d7 Implement top-down completion for nested builder inference calls
^KT-42742 Fixed

(cherry picked from commit 7a66e22bb2)
2021-03-31 11:12:43 +03:00
Victor Petukhov
035726372f Process captured types with type variable inside properly, in the operations related with the type variables fixation
(cherry picked from commit 60f2f85be7)
2021-03-31 11:12:43 +03:00
Victor Petukhov
d4db5eb818 Substitute captured types with type variables properly
^KT-44687 Fixed

(cherry picked from commit a2b1aa753b)
2021-03-31 11:12:42 +03:00
Victor Petukhov
371664caf3 Don't stop constraints processing if all type variables have proper equality constraints
Those type variable may have other constraints after incorporation into which, the constraint error may appear

^KT-42042 Fixed

(cherry picked from commit b87c2a15b5)
2021-03-31 11:12:42 +03:00
Ilmir Usmanov
372f412ffb JVM IR: IC coroutines: return boxed type from suspend function if
the function overrides function, returning type argument
 #KT-45451 Fixed
2021-03-31 01:19:19 +02:00
Alexander Udalov
dea37386c6 Workaround illegal access to JDK internals in DynamicBundle
This is basically a manual cherry-pick of
https://github.com/JetBrains/intellij-community/commit/547caebd980d.

 #KT-44624 Fixed

(cherry picked from commit 6e86df2f6d)
2021-03-30 20:36:58 +02:00
Alexander Udalov
8bc04c9465 Copy com.intellij.DynamicBundle to compiler/cli
This is needed to fix KT-44264 without updating the whole project to
intellij 203, which might take significant time.

In this commit, the file is copied as is from
27837dd8e6/platform/core-api/src/com/intellij/DynamicBundle.java.

(cherry picked from commit 8e1a70cff6)
2021-03-30 20:36:57 +02:00
Dmitriy Novozhilov
fb98338fb8 Add workaround for problem with incorrect bytecode generation for callable references
This commit may be removed after next bootstrap update
2021-03-30 18:21:32 +03:00
Dmitriy Novozhilov
43accd4127 Update testdata 2021-03-30 18:21:27 +03:00
Dmitriy Novozhilov
dcf2e0afc7 Advance bootstrap to 1.5.0-RC-556 2021-03-30 18:21:11 +03:00
Dmitriy Novozhilov
c3cfba6a8e Switch IS_PRE_RELEASE flag to false 2021-03-30 18:20:24 +03:00
Mikhail Zarechenskiy
5a410946e0 Fix add import quick fix for delegated property and missing extension
^KT-39199 Fixed
2021-03-30 17:02:44 +03:00
Steven Schäfer
6e8a5c88ad JVM IR: Avoid IndexOutOfBounds exceptions in TypeOperatorLowering
The code didn't account for SYNTHETIC_OFFSETs (KT-45688) and could
throw on IR containing broken line numbers (KT-44910).

(cherry picked from commit a7f8f0d903)
2021-03-30 14:35:10 +03:00
Dmitry Petrov
6cc687f16c JVM_IR fix receiver type for fake overrides
(cherry picked from commit 466e7b60b0)
2021-03-30 14:35:10 +03:00
Ilya Chernikov
cd97f2bcba Fix parameter index on IR script generation in REPL scenario
Before it, the wrong index lead to the validation error when repl
script definition had c-tor parameters (see test)
2021-03-26 18:24:20 +01:00
Ilya Chernikov
d0349731fa Fix arguments processing with scripting with old backend by default 2021-03-26 18:24:20 +01:00
Anton Yalyshev
de62199901 Add change-notes for 1.5-M2 release 2021-03-26 13:44:04 +03:00
Anton Yalyshev
aa10005b7a Add change-notes for 1.4.30 release
(cherry picked from commit 3e59adc7f3)
2021-03-26 13:44:03 +03:00
Ilya Goncharov
3df6559f30 [Gradle, JS] Fix packages with hardcoded display name
^KT-45621 fixed

[Gradle, JS] Use karma 6.0 API to set ping timeout

^KT-45621 fixed

[Gradle, JS] Changed API for warnings filter in Webpack 5

^KT-45621 fixed

[Gradle, JS] Add workaround for debugging with webpack 5

^KT-45621 fixed

[Gradle, JS] Use patch only for webpack 5

^KT-45621 fixed
2021-03-25 15:03:47 +03:00
Vladimir Dolzhenko
9423ba4ee1 Fix handling non ctor elements in SECONDARY_CONSTRUCTOR_DELEGATION_CALL
#KT-45339 Fixed

(cherry picked from commit 8068a5439f)
2021-03-24 21:20:00 +01:00
Andrei Klunnyi
712fe59d4b KT-44299 [Sealed Interfaces]: when exhaustiveness in IDE considers java inheritor
^KT-44299 fixed
2021-03-23 17:11:01 +01:00
Svyatoslav Kuzmich
0490fe79bb [JS IR] Fix kotlin.js.js with complex constant expressions
Use IR interpreter to evaluate complex constexprs
2021-03-23 19:06:49 +03:00
Victor Petukhov
c7666b173c Revert "Don't stop constraints processing if all type variables have proper equality constraints"
This reverts commit 8ba60d41
2021-03-23 18:33:25 +03:00
Alexander Udalov
bcb870f377 Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.

(cherry picked from commit ea01c97a8e)
2021-03-23 16:25:05 +01:00
Ilmir Usmanov
f6962dfb75 Allow Result return type and nullability operators on Result type
by default
2021-03-23 15:33:30 +01:00
Dmitry Petrov
ccba574e81 JVM_IR KT-45377 rewrite constants again after AddContinuationLowering 2021-03-23 17:17:06 +03:00
Ilya Goncharov
ae79455460 [Wizard, JS] Fix kotlin-redux version
(cherry picked from commit 0a444bbc43)
2021-03-23 15:13:12 +01:00
Alexander Udalov
df06c174d1 JVM IR: support inline classes with private constructors from other modules
#KT-44723 Fixed

(cherry picked from commit b5f9b1dfc0)
2021-03-23 15:02:54 +01:00
Ilmir Usmanov
69e8f77646 Check for backend when checking for suspend in fun interfaces 2021-03-23 12:35:30 +01:00
Dmitry Petrov
02ac4c49c5 Minor: regenerate compiler tests 2021-03-22 15:39:01 +03:00
Dmitry Petrov
643c9dffec JVM_IR KT-45581 generate H_INVOKEINTERFACE for interface method handles 2021-03-22 15:39:01 +03:00
Dmitry Petrov
42f382714d JVM_IR KT-45431 don't optimize out $$delegatedProperties in companion
Corresponding delegates are initialized in the host class, using
'$$delegatedProperties'.
TODO figure out proper code generation scheme for delegated properties
in companions (KT-45580)

(cherry picked from commit 73d4fa65ea)
2021-03-22 15:39:01 +03:00
Dmitry Petrov
b3fa48e9a3 JVM_IR KT-45408 rewrite static calls recursively
(cherry picked from commit f6baabd98e)
2021-03-22 15:39:01 +03:00
Alexander Udalov
dab0e642fe Deprecate KotlinJvmOptions.useIR
Starting from language version 1.5, JVM IR is enabled by default, so
this option has no effect. To rollback to the old JVM backend, the new
option useOldBackend can be used.

 #KT-45504 Fixed

(cherry picked from commit 415d52fe54)
2021-03-22 11:12:56 +01:00
Alexander Udalov
4b3eacf3a1 JVM IR: minor, improve error messages for inline classes
It will help in diagnosing problems like KT-44723.

(cherry picked from commit e5f218859b)
2021-03-22 11:12:44 +01:00
Ilya Gorbunov
9e987cfbf5 kotlin-test: make assertIs<T> returning value cast to T KT-45296
(cherry picked from commit 42648d55a0)
2021-03-19 17:06:19 +03:00
Ilya Gorbunov
8688f89680 Compile and run common tests of kotlin-test in kotlin-test-js-ir build
(cherry picked from commit 85a0538f0a)
2021-03-19 17:06:19 +03:00
Ilya Gorbunov
70d64b5db1 kotlin-test: assertIs and assertIsNot KT-45296
- Rename assertNotIs to assertIsNot
- Extract parts of implementation to helper internal PublishedApi
functions in order to inline minimum amount of code at use sites
- Remove PublishedApi from messagePrefix, no longer needed

(cherry picked from commit e66eeefe2a)
2021-03-19 17:06:18 +03:00
Ben Asher
5642780c88 kotlin-test: add assertIs and assertNotIs assertions KT-45296
(cherry picked from commit 3a0219d84c)
2021-03-19 17:06:18 +03:00
Sergey.Shanshin
d9cc6ccf1e Disabled deserialization fields check optimization for non-JVM platforms
Resolves KT-45440
2021-03-19 16:36:34 +03:00
Sergey.Shanshin
1635a258cc Revert lazy serializers for objects, sealed and abstract classes
Resolves KT-45440
2021-03-19 16:36:33 +03:00
Steven Schäfer
ee7a01e36b JVM IR: Resolve fake overrides when calculating return types (KT-44867)
(cherry picked from commit d0424465b8)
2021-03-19 11:56:06 +01:00
Dmitry Petrov
4a549af4b4 Minor: regenerate compiler tests 2021-03-19 12:54:08 +03:00
Dmitry Petrov
97d0170006 JVM_IR KT-45195 generate non-static annotation members as ACC_ABSTRACT 2021-03-19 12:54:08 +03:00
Dmitry Petrov
e9033aac9a Add bytecode listing tests for 'allopen' plugin with JVM_IR 2021-03-19 12:54:08 +03:00
Dmitry Petrov
4715dbc479 JVM_IR KT-36853 patch parents after tailrecPhase
(cherry picked from commit ac6232b4ba)
2021-03-19 12:54:08 +03:00
Ilya Goncharov
1967297d6f [Gradle, JS] Use one folder for sync tasks
[Gradle, JS] WA for tests with multiple binaries

^KT-45574 fixed
2021-03-19 12:48:02 +03:00
Ilya Goncharov
703cfabfd8 Add possibility to hardcode version
^KT-42921 fixed

[Gradle, JS] Adopt Gradle plugin to webpack 5

^KT-42921 fixed

[Gradle, JS] Update versions with karma-webpack 5.0.0

^KT-42921 fixed

[Gradle, JS] Webpack serve for webpack-dev-server

^KT-42921 fixed

[Gradle, JS] Fix of using format-util

^KT-42921 fixed

[Gradle, JS] Use compatible node version

^KT-42921 fixed

[Gradle, JS] Add compatibility with webpack 4

^KT-42921 fixed

[Gradle, JS] Support custom display name in npm versions generator

^KT-42921 fixed
2021-03-19 11:42:07 +03:00
Roman Artemev
847a9f247d [Psi2Ir] Fix generation of property references for synthetic java props
- Declare it on use-site
 - Fix export checker for that case
 - Fix KT-45297

(cherry picked from commit 44d03bc727)
2021-03-18 18:58:04 +03:00
Alexander Udalov
8cf8a31072 Fix ParallelBuildTest for Windows
Enclose file paths in raw strings. Otherwise in the string
"C:\Users\...", "\U" was detected as an illegal escape which led to an
error.

(cherry picked from commit a3a745e7a5)
2021-03-18 16:19:52 +01:00
Mikhail Zarechenskiy
e4d5e4e7d8 Disable check about unimplemented check for real defaults
Now we can generate proper defaults and there is no need in additional
 checks about unimplemented methods

 #KT-41130 Fixed
2021-03-18 15:25:54 +03:00
Mikhail Zarechenskiy
13df529a5a Use compiler arguments for Java against Kotlin highlighting tests
This is needed for the next commit to check jvm-default options

 #KT-41130 In Progress
2021-03-18 15:25:54 +03:00
Mikhail Zarechenskiy
bd489bc04d Do not generate DefaultImpls for light classes if not needed
#KT-41130 In Progress
2021-03-18 15:25:50 +03:00
SokolovaMaria
a0c1d73fee Exclude kotlinx.atomicfu compiler plugin modules 2021-03-18 14:39:12 +03:00
Alexander Udalov
3ff2ff7b8a Add JVM target bytecode version 16
#KT-45515 Fixed

(cherry picked from commit 27174de891)
2021-03-18 11:56:04 +01:00
Alexander Udalov
baf8edc3ff Deduplicate source roots in psi2ir and CLI
Compiler plugins can add new source roots to the next compilation round
by using `AnalysisResult.RetryWithAdditionalRoots`. Some plugins added
already existing source roots to this list in some cases. For example,
this is reproducible with `square/anvil` with incremental compilation
(KT-45100, KT-44925). Psi2ir didn't deduplicate the source files before,
which resulted in several classes with the same name linked to the same
symbol. This led to a "symbol is already bound" exception, and in case
of KT-44925, to an additional NPE when we were rendering the class to
display it in the message.

The solution is to deduplicate classes before psi2ir. Note that this
commit has two changes, in CLI and in psi2ir. Any one of these is
sufficient for fixing the problem, however both are made just to make it
more future-proof against new components and/or changes in existing
subsystems (e.g. fir2ir).

In the old JVM backend, similar deduplication was happening in
`ClassFileFactory.registerSourceFiles`, which is why the problem is not
reproducible there.

 #KT-45100 Fixed

(cherry picked from commit 83a4b6396a)
2021-03-18 11:56:01 +01:00
Alexander Udalov
2e6b75a5d8 Annotate kotlin.reflect.jvm.reflect with ExperimentalReflectionOnLambdas
This function was always experimental, as explained in its kdoc, but it
was introduced before opt-in requirement markers were supported. Thus,
breaking changes (such as in KT-42746) were always expected, and the
`@ExperimentalReflectionOnLambdas` annotation just makes it clearer.

 #KT-45486 Fixed

(cherry picked from commit fc36178f3a)
2021-03-18 11:55:57 +01:00
Anton Lakotka
8124a95467 Add separate Plugin Classpaths per compilation
Make them extend the common CP for sake of backward compatibility
^KT-45020 Fixed
2021-03-18 09:34:19 +01:00
Yahor Berdnikau
bf4a6492ae Fix issues in Android test projects setup.
(cherry picked from commit 543ab3fa2a)
2021-03-18 10:13:59 +03:00
Dmitry Petrov
60a4afc556 JVM_IR KT-45446 don't erase captured var if it's dead code 2021-03-17 15:57:43 +03:00
Dmitry Petrov
ad93189c4f JVM_IR KT-44993 preserve inner expression type when fusing if-null
(cherry picked from commit decfaa3ba5)
2021-03-17 15:57:43 +03:00
Dmitry Petrov
2dd73500af PSI2IR KT-44414 fix adapted reference to imported object member
(cherry picked from commit d74168fb8f)
2021-03-17 15:57:43 +03:00
Yaroslav Chernyshev
81e90f68a1 Fix infinite org.gradle.tooling.internal.adapter.TypeInspector.visit call on 201 platform 2021-03-17 13:28:57 +03:00
Yaroslav Chernyshev
e8dab960c5 Revert "Revert "loadClassOrNull: catch 'ClassNotFoundException' and 'LinkageError' over 'Exception'""
This reverts commit 758cd9d2
2021-03-17 13:28:57 +03:00
Yaroslav Chernyshev
e6b5695265 Revert "Revert "Continue 'populateModuleDependenciesBySourceSetVisibilityGraph' on missing GradleSourceSetData'""
This reverts commit e86ca3b4
2021-03-17 13:28:56 +03:00
Yaroslav Chernyshev
c83f02f4b7 Revert "Revert "Precise platform importing changes ported from new repository""
This reverts commit c38b48c7
2021-03-17 13:28:56 +03:00
Yaroslav Chernyshev
9f41993d1d Revert "Revert "Re-structure KotlinMPPGradleProjectResolver.populateModuleDependencies""
This reverts commit 2ff99611
2021-03-17 13:28:55 +03:00
Yaroslav Chernyshev
95666c55c2 Revert "Revert "HMPP import: add dependencies present on all compilation a jvm&android shared source set participates""
This reverts commit 18deb8eb
2021-03-17 13:28:55 +03:00
Stanislav Erokhin
18deb8eb3d Revert "HMPP import: add dependencies present on all compilation a jvm&android shared source set participates"
This reverts commit af07c48a
2021-03-16 15:12:11 +01:00
Stanislav Erokhin
2ff99611fb Revert "Re-structure KotlinMPPGradleProjectResolver.populateModuleDependencies"
This reverts commit e74eee55
2021-03-16 15:11:18 +01:00
Stanislav Erokhin
c38b48c7f1 Revert "Precise platform importing changes ported from new repository"
This reverts commit ee50a584
2021-03-16 15:11:10 +01:00
Stanislav Erokhin
e86ca3b49a Revert "Continue 'populateModuleDependenciesBySourceSetVisibilityGraph' on missing GradleSourceSetData'"
This reverts commit 1741f0fc
2021-03-16 15:11:01 +01:00
Stanislav Erokhin
758cd9d268 Revert "loadClassOrNull: catch 'ClassNotFoundException' and 'LinkageError' over 'Exception'"
This reverts commit 05144914
2021-03-16 15:10:27 +01:00
Dmitry Petrov
98ece21909 Minor: regenerate compiler tests 2021-03-15 17:43:44 +03:00
Dmitry Petrov
8d8745bd48 JVM_IR KT-44744 check accessibility of enum entry 'this' 2021-03-15 17:38:39 +03:00
Yaroslav Chernyshev
051449143c loadClassOrNull: catch 'ClassNotFoundException' and 'LinkageError' over 'Exception'
(cherry picked from commit aff49c76a9)
2021-03-15 17:25:44 +03:00
Yaroslav Chernyshev
1741f0fc9d Continue 'populateModuleDependenciesBySourceSetVisibilityGraph' on missing GradleSourceSetData'
(cherry picked from commit 116b11d8be)
2021-03-15 17:25:44 +03:00
Yaroslav Chernyshev
ee50a584a7 Precise platform importing changes ported from new repository
(cherry picked from commit d053ee33a8)
2021-03-15 17:25:44 +03:00
Yaroslav Chernyshev
e74eee55dd Re-structure KotlinMPPGradleProjectResolver.populateModuleDependencies
(cherry picked from commit 960a7dca45)
2021-03-15 17:25:44 +03:00
Yaroslav Chernyshev
af07c48a86 HMPP import: add dependencies present on all compilation a jvm&android shared source set participates
(cherry picked from commit 18a06dc37e)
2021-03-15 17:25:44 +03:00
Dmitry Savvinov
dbb6d03084 Minor: inline addDependsOnSourceSets in buildCompilation
(cherry picked from commit 96a4d19365)
2021-03-15 17:25:44 +03:00
Dmitry Savvinov
6d8a8bc20d Minor: rename KotlinCompilation.sourceSets -> allSourceSets
(cherry picked from commit 4927777ffb)
2021-03-15 17:25:43 +03:00
Dmitry Savvinov
3526ebfd88 Minor: add test on importing platform of commonMain in single-backend project
(cherry picked from commit 1143865e88)
2021-03-15 17:25:43 +03:00
Dmitry Savvinov
39b9ae7c5d Implement precise platforms importing in MPP
- skip metadata target from importing. That lead to metadata
compilations being imported is well -> some source-sets were
participating in metadata compilations as well -> logic for determining
platforms used to consider metadata compilations as well, adding COMMON
platform to set of platforms

Seems like metadata was never needed in import/IDE, and got there purely
by accident

- Use only targets, actually present in the project, as the default
platform. This is needed mostly for corner-cases/miconfigurations, like
orphan source-sets (source-sets which are created but not included into
any configuraion). Still, for those source-sets the tooling is required
to behave properly; presence of non-existing target can lead to various
issues like showing gutters for test runs, which would fail on launch
(because tests for that target actually do not exist)

^KT-37127 Fixed

(cherry picked from commit c3f5d57d3b)
2021-03-15 17:25:43 +03:00
Dmitry Savvinov
da044135d9 Refactoring: collect all logic regarding detecting sourceSet platform in one function
Note that previously addSourceSetsToCompilation had logic regarding
platforms. The reason for that is that it was the last place where
default soruce sets of compilations could be distinguished from all
participated source sets.

So, to move that logic, we have to preserve default source sets.
Therefore, this commit introduces 'KotlinCompilation.defaultSourceSets',
and 'ImportingContext.isDefaultSourceSet' method.

The rest is trivial code moving/methods introduction

The resulting code isn't really pretty and likely has non-orthogonal
predicates, this will be cleaned-up in the next commits

(cherry picked from commit 7a5b4ccb9a)
2021-03-15 17:25:43 +03:00
Dmitry Savvinov
a9285389ac Minor: swap receiver and parameter for shouldCoerceToCommon
Otherwise, it reads as if KotlinSourceSet coerces ImportingContext,
which is in fact the other way around

(cherry picked from commit ef04ae041e)
2021-03-15 17:25:43 +03:00
Dmitry Savvinov
b28db4d6d8 Dont coerce platforms of source-sets in HMPP to set of available targets in project
(cherry picked from commit 7ddcdca6bb)
2021-03-15 17:25:43 +03:00
Andrey Uskov
71e41b7c48 Update Gradle verion in tests from 6.1 to 6.1.1
Gradle 6.1 is not suitable for testing because of memory leak on
artefact validation (https://github.com/gradle/gradle/issues/11966)

(cherry picked from commit 9c000000cf)
2021-03-15 16:02:56 +03:00
Ilmir Usmanov
76d7b4254c Minor. Ignore tests on WASM 2021-03-15 13:29:44 +01:00
Ilmir Usmanov
f89ff877de JVM_IR: Do not unbox Result argument inside java SAM adapters
#KT-45259
2021-03-15 13:29:41 +01:00
Ilmir Usmanov
1d36def10c JVM_IR: Do not unbox Result argument inside SAM adapters
#KT-45259 Fixed
2021-03-15 13:29:40 +01:00
Ilmir Usmanov
8d68e56a78 Revert "Value Classes: Forbid var properties with value class receivers"
This reverts commit f43899086a.
2021-03-15 13:23:59 +01:00
Ilmir Usmanov
71f79a1ffc Revert "Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error"
This reverts commit bad197e075.
2021-03-15 13:23:56 +01:00
Roman Golyshev
37b90108ac KT-44756 Ignore annotations on value parameters if metadata says so
There is a `gradle-api-impldep.jar` created by Gradle which contains
our nullability annotations, but relocated in the
`org.gradle.internal.impldep` package

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

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

Lets consider two possible cases:

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

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

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

^KT-44756 Fixed

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

N.B. This does not fixes the cases when `kotlin.Metadata` and similar
annotations are relocated (e.g. KT-25709)

(cherry picked from commit 5d0760c685)
2021-03-15 12:40:02 +03:00
Abduqodiri Qurbonzoda
6bfd6c0afb Mark kt45410.kt with TARGET_BACKEND: JVM
(cherry picked from commit 77c263fcc4)
2021-03-15 12:10:02 +03:00
Mikhael Bogdanov
43bb78a566 Fix compilation after @JvmDefault deprecation
Suppress could be removed after switch to -Xjvm-default=all

(cherry picked from commit 6fab1305e9)
2021-03-15 09:13:08 +01:00
Mikhail Bogdanov
0a4a3b6480 Deprecate @JvmDefault
#KT-40392 Fixed

(cherry picked from commit c11f38688e)
(cherry picked from commit 95654bb9bc)
2021-03-15 09:13:07 +01:00
Abduqodiri Qurbonzoda
16d7b2ffbb Introduce firstNotNullOf and firstNotNullOfOrNull #KT-12109
(cherry picked from commit ff5b2404af)
2021-03-13 02:54:22 +03:00
Abduqodiri Qurbonzoda
67241f9760 Strict version of String.toBoolean() #KT-42071
(cherry picked from commit 09ad5ca602)
2021-03-13 02:54:19 +03:00
Abduqodiri Qurbonzoda
f22e90337e Introduce assertContentEquals in kotlin-test #KT-32996
(cherry picked from commit 5f4a4fd8ae)
2021-03-13 02:54:16 +03:00
pyos
7948533230 JVM: fix inline cycle detection
1. use the correct descriptor in the old backend;
 2. clear the temporary variables for arguments in the IR backend.

 #KT-45292 Fixed

(cherry picked from commit e06bacafad)
2021-03-12 18:02:02 +01:00
SokolovaMaria
d83a4fec7e Unused lambda parameter removed 2021-03-12 18:17:01 +03:00
SokolovaMaria
7868dc1880 Fixed running box tests for kotlinx.atomicfu compiler plugin 2021-03-12 18:17:01 +03:00
Mads Ager
5972130ee0 [JVM IR] Support break in do-while condition.
This breaks from the loop itself which is inconsistent with
what happens for breaks in while conditions.

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

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

Fixes KT-44412

(cherry picked from commit 8588412a56)
2021-03-12 14:47:11 +01:00
SokolovaMaria
bd9d8614dd Fix for running box tests on JS_IR 2021-03-12 16:18:14 +03:00
Victor Petukhov
c14d5d70ba Don't lose upper non-expected type constraints to include them to intersection type during finding the result type of the fixing type variable 2021-03-12 14:58:07 +03:00
Victor Petukhov
8ba60d41e1 Don't stop constraints processing if all type variables have proper equality constraints
Those type variable may have other constraints after incorporation into which, the constraint error may appear

^KT-42042 Fixed
2021-03-12 14:58:03 +03:00
Victor Petukhov
878b3a7616 Don't fix a type variable into the intersection type if there is an explicit expected type
^KT-43303 Fixed
^KT-42472 Fixed
2021-03-12 14:57:58 +03:00
Mikhael Bogdanov
9e979e1e65 Advance bootstrap to 1.5.0-RC-325 2021-03-12 11:04:15 +01:00
Igor Yakovlev
d4493104d2 [ULC] Fix invalid primitive type annotating
Fixed #KT-45417
2021-03-12 10:43:43 +01:00
Dmitry Petrov
16da790a04 JVM_IR Spill stack on array constructor call
KT-42932

(cherry picked from commit 44e6483090)
2021-03-12 11:36:43 +03:00
Ilya Goncharov
a775cd261e [JS IR] In file JsModule top level with fresh names
[JS IR] Fix name for external classes

^KT-39272 fixed
^KT-41650 fixed
2021-03-12 11:12:57 +03:00
Ilya Chernikov
ad0b1a1e26 [minor] disable implicits test on IR, see added comments for details 2021-03-11 18:31:24 +01:00
Ilya Chernikov
c2ae0e4887 Add script metedata flag 2021-03-11 18:31:24 +01:00
Ilya Chernikov
c16e0f1e83 Mark script result expression as used to avoid coercion to unit 2021-03-11 18:31:24 +01:00
Ilya Chernikov
92be633866 Fix handling of lambdas in top-level destructuring declarations 2021-03-11 18:31:23 +01:00
Ilya Chernikov
94b97ce950 Fix CFA for destructuring declarations in scripts
in particular without the fix, the CFA skipped marking of the used
result values in lambdas and they were coerced to unit in IR
2021-03-11 18:31:23 +01:00
Ilya Chernikov
8e26173ac0 [minor] fix scripting test dependencies 2021-03-11 18:31:23 +01:00
Ilya Chernikov
831eaa3b96 [minor] uncomment 2 scripting tests:
Tests were failing before, but now fixed, most likely by switching to
default target 1.8 and some changes in scripting IR support.
#KT-44471 fixed
2021-03-11 18:31:22 +01:00
Ilya Chernikov
9bd64c3976 [minor] fix script util tests 2021-03-11 18:31:22 +01:00
Ilya Chernikov
d7cc7f59fc Implement REPL support in IR scripting 2021-03-11 18:31:21 +01:00
Ilya Chernikov
1977cfa3a9 Fix provided properties generation in ir scripting 2021-03-11 18:31:20 +01:00
Ilya Chernikov
a8acfee1b1 Enable IR in jvm scripting host tests 2021-03-11 18:31:20 +01:00
Ilya Chernikov
a804bc2041 Implement property for passing argumens to isolated script compiler 2021-03-11 18:31:18 +01:00
Ilya Chernikov
a62cf77dcf Protect scripts compilation from passing -Xuse-ir via configuration
as well as other options that require changes in the compilation setup
before compiler options from the configuration could be processed
2021-03-11 18:31:18 +01:00
Ilya Chernikov
91ea3b04d9 Extend GeneratorExtensions with previous script, implemt it for JS REPL
also refactor JS REPL for better compatibility with the generic
REPL/scripting infrastructure
2021-03-11 18:31:18 +01:00
Ilya Chernikov
113117b8d3 [minor] Implement in-process test for main.kts cache
mainly to ease debugging
2021-03-11 18:31:18 +01:00
Ilya Chernikov
11588cdb7a Implement proper call to the base class ctor in ir script lowering 2021-03-11 18:31:16 +01:00
Ilya Chernikov
349c00ca28 Implement metadata handling for IR scripts 2021-03-11 18:31:16 +01:00
Ilya Chernikov
36503922c2 Implement IR backend support in scripting tests, enable for some tests 2021-03-11 18:31:16 +01:00
SokolovaMaria
e02c089bd4 kotlinx.atomicfu compiler plugin for JS_IR
Support transformations of atomic operations introduced by the kotlinx.atomicfu library for the JS_IR backend. Compiler plugin is applied externally by the kotlinx.atomicfu gradle plugin.
2021-03-11 20:03:15 +03:00
Ilya Gorbunov
518173d63b Suggest duration static factories instead of number extension properties
Introduce Duration companion functions to convert numbers to Duration.
Deprecate number extension properties and propose to use these
new functions instead.

(cherry picked from commit a7fda66fa1)
2021-03-11 17:54:57 +03:00
Ilya Gorbunov
c83988cc61 Make more lambda-taking functions in kotlin-test inline-only
So that the lambda can contain non-local control flow, such as suspend
calls. Inline-only helps preserving line numbers in the failed assertion
stack traces.

KT-44717

(cherry picked from commit ca99fc4fed)
2021-03-11 17:54:56 +03:00
Alexander Udalov
58e95e3af3 Fix compilation after cherry-picking 51edbfdd
It turns out that that commit depended on f332192d, which isn't
cherry-picked to 1.5.0.
2021-03-11 15:51:34 +01:00
Alexander Udalov
357a49a8c9 Update public API dump for stdlib
(cherry picked from commit f4c63c8ba2)
2021-03-11 15:11:33 +01:00
Michael Hoisie
d924303849 Make kotlin.jvm.internal.DefaultConstructorMarker public
DefaultConstructorMarker is used as a marker to ensure that a
constructor is unique for companion objects. Prior to this change,
DefaultConstructorMarker was package private.

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

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

Fixes https://youtrack.jetbrains.com/issue/KT-20869

(cherry picked from commit 83383ab9e5)
2021-03-11 15:11:29 +01:00
Alexander Udalov
51edbfdd03 JVM, JVM IR: report error if not all parts of multifile class are @JvmSynthetic
#KT-41884 Fixed

(cherry picked from commit bc5fc122c5)
2021-03-11 13:55:18 +01:00
Alexander Udalov
fc630fe25b Minor, move bytecodeListing tests on JvmMultifileClass
(cherry picked from commit 75850a618c)
2021-03-11 13:55:16 +01:00
Steven Schäfer
96a90b431a JVM: Add FILE target to the JvmSynthetic annotation (#4149)
(cherry picked from commit 057ead358c)
2021-03-11 13:55:15 +01:00
Victor Petukhov
568bde81d2 [jspecify] Change annotations' package from org.jspecify.annotations to org.jspecify.nullness, and DefaultNonNull to NullMarked
^KT-45409 Fixed

(cherry picked from commit b45d5abeb1)
2021-03-11 15:33:14 +03:00
Alexander Udalov
c67541ef26 JVM IR: prevent behavior change with operator dot calls on literals
#KT-42321 Fixed

(cherry picked from commit bf844aa8e4)
2021-03-11 13:15:29 +01:00
Alexander Udalov
438bb71a15 Remove one layer of nested exceptions in JVM backend
(cherry picked from commit c7498dd74d)
2021-03-11 12:42:12 +01:00
Vladimir Dolzhenko
da5fa4d573 Filter KtAnnotated on-the-fly diagnostic elements
Relates to #KTIJ-1760
Relates to #KT-45254

(cherry picked from commit fbe18164b4)
2021-03-11 10:51:08 +01:00
Dmitry Petrov
19f34c11c8 Minor: regenerate tests 2021-03-11 12:03:22 +03:00
Dmitry Petrov
0798d32630 Bump d8 used in box tests to 2.1.75 2021-03-11 12:03:22 +03:00
Dmitry Petrov
7ce6f2f30b JVM_IR Do not generate generic signatures for lifted lambda methods 2021-03-11 12:03:22 +03:00
Dmitry Petrov
3df95bc536 JVM_IR indy-SAM: use '-Xsam-conversions=indy' if JVM 1.8+, LV 1.5+ 2021-03-11 12:03:22 +03:00
Dmitriy Novozhilov
d5fd91918a [FE] Don't fail with exception if ESVisitor tries to visit ESLambda
#KT-45243 Fixed
2021-03-11 11:27:08 +03:00
Alexander Udalov
54ddbab79e JVM: fix EnclosingMethod information for SAMs in inline lambdas
Pass parentContext to SamWrapperCodegen from the outside instead of
using the one from parentCodegen. The difference is that in case of an
inline lambda, we're creating an InlineLambdaContext whose parent is a
ClosureContext, but the codegen for that lambda has that latter
ClosureContext as its context. So the getNonInlineOuterContext call in
SamWrapperCodegen.generateInnerClassInformation wasn't able to identify
that this is a context of a lambda that needs to be skipped, and
generated it as EnclosingMethod, which caused Java reflection to fail
because once that lambda was inlined, it was removed and thus didn't
make it to runtime.

 #KT-44827 Fixed

(cherry picked from commit 628d75c7cd)
2021-03-10 19:57:37 +01:00
Alexander Udalov
18bcf6a375 IR: add descriptor to "unbound symbols not allowed" message
This will help in diagnosing problems such as KT-45236.

(cherry picked from commit 8294aed40c)
2021-03-10 12:30:29 +01:00
Alexander Udalov
3528b854ff Add original KotlinType to rendered IrErrorType
Also improve an error message in `IrType.erasedUpperBound`, which seems
like a frequent first place where the JVM IR backend crashes in case an
error type has made it past psi2ir.

This will help in diagnosing problems such as KT-45016.

(cherry picked from commit e3dc112c5f)
2021-03-10 12:30:26 +01:00
Alexander Udalov
f46b8220a1 Psi2ir: do not generate default accessor body for expect properties
Because generateDefaultGetterBody/generateDefaultSetterBody reference
the property's backing field, which in case of extension properties
leads to an error "Unbound symbols not allowed" because extension
property cannot have a backing field.

In some way, this check is similar to the `isExpect` check in
`generatePrimaryConstructor`.

(cherry picked from commit bdaeaca5ae)
2021-03-10 12:30:22 +01:00
Alexander Udalov
a2fd3a86d0 Minor, add box test for unreachable uninitialized property
#KT-44496

(cherry picked from commit 5fc9f3bc17)
2021-03-10 12:30:18 +01:00
Alexander Udalov
31d93fd3b3 Do not require backing fields for extension properties
This has no effect on correct code because extension properties cannot
have a backing field anyway and that is checked separately. But this
function is used in psi2ir to determine whether or not to create a
backing field for a property, and in case the code where the property is
declared is unreachable like in KT-44496 and has no explicit getter or
setter, it would previously return true for extension properties, which
on JVM would result in an actual field in the class file, which made no
sense.

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

 #KT-44496

(cherry picked from commit 247efb220c)
2021-03-10 12:30:14 +01:00
Mikhael Bogdanov
33fc319c83 Use compatibility accessors only in compatibility stubs
(cherry picked from commit 66a29c70bf)
2021-03-10 10:50:23 +01:00
Mikhael Bogdanov
4eb85174e0 Don't generate private members in compatibility mode in DefaultImpls
(cherry picked from commit efceb89b98)
2021-03-10 10:50:20 +01:00
Mikhael Bogdanov
33d4e6f4f0 Generate stubs for private function with default arguments as public in interfaces
(cherry picked from commit f648d86d2b)
2021-03-10 10:50:19 +01:00
Ilmir Usmanov
250092c78d Regenerate test 2021-03-09 21:38:14 +01:00
Mads Ager
7de71d6045 [IR] Make IrGetObjectValue copyable to avoid duplicate IR nodes.
Fixes KT-45170
2021-03-09 18:52:50 +03:00
Svyatoslav Scherbina
2504a1cea1 Update Kotlin/Native: 1.5-M2-eap-1 2021-03-09 17:10:09 +03:00
Igor Yakovlev
1532a92209 [ULC] Fix annotations with no site for ctor
Fixed #KT-45291
2021-03-09 13:56:15 +01:00
Igor Yakovlev
f98ceaf5a7 [ULC] Fix annotations invalid parents
Fixed #KT-45287
2021-03-09 13:56:01 +01:00
sebastian.sellmair
dc0aae2dde [Commonizer] Implement safe SharedCommonizerTarget factory function
Do not try to instantiate SharedCommonizerTarget with no leaves
^KT-45350 Verification Pending
2021-03-09 12:21:47 +01:00
sebastian.sellmair
dfa1794deb [Commonizer] Add CommonizerIT test for ^KT-45350
Adding a test project containing commonization targets for
ios, linux and windows to test behaviour if at least one commonizer group
is fully not supported.

(cherry picked from commit 6527452143)
2021-03-09 12:21:47 +01:00
Ilmir Usmanov
209c18374c Extend LVT record of alive variables to end of next suspension point
Otherwise, arguments of suspend call become invisible in async stack
trace
 #KT-44714
2021-03-09 12:14:59 +01:00
Ilmir Usmanov
6c2e3af775 Make start label of LVT record the point where variable becomes alive
Otherwise, there will be overlapping LVT records, which leads to
removal of the whole LVT by R8.
 #KT-44714 Fixed
2021-03-09 12:14:48 +01:00
Ilmir Usmanov
e491e7e289 Do not remove dead variables' LVT records
Also, extend liveness of alive variable to nearest suspension points
 #KT-44714
2021-03-09 12:14:46 +01:00
Mikhael Bogdanov
733f4e7501 Fix EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE message
(cherry picked from commit 4d51d71699)
2021-03-09 12:06:49 +01:00
Mikhael Bogdanov
fcf75f60a1 Use actual implementation instead of inherited one in -Xjvm-default diagnostics
(cherry picked from commit 3568eba1b2)
2021-03-09 12:06:49 +01:00
Mikhael Bogdanov
389f489fda Fix checker for -Xjvm-defaults
(cherry picked from commit 71c134e54f)
2021-03-09 12:06:48 +01:00
Alexander Udalov
940469dc4f Add KClass.isValue to kotlin-reflect
#KT-44782 Fixed

(cherry picked from commit 6ddca4a592)
2021-03-09 11:45:48 +01:00
Alexander Udalov
d8b85debe6 Restore writing bytecode version to metadata for LV < 1.5
#KT-45323 Fixed

(cherry picked from commit 9970851684)
2021-03-08 11:19:12 +01:00
Alexander Udalov
ffe642c0b7 Revert "Do not write bytecode version to class file"
This reverts commit c6f5ce6837.

 #KT-45323

(cherry picked from commit a2200b5386)
2021-03-08 11:19:10 +01:00
Vladimir Dolzhenko
ee11ace111 Ignore when failed to get file text
Relates to #KTIJ-706

(cherry picked from commit 36ff952a0f)
2021-03-08 09:51:46 +01:00
Andrey Uskov
5aea142d3a Fixed loading Gradle script templates located on WSL2
#KT-45042 Fixed

(cherry picked from commit b7e13d677d)
2021-03-07 19:41:49 +03:00
Andrey Uskov
6794e4d54c Implemented collecting projectId from Gradle
#KT-45337 Fixed

(cherry picked from commit 63925ee018)
2021-03-07 19:41:44 +03:00
justin.wei
b63b1aee7a Support relocatable cache for InputCache
(cherry picked from commit 34274dd032)
2021-03-07 16:55:44 +03:00
Ivan Gavrilovic
c2bcc7be15 KAPT - Make StructureTransformAction cacheable
When computing classpath structure ignore absolute
paths and timestamps. This also makes the transform
cacheable and it should increase cache hit rate.

Test: existing BuildCacheRelocationIT
2021-03-07 16:55:41 +03:00
Ivan Gavrilovic
b2d4f0f9a2 KT-45168: Avoid generating stubs for generated Kotlin sources
Filter out Kotlin sources coming from KAPT-generated dirs.
Some annotation processors e.g Moshi, generate Kotlin sources,
and when generating stubs in non-incremental runs, stub generation
must ignore those sources. This fixes #KT-45168.

Test: Kapt3IT
(cherry picked from commit 08446e2371)
2021-03-07 16:55:39 +03:00
Yahor Berdnikau
96a91189b0 Distinguish outputs of JS IR tasks.
Now JS IR link and sync tasks will output produced artifacts based on
compilation name, binary name and binary mode. This will remove
Gradle 7 error about missing task dependencies, which should not depend
on each other.

^KT-44949 In Progress
2021-03-07 12:02:35 +01:00
Yahor Berdnikau
c34a05866e Fix test expects slightly different variant selection error message.
Error message was slightly changed on Gradle 7.

^KT-44949 In Progress
2021-03-07 12:02:34 +01:00
Yahor Berdnikau
99c24a8ce2 Update AGP tests.
Bump AGP version in some tests and ignore AGP 3.4 tests on Gradle 7.
AGP 3.4 is not compatible with Gradle 7.

^KT-44949 In Progress
2021-03-07 12:02:34 +01:00
Yahor Berdnikau
d393038762 Change source jar duplication error to warning.
For now Gradle 7 will print warnings on publishing sources jar containing
duplicate files.

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

^KT-44949 In Progress
2021-03-07 12:02:34 +01:00
Yahor Berdnikau
b1ddb612ee Fix test was using removed publication plugin.
Replace usage of removed 'maven' plugin with 'maven-publish'.

^KT-44949 In Progress
2021-03-07 12:02:33 +01:00
Yahor Berdnikau
6e5af9e6b6 Fix test project uses removed configuration for dependencies.
^KT-44949 In Progress
2021-03-07 12:02:33 +01:00
Yahor Berdnikau
11fc1dccaf Link task producing jar with sources to dukat tasks.
This required by Gradle 7 task validation.
Though in some cases sourcesJar task should not depend in some cases on Dukat tasks.

^KT-44949 In Progress
2021-03-07 12:02:33 +01:00
Yahor Berdnikau
d1b7f203d2 Split klib and cinterop outputs.
So Gradle 7 will not complain that some tasks using klib or cinterop
should depend on both tasks producing klib and cinterop, while they
don't need both.

^KT-44949 In Progress
2021-03-07 12:02:33 +01:00
Yahor Berdnikau
52454977ca Fix test was using old KMM dependency notation.
^KT-44949 In Progress
2021-03-07 12:02:32 +01:00
Yahor Berdnikau
e3833fedf1 Ensure compilation task depends on friend artifact producer task.
Without it Gradle 7.0 tasks dependency validation will fail.

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

^KT-44949 In Progress
2021-03-07 12:02:27 +01:00
Abduqodiri Qurbonzoda
906d434abb Fix @SinceKotlin in Common titlecase and titlecaseChar functions
(cherry picked from commit e7a45bba91)
2021-03-07 07:59:43 +03:00
Abduqodiri Qurbonzoda
476c157847 Mark with @SinceKotlin("1.5") the Common char category API
(cherry picked from commit 10b0d147af)
2021-03-07 07:59:41 +03:00
Cedric Champeau
b69dc5fde1 Fix File as input of an artifact transform
Using `File` as input of an artifact transform was deprecated.
With Gradle 7, this becomes an error. This commit fixes the
problem by using the proper replacement:

   Provider<FileSystemLocation>
2021-03-06 13:51:15 +01:00
Abduqodiri Qurbonzoda
f1503d8f10 Optimized toArray method for ArrayDeque and ListBuilder #KT-42720
(cherry picked from commit 421cb6971d)
2021-03-06 11:22:30 +03:00
Abduqodiri Qurbonzoda
54feaa8528 Commonize and generalize JVM-only String.contentEquals #KT-42840
(cherry picked from commit ed57bcb3b1)
2021-03-06 11:22:29 +03:00
Ilya Gorbunov
54d20b5768 Support mod and floorDiv extensions in constant evaluator
Ignore evaluation tests for floorDiv and mod with FIR for now.

(cherry picked from commit 9cc8f44390)
2021-03-06 02:02:32 +03:00
Ilya Gorbunov
8eaccb5d23 Rename test of rem operator evaluation
(cherry picked from commit 58e6f775bb)
2021-03-06 02:02:28 +03:00
Ilya Gorbunov
529e82cfcb Generate docs for floorDiv and mod and improve docs for div and rem
Refactor operator documentation generation for primitives and unsigned
types so that it is easier to specialize it.

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

 KT-26234

(cherry picked from commit 7e2c365b79)
2021-03-06 02:02:25 +03:00
Ilya Gorbunov
28f632987a Floor division and remainder for numeric types KT-26234
- floorDiv/mod for unsigned types
- floorDiv/mod for signed types
- mod for floating point types

- mod return type: same as divisor for integer types

- Update JS API dump
- Avoid triggering division overflow in tests due to K/N
- Workaround failing test in JS-legacy

(cherry picked from commit 50d4979531)
2021-03-06 02:02:22 +03:00
Mads Ager
c34d2f979a [IR] Move annotations from original to new constructor declarations.
LocalDeclarationsLowering did not move annotations when creating
a new constructor declaration, thereby losing the annotations.

Fixes KT-45298

(cherry picked from commit e5631addf3)
2021-03-05 21:24:54 +01:00
Mads Ager
970ca5264c [JVM IR] Make upper bounds check recursive for ieee Equals.
Fixes KT-44402

(cherry picked from commit 965c118521)
2021-03-05 21:23:12 +01:00
Mikhael Bogdanov
55e7d4bf7a Reports warning on super calls in public-api inline functions
(cherry picked from commit 8ff0b1e243)
2021-03-05 20:29:18 +01:00
Alexander Udalov
48fe3a699a Add test which runs Kotlin compiler in parallel
This will be useful in diagnosing issues like KT-45007 in the future.

 #KT-45007

(cherry picked from commit 027df41740)
2021-03-05 17:59:16 +01:00
Alexander Udalov
dfa7dadac4 Revert "Fix KotlinCoreEnvironment projectCount disposable"
This reverts commit 99a6bdeec7.

 #KT-45007 Fixed

(cherry picked from commit e7e17cdaa9)
2021-03-05 17:59:14 +01:00
Alexander Likhachev
da5c625f6e [Gradle] Rework KotlinTestReport to be compatible with configuration cache
(cherry picked from commit ef890464d8)
2021-03-05 17:48:58 +03:00
Roman Artemev
0137f3e39f [KLIB] Support assignable value parameters in deserializer
- fix KT-44945
2021-03-05 17:13:04 +03:00
Yahor Berdnikau
81dd45ab86 Fix Jvm target tries to use removed configuration.
KT-44949 In Progress
KT-44957 Fixed
2021-03-05 14:32:25 +01:00
Yahor Berdnikau
63d48416b6 Fix JS target configuration triggers task creation too early.
This raised the problem that task, compilation task depends on, has not
been yet created and Gradle fails the build with exception.

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

KT-44949 In Progress
2021-03-05 14:32:00 +01:00
Victor Turansky
147874be43 Use optimized Ktor client (-0.5MB)
[Details](https://youtrack.jetbrains.com/issue/KTOR-1084)
2021-03-05 13:11:12 +01:00
Victor Turansky
d25e48dbfe Use appropriate kotlin wrappers version (1.4.21 -> 1.4.30) 2021-03-05 13:11:11 +01:00
Bingran
b2489d87bb Update min supported gradle version to 6.1
This PR also updates the min agp version we test with because older agp
versions are using gradle apis which doesn't exist in gradle 6.0+.

GH PR: #4155
2021-03-05 12:42:41 +01:00
Alexander Likhachev
049580e639 [Gradle, JS] Make MultiplePluginDeclarationDetector compatible w/ conf cache 2021-03-05 12:41:13 +01:00
Alexander Likhachev
85d30c16f1 [Gradle] Replace deprecated dependencies configurations in buildscript
(cherry picked from commit ef458b20e1)
2021-03-05 14:05:42 +03:00
Ilya Gorbunov
d8de055767 Add runtime dependency on junit-jupiter-engine to kotlin-test-junit5
It is required to run tests authored with kotlin-test, so it seems
convenient to have it as a runtime dependency of kotlin-test-junit5
variant.

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

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

KT-45107

(cherry picked from commit 284e6f5bb3)
2021-03-05 04:14:57 +03:00
Ilya Gorbunov
a7a4ccee0c Unify test package names in kotlin-stdlib tests
This makes 'test.' an implicit package prefix, thus fixing the inspection
"Package directive doesn't match file location" positive in almost all
test files.

(cherry picked from commit ca6ce151a2)
2021-03-05 04:12:01 +03:00
Nikolay Krasko
30f654c4ea Add fasutil to the list of package to relocate (KT-44758)
#KT-44758 Fixed

(cherry picked from commit 3022fb396b)
2021-03-04 23:03:53 +03:00
Mikhail Zarechenskiy
67e812cd28 Increase stub versions for major release
^KT-41056 Fixed
2021-03-04 22:12:22 +03:00
Abduqodiri Qurbonzoda
4a936324b5 Commonize Char.titlecaseChar() and Char.titlecase() #KT-44369
(cherry picked from commit 2266cd4631)
2021-03-04 20:43:35 +03:00
Abduqodiri Qurbonzoda
a2bdee74e1 Add String case conversion tests
(cherry picked from commit 0c9205423f)
2021-03-04 20:43:32 +03:00
Abduqodiri Qurbonzoda
48582b1caa Add Char case conversion tests
(cherry picked from commit 49ce776bf4)
2021-03-04 20:43:29 +03:00
Abduqodiri Qurbonzoda
6b5379e6c0 Implement String case conversion generators #KT-45213
(cherry picked from commit fc5e4c20c1)
2021-03-04 20:43:26 +03:00
Abduqodiri Qurbonzoda
ce0fe0358a Implement Char one-to-one and one-to-many case conversion generators #KT-45213
(cherry picked from commit 1066de1be6)
2021-03-04 20:43:24 +03:00
Pavel Kirpichenkov
825563d4f8 [MPP] Consider expect-actual inline/value classes interchangeable
^KT-44926 Fixed
2021-03-04 20:13:20 +03:00
Pavel Kirpichenkov
68b2a0931a Add test for KT-44926 2021-03-04 20:13:20 +03:00
Pavel Kirpichenkov
9f793dab35 Minor: refactor extended compiler checks
Use an analysis flag instead of a stub language feature
2021-03-04 20:13:20 +03:00
Pavel Kirpichenkov
df243ebd66 Provide additional information about missing supertypes
Add -X flag to report extra compiler diagnostics which migth break compatibility.
Use the flag to unconditionally check constructors without fear of
prematurely evaluating lazy supertypes.

KT-19234
KT-42404
KT-44583
2021-03-04 20:13:20 +03:00
Alexander Likhachev
bb558c5282 Update tests after compiler properties rework
#KT-43605 Fixed

(cherry picked from commit 70d434e992)
2021-03-04 19:52:49 +03:00
Alexander Likhachev
de62c4cde7 [Gradle] Read system properties at configuration time using Gradle providers
The change is a step to fully support Gradle configuration cache.
Relates to #KT-43605
Relates to #KT-44611

(cherry picked from commit 3537c699b5)
2021-03-04 19:52:44 +03:00
Alexander Likhachev
5c05860ad3 [Gradle, MPP] Rework build finished listener into build service
Registering build finished listeners is not supported by configuration cache
Relates to #KT-44611
#KT-44900 Fixed

(cherry picked from commit 67632a495b)
2021-03-04 19:39:56 +03:00
Alexander Likhachev
a372dd7660 [Gradle] Bump gradle-download-task version to 4.1.1 to support configuration cache
Relates to #KT-44611

(cherry picked from commit 3e09bb3d3f)
2021-03-04 19:39:34 +03:00
Alexander Likhachev
268e33fa49 [Gradle, JVM] Don't create deprecated compile/runtime configurations
Gradle also removes these configurations in 7.0. See gradle/gradle@2cb45cdbd0
#KT-44462 Fixed

(cherry picked from commit 683bd0ed38)
2021-03-04 19:38:10 +03:00
Margarita Bobova
8d71befde0 Add Changelog for 1.5-M1, 1.4.31, 1.4.30 2021-03-04 14:20:14 +03:00
Sergey Shanshin
43a6d7a180 Lazy delegate for serializer in objects, sealed and abstract classes
Fixes Kotlin/kotlinx.serialization#585

(cherry picked from commit bf6dda2d99)
2021-03-03 21:45:26 +03:00
Yahor Berdnikau
3a11ac6799 Replace, where possible in tests, jcenter() with mavenCentral().
In few places I have to leave bintray repository due to not all kotlin
dependencies where migrated to maven central.

^KT-44949 In progress
2021-03-02 16:01:49 +01:00
Sergey Shanshin
45192ea73d Updated bytecode of serialization for IR
`shouldEncodeElementDefault` now checked before evaluating default value

(cherry picked from commit 8c20c655fe)
2021-03-02 17:03:56 +03:00
Sergey Shanshin
17bb85d624 Support serialization of java enum classes in IR
Fixes Kotlin/kotlinx.serialization#1334

(cherry picked from commit 91f1cb88c1)
2021-03-02 17:03:55 +03:00
Sergey Shanshin
06fa4b8128 Added external serializers in serialization plugin for IR backend
- added fallback support of external serializers in IR
- implemented calculations of properties default values in IR
- swapped check of shouldEncodeElementDefault and comparing the property with default value in IR. Now default value calculated only of shouldEncodeElementDefault returns false

(cherry picked from commit de06a69b12)
2021-03-02 17:03:55 +03:00
Yaroslav Chernyshev
cb97fe0274 Add lambda configurable languageSettings function in KotlinSourceSet
Function with Groovy Closure is already exists, it provides DSL parity
#KT-44834 Fixed

(cherry picked from commit 7d766add4b)
2021-03-02 16:37:43 +03:00
Ilmir Usmanov
c0c985993c IC: Add inline class -> @JvmInline value class warning 2021-03-02 13:07:42 +01:00
Yaroslav Chernyshev
48370ecf8c Fix jvmTarget default divergence between KGP & IDE after change to 1.8
(cherry picked from commit 634c8522a1)
2021-03-02 11:54:22 +03:00
Mikhael Bogdanov
a76ee3ae2e Fix ultra light class generation for private suspend methods
(cherry picked from commit 373d0ac660)
2021-03-01 16:25:33 +01:00
Mikhael Bogdanov
5d69bc5022 Remove version requirements for -Xjvm-default=enable (1.2.40) and JvmFieldInInterface(1.2.70)
(cherry picked from commit 989fea3399)
2021-03-01 16:25:32 +01:00
Mikhael Bogdanov
3aa7f72527 Generate local delegated properties in interface in jvm-default all modes
(cherry picked from commit 49aa36b70d)
2021-03-01 16:25:31 +01:00
Mikhael Bogdanov
a7002d5e38 Generate private suspend functions as private (not synthetic package-private)
#KT-26592 Fixed

(cherry picked from commit c25a694b6b)
2021-03-01 16:25:30 +01:00
Mikhael Bogdanov
6ceff112e2 Add test for private suspend and JVM defaults
(cherry picked from commit ad8eddac99)
2021-03-01 16:25:27 +01:00
Mikhael Bogdanov
491ee56cd4 Generate synthetic annotation method in interface if -Xjvm-default is on
(cherry picked from commit 8764bb09f2)
2021-03-01 16:25:25 +01:00
anastasiia.spaseeva
d5666ba699 Update compose version to 0.3.1
(cherry picked from commit fb83c491bb)
2021-03-01 16:08:45 +01:00
anastasiia.spaseeva
8cb17f57f7 Fix tests after libraries and wrappers versions updating 2021-03-01 16:08:44 +01:00
Andrei Klunnyi
ee11fbcbf7 KT-44821 [Sealed Interfaces]: when-exhaustiveness failure in IDE
Compiler check for 'when' exhaustiveness requires that module
descriptors of a sealed class and its inheritors are the same (reference
identity matters). Prior to this commit and under some conditions they
were not. Details follow below.

Resolution related data structures (resolution facades) are organized
into trees (sdks, libs, and modules have their own nodes/facades,
module/class descriptors are stored inside). And the trees themselves
are put into a map associating so called PlatformAnalysisSettings and
GlobalFacades (plays a role of a root). PlatformAnalysisSettings is an
abstraction describing target platform and sdk of a module. The more
combinations exist for a project the more facades are used. Please, see
KotlinCacheService for more details.

So why a module can have multiple ModuleDescriptor-s?
Every tree mentioned above is an isolated resolution environment
containing its own instances of the outer world descriptors. Say, if a
project has modules X, Y, Z and we consider X then all three might have
their own vision of X, i.e. 3 descriptors exist at a time.

What descriptor instance does compiler get?
The path starts when the user opens a file in the editor and
highlighting pass starts (see usages of
ResolutionUtils#analyzeWithAllCompilerChecks). Module descriptor stored
in the resolution tree of the file's module gets injected into the
compiler's context. Starting from this moment compiler sees other
modules through the prism of a single resolution facade (tree).
Descriptors residing outside are alien.

This commit allows IdeSealedClassInheritorsProvider to figure out what
PlatformAnalysisSettings are associated with the resolution facade (read
ModuleDescriptor) seen by the compiler. Later on the same facade is used
to provide correct instances of sealed inheritors back to the compiler.

(cherry picked from commit f45af5ea0e)
2021-03-01 12:34:40 +01:00
anastasiia.spaseeva
448a6cb995 Update libraries and wrappers versions for 1.5.0 2021-02-26 17:29:11 +01:00
Nikita Katkov
1132bde48f IDEA-253605 jvmClassPathUtil: preserve old behaviour
(cherry picked from commit e1b3cd32f3)
2021-02-26 15:07:32 +01:00
Nikita Katkov
6bcb4cc53a IDEA-253605 jvmClassPathUtil: correct collection of parent classloaders
(cherry picked from commit 738c6d3119)
2021-02-26 15:07:31 +01:00
Dmitry Savvinov
c0e01ddebb Minor: use more clear and specific naming for LazyClassContext.typeChecker (relevant for MPP with type refinement) 2021-02-26 12:56:09 +03:00
Dmitry Savvinov
1baa83bd34 Use overriding util with proper typechecker for overriding in LazyClassMemberScope
Note that LazyClassMemberScope actually has a separate field for
KotlinTypeRefiner, and it might be actually different from the one in
c.kotlinTypeChecker.

The one in c.kotlinTypeChecker is the refiner of *owner* module, i.e. a
module in which the class has been declared. If we have a class Foo :
Expect in common, then the refiner will be from common, and thus it
won't be able to refine supertypes to their platform-dependent values.

The one passed in constructor is actual refiner of dependant-module.
Say, if we're looking at Foo from the point of view of jvmMain, then
we'll create a (view-dependent) LCMS for that, and it will contain
refiner for jvmMain.

It is important to use proper refiner, otherwise the idea of having
"module-dependent view" breaks, and we might suddenly mismatch some
overrides with expect-classes in their signatures.

^KT-44898 Fixed
2021-02-26 12:56:08 +03:00
Dmitry Savvinov
3700d23b18 Add test on KT-44898 (MPP + type refinement + complex inheritance)
The current behaviour is undesired (ABSTRACT_MEMEBER_NOT_IMPLEMENTED
reported on class Concrete), will be fixed in the next commit
2021-02-26 12:56:07 +03:00
Dmitry Savvinov
023d80b5fa Minor: rename createMemberScope -> createScopesHolderForClass 2021-02-26 12:56:06 +03:00
Igor Chevdar
a2760b3f78 [IR] Fixed bug with reflectionTarget evaluation 2021-02-26 12:50:45 +05:00
Igor Chevdar
696557032c [PSI2IR] Set reflectionTarget for all adapted references 2021-02-26 12:50:38 +05:00
Alexander Udalov
94fe759b9d IR: support smart cast values in RangeContainsLowering
#KT-44878 Fixed

(cherry picked from commit acc2256de9)
2021-02-25 21:00:47 +01:00
Alexander Udalov
5f9fe82903 IR: add isUnsignedType/getUnsignedType
(cherry picked from commit 820762ca16)
2021-02-25 21:00:45 +01:00
Alexander Udalov
00668484bd IR: add getPrimitiveType, optimize some usages of isInt/isByte/...
(cherry picked from commit 0ebdf7c3c4)
2021-02-25 21:00:43 +01:00
Alexander Udalov
295fff2fbc Minor, fix compilation warning in DurationUnit.kt
(cherry picked from commit 17ee10a0d8)
2021-02-25 21:00:41 +01:00
Ilmir Usmanov
9e090ea744 Do not add @JvmInline annotation on JS and Native 2021-02-25 18:09:58 +01:00
Ilmir Usmanov
f783bb87b3 Minor. Remove outdated test and update maven test 2021-02-25 18:09:56 +01:00
Ilmir Usmanov
51394349d0 fixup! Rename inline class -> @JvmInline value class in stdlib and compiler 2021-02-25 18:09:54 +01:00
Ilmir Usmanov
a536d4c5b8 Add inline class -> @JvmInline value class intention 2021-02-25 18:09:52 +01:00
Ilmir Usmanov
6e654067ab Rename inline class -> @JvmInline value class in stdlib and compiler 2021-02-25 18:09:49 +01:00
Dmitriy Novozhilov
86b01d2ba6 Fix non-exhaustive when in common stdlib
(cherry picked from commit 99c47a0487)
2021-02-25 17:07:29 +03:00
Dmitriy Novozhilov
522cfebc9a [FE] Make whens on expect sealed classes and enums not exhaustive 2021-02-25 17:07:28 +03:00
Alexander Udalov
3b026c9116 JVM IR: do not hide constructor with inline class in anonymous object
#KT-45131 Fixed

(cherry picked from commit b417786fd4)
2021-02-25 14:44:53 +01:00
Alexander Udalov
1210381342 Do not ever run JVM test handlers after previous errors
If there's a frontend error in a test, or bytecode generation crashed
with an exception, it makes no sense to run JVM test handlers such as
lambda inlining checker or D8 checker.

(cherry picked from commit b026de768d)
2021-02-25 14:44:42 +01:00
Andrei Klunnyi
badfaf3db9 KT-45074 [Sealed Interfaces]: when exhaustiveness after gradle reimport
Module descriptor names in the form of 'stableName' depend on a build
system. See JvmCodegenUtil#getModuleName(). For JPS we get
<module-name.main> or <module-name.test> whereas for Gradle we get top
level <module-name>.
This commit changes approach: ModuleDescriptor-to-Module conversion is
no longer made by name. ModuleInfo is utilized instead.

^KT-45074 fixed
2021-02-25 11:41:07 +01:00
Victor Petukhov
ebfa56d9ed Don't throw an exception while loading type use annotations on implicit bounds of a wildcard
^KT-45067 Fixed
2021-02-24 21:07:59 +03:00
Stefan Wolf
cdc1aa8928 Remove references to validateTaskProperties
The task is now called `validatePlugins`.
2021-02-23 23:29:18 +03:00
Stefan Wolf
c2a4b2d886 Add PathSensitive annotation to all input file properties
So new validation which will be added in Gradle 7.1
won't cause warnings during the build.
2021-02-23 23:29:16 +03:00
Stefan Wolf
b69e119fd4 Enable stricter validation 2021-02-23 23:29:13 +03:00
Mads Ager
ca1df95052 [PSI2IR] Do not generate property reference setter if inaccessible.
Fixes KT-45064.

(cherry picked from commit 8852323a76)
2021-02-23 19:38:08 +01:00
Ilmir Usmanov
c90f01a81b JVM IR: Use INVOKESPECIAL instead of INVOKEVIRTUAL for default private
suspend functions.

 #KT-26592
2021-02-23 18:49:45 +01:00
Ilmir Usmanov
85b9b5b85f JVM IR: Do not generate private suspend functions as synthetic package-private
#KT-26592
2021-02-23 18:49:42 +01:00
Alexander Udalov
396ea68c1a Deprecate kotlin.Metadata.bytecodeVersion
#KT-41758 Fixed

(cherry picked from commit 48fb085bf6)
2021-02-23 14:16:24 +01:00
Alexander Udalov
15b3f54e66 Remove JvmBytecodeBinaryVersion from the compiler code
Move it to build-common where it's still used in incremental compilation
caches, and simplify a bit. In the future, it'll make sense to remove it
completely and to avoid writing it to caches. In this commit, I don't do
that to prevent the IC cache version to be updated, causing rebuilds for
all JPS projects.

 #KT-41758

(cherry picked from commit f63ffc51ae)
2021-02-23 14:16:22 +01:00
Alexander Udalov
e90e8fa53b Remove obsolete code in inliner for experimental coroutines
(cherry picked from commit d300e05be9)
2021-02-23 14:16:20 +01:00
Alexander Udalov
403245bd38 kotlinx-metadata-jvm: deprecate KotlinClassHeader.bytecodeVersion
#KT-41758

(cherry picked from commit 448c6c2f0d)
2021-02-23 14:16:18 +01:00
Alexander Udalov
02710c33d3 Do not write bytecode version to class file
#KT-41758

(cherry picked from commit c6f5ce6837)
2021-02-23 14:16:17 +01:00
Alexander Udalov
5a698f8121 Do not report errors about bytecode version
#KT-41758

(cherry picked from commit 862a9143da)
2021-02-23 14:16:08 +01:00
Alexander Udalov
4536b13ceb JVM IR: fix isMarkedNullable for nullability-flexible types
Since nullability-flexible types in IR are represented by an annotation
on an IrSimpleType, not a special instance, the common implementation of
`KotlinTypeMarker.isMarkedNullable` in `TypeSystemContext` doesn't work.

This method is used for example to generate `typeOf` in JVM IR, in
`TypeSystemCommonBackendContext.generateTypeOf`, and this issue led to a
difference in behavior of `typeOf` for nullability-flexible types.

 #KT-44726 Fixed

(cherry picked from commit e6476c39ca)
2021-02-22 12:53:02 +01:00
Vladimir Dolzhenko
c7376896d6 Do not swallow PCE
#KT-39776 Fixed

(cherry picked from commit b8d1bbdd0d)
2021-02-22 10:52:49 +01:00
Victor Petukhov
5f53dff7c9 Approximate captured types in contravariant positions properly
^KT-43802 Fixed

(cherry picked from commit 4e5647090e)
2021-02-20 17:01:36 +03:00
Dmitriy Novozhilov
be18cb1cb7 Don't run fir tests in :miscCompilerTest configuration
This is fine because FIR is not released, we don't track
  correctness of it in 1.5.0 release branch and there are
  no clients of FIR
2021-02-20 16:45:21 +03:00
Dmitriy Novozhilov
6a0e9d5d38 Fix FIR testdata 2021-02-20 16:18:48 +03:00
Dmitry Petrov
11c154226f JVM_IR indy-SAM: KT-45069 box lambda 'Unit' return type if needed 2021-02-20 13:46:19 +03:00
Ilya Goncharov
99fdcc647a [JS IR] Extract adding of function call to another function
[JS IR] Add option for dce mode

[JS IR] Add logging to non useful declarations if appropriate dce mode

[JS IR] Add mode with throwing exception

[JS IR] unreachableDeclaration method is in rootDeclarations

[JS IR] Add js extra help arg with dce mode and include debug.kt to compile unreachableMethod

[JS IR] unreachableDeclaration as internal to not reproduce stdlib api

[JS IR] Fix description of dce mode argument

- Use console.error instead of console.log
- Use JsError instead Kotlin exception for lightweight

[JS IR] Remove body for throwing exception

[JS IR] Remove default parameter in unreachableDeclaration

[JS IR] Process without removing fields and declaration containers

[JS IR] Rename dce mode on dce runtime diagnostic

[JS IR] Use console.trace instead of console.error

[JS IR] Extract JsError

- Fix naming in prependFunctionCall
- Fix description on runtime diagnostic argument
- Using message collector instead of throwing exception

[JS IR] Distinguish unreachableMethods for log and exception

[JS IR] Extract checking of Kotlin packages of IrField

^KT-45059 fixed

(cherry picked from commit bd2601f289)
2021-02-20 12:10:56 +03:00
Sergey Bogolepov
fe89c8d64e Support for macos_arm64 target in backend
(cherry picked from commit 06498c0efd)
2021-02-20 13:56:04 +07:00
Aleksei.Cherepanov
12b984e53d Add synchronization to MultiClassFiles maps
(cherry picked from commit d0eeb0535d)
2021-02-19 23:59:13 +03:00
Aleksei.Cherepanov
ef3c73554f JPS: Fix JvmMultifileClass processing for IR backend
#KT-44644 Fixed

(cherry picked from commit aa683d3b2a)
2021-02-19 23:59:11 +03:00
Alexander Udalov
ff0f0def59 JVM IR: do not generate invokeinterface hashCode if smart cast is present
#KT-45008 Fixed

(cherry picked from commit 56f9e3360f)
2021-02-19 14:22:15 +01:00
Dmitriy Novozhilov
b328532356 [FE] Assume that effective visibility of sealed class constructor is internal
#KT-45033 Fixed
#KT-45043
2021-02-19 14:10:16 +03:00
Dmitry Petrov
ce9381cfa4 JVM_IR indy-SAM: function reference to Java interface 2021-02-19 10:27:55 +03:00
Dmitry Petrov
9abfc6bc1c Minor: regenerate tests 2021-02-19 09:29:41 +03:00
Dmitry Petrov
22689c28d3 PSI2IR KT-45022 object in LHS of compound assignment
(cherry picked from commit 744a0fcd25)
2021-02-19 09:29:41 +03:00
Vladimir Dolzhenko
f89ebbe5d2 Report highlight errors to WolfTheProblemSolver
Relates to #KT-37702
#KTIJ-1246 Fixed

Original commit: bd222a5255c2fd6f4abfce3115f81733ef9a39f3

(cherry picked from commit 8783ebc352)
2021-02-19 06:49:55 +01:00
Ilmir Usmanov
8aedf23deb Use erased upper bound instead of checking for inline type 2021-02-18 18:38:15 +01:00
Ilmir Usmanov
a147080ac1 JVM_IR: IC: Unbox inline class argument of callable reference
if it is unbound and the underlying type is reference type.
If the underlying type is primitive, it is boxed and unboxed
correctly, otherwise, it is simply casted and not unboxed.
Additionally, generate functions for inliner with inline classes
in signature, so unboxing works.
The unboxing is removed after inlining.
 #KT-44722 Fixed
2021-02-18 18:38:12 +01:00
Victor Petukhov
65a490eefc KotlinBinaryClassCache: clean-up request caches for all threads
^KT-44550 Fixed

(cherry picked from commit ad9fd7ecf3)
2021-02-18 17:07:37 +03:00
Alexander Udalov
28fb718529 Update JVM metadata version to 1.5.0
Improve the test which checks that we use correct metadata version if
`-language-version` is passed by checking all supported language
versions.

The change in libraries/reflect/build.gradle.kts is needed because
kotlinx-metadata-jvm of version 0.1.0 is based on pre-1.4 Kotlin, which
doesn't support the new module file metadata generated with metadata
version 1.4 and later, and module files need to be readable there to be
able to transform them for the shadow plugin.

Similarly override dependency on kotlinx-metadata-jvm in the
binary-compatibility-validator module.

(cherry picked from commit 8c95b78346)
2021-02-18 12:42:50 +01:00
Mikhael Bogdanov
9bbd6ccb87 Fix test data 2021-02-18 07:23:50 +01:00
Dmitry Petrov
3361526e4a JVM_IR indy-SAM on functional expression
(cherry picked from commit 6d019d9544)
2021-02-18 09:11:18 +03:00
Alexander Udalov
9faf83899d JVM IR: write inherited multifile parts flag to kotlin.Metadata
This flag is unused at the moment, but might be used one day to support
proper incremental compilation for multifile classes.

(cherry picked from commit adb05ab076)
2021-02-17 21:56:36 +01:00
Mikhael Bogdanov
fcc1e7f54c Support Unit/V types in string-concat indy calls
unitComponent.kt test fails with JVM target 9+

(cherry picked from commit 134fda8bad)
2021-02-17 18:47:22 +01:00
Mikhael Bogdanov
2cbad94c09 Make indy-with-constants default for -jvm-target 9+
#KT-42522 Fixed

(cherry picked from commit e3e7e6b740)
2021-02-17 18:47:21 +01:00
Mikhael Bogdanov
46c11d1f85 Fail on compilation errors in AbstractBytecodeTextTest
(cherry picked from commit 3d8e8dd3ba)
2021-02-17 18:47:21 +01:00
Mikhael Bogdanov
786b405ed6 Support new targets in KotlinBytecodeToolWindow
#KT-30222 Fixed

(cherry picked from commit 61fce74b76)
2021-02-17 18:45:17 +01:00
Alexander Udalov
bb30ac2a04 Minor, add workaround for KT-45008
(cherry picked from commit 67e91b7ebd)
2021-02-17 16:40:04 +01:00
Dmitriy Novozhilov
94ecbbf8f7 [FE] Change message for sealed interfaces with language target < 1.5 2021-02-17 16:45:12 +03:00
Dmitriy Novozhilov
650e031aca [FE] Prohibit sealed fun interfaces 2021-02-17 16:45:11 +03:00
Alexander Udalov
031bc484ab Support structural equals/hashCode for type constructors of type parameters
Use the same logic as for type constructors of classes, based on the
fully-qualified name of the classifier, with special cases for error
types and local declarations, with an additional check that the type
constructors' declaration descriptors are structurally equal via
`DescriptorEquivalenceForOverrides`. The latter is required because type
parameters of overloaded functions must be different, even though their
full FQ name is the same.

This (hopefully) has no effect for the compiler, but is useful for
kotlin-reflect where `KType.equals` runs the type checker on the
underlying `KotlinType` instances, which eventually ends up comparing
type constructors. Descriptors and types in kotlin-reflect are cached on
soft references, so they may be suddenly garbage-collected and
recomputed, and we want copies of the same type parameter to be equal to
each other.

This fixes flaky codegen tests which started to fail after migration to
the new test infrastructure, where tests are now run in parallel in the
same process, thus with higher memory pressure and more soft references
being GC'd:

* `codegen/box/reflection/types/createType/typeParameter.kt`
* `codegen/box/reflection/supertypes/genericSubstitution.kt`

Also, add a new test to check that we do the instanceof check in
overrides of `AbstractTypeConstructor.isSameClassifier`.

 #KT-44850 Fixed

(cherry picked from commit 4d9cffccf2)
2021-02-17 14:41:58 +01:00
Alexander Udalov
db70ca4a69 Tests: compute runtime classpath for JVM box tests manually
Taking just the `jvmClasspathRoots` is not correct because it also
contains stuff needed for resolve to work correctly, such as JDK (full
or mock), stdlib (full or mock), reflect. JDK is obviously not needed in
the classpath, and stdlib/reflect are available via the parent class
loader, which is specifically reused across all tests to make them run
faster.

Also, don't try to create class loader for Java-only modules in
`JvmBoxRunner.processModule`. This happens, for example, for all tests
which were moved from `boxAgainstJava`.

(cherry picked from commit aaecb87d1b)
2021-02-17 14:41:57 +01:00
pyos
8b9867f2fb JVM: rename this$0 when regenerating nested objects too
In the old backend, this was unnecessary because nested objects would
reference their lambdas' captures through the original this$0. On
JVM_IR, using loose capture fields means a name/descriptor clash can
occur on any level of nesting, not just the top.

(cherry picked from commit 1310a65f0c)
2021-02-17 12:12:41 +01:00
Ilmir Usmanov
68d16d39dd Minor. Suppress errors in tests 2021-02-16 21:00:37 +01:00
Ilmir Usmanov
7ff2ad94d2 Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error 2021-02-16 21:00:35 +01:00
Dmitry Petrov
252556d91a JVM_IR KT-44974 fix SAM-converted capturing extension lambda 2021-02-16 18:13:15 +03:00
Vladimir Dolzhenko
f47eac03b3 Fix NPE
#KTIJ-898 Fixed

Original commit: 12d8e88b846f29598ca3904b49996bd6a9891ccd

(cherry picked from commit 6352814d45)
2021-02-16 15:45:11 +01:00
Vladimir Dolzhenko
d667c2f8b9 Fixed NPE on StandaloneScriptRootsCache instantiation
Relates to ^EA-218043
#KTIJ-1137 Fixed

Original commit: 1d63a1b48d480b958ff44676c42b698a8ca5f64a

(cherry picked from commit 98ba379e07)
2021-02-16 15:43:59 +01:00
Victor Petukhov
9f4cd75e43 [all-open] Don't affect private declarations to change their modality to open 2021-02-16 17:01:15 +03:00
Victor Petukhov
20e82953d7 [all-open] Fix formatting 2021-02-16 17:01:15 +03:00
SokolovaMaria
d71d57a9e7 Copy typeParameters from original declaration to the exportedDefaultStubFun before substitution of type parameters 2021-02-16 00:20:33 +03:00
Dmitry Petrov
2b1148448e JVM_IR KT-44483 argument adaptation is already done in PSI2IR
(cherry picked from commit b1ab64e854)
2021-02-15 21:08:36 +03:00
Dmitry Petrov
f83860a135 JVM_IR KT-44627 fix bridge signature for parameter with primitive bound
(cherry picked from commit b262d09a81)
2021-02-15 19:26:04 +03:00
Alexander Udalov
7f991305e6 Remove kotlin-annotations-android
#KT-44815 Fixed

(cherry picked from commit 6e7a9441a6261d29e5cb59e43965ccbf00a6156b)
2021-02-15 17:23:10 +01:00
Alexander Udalov
c79ba4448c Remove tests on kotlin-annotations-android
#KT-44815

(cherry picked from commit e9985d86e6e48625743aedb93f5cd18cf3882eb8)
2021-02-15 17:23:07 +01:00
Alexander Udalov
c15c593136 Remove compiler support for kotlin-annotations-android
#KT-44815

(cherry picked from commit d4e2bca029648af116f59f79494631efc7c8cd1b)
2021-02-15 17:23:01 +01:00
Mikhail Glukhikh
020cd45050 FIR2IR: support adapted references for constructors
(cherry picked from commit fa0f967c83)
2021-02-15 19:18:56 +03:00
Mikhail Glukhikh
2da4a4ea6b FIR2IR: use information about callable reference adaptation from resolve
(cherry picked from commit 8bab208322)
2021-02-15 19:18:48 +03:00
Victor Petukhov
6d2be950a3 Fix FIR test lambdaParameterTypeInElvis
(cherry picked from commit fa1507fb91)
2021-02-15 18:52:53 +03:00
Andrei Klunnyi
dad762eb61 KT-44839 [Sealed interfaces]: restore move-tests for lang-version < 15
This commit restores tests removed in 690fb47c.
2021-02-15 16:31:46 +01:00
Andrei Klunnyi
09b239f4b9 KT-44839 [Sealed interfaces]: ability to specify compiler options in tests 2021-02-15 16:31:46 +01:00
Andrei Klunnyi
9c6238ff03 KT-44839 [Sealed interfaces]: move refactoring for language level < 1.5
This commit restores sealed-check-logic for language level < 1.5
mistakenly removed in 690fb47c.

^KT-44839 fixed
2021-02-15 16:31:45 +01:00
Dmitriy Novozhilov
aaf6494faa [FIR] Ignore failing FIR tests related to sealed classes 2021-02-15 17:21:01 +03:00
Dmitriy Novozhilov
bc23b04d16 [FE] Allow declaring protected constructors in sealed classes
#KT-44865 Fixed
2021-02-15 17:21:01 +03:00
Dmitriy Novozhilov
a843800b2a [FE] Make constructors of sealed classes protected instead of internal 2021-02-15 17:21:01 +03:00
Victor Petukhov
62ef7f65dd Don't fix type variables into Nothing in priority way
^KT-44546 Fixed
2021-02-15 15:09:30 +03:00
Victor Petukhov
87f5cedf7f Fix FIR test lambdaParameterTypeInElvis 2021-02-15 12:56:38 +03:00
Yaroslav Chernyshev
95c2762432 [Cocoapods] Fail import if project's version wasn't specified
#Fixed KT-44000
2021-02-15 12:41:17 +03:00
Vladimir Dolzhenko
315190cc1b Lightweight hashCode calc for LibraryInfo
#EA-6040509 Fixed
#KTIJ-696 Fixed

(cherry picked from commit bf9fa4c9da)
2021-02-15 10:39:53 +01:00
Victor Petukhov
355ae07667 Reformat TypeWithEnhancement.kt 2021-02-15 12:15:08 +03:00
Victor Petukhov
13a97b56c1 Add reporting of the warnings based on Java annotations for expanded type aliases
Before that, such warnings weren't reported as the corresponding errors were reported during type inference (only original types took part there)
2021-02-15 12:15:05 +03:00
Victor Petukhov
7857230aa5 Use upper bound checker for typealias expansion 2021-02-15 12:15:03 +03:00
Victor Petukhov
f939fdc154 Add test for errors reporting of UPPER_BOUND_VIOLATED 2021-02-15 12:15:00 +03:00
Victor Petukhov
53bc498da4 Report warnings or errors for violated type parameter's upper bounds from Java annotated with nullability annotations
^KT-43262 Fixed
2021-02-15 12:14:56 +03:00
Victor Petukhov
0d50b13a2c Propagate inference session into declaration analyzers
It prevents missing inference session for local declaration (local functions, local classes or objects)

^KT-44801 Fixed
2021-02-15 11:14:06 +03:00
Victor Petukhov
9f69fe86a0 Remove redundant extension receiver substitution during lambda's completion 2021-02-15 11:14:05 +03:00
Victor Petukhov
918c5e7d4f Clear request cache properly during disposing component 2021-02-15 11:14:04 +03:00
Dmitry Petrov
2375817c1d Minor: regenerate tests after cherry-pick 2021-02-12 20:34:26 +03:00
Dmitry Petrov
e4130cd12f JVM don't use indy by default for SAM conversions (wait for KT-44844)
KT-44278 KT-26060 KT-42621

(cherry picked from commit 6ba57abb8f)
2021-02-12 20:34:25 +03:00
Dmitry Petrov
4d66d2ab98 JVM_IR nullability assertions test for indy lambdas
KT-44278 KT-26060 KT-42621

(cherry picked from commit 5013344bc4)
2021-02-12 20:34:25 +03:00
Dmitry Petrov
6c514ac028 JVM_IR indy: minor: use toLowerCaseAsciiOnly for options
KT-44278 KT-26060 KT-42621

(cherry picked from commit 4ab242ed51)
2021-02-12 20:34:25 +03:00
Dmitry Petrov
99a3979b27 JVM_IR indy: fix non-null assertions on indy lambda parameters
KT-44278 KT-26060 KT-42621

(cherry picked from commit afeb7e18cd)
2021-02-12 20:34:25 +03:00
Dmitry Petrov
19c742a0c2 JVM_IR indy: extract LambdaMetafactoryArguments code to separate file
KT-44278 KT-26060 KT-42621

(cherry picked from commit 43b1711010)
2021-02-12 20:34:24 +03:00
Dmitry Petrov
c9258f5c40 JVM_IR indy: use 'CLASS' mode in SAM bytecode listing tests
KT-44278 KT-26060 KT-42621

(cherry picked from commit 3438d19c22)
2021-02-12 20:34:24 +03:00
Dmitry Petrov
0ac096c108 JVM SamWrapperClassesAreSynthetic language feature
KT-44278 KT-26060 KT-42621

(cherry picked from commit 7564c9bb8c)
2021-02-12 20:34:24 +03:00
Dmitry Petrov
544285aaea JVM_IR indy SAM conversions: update tests
KT-44278 KT-26060 KT-42621

(cherry picked from commit 052f6929c9)
2021-02-12 20:34:24 +03:00
Dmitry Petrov
ccb8385b36 JVM_IR: use indy SAM conversions in jvmTarget 1.8+, fix bridges
KT-44278 KT-26060 KT-42621

(cherry picked from commit 3ebeca5852)
2021-02-12 20:34:23 +03:00
Dmitry Petrov
05423910d2 Minor: LAMBDAS directive in old back-end tests
(cherry picked from commit 2535e5d5c9)
2021-02-12 20:34:23 +03:00
Dmitry Petrov
49a0bee762 JVM_IR indy-lambdas: minor updates and fixes
KT-44278 KT-26060 KT-42621

(cherry picked from commit ab20a8ffff)
2021-02-12 20:34:23 +03:00
Dmitry Petrov
06cf09f91d JVM_IR indy-lambdas: don't use indy for big arity lambdas
KT-44278 KT-26060 KT-42621

(cherry picked from commit 088448043a)
2021-02-12 20:34:22 +03:00
Dmitry Petrov
cdf2f853aa JVM_IR indy-lambdas: initial implementation and tests
KT-44278 KT-26060 KT-42621

(cherry picked from commit d94912ed62)
2021-02-12 20:34:22 +03:00
Sergey Igushkin
99f2194af6 Fix extracted metadata for IDE erased when scopes conflict, KT-44845
The root cause was that extractors for different scopes used the same
base directory, and each erased its contents. Using different base dirs
fixes the issue.

Issue #KT-44845

(cherry picked from commit a719656118)
2021-02-12 19:00:07 +03:00
Mikhael Bogdanov
609e355d55 Generate proper hashCode for fun interface wrappers
#KT-44875 Fixed

(cherry picked from commit e795c2c407)
2021-02-12 11:38:26 +01:00
Dmitriy Novozhilov
e7f5df1423 fixup! [Test] Make some functions of environment configurators public 2021-02-11 16:29:41 +03:00
Dmitriy Novozhilov
ed5f40ab83 [Test] Move extracting JVM_TARGET to provideConfigurationKeys 2021-02-11 16:23:45 +03:00
Dmitriy Novozhilov
7de2eeaad5 [Test] Replace remaining KOTLIN_CONFIGURATION_FLAGS directives with specific ones 2021-02-11 16:23:42 +03:00
Dmitriy Novozhilov
6517f1d389 Parse compiler configuration for android tests using new test infrastructure 2021-02-11 16:23:02 +03:00
Dmitriy Novozhilov
b5d24f38bc Add analysisFlags of LanguageVersionSettings to toString() method 2021-02-11 16:23:02 +03:00
Dmitriy Novozhilov
662f209862 [Test] Make some functions of environment configurators public
This is needed for using those methods from android tests
2021-02-11 16:23:02 +03:00
Dmitriy Novozhilov
daea75908b [Test] Cleanup JvmEnvironmentConfigurator 2021-02-11 16:23:01 +03:00
Dmitriy Novozhilov
3a9e75b162 [Test] Don't pass MockProject to environment configurators 2021-02-11 16:23:01 +03:00
Alexander Udalov
fe27514e62 Move around some codegen box tests
In tests merged from boxAgainstJava in 29b96aa1, some directories were
named slightly differently compared to box, e.g. "property" vs
"properties", "varargs" vs "vararg". This change renames these, moves
some of the tests to more fitting directories, and also renames
"visibility" to "javaVisibility" because it's about Java visibilities
specifically.

(cherry picked from commit 510b9e6f2a)
2021-02-11 14:18:01 +01:00
Alexander Udalov
1000eaedba Remove codegen tests on old language and API versions
(cherry picked from commit 2d60fa787d)
2021-02-11 14:16:50 +01:00
Alexander Udalov
2a773e1f8a Use TARGET_BACKEND instead of DONT_TARGET_EXACT_BACKEND in box against Java tests
"// TARGET_BACKEND: JVM" more clearly says that the test is
JVM-specific, rather than DONT_TARGET_EXACT_BACKEND which excludes all
other backends.

(cherry picked from commit 401f0ac583)
2021-02-11 14:16:46 +01:00
Mikhail Glukhikh
a7c4d13619 Skip JDK 6 in failing BB test (java.util.function in use)
(cherry picked from commit 57e06992c9)
2021-02-11 15:01:05 +03:00
Mikhail Glukhikh
bf045e3a04 FIR2IR: fix raw SAM conversion (avoid * in type arguments)
(cherry picked from commit cd483ad231)
2021-02-11 15:00:41 +03:00
Mikhail Glukhikh
a560f431b4 FIR2IR: expand type before getting nullability #KT-44803 Fixed
(cherry picked from commit 5f3102bf2f)
2021-02-11 14:58:06 +03:00
Mikhail Glukhikh
cbb06a0856 FIR2IR: enhance approximation of captured types
(cherry picked from commit 4bc630d82c)
2021-02-11 14:58:00 +03:00
Mikhail Glukhikh
bf32cdc1f2 FIR2IR: support substitution for SAM types
(cherry picked from commit 346ffb3acf)
2021-02-11 14:57:54 +03:00
Mikhail Glukhikh
745043c466 FIR2IR: use invariant projections for SAM_CONVERSION types
(cherry picked from commit 7050af9b79)
2021-02-11 14:57:48 +03:00
Dmitry Gridin
edecafd887 [i18n] copy-paste message from RefactoringBundle to fix missing resource in 202
^KT-44675 Fixed

(cherry picked from commit b9c33a0c6e)
2021-02-11 18:34:08 +07:00
Alexander Udalov
b27dd8e3fe Apply illegal-access=permit workaround for JDK 16+
Apparently, the openjdk commit that enabled JEP 396 (encapsulated JDK
defaults) is effective since jdk-16+28:

https://github.com/openjdk/jdk/commit/ed4c4ee7

(cherry picked from commit 80daf120e6)
2021-02-11 12:13:21 +01:00
Dmitriy Novozhilov
ccffa1a8bf [FE] Don't analyze members with CLASSIFIERS kind filter in AbstractLazyMemberScope
This commit introduces partial support of descriptorKindFilter in
  `AbstractPsiBasedDeclarationProvider`. Without it there may be an error
  in following case:

```
sealed class Base
class Derived : Base()

class Test<out V>(val x: Base) {
    private val y = when (x) {
        is Derived -> null
    }
}
```

Here we start to resolve type of `y`, then go to computation of inheritors
  of sealed class Base, which also may be inside Test, so we need get all
  nested classifiers in Test. But without this filtration we will start
  computing descriptor for `y` again, which leads to ReenteringLazyComputationException

#KT-44316 Fixed
2021-02-11 13:27:41 +03:00
Victor Petukhov
72409bfef9 Substitute captured types with inner intersection one (NewTypeSubstitutor)
^KT-44651 Fixed
2021-02-11 12:40:44 +03:00
Roman Artemev
d35f31de68 [Plugin API] Fix missed call in resolveBySignatureInModule 2021-02-11 11:56:29 +03:00
Ilya Gorbunov
1a5c5bc2f5 Remove kotlin-test-multiplatform special dependency handling
#KT-40225

(cherry picked from commit af8061a4dd)
2021-02-10 22:02:23 +03:00
Ilya Gorbunov
a4f188615b Remove obsolete diagnostics suppression
The diagnostic NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS is now
obsolete because internal constructors of inline classes became allowed.

(cherry picked from commit 87e130e77a)
2021-02-10 22:02:20 +03:00
Yaroslav Chernyshev
155c814a4a Mark obsolete Gradle JVM options as Deprecated with Error
Options `includeRuntime`, `noStdlib` and `noReflect` were affected
#Fixed KT-44361

(cherry picked from commit 17fc10a8af)
2021-02-10 21:23:20 +03:00
Pavel Kirpichenkov
796d7274e6 Split combined test into two to avoid flaky behaviour
Prevent simultaneous access to the library directory
2021-02-10 15:19:48 +03:00
Yahor Berdnikau
c163bdded3 Fix KaptWithoutKotlincTask task tries to get wrong properties. 2021-02-10 12:23:59 +01:00
Alexander Udalov
b857f46533 CLI: include META-INF/services/ from kotlin-reflect with -include-runtime
This is an addition to bd205317aa where we
started to add the contents of kotlin-reflect into the resulting jar if
-include-runtime is specified. Apparently kotlin-reflect doesn't work
without some services in META-INF/services/, which didn't satisfy the
condition for inclusion. The existing test didn't catch that because
loading class annotations does not always lead to those services being
loaded.

(cherry picked from commit e6588ee8a4)
2021-02-10 12:06:34 +01:00
Andrei Klunnyi
5e91b4eaab Compilation fix for KT-44487 2021-02-10 11:41:32 +01:00
Dmitry Petrov
162356f99b JVM_IR KT-44798 don't generate multiple stubs with same signature
(cherry picked from commit d0f26abd18)
2021-02-10 11:53:52 +03:00
Ilya Chernikov
f40e815e28 Implement forced script configuration reloading API for plugins
#KT-43288 fixed
2021-02-10 08:29:31 +01:00
Ilya Chernikov
4f38e08c39 Pass provided script configuration to refining code
when script compilation configuration refinement
happening during parsing, the updated configuration
passed to the script compiler/REPL compile function
is now used.
#KT-44580 fixed

(cherry picked from commit ef4fa3381d)
2021-02-10 08:29:13 +01:00
Ilya Chernikov
2ef1d9c542 [minor] fix warnings in the script compiler and tests 2021-02-10 08:29:06 +01:00
Vladimir Dolzhenko
ecf0c6ce15 Make checker tests independent of plugin version
Relates to #KT-37702 #KTI-433
2021-02-09 22:07:48 +01:00
Roman Artemev
25432bd33a [Plugin API] Add API to load top level declaration by its signature
- request from JP Compose, #KT-44100

(cherry picked from commit d97a2b13c0)
2021-02-09 19:49:24 +03:00
Roman Artemev
f13342a362 [IR] Fix IrType equality in case of complex variance
- reimplement type capturing on top of pure IrCaptureType
 - add captured type substitutor
 - fix #KT-43831

(cherry picked from commit 79f986bb75)
2021-02-09 19:49:24 +03:00
Roman Artemev
3762321406 [IR] Add IrCapturedType into IR type system
- support it in TypeSystemContext

(cherry picked from commit 4ed93d3dee)
2021-02-09 19:49:24 +03:00
Andrei Klunnyi
521c23cc02 KT-44487 [Sealed Interfaces]: sealed-inheritors-provider for MPP
(cherry picked from commit e3c1aa599d)
2021-02-09 13:59:08 +01:00
Svyatoslav Scherbina
787124cb06 Update Kotlin/Native: 1.5-M1-eap-19 2021-02-09 15:46:17 +03:00
Ilmir Usmanov
0f75a4edc3 Minor. Ignore test on WASM 2021-02-09 12:31:52 +01:00
Ilmir Usmanov
74ae3219f3 JVM_IR. Do not mangle callable reference constructor call
#KT-44703 Fixed
2021-02-09 12:31:49 +01:00
Ilya Goncharov
b65accec4e [JS IR] Add test with chain export--not-export--export
^KT-44616 fixed

(cherry picked from commit 19bffc694b)
2021-02-08 14:24:32 +03:00
Ilya Goncharov
81de9f851f [JS IR] Method of any is exported
^KT-44616 fixed

(cherry picked from commit 76b124a9c0)
2021-02-08 14:24:31 +03:00
Ilya Goncharov
66bb5cdc6e [JS IR] Add exported method into exportNestedClass.kt
^KT-44616 fixed

(cherry picked from commit 7b4624aac4)
2021-02-08 14:24:31 +03:00
Ilya Goncharov
110f278d5e [JS IR] Override method are not exported
[JS IR] Add test with jsexport overrides not js export method with stable name

^KT-44616 fixed

(cherry picked from commit 6c051b2be4)
2021-02-08 14:24:31 +03:00
Ilya Goncharov
832d21fbdd [JS IR] Add test with fun interface call inside lambda
^KT-44433 fixed

(cherry picked from commit de3678a805)
2021-02-08 14:24:31 +03:00
Ilya Goncharov
30d9fafbc4 [JS IR] Use local scope for SAM if there are scopes
[JS IR] Use private for top level sam wrappers and local otherwise

^KT-44433 fixed

(cherry picked from commit d6e74b9620)
2021-02-08 13:57:04 +03:00
Victor Petukhov
ed20e2851c Report error about uninferred type parameter for all CallForImplicitInvoke psi calls
^KT-44368 Fixed
2021-02-08 10:41:53 +03:00
Yan Zhulanow
974654ec34 Remove unneeded artifacts for Kotlin IDE plugin
(cherry picked from commit 0d1f493b6c)
2021-02-05 16:04:06 +09:00
Ilmir Usmanov
ba786f5a46 JVM_IR. Do not unbox Result in inline lambda
Since JVM_IR generates inline lambdas differently from old backend,
in this case, it generates them as normal functions.
Thus, there is no need to unbox the lambda argument.
 #KT-44671 Fixed
2021-02-04 20:23:53 +01:00
Alexander Udalov
48592ec112 Do not create Array instance in kotlin-reflect where not necessary
Although the previous code of computing JVM internal name from a Class
instance was shorter, it led to unnecessary creation of array types,
which is less performant and makes configuration of kotlin-reflect for
GraalVM native-image more verbose.

Unfortunately I didn't succeed in writing a test for this, since
`Array.newInstance` calls a native method which doesn't record any trace
of it being called in the class loader: the resulting array type never
goes through findClass/loadClass, and is not visible via
findLoadedClass.

 #KT-44594 Fixed

(cherry picked from commit fb296b5b95)
2021-02-04 19:15:21 +01:00
Dmitriy Novozhilov
665a25f637 [Test] Print bytecode if DxCheckerHandler had failed 2021-02-04 11:15:11 +03:00
Dmitriy Novozhilov
c111f90251 [Test] Ignore multimodule tests in AbstractLightAnalysisModeTest 2021-02-04 11:15:11 +03:00
Dmitriy Novozhilov
da4bc74da3 [Test] Properly merge box against java testdata into codegen/box
Previous commit about it was 3199ce03 and it was completely wrong
2021-02-04 11:15:10 +03:00
Dmitriy Novozhilov
935f3b7659 [Test] Support different backends enumeration in DONT_TARGET_EXACT_BACKEND directive 2021-02-04 11:07:49 +03:00
Dmitriy Novozhilov
dcba27c3a8 [TD] Fix directive order in codegen testdata
(cherry picked from commit 4bf6e58f2b)
2021-02-04 11:07:49 +03:00
Dmitriy Novozhilov
1a68073292 [Test] Support new configuration directives in old codegen tests
(cherry picked from commit 571c4ce398)
2021-02-04 11:07:49 +03:00
Dmitriy Novozhilov
df0c050e4b [Test] Exclude multimodule tests from codegen tests on android
(cherry picked from commit 0ebb39a26e)
2021-02-04 11:07:49 +03:00
Dmitriy Novozhilov
4a0cb0aa5c [Test] Support skip of android codegen tests with new ASSERTION_MODE directive
(cherry picked from commit 17d59e0daa)
2021-02-04 11:07:48 +03:00
Dmitriy Novozhilov
1c1d41c864 [Test] Use javac for compilation test java files from runtime by default
(cherry picked from commit 81ba7aa833)
2021-02-04 11:07:48 +03:00
Dmitriy Novozhilov
3004b39304 [Build] Extract configuration of JUnit5 dependencies to common helper in buildSrc
(cherry picked from commit c432efc364)
2021-02-04 11:07:48 +03:00
Dmitriy Novozhilov
e77ad7f44f [Test] Add ability to stop test pipeline if there was an exception in handler
(cherry picked from commit dea3c954f1)
2021-02-04 11:07:48 +03:00
Dmitriy Novozhilov
06334aac59 [Test] Move fir backend tests back to :compiler:fir2ir module
(cherry picked from commit 2ae35b0b08)
2021-02-04 11:07:48 +03:00
Dmitriy Novozhilov
734495e9bf [Test] Don't generate extends clause for nested classes in generated tests for JUnit5
This is fine since all nested classes in tests are inners by JUnit5
  specification, so they will see `runTest` method from outer root class

(cherry picked from commit e79d02f482)
2021-02-04 11:07:47 +03:00
Dmitriy Novozhilov
98e23f4955 [Test] Migrate :tests-different-jdk on runners which are using JUnit5
(cherry picked from commit a4e9ab90a0)
2021-02-04 11:07:47 +03:00
Dmitriy Novozhilov
d9e2827e4c [Test] Set static field with application to null after tests are completed
(cherry picked from commit c969a34644)
2021-02-04 11:07:47 +03:00
Dmitriy Novozhilov
979bb3f67a [Test] Don't use PSI based class reading in codegen BB tests
#KT-34826 is rela ted

(cherry picked from commit 53e5aa4364)
2021-02-04 11:07:47 +03:00
Dmitriy Novozhilov
e7667b5397 [Test] Support various jdk targets in test infrastructure
(cherry picked from commit 09ec3f6eaf)
2021-02-04 11:07:47 +03:00
Dmitriy Novozhilov
3fafb2e9df [Test] Read default target version from sys property in new test infra
(cherry picked from commit 93741ced5c)
2021-02-04 11:07:46 +03:00
Dmitriy Novozhilov
22688b804f [Test] Support invoking box method in BB tests in separate process
(cherry picked from commit a3ad626f99)
2021-02-04 11:07:46 +03:00
Dmitriy Novozhilov
ba02081ebb [Test] Regenerate spec tests
(cherry picked from commit b351ca6bd4)
2021-02-04 11:07:46 +03:00
Dmitriy Novozhilov
ecf9fd0b8b [Test] Merge box against java testdata into codegen black box testsdata
(cherry picked from commit 3199ce03a6)
2021-02-04 11:07:46 +03:00
Dmitriy Novozhilov
98a31448c5 [TD] Ignore JS backends in boxAgainstJava tests
(cherry picked from commit e62b118351)
2021-02-04 11:07:45 +03:00
Dmitriy Novozhilov
465909f8c0 [Test] Merge box against java tests into codegen black box tests
(cherry picked from commit 99cb85ab00)
2021-02-04 11:07:43 +03:00
Dmitriy Novozhilov
232c260c9a [Test] Migrate AbstractIrCompileKotlinAgainstKotlinTest to new infrastructure
(cherry picked from commit 6f3713af5f)
2021-02-04 11:05:40 +03:00
Dmitriy Novozhilov
ebd8a9ea82 [Test] Enable SMAP dump handler in boxInline tests
(cherry picked from commit 49c2bfe637)
2021-02-04 11:05:40 +03:00
Dmitriy Novozhilov
69097dd444 [TD] Update testdata according to previous commit
(cherry picked from commit 64a300bfcd)
2021-02-04 11:05:40 +03:00
Dmitriy Novozhilov
1c5e61fb32 [Test] Migrate all jvm tests runners for boxInline tests
(cherry picked from commit 3a0eee64b8)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
f675081405 [TD] Update fir directives in boxInline tests
(cherry picked from commit 8973e3f362)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
0a3839c109 [Test] Implement SMAP dump handler
(cherry picked from commit 92e21e76ba)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
32f2d4939a [Test] Align lines in TestFile with lines in real testdata file
(cherry picked from commit e3ab3d6be3)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
620e823cc1 [Test] Introduce two module structure transformers for codegen test
(cherry picked from commit 60e0831c11)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
de7aade158 [Test] Add ability to freely transform module structure which was parsed from directive
Service ModuleStructureExtractor may break readabilty of test so it
  should be used very carefully

Originally it is created for box inline test where we have different
  runners on same testdata where one runner assumes that all files
  in test in same module and other that they in different ones

(cherry picked from commit 13a778fd9c)
2021-02-04 11:05:39 +03:00
Dmitriy Novozhilov
f7abb0b5c2 [Test] Support USE_OLD_INLINE_CLASSES_MANGLING_SCHEME directive
(cherry picked from commit fc83dc17fe)
2021-02-04 11:05:38 +03:00
Dmitriy Novozhilov
4efa634f37 [Test] Make BytecodeInliningHandler for new infrastructure
(cherry picked from commit 3f758a3fa2)
2021-02-04 11:05:38 +03:00
Dmitriy Novozhilov
db9bf8428d [TD] Fix friend modules
(cherry picked from commit 0768a7089c)
2021-02-04 11:05:38 +03:00
Dmitriy Novozhilov
2b297ccd7a [TD] Update directives in kotlinAgainstKotlin testdata
(cherry picked from commit 5075484c8e)
2021-02-04 11:05:38 +03:00
Dmitriy Novozhilov
8c18d88e61 [Test] Improve error reporting if there are too many values passed to directive
(cherry picked from commit 9ba41c5b88)
2021-02-04 11:05:38 +03:00
Dmitriy Novozhilov
ecfc1493d0 [Test] Move KotlinAgainstKotlin tests under BlackBoxCodegen tests
(cherry picked from commit 5c8d555808)
2021-02-04 11:05:37 +03:00
Dmitriy Novozhilov
64ccd3213c [Test] Support skip of android codegen tests with new ASSERTION_MODE directive
(cherry picked from commit f255f93ad9)
2021-02-04 11:05:37 +03:00
Alexander Udalov
4f0fc39c45 Do not generate $suspendImpl for JvmDefault functions in interfaces
#KT-44533 Fixed

(cherry picked from commit acd8c4503b)
2021-02-03 21:46:01 +01:00
Ilmir Usmanov
84076a11da JVM_IR: Box generic Result parameter in suspend lambda
#KT-44527 Fixed
2021-02-03 20:37:26 +01:00
Ilmir Usmanov
b73321b580 Minor. Throw exceptions in test coroutine builders 2021-02-03 20:37:24 +01:00
Dmitriy Dolovov
d8aafc0243 [Commonizer] Dump every module to disk immediately when it's ready
No need to retain all metadata modules in memory -> lesser memory consumption.
2021-02-03 20:43:56 +03:00
Ivan Gavrilovic
7b83677da5 Locate build history when file is outside of root project dir
Support use-cases when the build dir is outside of root project dir.
Many projects set up output dir as <root_project>/../out/<project_name>/build
to be able to clean build dir more easily. This commit adds support
to build history file detection and it tries to find build history
files for artifacts that are:
- under root project dir (a default structure)
- under root project's build dir parent (to support typical custom setup)

Fixes https://youtrack.jetbrains.com/issue/KT-40875

Test: BaseIncrementalCompilationMultiProjectIT
(cherry picked from commit 2fce6a4af9)
2021-02-03 15:22:27 +03:00
Alexander Udalov
449f9b1dfa Add -Xsuppress-deprecated-jvm-target-warning to modules compiled with 1.6
Currently this leads to an unknown argument warning, but it'll be
removed automatically on the next bootstrap.

(cherry picked from commit e0b6d4d917)
2021-02-03 12:54:10 +01:00
Alexander Udalov
632cfa7312 Deprecate JVM target 1.6
#KT-44650 Fixed

(cherry picked from commit 99b5e5a373)
2021-02-03 12:53:58 +01:00
Andrei Klunnyi
e407f4cff3 KT-44079 [Sealed Interfaces]: move refactoring update
The idea behind this commit is that Move Refactoring should warn
developers in case their intention potentially breaks sealed
hierarchies (members must share the same module and package).

Provided algorithm has two goals:
- prevent destruction of correct hierarchies
- help in fixing broken ones

^KT-44079 fixed
2021-02-03 12:04:58 +01:00
Dmitriy Dolovov
9e00b483bb [Commonizer] Force GC after each serialized target 2021-02-03 10:57:31 +03:00
Dmitriy Dolovov
347fd1e3c1 [Commonizer] Minor. Post-review changes, p.2 2021-02-03 10:57:30 +03:00
Dmitriy Dolovov
08dde21f02 [Commonizer] Minor. Post-review changes 2021-02-03 10:57:30 +03:00
Dmitriy Dolovov
e62eacce71 [Commonizer] Add tests for CommonizerTarget 2021-02-03 10:57:29 +03:00
Dmitriy Dolovov
900b15468b [Commonizer] Use kotlin/Any as the default supertype for commonized class 2021-02-03 10:57:28 +03:00
Dmitriy Dolovov
2734829513 [Commonizer] Dump every target to disk immediately when it's ready 2021-02-03 10:57:27 +03:00
Dmitriy Dolovov
5a43e1dcd3 [Commonizer] Ignore acceptable (minor) metadata mismatches in tests 2021-02-03 10:57:26 +03:00
Dmitriy Dolovov
f5553eef3e [Commonizer] Fix calculation of type parameter IDs for nested classes and their members 2021-02-03 10:57:26 +03:00
Dmitriy Dolovov
630f86d264 [Commonizer] Ignore constructors for enum entries 2021-02-03 10:57:25 +03:00
Dmitriy Dolovov
575ccab8b8 [Commonizer] Don't serialize kotlin/Any? as the single type parameter upper bound 2021-02-03 10:57:24 +03:00
Dmitriy Dolovov
c4c631f6e5 [Commonizer] Don't write IS_EXPECT flag for synthesized expect functions 2021-02-03 10:57:23 +03:00
Dmitriy Dolovov
a852608363 [Commonizer] Fix HAS_ANNOTATIONS flag calculation for serialized classes 2021-02-03 10:57:23 +03:00
Dmitriy Dolovov
49e96b11f8 [Commonizer] Minor. Improved diagnostics message in tests 2021-02-03 10:57:22 +03:00
Dmitriy Dolovov
1acdadf15e [Commonizer] Fix property backing/delegate field annotations serialization 2021-02-03 10:57:21 +03:00
Dmitriy Dolovov
5217bd1797 [Commonizer] Don't commonize built-ins 2021-02-03 10:57:20 +03:00
Dmitriy Dolovov
8feea385d5 [Commonizer] Drop descriptors for commonized declarations 2021-02-03 10:57:19 +03:00
Dmitriy Dolovov
5303713153 [Commonizer] Rework test infrastructure to compare metadata instead of descriptors 2021-02-03 10:57:19 +03:00
Dmitriy Dolovov
f0ec8c6e65 [Commonizer] Pretty target name output in console 2021-02-03 10:57:18 +03:00
Dmitriy Dolovov
e6412d6d75 [Commonizer] Fix approximation for aliases types 2021-02-03 10:57:17 +03:00
Dmitriy Dolovov
549f6f05f2 [Commonizer] Log stats during building metadata 2021-02-03 10:57:16 +03:00
Dmitriy Dolovov
72e0444d7c [Commonizer] Integrate metadata builder with the commonizer environment 2021-02-03 10:57:15 +03:00
Dmitriy Dolovov
daba02833c [Commonizer] Introduce metadata builder 2021-02-03 10:57:15 +03:00
Dmitriy Dolovov
4b4691518a Metadata: Chunked KlibModuleFragmentWriteStrategy implementation 2021-02-03 10:57:14 +03:00
Dmitriy Dolovov
7bf8949a24 [Commonizer] Introduce MetadataDeclarationsComparator for metadata-based comparison of KLIBs 2021-02-03 10:57:13 +03:00
Dmitriy Dolovov
12c766bf29 [Commonizer] Embed :kotlinx-metadata-klib into the commonizer Jar 2021-02-03 10:57:12 +03:00
Dmitriy Dolovov
b53320c587 [Commonizer] Restore lost nullability for underlying types in TAs 2021-02-03 10:57:12 +03:00
Dmitriy Dolovov
a8dd865f78 [Commonizer] Avoid leaking non-commonized underlying types in TAs 2021-02-03 10:57:11 +03:00
scaventz
d1c4ccd0b9 CLI: improve behavior of -include-runtime
1.fix KT-17344: Include kotlin-reflect to resulting jar if "-include-runtime" is specified, unless the -no-reflect option is specified.
2.fix KT-43220: -include-runtime should add .kotlin_builtins to the output

(cherry picked from commit bd205317aa)
2021-02-02 21:50:51 +01:00
Mads Ager
df5cf5ccb1 [JVM_IR] Fix accessibility bridges for static protected fields.
Super-qualifiers have to be taken into account. Otherwise, too
few accessibility bridges will be generated which can lead to
binary compatibility issues.

(cherry picked from commit 6a959fefd0)
2021-02-02 21:46:26 +01:00
Mikhael Bogdanov
e936bc466a Fix compilation against asm 7.0
(cherry picked from commit 206b38f0ab)
2021-02-02 18:51:52 +01:00
pyos
067cc9cba8 JVM_IR: give loops somewhat more debuggable labels
(cherry picked from commit bd3bc13e75)
2021-02-02 18:24:22 +01:00
pyos
fe4ab2c61e JVM: optimize temporary kotlin.jvm.internal.Refs as well
i.e. remove the condition that there must be an LVT entry. Such
temporary `Ref`s can be created, for example, by the JVM_IR backend
if a lambda inlined at an IR level (e.g. argument to `assert`/`Array`)
is the target of a non-local return from a function inlined at bytecode
level (e.g. `run`):

    IntArray(n) { i ->
        intOrNull?.let { return@IntArray it }
        someInt
    }

->

    val `tmp$0` = IntArray(n)
    for (i in 0 until `tmp$0`.size) {
        var `tmp$1`: Int
        do {
            intOrNull?.let {
                `tmp$1` = it // causes `tmp$1` to become an IntRef
                break
            }
            `tmp$1` = someInt
        } while (false)
        `tmp$0`[i] = `tmp$1`
    }

(cherry picked from commit ad53fc931e)
2021-02-02 18:24:22 +01:00
pyos
ab75917fbc JVM_IR: support non-local break/continue in the inliner
Not in the frontend or psi2ir, though, so this not a complete
implementation of KT-1436, but rather a part of it that is currently
useful to make other code compile. In particular, lambdas passed to
array constructors and JVM-style `assert` are inlined as IR returnable
blocks, which are then converted into `do { ... } while (false)` loops,
so non-local returns from them become non-local `break`s.

(cherry picked from commit 0f2ca5d84c)
2021-02-02 18:24:21 +01:00
Mikhael Bogdanov
32561fe41a Support proper frame maps for enumValues
(cherry picked from commit c13f38f6df)
2021-02-02 17:46:08 +01:00
Mikhael Bogdanov
f4b8261573 Support proper frame maps for enum valueOf
(cherry picked from commit 1a044e5af4)
2021-02-02 17:46:08 +01:00
Mikhael Bogdanov
9c7a5d61f9 JVM_IR. Generate additional checkcast for when/try epressions to avoid frame map problems on reification
(cherry picked from commit 5b64ceceb3)
2021-02-02 17:46:07 +01:00
Mikhael Bogdanov
0dc4f185e5 Don't remove checkcast for reified values
#KT-35511 Fixed

(cherry picked from commit 16928d6e3f)
2021-02-02 17:46:07 +01:00
Vladimir Dolzhenko
ac1d975fd3 Kotlin highlight passes are reworked
#KT-37702 Fixed

(cherry picked from commit 913c298be8)
2021-02-02 17:31:05 +01:00
Vladimir Dolzhenko
a6f8f60447 Lazy diagnostics API in frontend
Relates to #KT-37702

(cherry picked from commit 558338f997)
2021-02-02 17:31:05 +01:00
Zalim Bashorov
44301bd2d8 [JS] Replace usages of FileUtil.loadTextAndClose with functions from stdlib to avoid crashes on files larger than 10MiB
(cherry picked from commit 3f10914f05)
2021-02-02 18:48:37 +03:00
Anton Bannykh
cf3f984e75 JS DCE: use Multimaps to reduce Node fields RAM
(cherry picked from commit 165533fdb7)
2021-02-02 18:45:29 +03:00
Anton Bannykh
8036a257ce JS DCE: disable logging by default
Based on Vladislav Saifulin's PR #4031

(cherry picked from commit f42f2fa743)
2021-02-02 18:45:29 +03:00
Anton Bannykh
ad6ed3a10e JS DCE: inline Qualifier class to reduce RAM usage
(cherry picked from commit 26ce6b5131)
2021-02-02 18:45:29 +03:00
Anton Bannykh
5076734d3a JS DCE: use less LinkedHashSets
(cherry picked from commit bbc6d2b993)
2021-02-02 18:45:28 +03:00
Anton Bannykh
9036164902 JS DCE: create collections on demand
Based on Vladislav Saifulin's PR #4031

(cherry picked from commit 3c0b226344)
2021-02-02 18:45:28 +03:00
Steven Schäfer
e759649b56 JVM IR: Fix inline class mangling for calls to internal functions
...in a different module, e.g., using -Xfriend-paths.
2021-02-01 21:56:12 +01:00
Ilya Gorbunov
6abfbcaa0a Infer required kotlin-test jvm capability based on used test framework
Except when:
- the Gradle version is less than 6.0, it doesn't read the metadata
published by a newer Gradle by default.
- the requested dependency version is less than 1.5, because it doesn't
have metadata published.

Update integration tests to use kotlin-test common dependency.

KT-40225

(cherry picked from commit 4a17228621)
2021-02-01 23:23:20 +03:00
Ilya Gorbunov
cc31c7167e Disable metadata publishing for legacy common artifacts
When they are used explicitly in common source sets, they cannot be
resolved in platform ones after that since they only have
common kotlin-api variants in their metadata.

KT-40225

(cherry picked from commit cbeadba15d)
2021-02-01 23:23:18 +03:00
Ilya Gorbunov
a5a8c30089 Apply common configuration to custom publications in kotlin-test
To do that, extract parts of publishing setup into reusable functions.
This change makes signing and repository configuration applied to all
project publications, not just to the Main one.

Also:
- Get rid of dependencies from non-default variants in the root pom
- Add an empty javadoc jar

KT-40225

(cherry picked from commit 573aac7252)
2021-02-01 23:23:17 +03:00
Ilya Gorbunov
8a10ee4e8b Setup publications with MPP Gradle metadata for kotlin-test library
Move publication configuration from individual platform specific
kotlin-test- modules to the root module.

KT-40225

(cherry picked from commit a16aaa3824)
2021-02-01 23:23:15 +03:00
Ivan Gavrilovic
27e7a2fbee KT-43686: Make kapt Gradle task cacheable across machines
Use `@Classpath` for kotlin stdlib input property. This is to
allow cache hits when builds are running on different machines
and path to kotlin stdlib differs.

Test: BuildCacheRelocationIT
(cherry picked from commit 509ed64917)
2021-02-01 22:48:19 +03:00
Alexander Udalov
0d49acc1e6 Mute/unmute FIR box tests on functions with big arity 2021-02-01 18:27:44 +01:00
Dmitry Petrov
ca164bb8ad JVM_IR fix special bridge generation for inline classes
(cherry picked from commit 4ec369ac5b)
2021-02-01 18:00:13 +03:00
Alexander Udalov
565132b7a9 Change logic of applying JVM target from AGP options
Now that the default JVM target is 1.8, we have to add the JVM target
1.6 explicitly if the Android project is configured with source/target
1.6, and not do anything if it's configured with 1.8.

 #KT-31027

(cherry picked from commit e9436da858)
2021-02-01 11:57:06 +01:00
Alexander Udalov
0c5625e616 Light classes: use JVM target from the module
Using "JVM_1_8" always resulted in incorrect mapping of Kotlin
annotation targets to Java element types.

The change in AbstractKotlinRenderLogTest is needed because while
CliTraceHolder.module is technically a descriptor leak, it was never
detected by this test accidentally, because of the depth cutoff equal to
10, which started to not be enough after the minor refactoring of
replacing `Delegates.notNull` with `lateinit`.

(cherry picked from commit adfa8c788c)
2021-02-01 11:57:05 +01:00
Alexander Udalov
e502c1ad71 Light classes: map annotation targets depending on JVM target
Since the default JVM target (`JvmTarget.DEFAULT`) is now 1.8, the
changed test started to fail. This change fixes it.

(cherry picked from commit 64e97225b8)
2021-02-01 11:57:04 +01:00
Alexander Udalov
bd4d9491ba Switch default JVM target to 1.8
#KT-29405 Fixed

(cherry picked from commit d022bb0248)
2021-02-01 11:57:02 +01:00
Alexander Udalov
5d8bf3be87 Workaround illegal access problem in daemon for JDK 17-ea
Otherwise Kotlin cannot be used in Gradle since
https://github.com/openjdk/jdk/commit/ed4c4ee7 where JDK internals
started to be encapsulated by default.

For some reason, using

    listOf("--add-opens", "java.base/java.util=ALL-UNNAMED")

doesn't help, so use the more general `--illegal-access=permit`.

 #KT-43704

(cherry picked from commit e7cf34a2a9)
2021-02-01 11:56:17 +01:00
Alexander Udalov
c0ecb5c3c9 CLI: suppress warning on JDK 9+ with illegal access to ResourceBundle
The underlying issue is tracked in IDEA-248785.

 #KT-43704 Fixed

(cherry picked from commit f08733eb75)
2021-02-01 11:56:13 +01:00
Alexander Udalov
a4a2618cf7 CLI: do not pass -noverify to java process starting from JDK 13
#KT-44232 Fixed

(cherry picked from commit 2ef4ca4e6e)
2021-02-01 11:56:07 +01:00
Alexander Udalov
5c43a97e1e Update copyrights in CLI scripts
(cherry picked from commit 2bbe3db041)
2021-02-01 11:56:03 +01:00
Sergey Igushkin
497dacdc3c Add API version 1.5 to accepted values in MPP language settings 2021-02-01 12:42:53 +03:00
3835 changed files with 95226 additions and 44990 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
[![Revved up by Gradle Enterprise](https://img.shields.io/badge/Revved%20up%20by-Gradle%20Enterprise-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.jetbrains.com/scans?search.rootProjectNames=Kotlin)
# Kotlin Programming Language
# Kotlin Programming Language!!!
Welcome to [Kotlin](https://kotlinlang.org/)!
It is an open-source, statically typed programming language supported and developed by [JetBrains](https://www.jetbrains.com/) and open-source contributors.
@@ -168,6 +168,28 @@ includeBuild('/path/to/kotlin') {
}
```
### Dependency verification
We have a [dependencies verification](https://docs.gradle.org/current/userguide/dependency_verification.html) feature enabled in the
repository for all Gradle builds. Gradle will check hashes (md5 and sha256) of used dependencies and will fail builds with
`Dependency verification failed` errors when local artifacts are absent or have different hashes listed in the
[verification-metadata.xml](https://github.com/JetBrains/kotlin/blob/master/gradle/verification-metadata.xml) file.
It's expected that `verification-metadata.xml` should only be updated with the commits that modify the build. There are some tips how
to perform such updates:
- Use auto-generation for getting an initial list of new hashes (verify updates relate to you changes).
`./gradlew -M sha256,md5 help`
*(any other task may be used instead of `help`)*
- Consider removing old versions from the file if you are updating dependencies.
- Leave meaningful `origin` attribute (instead of `Generated by Gradle`) if you did some manual verification of the artifact.
- Always do manual verification if several hashes are needed and a new `also-trust` tag has to be added.
- If youre adding a dependency with OS mentioning in an artifact name (`darwin`, `mac`, `osx`, `linux`, `windows`), remember to add
counterparts for other platforms.
# License
Kotlin is distributed under the terms of the Apache License (Version 2.0). See [license folder](license/README.md) for details.

View File

@@ -1,36 +1,11 @@
import kotlinx.benchmark.gradle.benchmark
val benchmarks_version = "0.2.0-dev-7"
buildscript {
val benchmarks_version = "0.2.0-dev-7"
repositories {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
}
}
dependencies {
classpath("org.jetbrains.kotlinx:kotlinx.benchmark.gradle:$benchmarks_version")
}
}
apply(plugin = "kotlinx.benchmark")
val benchmarks_version = "0.3.0"
plugins {
java
kotlin("jvm")
}
repositories {
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
if (cacheRedirectorEnabled) {
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
} else {
maven("https://dl.bintray.com/kotlin/kotlinx")
}
id("org.jetbrains.kotlinx.benchmark") version "0.3.0"
}
dependencies {
@@ -42,7 +17,7 @@ dependencies {
compile(jpsStandalone()) { includeJars("jps-model") }
compile(intellijPluginDep("java"))
compile(intellijDep()) { includeIntellijCoreJarDependencies(project) }
compile("org.jetbrains.kotlinx:kotlinx.benchmark.runtime-jvm:$benchmarks_version")
compile("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:$benchmarks_version")
}
sourceSets {

View File

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

View File

@@ -29,21 +29,43 @@ import org.jetbrains.kotlin.cli.common.arguments.Argument;
import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments;
import org.jetbrains.kotlin.cli.common.arguments.InternalArgument;
import org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt;
import org.jetbrains.kotlin.idea.ExplicitDefaultSubstitutor;
import org.jetbrains.kotlin.idea.ExplicitDefaultSubstitutorsKt;
import org.jetbrains.kotlin.utils.StringsKt;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
public class ArgumentUtils {
private ArgumentUtils() {}
private ArgumentUtils() {
}
@NotNull
public static List<String> convertArgumentsToStringList(@NotNull CommonToolArguments arguments)
throws InstantiationException, IllegalAccessException, InvocationTargetException {
List<String> convertedArguments = convertArgumentsToStringListInternal(arguments);
Map<KClass<? extends CommonToolArguments>, Collection<ExplicitDefaultSubstitutor>> defaultSubstitutorsMap =
ExplicitDefaultSubstitutorsKt.getDefaultSubstitutors();
KClass<? extends CommonToolArguments> argumentsKClass = JvmClassMappingKt.getKotlinClass(arguments.getClass());
Collection<ExplicitDefaultSubstitutor> defaultSubstitutors = defaultSubstitutorsMap.get(argumentsKClass);
if (defaultSubstitutors != null) {
for (ExplicitDefaultSubstitutor substitutor : defaultSubstitutors) {
if (substitutor.isSubstitutable(convertedArguments)) convertedArguments.addAll(substitutor.getNewSubstitution());
}
}
return convertedArguments;
}
@NotNull
public static List<String> convertArgumentsToStringListNoDefaults(@NotNull CommonToolArguments arguments)
throws InstantiationException, IllegalAccessException, InvocationTargetException {
return convertArgumentsToStringListInternal(arguments);
}
private static List<String> convertArgumentsToStringListInternal(@NotNull CommonToolArguments arguments)
throws InstantiationException, IllegalAccessException, InvocationTargetException {
List<String> result = new ArrayList<>();
Class<? extends CommonToolArguments> argumentsClass = arguments.getClass();
convertArgumentsToStringList(arguments, argumentsClass.newInstance(), JvmClassMappingKt.getKotlinClass(argumentsClass), result);

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea
import org.jetbrains.kotlin.cli.common.arguments.Argument
import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.config.JvmTarget
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1
import kotlin.reflect.full.findAnnotation
val defaultSubstitutors: Map<KClass<out CommonToolArguments>, Collection<ExplicitDefaultSubstitutor>> =
mapOf(K2JVMCompilerArguments::class to listOf(JvmTargetDefaultSubstitutor))
sealed class ExplicitDefaultSubstitutor {
abstract val substitutedProperty: KProperty1<out CommonToolArguments, String?>
abstract val oldSubstitution: List<String>
abstract val newSubstitution: List<String>
abstract fun isSubstitutable(args: List<String>): Boolean
protected val argument: Argument by lazy {
substitutedProperty.findAnnotation() ?: error("Property \"${substitutedProperty.name}\" has no Argument annotation")
}
}
object JvmTargetDefaultSubstitutor : ExplicitDefaultSubstitutor() {
override val substitutedProperty
get() = K2JVMCompilerArguments::jvmTarget
private val oldDefault: String
get() = JvmTarget.JVM_1_6.description
private val newDefault: String
get() = JvmTarget.JVM_1_8.description
private fun prepareSubstitution(default: String): List<String> = listOf(argument.value, default)
override val oldSubstitution: List<String>
get() = prepareSubstitution(oldDefault)
override val newSubstitution: List<String>
get() = prepareSubstitution(newDefault)
override fun isSubstitutable(args: List<String>): Boolean = argument.value !in args
}

View File

@@ -94,6 +94,10 @@ open class IncrementalJvmCache(
fun sourcesByInternalName(internalName: String): Collection<File> =
internalNameToSource[internalName]
fun getAllPartsOfMultifileFacade(facade: JvmClassName): Collection<String>? {
return multifileFacadeToParts[facade]
}
fun isMultifileFacade(className: JvmClassName): Boolean =
className in multifileFacadeToParts
@@ -425,6 +429,8 @@ open class IncrementalJvmCache(
private inner class MultifileClassFacadeMap(storageFile: File) :
BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
@Synchronized
operator fun set(className: JvmClassName, partNames: Collection<String>) {
storage[className.internalName] = partNames
}
@@ -435,6 +441,7 @@ open class IncrementalJvmCache(
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}
@@ -444,6 +451,8 @@ open class IncrementalJvmCache(
private inner class MultifileClassPartMap(storageFile: File) :
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor.INSTANCE) {
@Synchronized
fun set(partName: String, facadeName: String) {
storage[partName] = facadeName
}
@@ -451,6 +460,7 @@ open class IncrementalJvmCache(
fun get(partName: JvmClassName): String? =
storage[partName.internalName]
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}

View File

@@ -21,6 +21,7 @@ data class IncrementalModuleEntry(
class IncrementalModuleInfo(
val projectRoot: File,
val rootProjectBuildDir: File,
val dirToModule: Map<File, IncrementalModuleEntry>,
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
val jarToClassListFile: Map<File, File>,
@@ -28,6 +29,6 @@ class IncrementalModuleInfo(
val jarToModule: Map<File, IncrementalModuleEntry>
) : Serializable {
companion object {
private const val serialVersionUID = 0L
private const val serialVersionUID = 1L
}
}

View File

@@ -182,6 +182,21 @@ open class ProtoCompareGenerated(
if (!checkEqualsClassSealedSubclassFqName(old, new)) return false
if (old.hasInlineClassUnderlyingPropertyName() != new.hasInlineClassUnderlyingPropertyName()) return false
if (old.hasInlineClassUnderlyingPropertyName()) {
if (!checkStringEquals(old.inlineClassUnderlyingPropertyName, new.inlineClassUnderlyingPropertyName)) return false
}
if (old.hasInlineClassUnderlyingType() != new.hasInlineClassUnderlyingType()) return false
if (old.hasInlineClassUnderlyingType()) {
if (!checkEquals(old.inlineClassUnderlyingType, new.inlineClassUnderlyingType)) return false
}
if (old.hasInlineClassUnderlyingTypeId() != new.hasInlineClassUnderlyingTypeId()) return false
if (old.hasInlineClassUnderlyingTypeId()) {
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) return false
}
if (!checkEqualsClassVersionRequirement(old, new)) return false
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) return false
@@ -266,6 +281,9 @@ open class ProtoCompareGenerated(
TYPE_ALIAS_LIST,
ENUM_ENTRY_LIST,
SEALED_SUBCLASS_FQ_NAME_LIST,
INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
INLINE_CLASS_UNDERLYING_TYPE,
INLINE_CLASS_UNDERLYING_TYPE_ID,
VERSION_REQUIREMENT_LIST,
VERSION_REQUIREMENT_TABLE,
JVM_EXT_CLASS_MODULE_NAME,
@@ -314,6 +332,21 @@ open class ProtoCompareGenerated(
if (!checkEqualsClassSealedSubclassFqName(old, new)) result.add(ProtoBufClassKind.SEALED_SUBCLASS_FQ_NAME_LIST)
if (old.hasInlineClassUnderlyingPropertyName() != new.hasInlineClassUnderlyingPropertyName()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME)
if (old.hasInlineClassUnderlyingPropertyName()) {
if (!checkStringEquals(old.inlineClassUnderlyingPropertyName, new.inlineClassUnderlyingPropertyName)) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME)
}
if (old.hasInlineClassUnderlyingType() != new.hasInlineClassUnderlyingType()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE)
if (old.hasInlineClassUnderlyingType()) {
if (!checkEquals(old.inlineClassUnderlyingType, new.inlineClassUnderlyingType)) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE)
}
if (old.hasInlineClassUnderlyingTypeId() != new.hasInlineClassUnderlyingTypeId()) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID)
if (old.hasInlineClassUnderlyingTypeId()) {
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID)
}
if (!checkEqualsClassVersionRequirement(old, new)) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_LIST)
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_TABLE)
@@ -1728,6 +1761,18 @@ fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
hashCode = 31 * hashCode + fqNameIndexes(getSealedSubclassFqName(i))
}
if (hasInlineClassUnderlyingPropertyName()) {
hashCode = 31 * hashCode + stringIndexes(inlineClassUnderlyingPropertyName)
}
if (hasInlineClassUnderlyingType()) {
hashCode = 31 * hashCode + inlineClassUnderlyingType.hashCode(stringIndexes, fqNameIndexes, typeById)
}
if (hasInlineClassUnderlyingTypeId()) {
hashCode = 31 * hashCode + typeById(inlineClassUnderlyingTypeId).hashCode(stringIndexes, fqNameIndexes, typeById)
}
for(i in 0..versionRequirementCount - 1) {
hashCode = 31 * hashCode + getVersionRequirement(i)
}

View File

@@ -290,6 +290,11 @@ class DifferenceCalculatorForClass(
isClassAffected = true
areSubclassesAffected = true
}
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE,
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID -> {
isClassAffected = true
}
}
}

View File

@@ -10347,6 +10347,37 @@ public final class DebugProtoBuf {
*/
int getSealedSubclassFqName(int index);
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
boolean hasInlineClassUnderlyingPropertyName();
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
int getInlineClassUnderlyingPropertyName();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
boolean hasInlineClassUnderlyingType();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType();
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder();
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
boolean hasInlineClassUnderlyingTypeId();
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
int getInlineClassUnderlyingTypeId();
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
@@ -10585,9 +10616,32 @@ public final class DebugProtoBuf {
input.popLimit(limit);
break;
}
case 136: {
bitField0_ |= 0x00000008;
inlineClassUnderlyingPropertyName_ = input.readInt32();
break;
}
case 146: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder subBuilder = null;
if (((bitField0_ & 0x00000010) == 0x00000010)) {
subBuilder = inlineClassUnderlyingType_.toBuilder();
}
inlineClassUnderlyingType_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.PARSER, extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(inlineClassUnderlyingType_);
inlineClassUnderlyingType_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000010;
break;
}
case 152: {
bitField0_ |= 0x00000020;
inlineClassUnderlyingTypeId_ = input.readInt32();
break;
}
case 242: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000008) == 0x00000008)) {
if (((bitField0_ & 0x00000040) == 0x00000040)) {
subBuilder = typeTable_.toBuilder();
}
typeTable_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.PARSER, extensionRegistry);
@@ -10595,13 +10649,13 @@ public final class DebugProtoBuf {
subBuilder.mergeFrom(typeTable_);
typeTable_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000040;
break;
}
case 248: {
if (!((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
if (!((mutable_bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00004000;
mutable_bitField0_ |= 0x00020000;
}
versionRequirement_.add(input.readInt32());
break;
@@ -10609,9 +10663,9 @@ public final class DebugProtoBuf {
case 250: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00004000) == 0x00004000) && input.getBytesUntilLimit() > 0) {
if (!((mutable_bitField0_ & 0x00020000) == 0x00020000) && input.getBytesUntilLimit() > 0) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00004000;
mutable_bitField0_ |= 0x00020000;
}
while (input.getBytesUntilLimit() > 0) {
versionRequirement_.add(input.readInt32());
@@ -10621,7 +10675,7 @@ public final class DebugProtoBuf {
}
case 258: {
org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
subBuilder = versionRequirementTable_.toBuilder();
}
versionRequirementTable_ = input.readMessage(org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.PARSER, extensionRegistry);
@@ -10629,7 +10683,7 @@ public final class DebugProtoBuf {
subBuilder.mergeFrom(versionRequirementTable_);
versionRequirementTable_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000010;
bitField0_ |= 0x00000080;
break;
}
}
@@ -10670,7 +10724,7 @@ public final class DebugProtoBuf {
if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
}
if (((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
if (((mutable_bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = java.util.Collections.unmodifiableList(versionRequirement_);
}
this.unknownFields = unknownFields.build();
@@ -11225,13 +11279,64 @@ public final class DebugProtoBuf {
}
private int sealedSubclassFqNameMemoizedSerializedSize = -1;
public static final int INLINE_CLASS_UNDERLYING_PROPERTY_NAME_FIELD_NUMBER = 17;
private int inlineClassUnderlyingPropertyName_;
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public boolean hasInlineClassUnderlyingPropertyName() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public int getInlineClassUnderlyingPropertyName() {
return inlineClassUnderlyingPropertyName_;
}
public static final int INLINE_CLASS_UNDERLYING_TYPE_FIELD_NUMBER = 18;
private org.jetbrains.kotlin.metadata.DebugProtoBuf.Type inlineClassUnderlyingType_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public boolean hasInlineClassUnderlyingType() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType() {
return inlineClassUnderlyingType_;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder() {
return inlineClassUnderlyingType_;
}
public static final int INLINE_CLASS_UNDERLYING_TYPE_ID_FIELD_NUMBER = 19;
private int inlineClassUnderlyingTypeId_;
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public boolean hasInlineClassUnderlyingTypeId() {
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public int getInlineClassUnderlyingTypeId() {
return inlineClassUnderlyingTypeId_;
}
public static final int TYPE_TABLE_FIELD_NUMBER = 30;
private org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable typeTable_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public boolean hasTypeTable() {
return ((bitField0_ & 0x00000008) == 0x00000008);
return ((bitField0_ & 0x00000040) == 0x00000040);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
@@ -11286,7 +11391,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public boolean hasVersionRequirementTable() {
return ((bitField0_ & 0x00000010) == 0x00000010);
return ((bitField0_ & 0x00000080) == 0x00000080);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
@@ -11315,6 +11420,9 @@ public final class DebugProtoBuf {
typeAlias_ = java.util.Collections.emptyList();
enumEntry_ = java.util.Collections.emptyList();
sealedSubclassFqName_ = java.util.Collections.emptyList();
inlineClassUnderlyingPropertyName_ = 0;
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
inlineClassUnderlyingTypeId_ = 0;
typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
versionRequirement_ = java.util.Collections.emptyList();
versionRequirementTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance();
@@ -11371,6 +11479,12 @@ public final class DebugProtoBuf {
return false;
}
}
if (hasInlineClassUnderlyingType()) {
if (!getInlineClassUnderlyingType().isInitialized()) {
memoizedIsInitialized = 0;
return false;
}
}
if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) {
memoizedIsInitialized = 0;
@@ -11443,12 +11557,21 @@ public final class DebugProtoBuf {
output.writeInt32NoTag(sealedSubclassFqName_.get(i));
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeInt32(17, inlineClassUnderlyingPropertyName_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(18, inlineClassUnderlyingType_);
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeInt32(19, inlineClassUnderlyingTypeId_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
output.writeMessage(30, typeTable_);
}
for (int i = 0; i < versionRequirement_.size(); i++) {
output.writeInt32(31, versionRequirement_.get(i));
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
output.writeMessage(32, versionRequirementTable_);
}
extensionWriter.writeUntil(19000, output);
@@ -11544,6 +11667,18 @@ public final class DebugProtoBuf {
sealedSubclassFqNameMemoizedSerializedSize = dataSize;
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(17, inlineClassUnderlyingPropertyName_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(18, inlineClassUnderlyingType_);
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32Size(19, inlineClassUnderlyingTypeId_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(30, typeTable_);
}
@@ -11556,7 +11691,7 @@ public final class DebugProtoBuf {
size += dataSize;
size += 2 * getVersionRequirementList().size();
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(32, versionRequirementTable_);
}
@@ -11678,6 +11813,7 @@ public final class DebugProtoBuf {
getPropertyFieldBuilder();
getTypeAliasFieldBuilder();
getEnumEntryFieldBuilder();
getInlineClassUnderlyingTypeFieldBuilder();
getTypeTableFieldBuilder();
getVersionRequirementTableFieldBuilder();
}
@@ -11742,20 +11878,30 @@ public final class DebugProtoBuf {
}
sealedSubclassFqName_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00001000);
inlineClassUnderlyingPropertyName_ = 0;
bitField0_ = (bitField0_ & ~0x00002000);
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
} else {
inlineClassUnderlyingTypeBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00004000);
inlineClassUnderlyingTypeId_ = 0;
bitField0_ = (bitField0_ & ~0x00008000);
if (typeTableBuilder_ == null) {
typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
} else {
typeTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00002000);
bitField0_ = (bitField0_ & ~0x00010000);
versionRequirement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
if (versionRequirementTableBuilder_ == null) {
versionRequirementTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance();
} else {
versionRequirementTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00008000);
bitField0_ = (bitField0_ & ~0x00040000);
return this;
}
@@ -11877,18 +12023,34 @@ public final class DebugProtoBuf {
if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
to_bitField0_ |= 0x00000008;
}
result.inlineClassUnderlyingPropertyName_ = inlineClassUnderlyingPropertyName_;
if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
to_bitField0_ |= 0x00000010;
}
if (inlineClassUnderlyingTypeBuilder_ == null) {
result.inlineClassUnderlyingType_ = inlineClassUnderlyingType_;
} else {
result.inlineClassUnderlyingType_ = inlineClassUnderlyingTypeBuilder_.build();
}
if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000020;
}
result.inlineClassUnderlyingTypeId_ = inlineClassUnderlyingTypeId_;
if (((from_bitField0_ & 0x00010000) == 0x00010000)) {
to_bitField0_ |= 0x00000040;
}
if (typeTableBuilder_ == null) {
result.typeTable_ = typeTable_;
} else {
result.typeTable_ = typeTableBuilder_.build();
}
if (((bitField0_ & 0x00004000) == 0x00004000)) {
if (((bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = java.util.Collections.unmodifiableList(versionRequirement_);
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
}
result.versionRequirement_ = versionRequirement_;
if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000010;
if (((from_bitField0_ & 0x00040000) == 0x00040000)) {
to_bitField0_ |= 0x00000080;
}
if (versionRequirementTableBuilder_ == null) {
result.versionRequirementTable_ = versionRequirementTable_;
@@ -12132,13 +12294,22 @@ public final class DebugProtoBuf {
}
onChanged();
}
if (other.hasInlineClassUnderlyingPropertyName()) {
setInlineClassUnderlyingPropertyName(other.getInlineClassUnderlyingPropertyName());
}
if (other.hasInlineClassUnderlyingType()) {
mergeInlineClassUnderlyingType(other.getInlineClassUnderlyingType());
}
if (other.hasInlineClassUnderlyingTypeId()) {
setInlineClassUnderlyingTypeId(other.getInlineClassUnderlyingTypeId());
}
if (other.hasTypeTable()) {
mergeTypeTable(other.getTypeTable());
}
if (!other.versionRequirement_.isEmpty()) {
if (versionRequirement_.isEmpty()) {
versionRequirement_ = other.versionRequirement_;
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
} else {
ensureVersionRequirementIsMutable();
versionRequirement_.addAll(other.versionRequirement_);
@@ -12200,6 +12371,12 @@ public final class DebugProtoBuf {
return false;
}
}
if (hasInlineClassUnderlyingType()) {
if (!getInlineClassUnderlyingType().isInitialized()) {
return false;
}
}
if (hasTypeTable()) {
if (!getTypeTable().isInitialized()) {
@@ -14258,6 +14435,186 @@ public final class DebugProtoBuf {
return this;
}
private int inlineClassUnderlyingPropertyName_ ;
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public boolean hasInlineClassUnderlyingPropertyName() {
return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public int getInlineClassUnderlyingPropertyName() {
return inlineClassUnderlyingPropertyName_;
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public Builder setInlineClassUnderlyingPropertyName(int value) {
bitField0_ |= 0x00002000;
inlineClassUnderlyingPropertyName_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 inline_class_underlying_property_name = 17;</code>
*/
public Builder clearInlineClassUnderlyingPropertyName() {
bitField0_ = (bitField0_ & ~0x00002000);
inlineClassUnderlyingPropertyName_ = 0;
onChanged();
return this;
}
private org.jetbrains.kotlin.metadata.DebugProtoBuf.Type inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder> inlineClassUnderlyingTypeBuilder_;
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public boolean hasInlineClassUnderlyingType() {
return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type getInlineClassUnderlyingType() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
return inlineClassUnderlyingType_;
} else {
return inlineClassUnderlyingTypeBuilder_.getMessage();
}
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder setInlineClassUnderlyingType(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type value) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
inlineClassUnderlyingType_ = value;
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.setMessage(value);
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder setInlineClassUnderlyingType(
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder builderForValue) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = builderForValue.build();
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder mergeInlineClassUnderlyingType(org.jetbrains.kotlin.metadata.DebugProtoBuf.Type value) {
if (inlineClassUnderlyingTypeBuilder_ == null) {
if (((bitField0_ & 0x00004000) == 0x00004000) &&
inlineClassUnderlyingType_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance()) {
inlineClassUnderlyingType_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.newBuilder(inlineClassUnderlyingType_).mergeFrom(value).buildPartial();
} else {
inlineClassUnderlyingType_ = value;
}
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00004000;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public Builder clearInlineClassUnderlyingType() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingType_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.getDefaultInstance();
onChanged();
} else {
inlineClassUnderlyingTypeBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00004000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder getInlineClassUnderlyingTypeBuilder() {
bitField0_ |= 0x00004000;
onChanged();
return getInlineClassUnderlyingTypeFieldBuilder().getBuilder();
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder getInlineClassUnderlyingTypeOrBuilder() {
if (inlineClassUnderlyingTypeBuilder_ != null) {
return inlineClassUnderlyingTypeBuilder_.getMessageOrBuilder();
} else {
return inlineClassUnderlyingType_;
}
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.Type inline_class_underlying_type = 18;</code>
*/
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder>
getInlineClassUnderlyingTypeFieldBuilder() {
if (inlineClassUnderlyingTypeBuilder_ == null) {
inlineClassUnderlyingTypeBuilder_ = new org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.Type, org.jetbrains.kotlin.metadata.DebugProtoBuf.Type.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeOrBuilder>(
getInlineClassUnderlyingType(),
getParentForChildren(),
isClean());
inlineClassUnderlyingType_ = null;
}
return inlineClassUnderlyingTypeBuilder_;
}
private int inlineClassUnderlyingTypeId_ ;
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public boolean hasInlineClassUnderlyingTypeId() {
return ((bitField0_ & 0x00008000) == 0x00008000);
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public int getInlineClassUnderlyingTypeId() {
return inlineClassUnderlyingTypeId_;
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public Builder setInlineClassUnderlyingTypeId(int value) {
bitField0_ |= 0x00008000;
inlineClassUnderlyingTypeId_ = value;
onChanged();
return this;
}
/**
* <code>optional int32 inline_class_underlying_type_id = 19;</code>
*/
public Builder clearInlineClassUnderlyingTypeId() {
bitField0_ = (bitField0_ & ~0x00008000);
inlineClassUnderlyingTypeId_ = 0;
onChanged();
return this;
}
private org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable typeTable_ = org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance();
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder, org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTableOrBuilder> typeTableBuilder_;
@@ -14265,7 +14622,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public boolean hasTypeTable() {
return ((bitField0_ & 0x00002000) == 0x00002000);
return ((bitField0_ & 0x00010000) == 0x00010000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
@@ -14290,7 +14647,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(value);
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14304,7 +14661,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14312,7 +14669,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeTypeTable(org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable value) {
if (typeTableBuilder_ == null) {
if (((bitField0_ & 0x00002000) == 0x00002000) &&
if (((bitField0_ & 0x00010000) == 0x00010000) &&
typeTable_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.getDefaultInstance()) {
typeTable_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial();
@@ -14323,7 +14680,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
return this;
}
/**
@@ -14336,14 +14693,14 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00002000);
bitField0_ = (bitField0_ & ~0x00010000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.TypeTable type_table = 30;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.TypeTable.Builder getTypeTableBuilder() {
bitField0_ |= 0x00002000;
bitField0_ |= 0x00010000;
onChanged();
return getTypeTableFieldBuilder().getBuilder();
}
@@ -14376,9 +14733,9 @@ public final class DebugProtoBuf {
private java.util.List<java.lang.Integer> versionRequirement_ = java.util.Collections.emptyList();
private void ensureVersionRequirementIsMutable() {
if (!((bitField0_ & 0x00004000) == 0x00004000)) {
if (!((bitField0_ & 0x00020000) == 0x00020000)) {
versionRequirement_ = new java.util.ArrayList<java.lang.Integer>(versionRequirement_);
bitField0_ |= 0x00004000;
bitField0_ |= 0x00020000;
}
}
/**
@@ -14463,7 +14820,7 @@ public final class DebugProtoBuf {
*/
public Builder clearVersionRequirement() {
versionRequirement_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00004000);
bitField0_ = (bitField0_ & ~0x00020000);
onChanged();
return this;
}
@@ -14475,7 +14832,7 @@ public final class DebugProtoBuf {
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public boolean hasVersionRequirementTable() {
return ((bitField0_ & 0x00008000) == 0x00008000);
return ((bitField0_ & 0x00040000) == 0x00040000);
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
@@ -14500,7 +14857,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.setMessage(value);
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14514,7 +14871,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.setMessage(builderForValue.build());
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14522,7 +14879,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeVersionRequirementTable(org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable value) {
if (versionRequirementTableBuilder_ == null) {
if (((bitField0_ & 0x00008000) == 0x00008000) &&
if (((bitField0_ & 0x00040000) == 0x00040000) &&
versionRequirementTable_ != org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.getDefaultInstance()) {
versionRequirementTable_ =
org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.newBuilder(versionRequirementTable_).mergeFrom(value).buildPartial();
@@ -14533,7 +14890,7 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.mergeFrom(value);
}
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
return this;
}
/**
@@ -14546,14 +14903,14 @@ public final class DebugProtoBuf {
} else {
versionRequirementTableBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00008000);
bitField0_ = (bitField0_ & ~0x00040000);
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.metadata.VersionRequirementTable version_requirement_table = 32;</code>
*/
public org.jetbrains.kotlin.metadata.DebugProtoBuf.VersionRequirementTable.Builder getVersionRequirementTableBuilder() {
bitField0_ |= 0x00008000;
bitField0_ |= 0x00040000;
onChanged();
return getVersionRequirementTableFieldBuilder().getBuilder();
}
@@ -34382,7 +34739,7 @@ public final class DebugProtoBuf {
"Variance:\003INV\0228\n\013upper_bound\030\005 \003(\0132#.org" +
".jetbrains.kotlin.metadata.Type\022\036\n\016upper" +
"_bound_id\030\006 \003(\005B\006\020\001\240\265\030\001\"$\n\010Variance\022\006\n\002I" +
"N\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\250\007\n\005Class\022\020" +
"N\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\327\010\n\005Class\022\020" +
"\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B\004\220\265\030\001\022",
"#\n\025companion_object_name\030\004 \001(\005B\004\210\265\030\001\022D\n\016" +
"type_parameter\030\005 \003(\0132,.org.jetbrains.kot" +
@@ -34398,122 +34755,127 @@ public final class DebugProtoBuf {
"brains.kotlin.metadata.TypeAlias\022<\n\nenum" +
"_entry\030\r \003(\0132(.org.jetbrains.kotlin.meta" +
"data.EnumEntry\022\'\n\027sealed_subclass_fq_nam" +
"e\030\020 \003(\005B\006\020\001\220\265\030\001\022<\n\ntype_table\030\036 \001(\0132(.or" +
"g.jetbrains.kotlin.metadata.TypeTable\022\033\n" +
"\023version_requirement\030\037 \003(\005\022Y\n\031version_re" +
"quirement_table\030 \001(\01326.org.jetbrains.ko" +
"tlin.metadata.VersionRequirementTable\"x\n" +
"\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_",
"CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_CL" +
"ASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020\006*" +
"\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010function\030\003 \003(\0132\'." +
"org.jetbrains.kotlin.metadata.Function\0229" +
"\n\010property\030\004 \003(\0132\'.org.jetbrains.kotlin." +
"metadata.Property\022<\n\ntype_alias\030\005 \003(\0132(." +
"org.jetbrains.kotlin.metadata.TypeAlias\022" +
"<\n\ntype_table\030\036 \001(\0132(.org.jetbrains.kotl" +
"in.metadata.TypeTable\022Y\n\031version_require" +
"ment_table\030 \001(\01326.org.jetbrains.kotlin.",
"metadata.VersionRequirementTable*\005\010d\020\310\001\"" +
"`\n\tTypeTable\0221\n\004type\030\001 \003(\0132#.org.jetbrai" +
"ns.kotlin.metadata.Type\022\032\n\016first_nullabl" +
"e\030\002 \001(\005:\002-1:\004\240\273\030\001\"\214\001\n\013Constructor\022\020\n\005fla" +
"gs\030\001 \001(\005:\0016\022F\n\017value_parameter\030\002 \003(\0132-.o" +
"rg.jetbrains.kotlin.metadata.ValueParame" +
"ter\022\033\n\023version_requirement\030\037 \003(\005*\006\010d\020\270\224\001" +
"\"\246\004\n\010Function\022\020\n\005flags\030\t \001(\005:\0016\022\024\n\told_f" +
"lags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013ret" +
"urn_type\030\003 \001(\0132#.org.jetbrains.kotlin.me",
"tadata.Type\022\034\n\016return_type_id\030\007 \001(\005B\004\240\265\030" +
"\001\022D\n\016type_parameter\030\004 \003(\0132,.org.jetbrain" +
"s.kotlin.metadata.TypeParameter\022:\n\rrecei" +
"ver_type\030\005 \001(\0132#.org.jetbrains.kotlin.me" +
"tadata.Type\022\036\n\020receiver_type_id\030\010 \001(\005B\004\240" +
"\265\030\001\022F\n\017value_parameter\030\006 \003(\0132-.org.jetbr" +
"ains.kotlin.metadata.ValueParameter\022<\n\nt" +
"ype_table\030\036 \001(\0132(.org.jetbrains.kotlin.m" +
"etadata.TypeTable\022\033\n\023version_requirement" +
"\030\037 \003(\005\0229\n\010contract\030 \001(\0132\'.org.jetbrains",
".kotlin.metadata.Contract*\006\010d\020\270\224\001\"\345\003\n\010Pr" +
"operty\022\022\n\005flags\030\013 \001(\005:\003518\022\027\n\told_flags\030" +
"\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0228\n\013retur" +
"n_type\030\003 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022\034\n\016return_type_id\030\t \001(\005B\004\240\265\030\001\022" +
"D\n\016type_parameter\030\004 \003(\0132,.org.jetbrains." +
"kotlin.metadata.TypeParameter\022:\n\rreceive" +
"r_type\030\005 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022\036\n\020receiver_type_id\030\n \001(\005B\004\240\265\030" +
"\001\022M\n\026setter_value_parameter\030\006 \001(\0132-.org.",
"jetbrains.kotlin.metadata.ValueParameter" +
"\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_flags\030\010" +
" \001(\005\022\033\n\023version_requirement\030\037 \003(\005*\006\010d\020\270\224" +
"\001\"\357\001\n\016ValueParameter\022\020\n\005flags\030\001 \001(\005:\0010\022\022" +
"\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004type\030\003 \001(\0132#.org.j" +
"etbrains.kotlin.metadata.Type\022\025\n\007type_id" +
"\030\005 \001(\005B\004\240\265\030\001\022@\n\023vararg_element_type\030\004 \001(" +
"\0132#.org.jetbrains.kotlin.metadata.Type\022$" +
"\n\026vararg_element_type_id\030\006 \001(\005B\004\240\265\030\001*\005\010d" +
"\020\310\001\"\226\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004n",
"ame\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_parameter\030\003 \003(\0132" +
",.org.jetbrains.kotlin.metadata.TypePara" +
"meter\022<\n\017underlying_type\030\004 \001(\0132#.org.jet" +
"brains.kotlin.metadata.Type\022 \n\022underlyin" +
"g_type_id\030\005 \001(\005B\004\240\265\030\001\022:\n\rexpanded_type\030\006" +
" \001(\0132#.org.jetbrains.kotlin.metadata.Typ" +
"e\022\036\n\020expanded_type_id\030\007 \001(\005B\004\240\265\030\001\022=\n\nann" +
"otation\030\010 \003(\0132).org.jetbrains.kotlin.met" +
"adata.Annotation\022\033\n\023version_requirement\030" +
"\037 \003(\005*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004name\030\001 \001(\005B",
"\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022VersionRequirement\022\017\n\007v" +
"ersion\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022M\n\005le" +
"vel\030\003 \001(\01627.org.jetbrains.kotlin.metadat" +
"a.VersionRequirement.Level:\005ERROR\022\022\n\nerr" +
"or_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\022e\n\014" +
"version_kind\030\006 \001(\0162=.org.jetbrains.kotli" +
"n.metadata.VersionRequirement.VersionKin" +
"d:\020LANGUAGE_VERSION\"+\n\005Level\022\013\n\007WARNING\020" +
"\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"J\n\013VersionKind\022" +
"\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020COMPILER_VERSIO",
"N\020\001\022\017\n\013API_VERSION\020\002\"a\n\027VersionRequireme" +
"ntTable\022F\n\013requirement\030\001 \003(\01321.org.jetbr" +
"ains.kotlin.metadata.VersionRequirement\"" +
"\217\002\n\017PackageFragment\022;\n\007strings\030\001 \001(\0132*.o" +
"rg.jetbrains.kotlin.metadata.StringTable" +
"\022J\n\017qualified_names\030\002 \001(\01321.org.jetbrain" +
"s.kotlin.metadata.QualifiedNameTable\0227\n\007" +
"package\030\003 \001(\0132&.org.jetbrains.kotlin.met" +
"adata.Package\0223\n\005class\030\004 \003(\0132$.org.jetbr" +
"ains.kotlin.metadata.Class*\005\010d\020\310\001\"A\n\010Con",
"tract\0225\n\006effect\030\001 \003(\0132%.org.jetbrains.ko" +
"tlin.metadata.Effect\"\306\003\n\006Effect\022E\n\013effec" +
"t_type\030\001 \001(\01620.org.jetbrains.kotlin.meta" +
"data.Effect.EffectType\022N\n\033effect_constru" +
"ctor_argument\030\002 \003(\0132).org.jetbrains.kotl" +
"in.metadata.Expression\022S\n conclusion_of_" +
"conditional_effect\030\003 \001(\0132).org.jetbrains" +
".kotlin.metadata.Expression\022B\n\004kind\030\004 \001(" +
"\01624.org.jetbrains.kotlin.metadata.Effect" +
".InvocationKind\"C\n\nEffectType\022\024\n\020RETURNS",
"_CONSTANT\020\000\022\t\n\005CALLS\020\001\022\024\n\020RETURNS_NOT_NU" +
"LL\020\002\"G\n\016InvocationKind\022\020\n\014AT_MOST_ONCE\020\000" +
"\022\020\n\014EXACTLY_ONCE\020\001\022\021\n\rAT_LEAST_ONCE\020\002\"\245\003" +
"\n\nExpression\022\020\n\005flags\030\001 \001(\005:\0010\022!\n\031value_" +
"parameter_reference\030\002 \001(\005\022O\n\016constant_va" +
"lue\030\003 \001(\01627.org.jetbrains.kotlin.metadat" +
"a.Expression.ConstantValue\022=\n\020is_instanc" +
"e_type\030\004 \001(\0132#.org.jetbrains.kotlin.meta" +
"data.Type\022!\n\023is_instance_type_id\030\005 \001(\005B\004" +
"\240\265\030\001\022?\n\014and_argument\030\006 \003(\0132).org.jetbrai",
"ns.kotlin.metadata.Expression\022>\n\013or_argu" +
"ment\030\007 \003(\0132).org.jetbrains.kotlin.metada" +
"ta.Expression\".\n\rConstantValue\022\010\n\004TRUE\020\000" +
"\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n\010Modality\022\t\n\005FIN" +
"AL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003" +
"*b\n\nVisibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020" +
"\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_" +
"TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013DE" +
"CLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELEGA" +
"TION\020\002\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProtoBuf"
"e\030\020 \003(\005B\006\020\001\220\265\030\001\0223\n%inline_class_underlyi" +
"ng_property_name\030\021 \001(\005B\004\210\265\030\001\022I\n\034inline_c" +
"lass_underlying_type\030\022 \001(\0132#.org.jetbrai" +
"ns.kotlin.metadata.Type\022-\n\037inline_class_" +
"underlying_type_id\030\023 \001(\005B\004\240\265\030\001\022<\n\ntype_t" +
"able\030\036 \001(\0132(.org.jetbrains.kotlin.metada",
"ta.TypeTable\022\033\n\023version_requirement\030\037 \003(" +
"\005\022Y\n\031version_requirement_table\030 \001(\01326.o" +
"rg.jetbrains.kotlin.metadata.VersionRequ" +
"irementTable\"x\n\004Kind\022\t\n\005CLASS\020\000\022\r\n\tINTER" +
"FACE\020\001\022\016\n\nENUM_CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024" +
"\n\020ANNOTATION_CLASS\020\004\022\n\n\006OBJECT\020\005\022\024\n\020COMP" +
"ANION_OBJECT\020\006*\006\010d\020\270\224\001\"\335\002\n\007Package\0229\n\010fu" +
"nction\030\003 \003(\0132\'.org.jetbrains.kotlin.meta" +
"data.Function\0229\n\010property\030\004 \003(\0132\'.org.je" +
"tbrains.kotlin.metadata.Property\022<\n\ntype",
"_alias\030\005 \003(\0132(.org.jetbrains.kotlin.meta" +
"data.TypeAlias\022<\n\ntype_table\030\036 \001(\0132(.org" +
".jetbrains.kotlin.metadata.TypeTable\022Y\n\031" +
"version_requirement_table\030 \001(\01326.org.je" +
"tbrains.kotlin.metadata.VersionRequireme" +
"ntTable*\005\010d\020\310\001\"`\n\tTypeTable\0221\n\004type\030\001 \003(" +
"\0132#.org.jetbrains.kotlin.metadata.Type\022\032" +
"\n\016first_nullable\030\002 \001(\005:\002-1:\004\240\273\030\001\"\214\001\n\013Con" +
"structor\022\020\n\005flags\030\001 \001(\005:\0016\022F\n\017value_para" +
"meter\030\002 \003(\0132-.org.jetbrains.kotlin.metad",
"ata.ValueParameter\022\033\n\023version_requiremen" +
"t\030\037 \003(\005*\006\010d\020\270\224\001\"\246\004\n\010Function\022\020\n\005flags\030\t " +
"\001(\005:\0016\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002" +
"(\005B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.jetb" +
"rains.kotlin.metadata.Type\022\034\n\016return_typ" +
"e_id\030\007 \001(\005B\004\240\265\030\001\022D\n\016type_parameter\030\004 \003(\013" +
"2,.org.jetbrains.kotlin.metadata.TypePar" +
"ameter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetb" +
"rains.kotlin.metadata.Type\022\036\n\020receiver_t" +
"ype_id\030\010 \001(\005B\004\240\265\030\001\022F\n\017value_parameter\030\006 ",
"\003(\0132-.org.jetbrains.kotlin.metadata.Valu" +
"eParameter\022<\n\ntype_table\030\036 \001(\0132(.org.jet" +
"brains.kotlin.metadata.TypeTable\022\033\n\023vers" +
"ion_requirement\030\037 \003(\005\0229\n\010contract\030 \001(\0132" +
"\'.org.jetbrains.kotlin.metadata.Contract" +
"*\006\010d\020\270\224\001\"\345\003\n\010Property\022\022\n\005flags\030\013 \001(\005:\00351" +
"8\022\027\n\told_flags\030\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005" +
"B\004\210\265\030\001\0228\n\013return_type\030\003 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022\034\n\016return_type_" +
"id\030\t \001(\005B\004\240\265\030\001\022D\n\016type_parameter\030\004 \003(\0132,",
".org.jetbrains.kotlin.metadata.TypeParam" +
"eter\022:\n\rreceiver_type\030\005 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022\036\n\020receiver_typ" +
"e_id\030\n \001(\005B\004\240\265\030\001\022M\n\026setter_value_paramet" +
"er\030\006 \001(\0132-.org.jetbrains.kotlin.metadata" +
".ValueParameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n" +
"\014setter_flags\030\010 \001(\005\022\033\n\023version_requireme" +
"nt\030\037 \003(\005*\006\010d\020\270\224\001\"\357\001\n\016ValueParameter\022\020\n\005f" +
"lags\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0221\n\004typ" +
"e\030\003 \001(\0132#.org.jetbrains.kotlin.metadata.",
"Type\022\025\n\007type_id\030\005 \001(\005B\004\240\265\030\001\022@\n\023vararg_el" +
"ement_type\030\004 \001(\0132#.org.jetbrains.kotlin." +
"metadata.Type\022$\n\026vararg_element_type_id\030" +
"\006 \001(\005B\004\240\265\030\001*\005\010d\020\310\001\"\226\003\n\tTypeAlias\022\020\n\005flag" +
"s\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022D\n\016type_p" +
"arameter\030\003 \003(\0132,.org.jetbrains.kotlin.me" +
"tadata.TypeParameter\022<\n\017underlying_type\030" +
"\004 \001(\0132#.org.jetbrains.kotlin.metadata.Ty" +
"pe\022 \n\022underlying_type_id\030\005 \001(\005B\004\240\265\030\001\022:\n\r" +
"expanded_type\030\006 \001(\0132#.org.jetbrains.kotl",
"in.metadata.Type\022\036\n\020expanded_type_id\030\007 \001" +
"(\005B\004\240\265\030\001\022=\n\nannotation\030\010 \003(\0132).org.jetbr" +
"ains.kotlin.metadata.Annotation\022\033\n\023versi" +
"on_requirement\030\037 \003(\005*\005\010d\020\310\001\"&\n\tEnumEntry" +
"\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\225\003\n\022VersionR" +
"equirement\022\017\n\007version\030\001 \001(\005\022\024\n\014version_f" +
"ull\030\002 \001(\005\022M\n\005level\030\003 \001(\01627.org.jetbrains" +
".kotlin.metadata.VersionRequirement.Leve" +
"l:\005ERROR\022\022\n\nerror_code\030\004 \001(\005\022\025\n\007message\030" +
"\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind\030\006 \001(\0162=.org.",
"jetbrains.kotlin.metadata.VersionRequire" +
"ment.VersionKind:\020LANGUAGE_VERSION\"+\n\005Le" +
"vel\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"" +
"J\n\013VersionKind\022\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020" +
"COMPILER_VERSION\020\001\022\017\n\013API_VERSION\020\002\"a\n\027V" +
"ersionRequirementTable\022F\n\013requirement\030\001 " +
"\003(\01321.org.jetbrains.kotlin.metadata.Vers" +
"ionRequirement\"\217\002\n\017PackageFragment\022;\n\007st" +
"rings\030\001 \001(\0132*.org.jetbrains.kotlin.metad" +
"ata.StringTable\022J\n\017qualified_names\030\002 \001(\013",
"21.org.jetbrains.kotlin.metadata.Qualifi" +
"edNameTable\0227\n\007package\030\003 \001(\0132&.org.jetbr" +
"ains.kotlin.metadata.Package\0223\n\005class\030\004 " +
"\003(\0132$.org.jetbrains.kotlin.metadata.Clas" +
"s*\005\010d\020\310\001\"A\n\010Contract\0225\n\006effect\030\001 \003(\0132%.o" +
"rg.jetbrains.kotlin.metadata.Effect\"\306\003\n\006" +
"Effect\022E\n\013effect_type\030\001 \001(\01620.org.jetbra" +
"ins.kotlin.metadata.Effect.EffectType\022N\n" +
"\033effect_constructor_argument\030\002 \003(\0132).org" +
".jetbrains.kotlin.metadata.Expression\022S\n",
" conclusion_of_conditional_effect\030\003 \001(\0132" +
").org.jetbrains.kotlin.metadata.Expressi" +
"on\022B\n\004kind\030\004 \001(\01624.org.jetbrains.kotlin." +
"metadata.Effect.InvocationKind\"C\n\nEffect" +
"Type\022\024\n\020RETURNS_CONSTANT\020\000\022\t\n\005CALLS\020\001\022\024\n" +
"\020RETURNS_NOT_NULL\020\002\"G\n\016InvocationKind\022\020\n" +
"\014AT_MOST_ONCE\020\000\022\020\n\014EXACTLY_ONCE\020\001\022\021\n\rAT_" +
"LEAST_ONCE\020\002\"\245\003\n\nExpression\022\020\n\005flags\030\001 \001" +
"(\005:\0010\022!\n\031value_parameter_reference\030\002 \001(\005" +
"\022O\n\016constant_value\030\003 \001(\01627.org.jetbrains",
".kotlin.metadata.Expression.ConstantValu" +
"e\022=\n\020is_instance_type\030\004 \001(\0132#.org.jetbra" +
"ins.kotlin.metadata.Type\022!\n\023is_instance_" +
"type_id\030\005 \001(\005B\004\240\265\030\001\022?\n\014and_argument\030\006 \003(" +
"\0132).org.jetbrains.kotlin.metadata.Expres" +
"sion\022>\n\013or_argument\030\007 \003(\0132).org.jetbrain" +
"s.kotlin.metadata.Expression\".\n\rConstant" +
"Value\022\010\n\004TRUE\020\000\022\t\n\005FALSE\020\001\022\010\n\004NULL\020\002*9\n\010" +
"Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRAC" +
"T\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010INTERNA",
"L\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLI" +
"C\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nM" +
"emberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAKE_OVERR" +
"IDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED\020\003B\017" +
"B\rDebugProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -34587,7 +34949,7 @@ public final class DebugProtoBuf {
internal_static_org_jetbrains_kotlin_metadata_Class_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_metadata_Class_descriptor,
new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "SealedSubclassFqName", "TypeTable", "VersionRequirement", "VersionRequirementTable", });
new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "SealedSubclassFqName", "InlineClassUnderlyingPropertyName", "InlineClassUnderlyingType", "InlineClassUnderlyingTypeId", "TypeTable", "VersionRequirement", "VersionRequirementTable", });
internal_static_org_jetbrains_kotlin_metadata_Package_descriptor =
getDescriptor().getMessageTypes().get(6);
internal_static_org_jetbrains_kotlin_metadata_Package_fieldAccessorTable = new
@@ -34696,6 +35058,8 @@ public final class DebugProtoBuf {
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.skipMessageInComparison);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.metadata.DebugExtOptionsProtoBuf.typeIdInTable);

View File

@@ -178,7 +178,7 @@ extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.1.3"
extra["versions.r8"] = "2.0.88"
extra["versions.r8"] = "2.1.75"
val immutablesVersion = "0.3.1"
extra["versions.kotlinx-collections-immutable"] = immutablesVersion
extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
@@ -187,7 +187,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.5-dev-17775"
extra["versions.kotlin-native"] = "1.5-rc1-41"
}
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
@@ -345,6 +345,7 @@ val coreLibProjects = listOfNotNull(
":kotlin-stdlib-js",
":kotlin-stdlib-jdk7",
":kotlin-stdlib-jdk8",
":kotlin-test",
":kotlin-test:kotlin-test-annotations-common",
":kotlin-test:kotlin-test-common",
":kotlin-test:kotlin-test-jvm",
@@ -423,14 +424,19 @@ allprojects {
repositories {
kotlinBuildLocalRepo(project)
mirrorRepo?.let(::maven)
jcenter()
maven(protobufRepo)
maven(intellijRepo)
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
maven("https://dl.google.com/dl/android/maven2")
bootstrapKotlinRepo?.let(::maven)
internalBootstrapRepo?.let(::maven)
bootstrapKotlinRepo?.let(::maven)
maven(protobufRepo)
maven(intellijRepo)
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
maven("https://dl.google.com/dl/android/maven2")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
jcenter()
}
configureJvmProject(javaHome!!, jvmTarget!!)
@@ -471,7 +477,7 @@ allprojects {
}
}
if (!kotlinBuildProperties.isInJpsBuildIdeaSync && !kotlinBuildProperties.useFir) {
if (!kotlinBuildProperties.isInJpsBuildIdeaSync && !kotlinBuildProperties.useFir && !kotlinBuildProperties.disableWerror) {
// For compiler and stdlib, allWarningsAsErrors is configured in the corresponding "root" projects
// (compiler/build.gradle.kts and libraries/commonConfiguration.gradle).
val projectsWithWarningsAsErrors = listOf("core", "plugins").map { File(it).absoluteFile }
@@ -637,7 +643,10 @@ tasks {
listOf("clean", "assemble", "install").forEach { taskName ->
register("coreLibs${taskName.capitalize()}") {
coreLibProjects.forEach { projectName -> dependsOn("$projectName:$taskName") }
for (projectName in coreLibProjects) {
if (projectName.startsWith(":kotlin-test:") && taskName == "install") continue
dependsOn("$projectName:$taskName")
}
}
}
@@ -728,10 +737,12 @@ tasks {
register("scriptingTest") {
dependsOn("dist")
dependsOn(":kotlin-script-util:test")
dependsOn(":kotlin-scripting-compiler-embeddable:test")
dependsOn(":kotlin-scripting-compiler:test")
dependsOn(":kotlin-scripting-compiler:testWithIr")
dependsOn(":kotlin-scripting-common:test")
dependsOn(":kotlin-scripting-jvm:test")
dependsOn(":kotlin-scripting-jvm-host-test:test")
dependsOn(":kotlin-scripting-jvm-host-test:testWithIr")
dependsOn(":kotlin-scripting-dependencies:test")
dependsOn(":kotlin-scripting-dependencies-maven:test")
dependsOn(":kotlin-scripting-jsr223-test:test")
@@ -739,6 +750,7 @@ tasks {
// dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
dependsOn(":kotlin-main-kts-test:test")
dependsOn(":kotlin-main-kts-test:testWithIr")
dependsOn(":kotlin-scripting-ide-services-test:test")
dependsOn(":kotlin-scripting-ide-services-test:embeddableTest")
dependsOn(":kotlin-scripting-js-test:test")
@@ -752,7 +764,6 @@ tasks {
register("miscCompilerTest") {
dependsOn("nativeCompilerTest")
dependsOn("firCompilerTest")
dependsOn(":kotlin-daemon-tests:test")
dependsOn("scriptingTest")
@@ -953,7 +964,6 @@ tasks {
dependsOn(
":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide:publish",
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-build-common-tests-for-ide:publish",
":prepare:ide-plugin-dependencies:kotlin-compiler-for-ide:publish",
@@ -975,9 +985,7 @@ tasks {
":kotlin-stdlib-jdk7:publish",
":kotlin-stdlib-jdk8:publish",
":kotlin-reflect:publish",
":kotlin-main-kts:publish",
":kotlin-stdlib-js:publish",
":kotlin-test:kotlin-test-js:publish"
":kotlin-main-kts:publish"
)
}
}

View File

@@ -87,7 +87,7 @@ extra["customDepsOrg"] = "kotlin.build"
repositories {
jcenter()
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
gradlePluginPortal()

View File

@@ -65,28 +65,11 @@ repositories {
artifact()
}
}
ivy {
url = URI("https://dl.bintray.com/kotlin/as/")
patternLayout {
artifact("[artifact]-[revision]-$androidStudioOs.[ext]")
}
credentials {
username = System.getenv("AS_BINTRAY_USER_NAME") ?: findProperty("bintray.user") as String?
password = System.getenv("AS_BINTRAY_API_KEY") ?: findProperty("bintray.apikey") as String?
}
metadataSources {
artifact()
}
}
}
maven("https://www.jetbrains.com/intellij-repository/$intellijReleaseType")
maven("https://plugins.jetbrains.com/maven")
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
}
val intellij by configurations.creating

View File

@@ -18,3 +18,5 @@ val KotlinBuildProperties.proguard: Boolean get() = postProcessing && getBoolean
val KotlinBuildProperties.jarCompression: Boolean get() = getBoolean("kotlin.build.jar.compression", isTeamcityBuild)
val KotlinBuildProperties.ignoreTestFailures: Boolean get() = getBoolean("ignoreTestFailures", isTeamcityBuild)
val KotlinBuildProperties.disableWerror: Boolean get() = getBoolean("kotlin.build.disable.werror", isTeamcityBuild)

View File

@@ -9,10 +9,13 @@
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import java.io.File
@@ -112,6 +115,50 @@ fun DependencyHandler.projectTests(name: String): ProjectDependency = project(na
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives")
fun Project.testApiJUnit5(
vintageEngine: Boolean = false,
runner: Boolean = false,
suiteApi: Boolean = false
) {
with(dependencies) {
val platformVersion = commonVer("org.junit", "junit-bom")
testApi(platform("org.junit:junit-bom:$platformVersion"))
testApi("org.junit.jupiter:junit-jupiter")
if (vintageEngine) {
testApi("org.junit.vintage:junit-vintage-engine:$platformVersion")
}
val componentsVersion = commonVer("org.junit.platform", "")
val components = mutableListOf(
"org.junit.platform:junit-platform-commons",
"org.junit.platform:junit-platform-launcher"
)
if (runner) {
components += "org.junit.platform:junit-platform-runner"
}
if (suiteApi) {
components += "org.junit.platform:junit-platform-suite-api"
}
for (component in components) {
testApi("$component:$componentsVersion")
}
addDependencyTo<ExternalModuleDependency>(this, "testImplementation", intellijDep()) {
// This dependency is needed only for FileComparisonFailure
includeJars("idea_rt", rootProject = rootProject)
isTransitive = false
}
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
add("testRuntimeOnly", commonDep("junit:junit"))
}
}
private fun DependencyHandler.testApi(dependencyNotation: Any) {
add("testApi", dependencyNotation)
}
val Project.protobufVersion: String get() = findProperty("versions.protobuf") as String
val Project.protobufRepo: String

View File

@@ -25,6 +25,7 @@ val packagesToRelocate =
"org.fusesource",
"net.jpountz",
"one.util.streamex",
"it.unimi.dsi.fastutil",
"kotlinx.collections.immutable"
)

View File

@@ -41,7 +41,7 @@ open class DexMethodCount : DefaultTask() {
dependsOn(jar)
}
@Internal // plain output properties are not supported, mark as internal to suppress warning from validateTaskProperties
@Internal // plain output properties are not supported, mark as internal to suppress warning from validatePlugins
lateinit var counts: Counts
@get:OutputFile

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -71,62 +71,11 @@ class KotlinBuildPublishingPlugin @Inject constructor(
create<MavenPublication>(PUBLICATION_NAME) {
from(kotlinLibraryComponent)
pom {
packaging = "jar"
name.set(humanReadableName(project))
description.set(project.description ?: humanReadableName(project))
url.set("https://kotlinlang.org/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
url.set("https://github.com/JetBrains/kotlin")
connection.set("scm:git:https://github.com/JetBrains/kotlin.git")
developerConnection.set("scm:git:https://github.com/JetBrains/kotlin.git")
}
developers {
developer {
name.set("Kotlin Team")
organization.set("JetBrains")
organizationUrl.set("https://www.jetbrains.com")
}
}
}
}
}
repositories {
maven {
name = REPOSITORY_NAME
url = file("${project.rootDir}/build/repo").toURI()
configureKotlinPomAttributes(project)
}
}
}
val signingRequired = provider {
project.findProperty("signingRequired")?.toString()?.toBoolean()
?: project.property("isSonatypeRelease") as Boolean
}
configure<SigningExtension> {
setRequired(signingRequired)
sign(extensions.getByType<PublishingExtension>().publications[PUBLICATION_NAME])
useGpgCmd()
}
tasks.withType<Sign>().configureEach {
setOnlyIf { signingRequired.get() }
}
tasks.register("install") {
dependsOn(tasks.named("publishToMavenLocal"))
}
tasks.named<PublishToMavenRepository>("publish${PUBLICATION_NAME}PublicationTo${REPOSITORY_NAME}Repository")
.configureRepository()
configureDefaultPublishing()
}
companion object {
@@ -137,13 +86,84 @@ class KotlinBuildPublishingPlugin @Inject constructor(
const val COMPILE_CONFIGURATION = "publishedCompile"
const val RUNTIME_CONFIGURATION = "publishedRuntime"
@OptIn(ExperimentalStdlibApi::class)
fun humanReadableName(project: Project) =
project.name.split("-").joinToString(separator = " ") { it.capitalize(Locale.ROOT) }
}
}
fun TaskProvider<PublishToMavenRepository>.configureRepository() = configure {
@OptIn(ExperimentalStdlibApi::class)
private fun humanReadableName(name: String) =
name.split("-").joinToString(separator = " ") { it.capitalize(Locale.ROOT) }
fun MavenPublication.configureKotlinPomAttributes(project: Project, explicitDescription: String? = null) {
val publication = this
pom {
packaging = "jar"
name.set(humanReadableName(publication.artifactId))
description.set(explicitDescription ?: project.description ?: humanReadableName(publication.artifactId))
url.set("https://kotlinlang.org/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
url.set("https://github.com/JetBrains/kotlin")
connection.set("scm:git:https://github.com/JetBrains/kotlin.git")
developerConnection.set("scm:git:https://github.com/JetBrains/kotlin.git")
}
developers {
developer {
name.set("Kotlin Team")
organization.set("JetBrains")
organizationUrl.set("https://www.jetbrains.com")
}
}
}
}
fun Project.configureDefaultPublishing() {
configure<PublishingExtension> {
repositories {
maven {
name = KotlinBuildPublishingPlugin.REPOSITORY_NAME
url = file("${project.rootDir}/build/repo").toURI()
}
}
}
configureSigning()
tasks.register("install") {
dependsOn(tasks.named("publishToMavenLocal"))
}
tasks.withType<PublishToMavenRepository>()
.matching { it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository") }
.all { configureRepository() }
}
private fun Project.configureSigning() {
val signingRequired = provider {
project.findProperty("signingRequired")?.toString()?.toBoolean()
?: project.property("isSonatypeRelease") as Boolean
}
configure<SigningExtension> {
setRequired(signingRequired)
sign(extensions.getByType<PublishingExtension>().publications) // all publications
useGpgCmd()
}
tasks.withType<Sign>().configureEach {
setOnlyIf { signingRequired.get() }
}
}
fun TaskProvider<PublishToMavenRepository>.configureRepository() =
configure { configureRepository() }
private fun PublishToMavenRepository.configureRepository() {
dependsOn(project.rootProject.tasks.named("preparePublication"))
doFirst {
val preparePublication = project.rootProject.tasks.named("preparePublication").get()

View File

@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -51,11 +40,7 @@ fun Task.dependsOnKotlinPluginInstall() {
":kotlin-gradle-plugin-model:install",
":kotlin-reflect:install",
":kotlin-annotation-processing-gradle:install",
":kotlin-test:kotlin-test-common:install",
":kotlin-test:kotlin-test-annotations-common:install",
":kotlin-test:kotlin-test-jvm:install",
":kotlin-test:kotlin-test-js:install",
":kotlin-test:kotlin-test-junit:install",
":kotlin-test:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-common:install",
":kotlin-stdlib:install",

View File

@@ -19,6 +19,10 @@ dependencies {
testCompile(project(":kotlin-reflect"))
testCompile(projectTests(":compiler:tests-common"))
testCompile(commonDep("junit:junit"))
testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils"))
testApi(projectTests(":compiler:tests-compiler-utils"))
testApi(projectTests(":compiler:tests-common-new"))
testCompile(projectTests(":jps-plugin"))
testCompile(commonDep("junit:junit"))
@@ -37,6 +41,8 @@ dependencies {
testCompile(intellijPluginDep("java")) { includeJars("jps-builders") }
testCompile(jpsStandalone()) { includeJars("jps-model") }
testCompile(jpsBuildTest())
testCompile("org.junit.platform:junit-platform-launcher:${commonVer("org.junit.platform", "")}")
}
sourceSets {

View File

@@ -20,7 +20,9 @@ import com.intellij.openapi.util.Ref
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.test.KotlinBaseTest
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.sourceFileProvider
import java.io.File
import java.util.regex.Pattern
@@ -34,28 +36,24 @@ private data class OldPackageAndNew(val oldFqName: FqName, val newFqName: FqName
internal fun patchFilesAndAddTest(
testFile: File,
testFiles: List<KotlinBaseTest.TestFile>,
module: TestModule,
services: TestServices,
filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter
): FqName? {
if (testFiles.any { it.name.endsWith(".java") }) {
//TODO support java files
return null
}
val ktFiles = testFiles.filter { it.name.endsWith(".kt") }
if (ktFiles.isEmpty()) return null
): FqName {
val newPackagePrefix = testFile.path.replace("\\\\|-|\\.|/".toRegex(), "_")
val oldPackage = Ref<FqName>()
val isJvmName = Ref<Boolean>(false)
val testFiles = module.files
val isSingle = testFiles.size == 1
val resultFiles = testFiles.map {
val fileName = if (isSingle) it.name else testFile.name.substringBeforeLast(".kt") + "/" + it.name
val content = services.sourceFileProvider.getContentOfSourceFile(it)
TestClassInfo(
fileName,
changePackage(newPackagePrefix, it.content, oldPackage, isJvmName),
changePackage(newPackagePrefix, content, oldPackage, isJvmName),
oldPackage.get(),
isJvmName.get(),
getGeneratedClassName(File(fileName), it.content, newPackagePrefix, oldPackage.get())
getGeneratedClassName(File(fileName), content, newPackagePrefix, oldPackage.get())
)
}
val packages =

View File

@@ -16,12 +16,25 @@ import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.codegen.CodegenTestFiles
import org.jetbrains.kotlin.codegen.GenerationUtils
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.impl.BackendKindExtractorImpl
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider
import org.jetbrains.kotlin.test.services.sourceProviders.CodegenHelpersSourceFilesProvider
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
import org.jetbrains.kotlin.test.util.KtTestUtil
import org.junit.Assert
import java.io.File
@@ -241,6 +254,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}
}
@OptIn(TestInfrastructureInternals::class)
@Throws(IOException::class)
private fun processFiles(
files: Array<File>,
@@ -279,7 +293,8 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
//TODO support JvmPackageName
if (fullFileText.contains("@file:JvmPackageName(")) continue
// TODO: Support jvm assertions
if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue
if (fullFileText.contains("// ASSERTIONS_MODE: jvm")) continue
if (fullFileText.contains("// MODULE: ")) continue
val targets = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fullFileText, "// JVM_TARGET:")
.also { it.remove(JvmTarget.JVM_1_6.description) }
@@ -292,31 +307,90 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
if (fullFileText.contains("// SKIP_JDK6")) continue
if (hasBoxMethod(fullFileText)) {
val testFiles = createTestFiles(file, fullFileText)
val kind = KotlinBaseTest.extractConfigurationKind(testFiles)
val jdkKind = KotlinBaseTest.getTestJdkKind(testFiles)
val testConfiguration = createTestConfiguration(file)
val services = testConfiguration.testServices
val moduleStructure = try {
testConfiguration.moduleStructureExtractor.splitTestDataByModules(
file.path,
testConfiguration.directives,
).also {
services.register(TestModuleStructure::class, it)
}
} catch (e: ExceptionFromModuleStructureTransformer) {
continue
}
val module = moduleStructure.modules.singleOrNull() ?: continue
if (module.files.any { it.isJavaFile || it.isKtsFile }) continue
if (module.files.isEmpty()) continue
services.registerDependencyProvider(DependencyProviderImpl(services, moduleStructure.modules))
val keyConfiguration = CompilerConfiguration()
KotlinBaseTest.updateConfigurationByDirectivesInTestFiles(testFiles, keyConfiguration)
val configuratorForFlags = JvmEnvironmentConfigurator(services)
with(configuratorForFlags) {
val extractor = DirectiveToConfigurationKeyExtractor()
extractor.provideConfigurationKeys()
extractor.configure(keyConfiguration, module.directives)
}
val kind = configuratorForFlags.extractConfigurationKind(module.directives)
val jdkKind = configuratorForFlags.extractJdkKind(module.directives)
keyConfiguration.languageVersionSettings = module.languageVersionSettings
val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString())
val compiler = if (isJvm8Target) {
if (kind.withReflection) JVM8REFLECT else JVM8
} else if (kind.withReflection) REFLECT else COMMON
val compilerConfigurationProvider = services.compilerConfigurationProvider as CompilerConfigurationProviderImpl
val filesHolder = holders.getOrPut(key) {
FilesWriter(compiler, KotlinTestUtils.newConfiguration(kind, jdkKind,
KtTestUtil.getAnnotationsJar()
).apply {
FilesWriter(compiler, compilerConfigurationProvider.createCompilerConfiguration(module)).also {
println("Creating new configuration by $key")
KotlinBaseTest.updateConfigurationByDirectivesInTestFiles(testFiles, this)
})
}
}
patchFilesAndAddTest(file, testFiles, filesHolder)
patchFilesAndAddTest(file, module, services, filesHolder)
}
}
}
}
private fun createTestConfiguration(testDataFile: File): TestConfiguration {
return TestConfigurationBuilder().apply {
testConfiguration()
testInfo = KotlinTestInfo(
"org.jetbrains.kotlin.android.tests.AndroidRunner",
"test${testDataFile.nameWithoutExtension.capitalize()}",
emptySet()
)
}.build(testDataFile.path)
}
private val testConfiguration: TestConfigurationBuilder.() -> Unit = {
globalDefaults {
frontend = FrontendKinds.ClassicFrontend
targetBackend = TargetBackend.ANDROID
targetPlatform = JvmPlatforms.defaultJvmPlatform
dependencyKind = DependencyKind.Binary
}
useConfigurators(
::CommonEnvironmentConfigurator,
::JvmEnvironmentConfigurator
)
useAdditionalSourceProviders(
::AdditionalDiagnosticsSourceFilesProvider,
::CoroutineHelpersSourceFilesProvider,
::CodegenHelpersSourceFilesProvider,
)
assertions = JUnit5Assertions
useAdditionalService<TemporaryDirectoryManager>(::TemporaryDirectoryManagerImpl)
useAdditionalService<BackendKindExtractor>(::BackendKindExtractorImpl)
useSourcePreprocessor(*AbstractKotlinCompilerTest.defaultPreprocessors.toTypedArray())
useDirectives(*AbstractKotlinCompilerTest.defaultDirectiveContainers.toTypedArray())
}
private fun createTestFiles(file: File, expectedText: String): List<KotlinBaseTest.TestFile> =
CodegenTestCase.createTestFilesFromFile(file, expectedText, false, TargetBackend.JVM)

View File

@@ -14,7 +14,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class AsmTypes {
private static final Map<Class<?>, Type> TYPES_MAP = new HashMap<>();

View File

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

View File

@@ -50,7 +50,7 @@ class AccessorForFunctionDescriptor(
if (calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) != null) {
userDataMap = LinkedHashMap<CallableDescriptor.UserDataKey<*>, Any>()
userDataMap[INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION] =
calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
calleeDescriptor.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION)
}
}

View File

@@ -20,11 +20,9 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.kotlin.utils.mapToIndex
class ArgumentAndDeclIndex(val arg: ResolvedValueArgument, val declIndex: Int)
@@ -70,12 +68,8 @@ abstract class ArgumentGenerator {
generateExpression(declIndex, argument)
}
is DefaultValueArgument -> {
if (calleeDescriptor?.defaultValueFromJava(declIndex) == true) {
generateDefaultJava(declIndex, argument)
} else {
defaultArgs.mark(declIndex)
generateDefault(declIndex, argument)
}
defaultArgs.mark(declIndex)
generateDefault(declIndex, argument)
}
is VarargValueArgument -> {
generateVararg(declIndex, argument)
@@ -103,10 +97,6 @@ abstract class ArgumentGenerator {
throw UnsupportedOperationException("Unsupported vararg value argument #$i: $argument")
}
protected open fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
throw UnsupportedOperationException("Unsupported default java argument #$i: $argument")
}
protected open fun generateOther(i: Int, argument: ResolvedValueArgument) {
throw UnsupportedOperationException("Unsupported value argument #$i: $argument")
}
@@ -116,28 +106,6 @@ abstract class ArgumentGenerator {
}
}
private fun CallableDescriptor.defaultValueFromJava(index: Int): Boolean = DFS.ifAny(
listOf(this),
{ current -> current.original.overriddenDescriptors.map { it.original } },
{ descriptor ->
descriptor.original.overriddenDescriptors.isEmpty() &&
descriptor is JavaCallableMemberDescriptor &&
descriptor.valueParameters[index].declaresDefaultValue()
}
)
fun shouldInvokeDefaultArgumentsStub(resolvedCall: ResolvedCall<*>): Boolean {
val descriptor = resolvedCall.resultingDescriptor
val valueArgumentsByIndex = resolvedCall.valueArgumentsByIndex ?: return false
for (index in valueArgumentsByIndex.indices) {
val resolvedValueArgument = valueArgumentsByIndex[index]
if (resolvedValueArgument is DefaultValueArgument && !descriptor.defaultValueFromJava(index)) {
return true
}
}
return false
}
fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): FunctionDescriptor {
if (functionDescriptor.containingDeclaration !is ClassDescriptor) return functionDescriptor
if (functionDescriptor.overriddenDescriptors.isEmpty()) return functionDescriptor
@@ -155,4 +123,4 @@ fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): Fun
function.valueParameters.any { valueParameter -> valueParameter.hasDefaultValue() }
}
?: functionDescriptor
}
}

View File

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

View File

@@ -72,12 +72,6 @@ class CallBasedArgumentGenerator(
callGenerator.putValueIfNeeded(getJvmKotlinType(i), lazyVararg, ValueKind.GENERAL_VARARG, i)
}
override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
val argumentValue = valueParameters[i].findJavaDefaultArgumentValue(valueParameterTypes[i], codegen.typeMapper)
callGenerator.putValueIfNeeded(getJvmKotlinType(i), argumentValue)
}
override fun reorderArgumentsIfNeeded(args: List<ArgumentAndDeclIndex>) {
callGenerator.reorderArgumentsIfNeeded(args, valueParameterTypes)
}

View File

@@ -232,9 +232,7 @@ public class DescriptorAsmUtil {
int flags = getVisibilityAccessFlag(functionDescriptor, kind);
flags |= getVarargsFlag(functionDescriptor);
flags |= getDeprecatedAccessFlag(functionDescriptor);
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
isInlineWithReified(functionDescriptor) ||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(DescriptorVisibilities.PRIVATE)) {
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) || isInlineWithReified(functionDescriptor)) {
flags |= ACC_SYNTHETIC;
}
return flags;
@@ -427,10 +425,6 @@ public class DescriptorAsmUtil {
return null;
}
if (memberDescriptor instanceof FunctionDescriptor && ((FunctionDescriptor) memberDescriptor).isSuspend()) {
return NO_FLAG_PACKAGE_PRIVATE;
}
if (memberDescriptor instanceof AccessorForCompanionObjectInstanceFieldDescriptor) {
return NO_FLAG_PACKAGE_PRIVATE;
}

View File

@@ -74,7 +74,10 @@ import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluatorKt;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
import org.jetbrains.kotlin.resolve.jvm.*;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices;
import org.jetbrains.kotlin.resolve.jvm.JvmConstantsKt;
import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionInfo;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
@@ -85,6 +88,7 @@ import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContextImpl;
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS;
import org.jetbrains.kotlin.types.model.KotlinTypeMarker;
import org.jetbrains.kotlin.types.model.TypeParameterMarker;
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
import org.jetbrains.kotlin.util.OperatorNameConventions;
@@ -2690,7 +2694,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
@NotNull
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall resolvedCall) {
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall<?> resolvedCall) {
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
if (intrinsic != null) {
return intrinsic.toCallable(fd, superCall, resolvedCall, this);
@@ -2698,7 +2702,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
fd = SamCodegenUtil.resolveSamAdapter(fd);
if (ArgumentGeneratorKt.shouldInvokeDefaultArgumentsStub(resolvedCall)) {
List<ResolvedValueArgument> valueArguments = resolvedCall.getValueArgumentsByIndex();
if (valueArguments != null && valueArguments.stream().anyMatch(it -> it instanceof DefaultValueArgument)) {
// When we invoke a function with some arguments mapped as defaults,
// we later reroute this call to an overridden function in a base class that processes the default arguments.
// If the base class is generic, this overridden function can have a different Kotlin signature
@@ -5528,4 +5533,11 @@ The "returned" value of try expression with no finally is either the last expres
parentCodegen.getReifiedTypeParametersUsages().addUsedReifiedParameter(typeParameterDescriptor.getName().asString());
}
}
@Override
public void putReifiedOperationMarkerIfTypeIsReifiedParameter(
@NotNull KotlinTypeMarker type, @NotNull ReifiedTypeInliner.OperationKind operationKind
) {
BaseExpressionCodegen.DefaultImpls.putReifiedOperationMarkerIfTypeIsReifiedParameter(this, type, operationKind);
}
}

View File

@@ -1152,8 +1152,10 @@ public class FunctionCodegen {
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
// $default methods are never protected to be accessible from subclass nested classes
// TODO: maybe best to generate private default in interface as private
int visibilityFlag =
DescriptorVisibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
(!isInterface(functionDescriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS) &&
(DescriptorVisibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor))
? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
if (!(functionDescriptor instanceof ConstructorDescriptor &&
@@ -1685,10 +1687,11 @@ public class FunctionCodegen {
// Fake overrides in interfaces should be expanded to implementation to make proper default check
if (JvmAnnotationUtilKt.checkIsImplementationCompiledToJvmDefault(memberDescriptor, mode)) {
return (kind != OwnerKind.DEFAULT_IMPLS && !isSynthetic) ||
boolean isSyntheticInCompatibilityOrJvmDefault = isSynthetic && (mode.isCompatibility() || mode == JvmDefaultMode.ENABLE);
return (kind != OwnerKind.DEFAULT_IMPLS && !isSyntheticInCompatibilityOrJvmDefault) ||
(kind == OwnerKind.DEFAULT_IMPLS &&
(isSynthetic || //TODO: move synthetic method generation into interface
(mode.isCompatibility() && !JvmAnnotationUtilKt.hasJvmDefaultNoCompatibilityAnnotation(containingDeclaration))));
(isSyntheticInCompatibilityOrJvmDefault ||
(mode.isCompatibility() && !JvmAnnotationUtilKt.hasJvmDefaultNoCompatibilityAnnotation(containingDeclaration))) && !DescriptorVisibilities.isPrivate(memberDescriptor.getVisibility()));
} else {
switch (kind) {
case DEFAULT_IMPLS: return true;

View File

@@ -660,7 +660,8 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
List<VariableDescriptorWithAccessors> delegatedProperties = bindingContext.get(CodegenBinding.DELEGATED_PROPERTIES_WITH_METADATA, thisAsmType);
if (delegatedProperties == null || delegatedProperties.isEmpty()) return;
v.newField(NO_ORIGIN, ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
int additionalFlags = context.getContextKind() != OwnerKind.DEFAULT_IMPLS && isInterface(context.getContextDescriptor()) ? ACC_PUBLIC : 0;
v.newField(NO_ORIGIN, ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC | additionalFlags, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
"[" + K_PROPERTY_TYPE, null, null);
if (!state.getClassBuilderMode().generateBodies) return;

View File

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

View File

@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
internal class ObjectSuperCallArgumentGenerator(
@@ -65,12 +64,6 @@ internal class ObjectSuperCallArgumentGenerator(
pushDefaultValueOnStack(type, iv)
}
public override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
val type = parameters[i].asmType
val value = superValueParameters[i].findJavaDefaultArgumentValue(type, typeMapper)
value.put(type, iv)
}
public override fun generateVararg(i: Int, argument: VarargValueArgument) {
generateSuperCallArgument(i)
}

View File

@@ -58,7 +58,7 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
}
override fun asBytes(builder: ClassBuilder): ByteArray {
val classWriter = ClassWriter(0)
val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS)
(builder as OriginCollectingClassBuilder).classNode.accept(classWriter)
return classWriter.toByteArray()
}
@@ -66,4 +66,4 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
override fun asText(builder: ClassBuilder) = throw UnsupportedOperationException()
override fun close() {}
}
}

View File

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

View File

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

View File

@@ -629,7 +629,11 @@ public abstract class StackValue {
}
public static void coerce(@NotNull Type fromType, @NotNull Type toType, @NotNull InstructionAdapter v) {
if (toType.equals(fromType)) return;
coerce(fromType, toType, v, false);
}
public static void coerce(@NotNull Type fromType, @NotNull Type toType, @NotNull InstructionAdapter v, boolean forceSelfCast) {
if (toType.equals(fromType) && !forceSelfCast) return;
if (toType.getSort() == Type.VOID) {
pop(v, fromType);

View File

@@ -5,18 +5,7 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.AsmUtil.unboxPrimitiveTypeOrNull
import org.jetbrains.kotlin.codegen.StackValue.*
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.Constant
import org.jetbrains.kotlin.load.java.EnumEntry
import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue
import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue
import org.jetbrains.kotlin.load.java.descriptors.getDefaultValueFromAnnotation
import org.jetbrains.kotlin.load.java.lexicalCastFrom
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
@@ -86,40 +75,3 @@ class FunctionCallStackValue(
resultKotlinType: KotlinType?,
lambda: (v: InstructionAdapter) -> Unit
) : OperationStackValue(resultType, resultKotlinType, lambda)
fun ValueParameterDescriptor.findJavaDefaultArgumentValue(targetType: Type, typeMapper: KotlinTypeMapper): StackValue {
val descriptorWithDefaultValue = DFS.dfs(
listOf(this.original),
{ it.original.overriddenDescriptors.map(ValueParameterDescriptor::getOriginal) },
object : DFS.AbstractNodeHandler<ValueParameterDescriptor, ValueParameterDescriptor?>() {
var result: ValueParameterDescriptor? = null
override fun beforeChildren(current: ValueParameterDescriptor?): Boolean {
if (current?.declaresDefaultValue() == true && current.getDefaultValueFromAnnotation() != null) {
result = current
return false
}
return true
}
override fun result(): ValueParameterDescriptor? = result
}
) ?: error("Should be at least one descriptor with default value: $this")
val defaultValue = descriptorWithDefaultValue.getDefaultValueFromAnnotation()
if (defaultValue is NullDefaultValue) {
return constant(null, targetType)
}
val value = (defaultValue as StringDefaultValue).value
val castResult = type.lexicalCastFrom(value) ?: error("Should be checked in frontend")
return when (castResult) {
is EnumEntry -> enumEntry(castResult.descriptor, typeMapper)
is Constant -> {
val unboxedType = unboxPrimitiveTypeOrNull(targetType) ?: targetType
return coercion(constant(castResult.value, unboxedType), targetType, null)
}
}
}

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.when.SwitchCodegenProvider;
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
import org.jetbrains.kotlin.config.JvmDefaultMode;
import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.coroutines.CoroutineUtilKt;
@@ -87,6 +88,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
private final LanguageVersionSettings languageVersionSettings;
private final ClassBuilderMode classBuilderMode;
private final DelegatedPropertiesCodegenHelper delegatedPropertiesCodegenHelper;
private final JvmDefaultMode jvmDefaultMode;
public CodegenAnnotatingVisitor(@NotNull GenerationState state) {
this.bindingTrace = state.getBindingTrace();
@@ -97,6 +99,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
this.languageVersionSettings = state.getLanguageVersionSettings();
this.classBuilderMode = state.getClassBuilderMode();
this.delegatedPropertiesCodegenHelper = new DelegatedPropertiesCodegenHelper(state);
jvmDefaultMode = state.getJvmDefaultMode();
}
@NotNull
@@ -585,7 +588,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
}
return AsmUtil.asmTypeByClassId(
DescriptorUtils.isInterface(descriptor)
DescriptorUtils.isInterface(descriptor) && !jvmDefaultMode.getForAllMethodsWithBody()
? classId.createNestedClassId(Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME))
: classId
);

View File

@@ -721,9 +721,16 @@ class CoroutineCodegenForNamedFunction private constructor(
}
val isInterfaceMethod = DescriptorUtils.isInterface(suspendFunctionJvmView.containingDeclaration)
val callableAccessorMethod =
typeMapper.mapToCallableMethod(
context.accessibleDescriptor(suspendFunctionJvmView.unwrapFrontendVersion(), null),
// Obtain default impls method for interfaces
isInterfaceMethod
)
val callableMethod =
typeMapper.mapToCallableMethod(
suspendFunctionJvmView,
suspendFunctionJvmView.unwrapFrontendVersion(),
// Obtain default impls method for interfaces
isInterfaceMethod
)
@@ -736,10 +743,10 @@ class CoroutineCodegenForNamedFunction private constructor(
if (suspendFunctionJvmView.isOverridable && !isInterfaceMethod && captureThisType != null) {
val owner = captureThisType.internalName
val impl = callableMethod.getAsmMethod().getImplForOpenMethod(owner)
val impl = callableAccessorMethod.getAsmMethod().getImplForOpenMethod(owner)
codegen.v.invokestatic(owner, impl.name, impl.descriptor, false)
} else {
callableMethod.genInvokeInstruction(codegen.v)
callableAccessorMethod.genInvokeInstruction(codegen.v)
}
if (inlineClassToBoxInInvokeSuspend != null) {

View File

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

View File

@@ -90,7 +90,10 @@ class AnonymousObjectTransformer(
val node = MethodNode(access, name, desc, signature, exceptions)
if (name == "<init>") {
if (constructor != null) {
throw RuntimeException("Lambda, SAM or anonymous object should have only one constructor")
throw RuntimeException(
"Lambda, SAM or anonymous object should have only one constructor.\n" +
"First:\n${constructor.nodeText}\n\nSecond:\n${node.nodeText}\n"
)
}
constructor = node
} else {
@@ -319,7 +322,7 @@ class AnonymousObjectTransformer(
), null
)
val result = inliner.doInline(deferringVisitor, LocalVarRemapper(parameters, 0), false, ReturnLabelOwner.NOT_APPLICABLE)
val result = inliner.doInline(deferringVisitor, LocalVarRemapper(parameters, 0), false, mapOf())
result.reifiedTypeParametersUsages.mergeAll(typeParametersToReify)
deferringVisitor.visitMaxs(-1, -1)
return result
@@ -462,6 +465,29 @@ class AnonymousObjectTransformer(
val indexToFunctionalArgument = transformationInfo.functionalArguments
val capturedParams = HashSet<Int>()
// Possible cases where we need to add each lambda's captures separately:
//
// 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we
// have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty
// (already have the fields) or contains the parent lambda object (captures used to be read from it, but
// the object will be removed and its contents inlined).
//
// 2. Top-level object in a named inline function. Again, there's no option but to add separate fields.
// `capturedLambdas` contains all lambdas used by this object and nested objects.
//
// 3. Nested object, either in an inline lambda or an inline function. This case has two subcases:
// * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda);
// we *could* group them into `this$0` now, but choose not to. Lambdas are replaced by their captures to match.
// * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in
// inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is
// empty anyway.
//
// The only remaining case is a top-level object inside a (crossinline) lambda that is inlined into another object.
// Then, the reference to the soon-to-be-removed lambda class containing the captures (and it exists, or else the object
// would not have needed regeneration in the first place) is simply replaced with a reference to the outer object, and
// that object will contain loose fields for everything we need to capture.
val topLevelInCrossinlineLambda = parentFieldRemapper is InlinedLambdaRemapper && !parentFieldRemapper.parent!!.isRoot
//load captured parameters and patch instruction list
// NB: there is also could be object fields
val toDelete = arrayListOf<AbstractInsnNode>()
@@ -470,10 +496,12 @@ class AnonymousObjectTransformer(
val parameterAload = fieldNode.previous as VarInsnNode
val varIndex = parameterAload.`var`
val functionalArgument = indexToFunctionalArgument[varIndex]
val newFieldName = if (isThis0(fieldName) && shouldRenameThis0(parentFieldRemapper, indexToFunctionalArgument.values))
getNewFieldName(fieldName, true)
else
fieldName
// If an outer `this` is already captured by this object, rename it if any inline lambda will capture
// one of the same type, causing the code below to create a clash. Note that the values can be different.
// TODO: this is only really necessary if there will be a name *and* type clash.
val shouldRename = !topLevelInCrossinlineLambda && isThis0(fieldName) &&
indexToFunctionalArgument.values.any { it is LambdaInfo && it.capturedVars.any { it.fieldName == fieldName } }
val newFieldName = if (shouldRename) addUniqueField(fieldName + INLINE_FUN_THIS_0_SUFFIX) else fieldName
val info = capturedParamBuilder.addCapturedParam(
Type.getObjectType(transformationInfo.oldClassName), fieldName, newFieldName,
Type.getType(fieldNode.desc), functionalArgument is LambdaInfo, null
@@ -508,35 +536,17 @@ class AnonymousObjectTransformer(
//For all inlined lambdas add their captured parameters
//TODO: some of such parameters could be skipped - we should perform additional analysis
val allRecapturedParameters = ArrayList<CapturedParamDesc>()
if (parentFieldRemapper !is InlinedLambdaRemapper || parentFieldRemapper.parent!!.isRoot) {
// Possible cases:
//
// 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we
// have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty
// (already have the fields) or contains the parent lambda object (captures used to be read from it, but
// the object will be removed and its contents inlined).
//
// 2. Top-level object in a named inline function. Again, there's no option but to add separate fields.
// `capturedLambdas` contains all lambdas used by this object and nested objects.
//
// 3. Nested object, either in an inline lambda or an inline function. This case has two subcases:
// * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda);
// we could group them into `this$0` now, but choose not to. Lambdas are replaced by their captures.
// * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in
// inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is
// empty and the choice doesn't matter.
//
val alreadyAdded = HashMap<String, CapturedParamInfo>()
if (!topLevelInCrossinlineLambda) {
val capturedOuterThisTypes = mutableSetOf<String>()
for (info in capturedLambdas) {
for (desc in info.capturedVars) {
val key = desc.fieldName + "$$$" + desc.type.className
val alreadyAddedParam = alreadyAdded[key]
val recapturedParamInfo = capturedParamBuilder.addCapturedParam(
desc,
alreadyAddedParam?.newFieldName ?: getNewFieldName(desc.fieldName, false),
alreadyAddedParam != null
)
// Merge all outer `this` of the same type captured by inlined lambdas, since they have to be the same
// object. Outer `this` captured by the original object itself should have been renamed above,
// and can have a different value even if the same type is captured by a lambda.
val recapturedParamInfo = if (isThis0(desc.fieldName))
capturedParamBuilder.addCapturedParam(desc, desc.fieldName, !capturedOuterThisTypes.add(desc.type.className))
else
capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false)
if (info is ExpressionLambda && info.isCapturedSuspend(desc)) {
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
}
@@ -551,10 +561,6 @@ class AnonymousObjectTransformer(
allRecapturedParameters.add(desc)
constructorParamBuilder.addCapturedParam(recapturedParamInfo, recapturedParamInfo.newFieldName).remapValue = composed
if (isThis0(desc.fieldName)) {
alreadyAdded.put(key, recapturedParamInfo)
}
}
}
} else if (capturedLambdas.isNotEmpty()) {
@@ -579,24 +585,6 @@ class AnonymousObjectTransformer(
return constructorAdditionalFakeParams
}
private fun shouldRenameThis0(parentFieldRemapper: FieldRemapper, values: Collection<FunctionalArgument>): Boolean {
return if (isFirstDeclSiteLambdaFieldRemapper(parentFieldRemapper)) {
values.any { it is LambdaInfo && it.capturedVars.any { isThis0(it.fieldName) } }
} else false
}
private fun getNewFieldName(oldName: String, originalField: Boolean): String {
if (AsmUtil.CAPTURED_THIS_FIELD == oldName) {
return if (!originalField) {
oldName
} else {
//rename original 'this$0' in declaration site lambda (inside inline function) to use this$0 only for outer lambda/object access on call site
addUniqueField(oldName + INLINE_FUN_THIS_0_SUFFIX)
}
}
return addUniqueField(oldName + INLINE_TRANSFORMATION_SUFFIX)
}
private fun addUniqueField(name: String): String {
val existNames = fieldNames.getOrPut(name) { LinkedList() }
val suffix = if (existNames.isEmpty()) "" else "$" + existNames.size
@@ -604,7 +592,4 @@ class AnonymousObjectTransformer(
existNames.add(newName)
return newName
}
private fun isFirstDeclSiteLambdaFieldRemapper(parentRemapper: FieldRemapper): Boolean =
parentRemapper !is RegeneratedLambdaFieldRemapper && parentRemapper !is InlinedLambdaRemapper
}

View File

@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.Position
import org.jetbrains.kotlin.incremental.components.ScopeKind
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
@@ -42,8 +41,6 @@ import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.*
import java.util.*
import kotlin.collections.HashSet
import kotlin.math.max
abstract class InlineCodegen<out T : BaseExpressionCodegen>(
@@ -111,11 +108,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
)
}
protected fun generateStub(resolvedCall: ResolvedCall<*>?, codegen: BaseExpressionCodegen) {
protected fun generateStub(text: String, codegen: BaseExpressionCodegen) {
leaveTemps()
assert(resolvedCall != null)
val message = "Call is part of inline cycle: " + resolvedCall!!.call.callElement.text
AsmUtil.genThrow(codegen.v, "java/lang/UnsupportedOperationException", message)
AsmUtil.genThrow(codegen.v, "java/lang/UnsupportedOperationException", "Call is part of inline cycle: $text")
}
protected fun endCall(result: InlineResult, registerLineNumberAfterwards: Boolean) {
@@ -243,12 +238,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
//hack to keep linenumber info, otherwise jdi will skip begin of linenumber chain
adapter.visitInsn(Opcodes.NOP)
val result = inliner.doInline(adapter, remapper, true, ReturnLabelOwner.SKIP_ALL)
val result = inliner.doInline(adapter, remapper, true, mapOf())
result.reifiedTypeParametersUsages.mergeAll(reificationResult)
val labels = sourceCompiler.getContextLabels()
val infos = MethodInliner.processReturns(adapter, ReturnLabelOwner { labels.contains(it) }, true, null)
val infos = MethodInliner.processReturns(adapter, sourceCompiler.getContextLabels(), null)
generateAndInsertFinallyBlocks(
adapter, infos, (remapper.remap(parameters.argsSizeOnStack + 1).value as StackValue.Local).index
)
@@ -319,7 +312,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
frameMap.enterTemp(Type.INT_TYPE)
}
sourceCompiler.generateFinallyBlocksIfNeeded(finallyCodegen, extension.returnType, extension.finallyIntervalEnd.label)
sourceCompiler.generateFinallyBlocksIfNeeded(
finallyCodegen, extension.returnType, extension.finallyIntervalEnd.label, extension.jumpTarget
)
//Exception table for external try/catch/finally blocks will be generated in original codegen after exiting this method
insertNodeBefore(finallyNode, intoNode, curInstr)
@@ -639,35 +634,17 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
?: throw IllegalStateException("Couldn't find declaration file for $containerId")
}
val methodNode = getMethodNodeInner(containerId, bytes, asmMethod, callableDescriptor) ?: return null
// KLUDGE: Inline suspend function built with compiler version less than 1.1.4/1.2-M1 did not contain proper
// before/after suspension point marks, so we detect those functions here and insert the corresponding marks
if (isLegacySuspendInlineFunction(callableDescriptor)) {
insertLegacySuspendInlineMarks(methodNode.node)
}
return methodNode
}
private fun getMethodNodeInner(
containerId: ClassId,
bytes: ByteArray,
asmMethod: Method,
callableDescriptor: CallableMemberDescriptor
): SMAPAndMethodNode? {
val classType = AsmUtil.asmTypeByClassId(containerId)
var methodNode = getMethodNode(bytes, asmMethod.name, asmMethod.descriptor, classType)
val methodNode = getMethodNode(bytes, asmMethod.name, asmMethod.descriptor, classType)
if (methodNode == null && requiresFunctionNameManglingForReturnType(callableDescriptor)) {
val nameWithoutManglingSuffix = asmMethod.name.stripManglingSuffixOrNull()
if (nameWithoutManglingSuffix != null) {
methodNode = getMethodNode(bytes, nameWithoutManglingSuffix, asmMethod.descriptor, classType)
}
if (methodNode == null) {
val nameWithImplSuffix = "$nameWithoutManglingSuffix-impl"
methodNode = getMethodNode(bytes, nameWithImplSuffix, asmMethod.descriptor, classType)
val methodWithoutMangling = getMethodNode(bytes, nameWithoutManglingSuffix, asmMethod.descriptor, classType)
if (methodWithoutMangling != null) return methodWithoutMangling
}
return getMethodNode(bytes, "$nameWithoutManglingSuffix-impl", asmMethod.descriptor, classType)
}
return methodNode
}

View File

@@ -30,17 +30,14 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.*
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.*
import org.jetbrains.org.objectweb.asm.commons.Method
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode
import kotlin.properties.Delegates
interface FunctionalArgument
abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgument, ReturnLabelOwner {
abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgument {
abstract val isBoundCallableReference: Boolean
@@ -54,6 +51,9 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
abstract val capturedVars: List<CapturedParamDesc>
open val returnLabels: Map<String, Label?>
get() = mapOf()
lateinit var node: SMAPAndMethodNode
abstract fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>)
@@ -129,8 +129,6 @@ abstract class DefaultLambda(
final override lateinit var capturedVars: List<CapturedParamDesc>
private set
override fun isReturnFromMe(labelName: String): Boolean = false
var originalBoundReceiverType: Type? = null
private set
@@ -247,7 +245,7 @@ class PsiExpressionLambda(
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
private val labels: Set<String>
override val returnLabels: Map<String, Label?>
override val isSuspend: Boolean
@@ -284,7 +282,7 @@ class PsiExpressionLambda(
closure = it!!
}
labels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor)
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
isSuspend = invokeMethodDescriptor.isSuspend
}
@@ -324,10 +322,6 @@ class PsiExpressionLambda(
}
}
override fun isReturnFromMe(labelName: String): Boolean {
return labels.contains(labelName)
}
val isPropertyReference: Boolean
get() = propertyReferenceInfo != null

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen.inline
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.load.kotlin.getContainingKotlinJvmBinaryClass
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import org.jetbrains.org.objectweb.asm.tree.MethodNode
// KLUDGE: Inline suspend function built with compiler version less than 1.1.4/1.2-M1 did not contain proper
// before/after suspension point marks, so we detect those functions here and insert the corresponding marks
fun insertLegacySuspendInlineMarks(node: MethodNode) {
with(node.instructions) {
// look for return instruction before the end and insert "afterSuspendMarker" there
insertBefore(findLastReturn(last) ?: return, produceSuspendMarker(false).instructions)
// insert "beforeSuspendMarker" at the beginning
insertBefore(first, produceSuspendMarker(true).instructions)
}
node.maxStack = node.maxStack.coerceAtLeast(2) // min stack need for suspend marker before return
}
fun findLastReturn(node: AbstractInsnNode?): AbstractInsnNode? {
var cur = node
while (cur != null && cur.opcode != Opcodes.ARETURN) cur = cur.previous
return cur
}
private fun produceSuspendMarker(isStartNotEnd: Boolean): MethodNode =
MethodNode().also { addSuspendMarker(InstructionAdapter(it), isStartNotEnd) }
fun isLegacySuspendInlineFunction(descriptor: CallableMemberDescriptor): Boolean {
if (descriptor !is FunctionDescriptor) return false
if (!descriptor.isSuspend || !descriptor.isInline) return false
val jvmBytecodeVersion = descriptor.getContainingKotlinJvmBinaryClass()?.classHeader?.bytecodeVersion ?: return false
return !jvmBytecodeVersion.isAtLeast(1, 0, 2)
}

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
import org.jetbrains.kotlin.codegen.optimization.fixStack.peek
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.nullCheck.isCheckParameterIsNotNull
import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
@@ -72,9 +73,9 @@ class MethodInliner(
adapter: MethodVisitor,
remapper: LocalVarRemapper,
remapReturn: Boolean,
returnLabelOwner: ReturnLabelOwner
returnLabels: Map<String, Label?>
): InlineResult {
return doInline(adapter, remapper, remapReturn, returnLabelOwner, 0)
return doInline(adapter, remapper, remapReturn, returnLabels, 0)
}
private fun recordTransformation(info: TransformationInfo) {
@@ -91,11 +92,11 @@ class MethodInliner(
adapter: MethodVisitor,
remapper: LocalVarRemapper,
remapReturn: Boolean,
returnLabelOwner: ReturnLabelOwner,
returnLabels: Map<String, Label?>,
finallyDeepShift: Int
): InlineResult {
//analyze body
var transformedNode = markPlacesForInlineAndRemoveInlinable(node, returnLabelOwner, finallyDeepShift)
var transformedNode = markPlacesForInlineAndRemoveInlinable(node, returnLabels, finallyDeepShift)
if (inliningContext.isInliningLambda && isDefaultLambdaWithReification(inliningContext.lambdaInfo!!)) {
//TODO maybe move reification in one place
inliningContext.root.inlineMethodReifier.reifyInstructions(transformedNode)
@@ -139,7 +140,9 @@ class MethodInliner(
)
}
processReturns(resultNode, returnLabelOwner, remapReturn, end)
if (remapReturn) {
processReturns(resultNode, returnLabels, end)
}
//flush transformed node to output
resultNode.accept(SkipMaxAndEndVisitor(adapter))
return result
@@ -297,7 +300,7 @@ class MethodInliner(
val varRemapper = LocalVarRemapper(lambdaParameters, valueParamShift)
//TODO add skipped this and receiver
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info, invokeCall.finallyDepthShift)
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info.returnLabels, invokeCall.finallyDepthShift)
result.mergeWithNotChangeInfo(lambdaResult)
result.reifiedTypeParametersUsages.mergeAll(lambdaResult.reifiedTypeParametersUsages)
@@ -486,11 +489,11 @@ class MethodInliner(
}
private fun markPlacesForInlineAndRemoveInlinable(
node: MethodNode, returnLabelOwner: ReturnLabelOwner, finallyDeepShift: Int
node: MethodNode, returnLabels: Map<String, Label?>, finallyDeepShift: Int
): MethodNode {
val processingNode = prepareNode(node, finallyDeepShift)
preprocessNodeBeforeInline(processingNode, returnLabelOwner)
preprocessNodeBeforeInline(processingNode, returnLabels)
replaceContinuationAccessesWithFakeContinuationsIfNeeded(processingNode)
@@ -765,7 +768,7 @@ class MethodInliner(
}
}
private fun preprocessNodeBeforeInline(node: MethodNode, returnLabelOwner: ReturnLabelOwner) {
private fun preprocessNodeBeforeInline(node: MethodNode, returnLabels: Map<String, Label?>) {
try {
FixStackWithLabelNormalizationMethodTransformer().transform("fake", node)
} catch (e: Throwable) {
@@ -787,16 +790,13 @@ class MethodInliner(
if (!isReturnOpcode(insnNode.opcode)) continue
var insertBeforeInsn = insnNode
// TODO extract isLocalReturn / isNonLocalReturn, see processReturns
val labelName = getMarkedReturnLabelOrNull(insnNode)
if (labelName != null) {
if (!returnLabelOwner.isReturnFromMe(labelName)) continue
insertBeforeInsn = insnNode.previous
if (labelName == null) {
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insnNode, frame)
} else if (labelName in returnLabels) {
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insnNode.previous, frame)
}
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insertBeforeInsn, frame)
}
localReturnsNormalizer.transform(node)
@@ -1001,7 +1001,8 @@ class MethodInliner(
class PointForExternalFinallyBlocks(
@JvmField val beforeIns: AbstractInsnNode,
@JvmField val returnType: Type,
@JvmField val finallyIntervalEnd: LabelNode
@JvmField val finallyIntervalEnd: LabelNode,
@JvmField val jumpTarget: Label?
)
companion object {
@@ -1115,55 +1116,44 @@ class MethodInliner(
//process local and global returns (local substituted with goto end-label global kept unchanged)
@JvmStatic
fun processReturns(
node: MethodNode, returnLabelOwner: ReturnLabelOwner, remapReturn: Boolean, endLabel: Label?
node: MethodNode, returnLabels: Map<String, Label?>, endLabel: Label?
): List<PointForExternalFinallyBlocks> {
if (!remapReturn) {
return emptyList()
}
val result = ArrayList<PointForExternalFinallyBlocks>()
val instructions = node.instructions
var insnNode: AbstractInsnNode? = instructions.first
while (insnNode != null) {
if (isReturnOpcode(insnNode.opcode)) {
var isLocalReturn = true
val labelName = getMarkedReturnLabelOrNull(insnNode)
val returnType = getReturnType(insnNode.opcode)
if (labelName != null) {
isLocalReturn = returnLabelOwner.isReturnFromMe(labelName)
//remove global return flag
if (isLocalReturn) {
instructions.remove(insnNode.previous)
}
val isLocalReturn = labelName == null || labelName in returnLabels
val jumpTarget = returnLabels[labelName] ?: endLabel
if (isLocalReturn && labelName != null) {
// remove non-local return flag
instructions.remove(insnNode.previous)
}
if (isLocalReturn && endLabel != null) {
val nop = InsnNode(Opcodes.NOP)
instructions.insert(insnNode, nop)
val labelNode = endLabel.info as LabelNode
val jumpInsnNode = JumpInsnNode(Opcodes.GOTO, labelNode)
instructions.insert(nop, jumpInsnNode)
if (isLocalReturn && jumpTarget != null) {
val jumpInsnNode = JumpInsnNode(Opcodes.GOTO, jumpTarget.info as LabelNode)
instructions.insertBefore(insnNode, InsnNode(Opcodes.NOP))
if (jumpTarget != endLabel) {
instructions.insertBefore(insnNode, PseudoInsn.FIX_STACK_BEFORE_JUMP.createInsnNode())
}
instructions.insertBefore(insnNode, jumpInsnNode)
instructions.remove(insnNode)
insnNode = jumpInsnNode
}
//generate finally block before nonLocalReturn flag/return/goto
val label = LabelNode()
instructions.insert(insnNode, label)
result.add(
PointForExternalFinallyBlocks(
getInstructionToInsertFinallyBefore(insnNode, isLocalReturn), getReturnType(insnNode.opcode), label
)
)
// generate finally blocks before the non-local return flag or the stack fixup pseudo instruction
val finallyInsertionPoint = if (isLocalReturn && jumpTarget == endLabel) insnNode else insnNode.previous
result.add(PointForExternalFinallyBlocks(finallyInsertionPoint, returnType, label, jumpTarget))
}
insnNode = insnNode.next
}
return result
}
private fun getInstructionToInsertFinallyBefore(nonLocalReturnOrJump: AbstractInsnNode, isLocal: Boolean): AbstractInsnNode {
return if (isLocal) nonLocalReturnOrJump else nonLocalReturnOrJump.previous
}
}
}

View File

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

View File

@@ -1,29 +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.codegen.inline;
import org.jetbrains.annotations.NotNull;
public interface ReturnLabelOwner {
boolean isReturnFromMe(@NotNull String labelName);
ReturnLabelOwner SKIP_ALL = name -> false;
ReturnLabelOwner NOT_APPLICABLE = name -> {
throw new RuntimeException("This operation not applicable for current context");
};
}

View File

@@ -64,7 +64,7 @@ interface SourceCompilerForInline {
curFinallyDepth: Int
): BaseExpressionCodegen
fun generateFinallyBlocksIfNeeded(finallyCodegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label)
fun generateFinallyBlocksIfNeeded(codegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label, target: Label?)
fun isCallInsideSameModuleAsDeclared(functionDescriptor: FunctionDescriptor): Boolean
@@ -74,7 +74,7 @@ interface SourceCompilerForInline {
val compilationContextFunctionDescriptor: FunctionDescriptor
fun getContextLabels(): Set<String>
fun getContextLabels(): Map<String, Label?>
fun reportSuspensionPointInsideMonitor(stackTraceElement: String)
}
@@ -311,9 +311,10 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
override fun hasFinallyBlocks() = codegen.hasFinallyBlocks()
override fun generateFinallyBlocksIfNeeded(finallyCodegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label) {
require(finallyCodegen is ExpressionCodegen)
finallyCodegen.generateFinallyBlocksIfNeeded(returnType, null, afterReturnLabel)
override fun generateFinallyBlocksIfNeeded(codegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label, target: Label?) {
// TODO use the target label for non-local break/continue
require(codegen is ExpressionCodegen)
codegen.generateFinallyBlocksIfNeeded(returnType, null, afterReturnLabel)
}
override fun createCodegenForExternalFinallyBlockGenerationOnNonLocalReturn(finallyNode: MethodNode, curFinallyDepth: Int) =
@@ -337,14 +338,15 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
override val compilationContextFunctionDescriptor
get() = codegen.getContext().functionDescriptor
override fun getContextLabels(): Set<String> {
override fun getContextLabels(): Map<String, Label?> {
val context = codegen.getContext()
val parentContext = context.parentContext
val descriptor = if (parentContext is ClosureContext && parentContext.originalSuspendLambdaDescriptor != null) {
parentContext.originalSuspendLambdaDescriptor!!
} else context.contextDescriptor
return InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
val labels = InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
return labels.associateWith { null } // TODO add break/continue labels
}
fun initializeInlineFunctionContext(functionDescriptor: FunctionDescriptor) {

View File

@@ -84,9 +84,11 @@ private fun createSpecialEnumMethodBody(
Opcodes.INVOKESTATIC, ENUM_TYPE.internalName, "valueOf",
Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, JAVA_STRING_TYPE), false
)
node.visitTypeInsn(Opcodes.CHECKCAST, ENUM_TYPE.internalName)
} else {
node.visitInsn(Opcodes.ICONST_0)
node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.internalName)
node.visitTypeInsn(Opcodes.CHECKCAST, AsmUtil.getArrayType(ENUM_TYPE).internalName)
}
node.visitInsn(Opcodes.ARETURN)
node.visitMaxs(if (isValueOf) 3 else 2, if (isValueOf) 1 else 0)

View File

@@ -37,17 +37,9 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
// Tracks proper usages of objects corresponding to captured variables.
//
// The 'kotlin.jvm.internal.Ref.*' instance can be replaced with a local variable,
// if all of the following conditions are satisfied:
// * It is created inside a current method.
// * The only permitted operations on it are:
// - store to a local variable
// - ALOAD, ASTORE
// - DUP, POP
// - GETFIELD <owner>.element, PUTFIELD <owner>.element
// * There's a corresponding local variable definition,
// and all ALOAD/ASTORE instructions operate on that particular local variable.
// * Its 'element' field is initialized at start of local variable visibility range.
// The 'kotlin.jvm.internal.Ref.*' instance can be replaced with a local variable, if
// * it is created inside a current method;
// * the only operations on it are ALOAD, ASTORE, DUP, POP, GETFIELD element, PUTFIELD element.
//
// Note that for code that doesn't create Ref objects explicitly these conditions are true,
// unless the Ref object escapes to a local class constructor (including local classes for lambdas).
@@ -58,47 +50,43 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
var initCallInsn: MethodInsnNode? = null
var localVar: LocalVariableNode? = null
var localVarIndex = -1
val astoreInsns: MutableCollection<VarInsnNode> = LinkedHashSet()
val aloadInsns: MutableCollection<VarInsnNode> = LinkedHashSet()
val stackInsns: MutableCollection<AbstractInsnNode> = LinkedHashSet()
val wrapperInsns: MutableCollection<AbstractInsnNode> = LinkedHashSet()
val getFieldInsns: MutableCollection<FieldInsnNode> = LinkedHashSet()
val putFieldInsns: MutableCollection<FieldInsnNode> = LinkedHashSet()
var cleanVarInstruction: VarInsnNode? = null
fun canRewrite(): Boolean =
!hazard &&
initCallInsn != null &&
localVar != null &&
localVarIndex >= 0
override fun onUseAsTainted() {
hazard = true
}
fun canRewrite() = !hazard && initCallInsn != null
}
private class Transformer(private val internalClassName: String, private val methodNode: MethodNode) {
private val refValues = ArrayList<CapturedVarDescriptor>()
private val refValuesByNewInsn = LinkedHashMap<TypeInsnNode, CapturedVarDescriptor>()
private val insns = methodNode.instructions.toArray()
private lateinit var frames: Array<out Frame<BasicValue>?>
val hasRewritableRefValues: Boolean
get() = refValues.isNotEmpty()
fun run() {
createRefValues()
if (!hasRewritableRefValues) return
if (refValues.isEmpty()) return
analyze()
if (!hasRewritableRefValues) return
val frames = analyze(internalClassName, methodNode, Interpreter())
trackPops(frames)
assignLocalVars(frames)
rewrite()
for (refValue in refValues) {
if (refValue.canRewrite()) {
rewriteRefValue(refValue)
}
}
methodNode.removeEmptyCatchBlocks()
methodNode.removeUnusedLocalVariables()
}
private fun AbstractInsnNode.getIndex() = methodNode.instructions.indexOf(this)
private fun createRefValues() {
for (insn in insns) {
for (insn in methodNode.instructions.asSequence()) {
if (insn.opcode == Opcodes.NEW && insn is TypeInsnNode) {
val type = Type.getObjectType(insn.desc)
if (AsmTypes.isSharedVarType(type)) {
@@ -113,19 +101,15 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
private inner class Interpreter : ReferenceTrackingInterpreter() {
override fun newOperation(insn: AbstractInsnNode): BasicValue =
refValuesByNewInsn[insn]?.let { descriptor ->
ProperTrackedReferenceValue(descriptor.refType, descriptor)
}
?: super.newOperation(insn)
refValuesByNewInsn[insn]?.let { ProperTrackedReferenceValue(it.refType, it) } ?: super.newOperation(insn)
override fun processRefValueUsage(value: TrackedReferenceValue, insn: AbstractInsnNode, position: Int) {
for (descriptor in value.descriptors) {
if (descriptor !is CapturedVarDescriptor) throw AssertionError("Unexpected descriptor: $descriptor")
when {
insn.opcode == Opcodes.ALOAD ->
descriptor.aloadInsns.add(insn as VarInsnNode)
insn.opcode == Opcodes.ASTORE ->
descriptor.astoreInsns.add(insn as VarInsnNode)
insn.opcode == Opcodes.DUP -> descriptor.wrapperInsns.add(insn)
insn.opcode == Opcodes.ALOAD -> descriptor.wrapperInsns.add(insn)
insn.opcode == Opcodes.ASTORE -> descriptor.wrapperInsns.add(insn)
insn.opcode == Opcodes.GETFIELD && insn is FieldInsnNode && insn.name == REF_ELEMENT_FIELD && position == 0 ->
descriptor.getFieldInsns.add(insn)
insn.opcode == Opcodes.PUTFIELD && insn is FieldInsnNode && insn.name == REF_ELEMENT_FIELD && position == 0 ->
@@ -135,32 +119,18 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
descriptor.hazard = true
else
descriptor.initCallInsn = insn
insn.opcode == Opcodes.DUP ->
descriptor.stackInsns.add(insn)
else ->
descriptor.hazard = true
else -> descriptor.hazard = true
}
}
}
}
private fun analyze() {
frames = MethodTransformer.analyze(internalClassName, methodNode, Interpreter())
trackPops()
assignLocalVars()
refValues.removeAll { !it.canRewrite() }
}
private fun trackPops() {
for (i in insns.indices) {
private fun trackPops(frames: Array<out Frame<BasicValue>?>) {
for ((i, insn) in methodNode.instructions.asSequence().withIndex()) {
val frame = frames[i] ?: continue
val insn = insns[i]
when (insn.opcode) {
Opcodes.POP -> {
frame.top()?.getCapturedVarOrNull()?.run { stackInsns.add(insn) }
frame.top()?.getCapturedVarOrNull()?.run { wrapperInsns.add(insn) }
}
Opcodes.POP2 -> {
val top = frame.top()
@@ -176,7 +146,7 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
private fun BasicValue.getCapturedVarOrNull() =
safeAs<ProperTrackedReferenceValue>()?.descriptor?.safeAs<CapturedVarDescriptor>()
private fun assignLocalVars() {
private fun assignLocalVars(frames: Array<out Frame<BasicValue>?>) {
for (localVar in methodNode.localVariables) {
val type = Type.getType(localVar.desc)
if (!AsmTypes.isSharedVarType(type)) continue
@@ -197,51 +167,20 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
for (refValue in refValues) {
if (refValue.hazard) continue
val localVar = refValue.localVar ?: continue
val oldVarIndex = localVar.index
if (refValue.valueType.size != 1) {
if (refValue.localVar == null || refValue.valueType.size != 1) {
refValue.localVarIndex = methodNode.maxLocals
methodNode.maxLocals += 2
localVar.index = refValue.localVarIndex
methodNode.maxLocals += refValue.valueType.size
} else {
refValue.localVarIndex = localVar.index
refValue.localVarIndex = refValue.localVar!!.index
}
val cleanInstructions = findCleanInstructions(refValue, oldVarIndex, methodNode.instructions)
if (cleanInstructions.size > 1) {
refValue.hazard = true
continue
}
refValue.cleanVarInstruction = cleanInstructions.firstOrNull()
}
}
private fun findCleanInstructions(refValue: CapturedVarDescriptor, oldVarIndex: Int, instructions: InsnList): List<VarInsnNode> {
return InsnSequence(instructions).filterIsInstance<VarInsnNode>().filter {
it.opcode == Opcodes.ASTORE && it.`var` == oldVarIndex
}.filter {
it.previous?.opcode == Opcodes.ACONST_NULL
}.filter {
val operationIndex = instructions.indexOf(it)
val localVariableNode = refValue.localVar!!
instructions.indexOf(localVariableNode.start) < operationIndex && operationIndex < instructions.indexOf(
localVariableNode.end
)
}.toList()
}
private fun rewrite() {
for (refValue in refValues) {
if (!refValue.canRewrite()) continue
rewriteRefValue(refValue)
private fun LocalVariableNode.findCleanInstructions() =
InsnSequence(methodNode.instructions).dropWhile { it != start }.takeWhile { it != end }.filter {
it is VarInsnNode && it.opcode == Opcodes.ASTORE && it.`var` == index && it.previous?.opcode == Opcodes.ACONST_NULL
}
methodNode.removeEmptyCatchBlocks()
methodNode.removeUnusedLocalVariables()
}
// Be careful to not remove instructions that are the only instruction for a line number. That will
// break debugging. If the previous instruction is a line number and the following instruction is
// a label followed by a line number, insert a nop instead of deleting the instruction.
@@ -255,34 +194,38 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
private fun rewriteRefValue(capturedVar: CapturedVarDescriptor) {
methodNode.instructions.run {
val localVar = capturedVar.localVar!!
localVar.signature = null
localVar.desc = capturedVar.valueType.descriptor
val loadOpcode = capturedVar.valueType.getOpcode(Opcodes.ILOAD)
val storeOpcode = capturedVar.valueType.getOpcode(Opcodes.ISTORE)
if (capturedVar.putFieldInsns.none { it.getIndex() < localVar.start.getIndex() }) {
// variable needs to be initialized before its live range can begin
insertBefore(capturedVar.newInsn, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
insertBefore(capturedVar.newInsn, VarInsnNode(storeOpcode, capturedVar.localVarIndex))
val localVar = capturedVar.localVar
if (localVar != null) {
if (capturedVar.putFieldInsns.none { it.getIndex() < localVar.start.getIndex() }) {
// variable needs to be initialized before its live range can begin
insertBefore(capturedVar.newInsn, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
insertBefore(capturedVar.newInsn, VarInsnNode(storeOpcode, capturedVar.localVarIndex))
}
for (insn in localVar.findCleanInstructions()) {
// after visiting block codegen tries to delete all allocated references:
// see ExpressionCodegen.addLeaveTaskToRemoveLocalVariableFromFrameMap
if (storeOpcode == Opcodes.ASTORE) {
set(insn.previous, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
} else {
remove(insn.previous)
remove(insn)
}
}
localVar.index = capturedVar.localVarIndex
localVar.desc = capturedVar.valueType.descriptor
localVar.signature = null
}
remove(capturedVar.newInsn)
remove(capturedVar.initCallInsn!!)
capturedVar.stackInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.aloadInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.astoreInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.wrapperInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.getFieldInsns.forEach { set(it, VarInsnNode(loadOpcode, capturedVar.localVarIndex)) }
capturedVar.putFieldInsns.forEach { set(it, VarInsnNode(storeOpcode, capturedVar.localVarIndex)) }
//after visiting block codegen tries to delete all allocated references:
// see ExpressionCodegen.addLeaveTaskToRemoveLocalVariableFromFrameMap
capturedVar.cleanVarInstruction?.let {
remove(it.previous)
remove(it)
}
}
}

View File

@@ -28,7 +28,8 @@ import org.jetbrains.org.objectweb.asm.tree.TypeInsnNode
class RedundantCheckCastEliminationMethodTransformer : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
val insns = methodNode.instructions.toArray()
if (!insns.any { it.opcode == Opcodes.CHECKCAST }) return
if (!insns.any { it.opcode == Opcodes.CHECKCAST}) return
if (insns.any { ReifiedTypeInliner.isOperationReifiedMarker(it) }) return
val redundantCheckCasts = ArrayList<TypeInsnNode>()
@@ -36,7 +37,6 @@ class RedundantCheckCastEliminationMethodTransformer : MethodTransformer() {
for (i in insns.indices) {
val valueType = frames[i]?.top()?.type ?: continue
val insn = insns[i]
if (ReifiedTypeInliner.isOperationReifiedMarker(insn.previous)) continue
if (insn is TypeInsnNode) {
val insnType = Type.getObjectType(insn.desc)

View File

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

View File

@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.codegen.createFreeFakeLocalPropertyDescriptor
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapperBase
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.JvmDefaultMode
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.*
@@ -32,7 +31,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPrivateApi
import org.jetbrains.kotlin.resolve.descriptorUtil.nonSourceAnnotations
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmDefaultAnnotation
import org.jetbrains.kotlin.resolve.jvm.requiresFunctionNameManglingForParameterTypes
import org.jetbrains.kotlin.resolve.jvm.requiresFunctionNameManglingForReturnType
import org.jetbrains.kotlin.serialization.DescriptorSerializer
@@ -91,7 +89,7 @@ class JvmSerializerExtension @JvmOverloads constructor(
}
//TODO: support local delegated properties in new defaults scheme
val containerAsmType =
if (isInterface(descriptor)) typeMapper.mapDefaultImpls(descriptor) else typeMapper.mapClass(descriptor)
if (isInterface(descriptor) && !jvmDefaultMode.forAllMethodsWithBody) typeMapper.mapDefaultImpls(descriptor) else typeMapper.mapClass(descriptor)
writeLocalProperties(proto, containerAsmType, JvmProtoBuf.classLocalVariable)
writeVersionRequirementForJvmDefaultIfNeeded(descriptor, proto, versionRequirementTable)
@@ -114,13 +112,6 @@ class JvmSerializerExtension @JvmOverloads constructor(
versionRequirementTable: MutableVersionRequirementTable
) {
if (isInterface(classDescriptor)) {
if (jvmDefaultMode == JvmDefaultMode.ENABLE && classDescriptor.unsubstitutedMemberScope.getContributedDescriptors().any {
it is CallableMemberDescriptor && it.hasJvmDefaultAnnotation()
}) {
builder.addVersionRequirement(
writeVersionRequirement(1, 2, 40, ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, versionRequirementTable)
)
}
if (jvmDefaultMode == JvmDefaultMode.ALL_INCOMPATIBLE) {
builder.addVersionRequirement(
writeVersionRequirement(1, 4, 0, ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, versionRequirementTable)
@@ -280,10 +271,6 @@ class JvmSerializerExtension @JvmOverloads constructor(
if (descriptor.isJvmFieldPropertyInInterfaceCompanion() && versionRequirementTable != null) {
proto.setExtension(JvmProtoBuf.flags, JvmFlags.getPropertyFlags(true))
proto.addVersionRequirement(
writeVersionRequirement(1, 2, 70, ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, versionRequirementTable)
)
}
if (getter?.needsInlineParameterNullCheckRequirement() == true || setter?.needsInlineParameterNullCheckRequirement() == true) {

View File

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

View File

@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.LanguageVersion.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
@@ -49,6 +50,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeApproximator
import org.jetbrains.org.objectweb.asm.Type
import java.io.File
import java.util.*
class GenerationState private constructor(
val project: Project,
@@ -204,15 +206,29 @@ class GenerationState private constructor(
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
val runtimeStringConcat =
if (target.majorVersion >= JvmTarget.JVM_9.majorVersion)
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INDY_WITH_CONSTANTS
else JvmStringConcat.INLINE
val samConversionsScheme = run {
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS) ?: JvmSamConversions.DEFAULT
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS)
if (fromConfig != null && target >= fromConfig.minJvmTarget)
fromConfig
else if (
target >= JvmClosureGenerationScheme.INDY.minJvmTarget &&
languageVersionSettings.supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic)
)
JvmClosureGenerationScheme.INDY
else
JvmClosureGenerationScheme.CLASS
}
val lambdasScheme = run {
val fromConfig = configuration.get(JVMConfigurationKeys.LAMBDAS)
?: JvmClosureGenerationScheme.DEFAULT
if (target >= fromConfig.minJvmTarget)
fromConfig
else
JvmSamConversions.DEFAULT
JvmClosureGenerationScheme.DEFAULT
}
val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
@@ -229,7 +245,6 @@ class GenerationState private constructor(
this.moduleName,
languageVersionSettings,
useOldManglingSchemeForFunctionsWithInlineClassesInSignatures,
IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace),
target,
isIrBackend
)
@@ -306,8 +321,7 @@ class GenerationState private constructor(
val metadataVersion =
configuration.get(CommonConfigurationKeys.METADATA_VERSION)
?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE
else JvmMetadataVersion(1, 1, 18)
?: LANGUAGE_TO_METADATA_VERSION.getValue(languageVersionSettings.languageVersion)
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
@@ -378,6 +392,24 @@ class GenerationState private constructor(
private fun shouldOnlyCollectSignatures(origin: JvmDeclarationOrigin) =
classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && origin.originKind in doNotGenerateInLightClassMode
companion object {
private val LANGUAGE_TO_METADATA_VERSION = EnumMap<LanguageVersion, JvmMetadataVersion>(LanguageVersion::class.java).apply {
val oldMetadataVersion = JvmMetadataVersion(1, 1, 18)
this[KOTLIN_1_0] = oldMetadataVersion
this[KOTLIN_1_1] = oldMetadataVersion
this[KOTLIN_1_2] = oldMetadataVersion
this[KOTLIN_1_3] = oldMetadataVersion
this[KOTLIN_1_4] = JvmMetadataVersion(1, 4, 3)
this[KOTLIN_1_5] = JvmMetadataVersion.INSTANCE
this[KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0)
check(size == LanguageVersion.values().size) {
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
"in `GenerationState.LANGUAGE_TO_METADATA_VERSION`"
}
}
}
}
private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API)

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2010-2016 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.codegen.state
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
import org.jetbrains.kotlin.util.slicedMap.Slices
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
interface IncompatibleClassTracker {
fun record(binaryClass: KotlinJvmBinaryClass)
object DoNothing : IncompatibleClassTracker {
override fun record(binaryClass: KotlinJvmBinaryClass) {
}
}
}
class IncompatibleClassTrackerImpl(val trace: BindingTrace) : IncompatibleClassTracker {
private val classes = linkedSetOf<String>()
override fun record(binaryClass: KotlinJvmBinaryClass) {
if (classes.add(binaryClass.location)) {
val errorData = IncompatibleVersionErrorData(
binaryClass.classHeader.bytecodeVersion,
JvmBytecodeBinaryVersion.INSTANCE,
binaryClass.location,
binaryClass.classId
)
trace.record(BYTECODE_VERSION_ERRORS, binaryClass.location, errorData)
}
}
companion object {
@JvmField
val BYTECODE_VERSION_ERRORS: WritableSlice<String, IncompatibleVersionErrorData<JvmBytecodeBinaryVersion>> = Slices.createCollectiveSlice()
}
}

View File

@@ -87,7 +87,6 @@ class KotlinTypeMapper @JvmOverloads constructor(
private val moduleName: String,
val languageVersionSettings: LanguageVersionSettings,
private val useOldInlineClassesManglingScheme: Boolean,
private val incompatibleClassTracker: IncompatibleClassTracker = IncompatibleClassTracker.DoNothing,
val jvmTarget: JvmTarget = JvmTarget.DEFAULT,
private val isIrBackend: Boolean = false,
private val typePreprocessor: ((KotlinType) -> KotlinType?)? = null,
@@ -494,9 +493,8 @@ class KotlinTypeMapper @JvmOverloads constructor(
boxInlineClassBeforeInvoke = true
}
else -> {
val isPrivateFunInvocation =
DescriptorVisibilities.isPrivate(functionDescriptor.visibility) && !functionDescriptor.isSuspend
invokeOpcode = if (superCall || isPrivateFunInvocation) INVOKESPECIAL else INVOKEVIRTUAL
invokeOpcode =
if (superCall || DescriptorVisibilities.isPrivate(functionDescriptor.visibility)) INVOKESPECIAL else INVOKEVIRTUAL
isInterfaceMember = false
}
}
@@ -845,8 +843,6 @@ class KotlinTypeMapper @JvmOverloads constructor(
skipGenericSignature: Boolean,
hasSpecialBridge: Boolean
): JvmMethodGenericSignature {
checkOwnerCompatibility(f)
val sw = if (skipGenericSignature || f is AccessorForCallableDescriptor<*>)
JvmSignatureWriter()
else
@@ -969,15 +965,6 @@ class KotlinTypeMapper @JvmOverloads constructor(
}
}
private fun checkOwnerCompatibility(descriptor: FunctionDescriptor) {
val ownerClass = descriptor.getContainingKotlinJvmBinaryClass() ?: return
val version = ownerClass.classHeader.bytecodeVersion
if (!version.isCompatible()) {
incompatibleClassTracker.record(ownerClass)
}
}
fun mapDefaultMethod(functionDescriptor: FunctionDescriptor, kind: OwnerKind): Method {
val jvmSignature = mapAsmMethod(functionDescriptor, kind)
val ownerType = mapOwner(functionDescriptor)

View File

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

View File

@@ -87,7 +87,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
idea {
this.module.generatedSourceDirs.add(generationRoot)
}
} else {
} else if (!kotlinBuildProperties.disableWerror) {
allprojects {
tasks.withType<KotlinCompile<*>> {
if (path !in tasksWithWarnings) {

View File

@@ -1,18 +1,7 @@
#!/usr/bin/env bash
# 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.
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
export KOTLIN_TOOL=kotlin-annotation-processing-cli.jar

View File

@@ -1,18 +1,7 @@
@echo off
rem Copyright 2010-2015 JetBrains s.r.o.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
setlocal
set _KOTLIN_COMPILER=org.jetbrains.kotlin.kapt.cli.KaptCli

View File

@@ -1,18 +1,7 @@
#!/usr/bin/env bash
# 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.
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
export KOTLIN_RUNNER=1

View File

@@ -1,18 +1,7 @@
#!/usr/bin/env bash
# Copyright 2010-2017 JetBrains s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce

View File

@@ -1,18 +1,7 @@
@echo off
rem Copyright 2010-2015 JetBrains s.r.o.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
setlocal
set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce

View File

@@ -1,18 +1,7 @@
@echo off
rem Copyright 2010-2015 JetBrains s.r.o.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
setlocal
set _KOTLIN_RUNNER=1

View File

@@ -1,13 +1,9 @@
#!/usr/bin/env bash
#
##############################################################################
# Based on scalac from the Scala distribution
# Copyright 2002-2011, LAMP/EPFL
# Copyright 2011-2015, JetBrains
#
# This is free software; see the distribution for copying conditions.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
##############################################################################
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
cygwin=false;
case "`uname`" in
@@ -25,6 +21,17 @@ findKotlinHome() {
(cd -P "$(dirname "$source")/.." && pwd)
}
findJavaVersion() {
# Note that this only loads the first component of the version, so "1.8.0_265" -> "1".
# But it's fine because major version is 9 for JDK 9, and so on.
regex='^.*version "([[:digit:]]+).*$'
while read -r line; do
if [[ "$line" =~ $regex ]]; then
echo ${BASH_REMATCH[1]}
fi
done <<< $("${JAVACMD:=java}" -version 2>&1)
}
KOTLIN_HOME="$(findKotlinHome)"
if $cygwin; then
@@ -60,17 +67,24 @@ fi
declare -a kotlin_app
if [ -n "$KOTLIN_RUNNER" ];
then
java_version="$(findJavaVersion)"
if [[ $java_version -ge 9 ]]; then
# Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
java_args=("${java_args[@]}" "--add-opens" "java.base/java.util=ALL-UNNAMED")
fi
if [ -n "$KOTLIN_RUNNER" ]; then
java_args=("${java_args[@]}" "-Dkotlin.home=${KOTLIN_HOME}")
kotlin_app=("${KOTLIN_HOME}/lib/kotlin-runner.jar" "org.jetbrains.kotlin.runner.Main")
else
[ -n "$KOTLIN_COMPILER" ] || KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
java_args=("${java_args[@]}" "-noverify")
if [[ $java_version < 13 ]]; then
java_args=("${java_args[@]}" "-noverify")
fi
declare additional_classpath=""
if [ -n "$KOTLIN_TOOL" ];
then
if [ -n "$KOTLIN_TOOL" ]; then
additional_classpath=":${KOTLIN_HOME}/lib/${KOTLIN_TOOL}"
fi

View File

@@ -1,18 +1,7 @@
#!/usr/bin/env bash
# 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.
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler

View File

@@ -1,18 +1,7 @@
@echo off
rem Copyright 2010-2015 JetBrains s.r.o.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
setlocal
set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler

View File

@@ -1,18 +1,7 @@
#!/usr/bin/env bash
# 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.
# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
DIR="${BASH_SOURCE[0]%/*}"
: ${DIR:="."}

View File

@@ -1,17 +1,6 @@
@echo off
rem Copyright 2010-2015 JetBrains s.r.o.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
call %~dps0kotlinc.bat %*

View File

@@ -1,13 +1,9 @@
@echo off
rem based on scalac.bat from the Scala distribution
rem ##########################################################################
rem # Copyright 2002-2011, LAMP/EPFL
rem # Copyright 2011-2015, JetBrains
rem #
rem # This is free software; see the distribution for copying conditions.
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
rem # PARTICULAR PURPOSE.
rem ##########################################################################
rem Based on scalac.bat from the Scala distribution
rem Copyright 2002-2011, LAMP/EPFL
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
rem We adopt the following conventions:
rem - System/user environment variables start with a letter
@@ -19,11 +15,10 @@ call :set_home
if "%_KOTLIN_COMPILER%"=="" set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
if not "%JAVA_HOME%"=="" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
rem Prepend JAVA_HOME to local PATH to be able to simply execute "java" later in the script.
set "PATH=%JAVA_HOME%\bin;%PATH%"
)
if "%_JAVACMD%"=="" set _JAVACMD=java
rem We use the value of the JAVA_OPTS environment variable if defined
if "%JAVA_OPTS%"=="" set JAVA_OPTS=-Xmx256M -Xms32M
@@ -45,18 +40,29 @@ shift
goto loop
:loopend
if "%_KOTLIN_RUNNER%"=="1" (
"%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
setlocal EnableDelayedExpansion
call :set_java_version
if !_java_major_version! geq 9 (
rem Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
set JAVA_OPTS=!JAVA_OPTS! "--add-opens" "java.base/java.util=ALL-UNNAMED"
)
if "!_KOTLIN_RUNNER!"=="1" (
java !JAVA_OPTS! "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
) else (
setlocal EnableDelayedExpansion
SET _ADDITIONAL_CLASSPATH=
set _ADDITIONAL_CLASSPATH=
if !_java_major_version! lss 13 (
set JAVA_OPTS=!JAVA_OPTS! "-noverify"
)
if not "%_KOTLIN_TOOL%"=="" (
set _ADDITIONAL_CLASSPATH=;%_KOTLIN_HOME%\lib\%_KOTLIN_TOOL%
)
"%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
java !JAVA_OPTS! -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
)
@@ -73,6 +79,29 @@ rem # subroutines
set _KOTLIN_HOME=%_BIN_DIR%..
goto :eof
rem Parses "java -version" output and stores the major version to _java_major_version.
rem Note that this only loads the first component of the version, so "1.8.0_265" -> "1".
rem But it's fine because major version is 9 for JDK 9, and so on.
rem Needs to be executed in the EnableDelayedExpansion mode.
:set_java_version
set _version=
rem Parse output and take the third token from the string containing " version ".
rem It should be something like "1.8.0_275" or "15.0.1".
for /f "tokens=3" %%i in ('java -version 2^>^&1 ^| findstr /i " version "') do (
rem Split the string by "-" or "." and take the first token.
for /f "delims=-. tokens=1" %%j in ("%%i") do (
rem At this point, _version should be something like "1 or "15. Note the leading quote.
set _version=%%j
)
)
if "!_version!"=="" (
rem If failed to parse the output, set the version to 1.
set _java_major_version=1
) else (
rem Strip the leading quote.
set _java_major_version=!_version:~1!
)
goto :eof
:end
endlocal

View File

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

View File

@@ -351,6 +351,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var inferenceCompatibility: Boolean by FreezableVar(false)
@Argument(
value = "-Xextended-compiler-checks",
description = "Enable additional compiler checks that might provide verbose diagnostic information for certain errors.\n" +
"Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code."
)
var extendedCompilerChecks: Boolean by FreezableVar(false)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
@@ -369,6 +376,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
CompilerMessageSeverity.ERROR,
"Unknown value for parameter -Xexplicit-api: '$explicitApi'. Value should be one of ${ExplicitApiMode.availableValues()}"
)
put(AnalysisFlags.extendedCompilerChecks, extendedCompilerChecks)
}
}

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.common.arguments
@Retention(AnnotationRetention.RUNTIME)
annotation class DeprecatedOption(
val message: String = "This option has no effect and will be removed in a future release.",
val removeAfter: String,
val level: DeprecationLevel
)

View File

@@ -5,8 +5,7 @@
package org.jetbrains.kotlin.cli.common.arguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.ApiVersion
@@ -126,6 +125,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xir-dce", description = "Perform experimental dead code elimination")
var irDce: Boolean by FreezableVar(false)
@Argument(
value = "-Xir-dce-runtime-diagnostic",
valueDescription = "{$DCE_RUNTIME_DIAGNOSTIC_LOG|$DCE_RUNTIME_DIAGNOSTIC_EXCEPTION}",
description = "Enable runtime diagnostics when performing DCE instead of removing declarations"
)
var irDceRuntimeDiagnostic: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xir-dce-driven", description = "Perform a more experimental faster dead code elimination")
var irDceDriven: Boolean by FreezableVar(false)

View File

@@ -25,6 +25,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
description = "List of directories and JAR/ZIP archives to search for user class files")
var classpath: String? by NullableStringFreezableVar(null)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR")
var includeRuntime: Boolean by FreezableVar(false)
@@ -41,10 +42,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
var noJdk: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(value = "-no-stdlib", description = "Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection into the classpath")
var noStdlib: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(value = "-no-reflect", description = "Don't automatically include Kotlin reflection into the classpath")
var noReflect: Boolean by FreezableVar(false)
@@ -71,7 +74,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(
value = "-jvm-target",
valueDescription = "<version>",
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.6"
description = "Target version of the generated JVM bytecode (1.6 (DEPRECATED), 1.8, 9, 10, 11, 12, 13, 14, 15 or 16), default is 1.8"
)
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)
@@ -81,8 +84,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
// Advanced options
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.WARNING)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-Xuse-ir", description = "Use the IR backend")
@Argument(
value = "-Xuse-ir",
description = "Use the IR backend. This option has no effect unless the language version less than 1.5 is used"
)
var useIR: Boolean by FreezableVar(false)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@@ -355,10 +362,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(
value = "-Xstring-concat",
valueDescription = "{indy-with-constants|indy|inline}",
description = """Switch a way in which string concatenation is performed.
-Xstring-concat=indy-with-constants Performs string concatenation via `invokedynamic` 'makeConcatWithConstants'. Works only with `-jvm-target 9` or greater
-Xstring-concat=indy Performs string concatenation via `invokedynamic` 'makeConcat'. Works only with `-jvm-target 9` or greater
-Xstring-concat=inline Performs string concatenation via `StringBuilder`"""
description = """Select code generation scheme for string concatenation.
-Xstring-concat=indy-with-constants Concatenate strings using `invokedynamic` `makeConcatWithConstants`. Requires `-jvm-target 9` or greater.
-Xstring-concat=indy Concatenate strings using `invokedynamic` `makeConcat`. Requires `-jvm-target 9` or greater.
-Xstring-concat=inline Concatenate strings using `StringBuilder`
default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"""
)
var stringConcat: String? by NullableStringFreezableVar(JvmStringConcat.INLINE.description)
@@ -366,10 +375,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
value = "-Xsam-conversions",
valueDescription = "{class|indy}",
description = """Select code generation scheme for SAM conversions.
-Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 8` or greater.
-Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater.
-Xsam-conversions=class Generate SAM conversions as explicit classes"""
)
var samConversions: String? by NullableStringFreezableVar(JvmSamConversions.CLASS.description)
var samConversions: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xlambdas",
valueDescription = "{class|indy}",
description = """Select code generation scheme for lambdas.
-Xlambdas=indy Generate lambdas using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater.
Lambda objects created using `LambdaMetafactory.metafactory` will have different `toString()`.
-Xlambdas=class Generate lambdas as explicit classes"""
)
var lambdas: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xklib",
@@ -438,6 +457,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var enableJvmPreview: Boolean by FreezableVar(false)
@Argument(
value = "-Xsuppress-deprecated-jvm-target-warning",
description = "Suppress deprecation warning about deprecated JVM target versions"
)
var suppressDeprecatedJvmTargetWarning: Boolean by FreezableVar(false)
@Argument(
value = "-Xtype-enhancement-improvements-strict-mode",
description = "Enable strict mode for some improvements in the type enhancement for loaded Java types based on nullability annotations," +
"including freshly supported reading of the type use annotations from class files. " +
"See KT-45671 for more details"
)
var typeEnhancementImprovementsInStrictMode: Boolean by FreezableVar(false)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
@@ -460,6 +493,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
result[JvmAnalysisFlags.enableJvmPreview] = enableJvmPreview
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies || useFir
result[JvmAnalysisFlags.disableUltraLightClasses] = disableUltraLightClasses
result[JvmAnalysisFlags.useIR] = !useOldBackend
return result
}
@@ -468,6 +502,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
if (strictJavaNullabilityAssertions) {
result[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED
}
if (typeEnhancementImprovementsInStrictMode) {
result[LanguageFeature.TypeEnhancementImprovementsInStrictMode] = LanguageFeature.State.ENABLED
}
return result
}

View File

@@ -28,4 +28,7 @@ public interface K2JsArgumentConstants {
String SOURCE_MAP_SOURCE_CONTENT_ALWAYS = "always";
String SOURCE_MAP_SOURCE_CONTENT_NEVER = "never";
String SOURCE_MAP_SOURCE_CONTENT_INLINING = "inlining";
String DCE_RUNTIME_DIAGNOSTIC_LOG = "log";
String DCE_RUNTIME_DIAGNOSTIC_EXCEPTION = "exception";
}

View File

@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR
import org.jetbrains.kotlin.cli.common.ExitCode.OK
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.extensions.ScriptEvaluationExtension
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
@@ -264,6 +265,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
mainArguments = mainCallArguments,
generateFullJs = !arguments.irDce,
generateDceJs = arguments.irDce,
dceRuntimeDiagnostic = DceRuntimeDiagnostic.resolve(
arguments.irDceRuntimeDiagnostic,
messageCollector
),
dceDriven = arguments.irDceDriven,
multiModule = arguments.irPerModule,
relativeRequirePath = true,
@@ -273,6 +278,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
return COMPILATION_ERROR
}
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
outputFile.writeText(jsCode.mainModule)
jsCode.dependencies.forEach { (name, content) ->
@@ -430,6 +436,19 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
}
fun DceRuntimeDiagnostic.Companion.resolve(
value: String?,
messageCollector: MessageCollector
): DceRuntimeDiagnostic? = when (value?.toLowerCase()) {
DCE_RUNTIME_DIAGNOSTIC_LOG -> DceRuntimeDiagnostic.LOG
DCE_RUNTIME_DIAGNOSTIC_EXCEPTION -> DceRuntimeDiagnostic.EXCEPTION
null -> null
else -> {
messageCollector.report(STRONG_WARNING, "Unknown DCE runtime diagnostic '$value'")
null
}
}
fun messageCollectorLogger(collector: MessageCollector) = object : Logger {
override fun warning(message: String) = collector.report(STRONG_WARNING, message)
override fun error(message: String) = collector.report(ERROR, message)

View File

@@ -76,17 +76,23 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
messageCollector.report(severity, message)
}
val dceResult = DeadCodeElimination.run(files, includedDeclarations, logConsumer)
val dceResult = DeadCodeElimination.run(
files,
includedDeclarations,
arguments.printReachabilityInfo,
logConsumer
)
if (dceResult.status == DeadCodeEliminationStatus.FAILED) return ExitCode.COMPILATION_ERROR
val nodes = dceResult.reachableNodes.filterTo(mutableSetOf()) { it.reachable }
val reachabilitySeverity = if (arguments.printReachabilityInfo) CompilerMessageSeverity.INFO else CompilerMessageSeverity.LOGGING
messageCollector.report(reachabilitySeverity, "")
for (node in nodes.extractRoots()) {
printTree(
node, { messageCollector.report(reachabilitySeverity, it) },
printNestedMembers = false, showLocations = true
)
if (arguments.printReachabilityInfo) {
val reachabilitySeverity = CompilerMessageSeverity.INFO
messageCollector.report(reachabilitySeverity, "")
for (node in dceResult.reachableNodes.extractReachableRoots(dceResult.context!!)) {
printTree(
node, { messageCollector.report(reachabilitySeverity, it) },
printNestedMembers = false, showLocations = true
)
}
}
return ExitCode.OK

View File

@@ -0,0 +1,137 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Map;
import java.util.ResourceBundle;
public abstract class DynamicBundle extends AbstractBundle {
private final static Logger LOG = Logger.getInstance(DynamicBundle.class);
protected DynamicBundle(@NotNull String pathToBundle) {
super(pathToBundle);
}
// see BundleUtil
@Override
protected ResourceBundle findBundle(@NotNull String pathToBundle,
@NotNull ClassLoader baseLoader,
@NotNull ResourceBundle.Control control) {
ResourceBundle base = super.findBundle(pathToBundle, baseLoader, control);
LanguageBundleEP langBundle = findLanguageBundle();
if (langBundle == null) return base;
ResourceBundle pluginBundle = super.findBundle(pathToBundle, langBundle.getLoaderForClass(), control);
if (pluginBundle == null) return base;
try {
if (DynamicBundleInternal.SET_PARENT != null) {
DynamicBundleInternal.SET_PARENT.invoke(pluginBundle, base);
}
}
catch (Throwable e) {
LOG.warn(e);
return base;
}
return pluginBundle;
}
/**
* "SET_PARENT" has been temporary moved into the internal class to fix Kotlin compiler.
* It's to be refactored with "ResourceBundleProvider" since 'core-api' module will use java 1.9+
*/
private static class DynamicBundleInternal {
private static final MethodHandle SET_PARENT;
static {
try {
Method method = ResourceBundle.class.getDeclaredMethod("setParent", ResourceBundle.class);
method.setAccessible(true);
SET_PARENT = MethodHandles.lookup().unreflect(method);
}
catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
// todo: one language per application
@Nullable
private static LanguageBundleEP findLanguageBundle() {
try {
Application application = ApplicationManager.getApplication();
if (application == null) return null;
if (application.isUnitTestMode() && !application.getExtensionArea().hasExtensionPoint(LanguageBundleEP.EP_NAME)) {
return null;
}
return LanguageBundleEP.EP_NAME.findExtension(LanguageBundleEP.class);
}
catch (ProcessCanceledException e) {
throw e;
}
catch (Exception e) {
LOG.error(e);
return null;
}
}
public static final DynamicBundle INSTANCE = new DynamicBundle("") {
};
public static class LanguageBundleEP extends AbstractExtensionPointBean {
public static final ExtensionPointName<LanguageBundleEP> EP_NAME = ExtensionPointName.create("com.intellij.languageBundle");
}
private static final Map<String, DynamicBundle> ourBundlesForForms = ContainerUtil.createConcurrentSoftValueMap();
/**
* @deprecated used only dy GUI form builder
*/
@Deprecated
public static ResourceBundle getBundle(@NotNull String baseName) {
Class<?> callerClass = ReflectionUtil.findCallerClass(2);
return getBundle(baseName, callerClass == null ? DynamicBundle.class : callerClass);
}
/**
* @deprecated used only dy GUI form builder
*/
@Deprecated
public static ResourceBundle getBundle(@NotNull String baseName, @NotNull Class<?> formClass) {
DynamicBundle dynamic = ourBundlesForForms.computeIfAbsent(baseName, s -> new DynamicBundle(s) {});
ResourceBundle rb = dynamic.getResourceBundle(formClass.getClassLoader());
if (BundleBase.SHOW_LOCALIZED_MESSAGES) {
return new ResourceBundle() {
@Override
protected Object handleGetObject(@NotNull String key) {
Object get = rb.getObject(key);
assert get instanceof String : "Language bundles should contain only strings";
return BundleBase.appendLocalizationMarker((String)get);
}
@NotNull
@Override
public Enumeration<String> getKeys() {
return rb.getKeys();
}
};
}
return rb;
}
}

View File

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

View File

@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.cli.common.messages
import com.intellij.openapi.util.io.FileUtil.toSystemDependentName
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.*
import com.intellij.psi.util.PsiFormatUtil
@@ -24,7 +23,7 @@ import org.jetbrains.kotlin.analyzer.AbstractAnalyzerWithCompilerReport
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTrackerImpl
import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.languageVersionSettings
@@ -32,16 +31,12 @@ import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.sortedDiagnostics
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.load.java.components.TraceBasedErrorReporter
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.AnalyzingUtils
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
class AnalyzerWithCompilerReport(
private val messageCollector: MessageCollector,
@@ -72,6 +67,9 @@ class AnalyzerWithCompilerReport(
.append(", unresolved supertypes: ").append(unresolved!!.joinToString())
.append("\n")
}
if (!languageVersionSettings.getFlag(AnalysisFlags.extendedCompilerChecks)) {
message.append("Adding -Xextended-compiler-checks argument might provide additional information.\n")
}
messageCollector.report(ERROR, message.toString())
}
}
@@ -242,33 +240,5 @@ class AnalyzerWithCompilerReport(
fun reportSyntaxErrors(file: PsiElement, messageCollector: MessageCollector): SyntaxErrorReport {
return reportSyntaxErrors(file, DefaultDiagnosticReporter(messageCollector))
}
fun reportBytecodeVersionErrors(bindingContext: BindingContext, messageCollector: MessageCollector) {
val severity =
if (System.getProperty("kotlin.jvm.disable.bytecode.version.error") == "true") STRONG_WARNING
else ERROR
val locations = bindingContext.getKeys(IncompatibleClassTrackerImpl.BYTECODE_VERSION_ERRORS)
if (locations.isEmpty()) return
for (location in locations) {
val data = bindingContext.get(IncompatibleClassTrackerImpl.BYTECODE_VERSION_ERRORS, location)
?: error("Value is missing for key in binding context: $location")
reportIncompatibleBinaryVersion(messageCollector, data, severity)
}
}
private fun reportIncompatibleBinaryVersion(
messageCollector: MessageCollector,
data: IncompatibleVersionErrorData<JvmBytecodeBinaryVersion>,
severity: CompilerMessageSeverity
) {
messageCollector.report(
severity,
"Class '" + JvmClassName.byClassId(data.classId) + "' was compiled with an incompatible version of Kotlin. " +
"The binary version of its bytecode is " + data.actualVersion + ", expected version is " + data.expectedVersion,
CompilerMessageLocation.create(toSystemDependentName(data.filePath))
)
}
}
}

View File

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

View File

@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
import org.jetbrains.kotlin.asJava.classes.KtLightClassForScript
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
import org.jetbrains.kotlin.load.java.components.FilesByFacadeFqNameIndexer
@@ -110,7 +111,7 @@ class CliKotlinAsJavaSupport(
}
override fun getLightClass(classOrObject: KtClassOrObject): KtLightClass? =
KtLightClassForSourceDeclaration.create(classOrObject)
KtLightClassForSourceDeclaration.create(classOrObject, traceHolder.languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode))
override fun getLightClassForScript(script: KtScript): KtLightClassForScript? =
KtLightClassForScript.create(script)

View File

@@ -23,11 +23,17 @@ import org.jetbrains.kotlin.asJava.builder.InvalidLightClassDataHolder
import org.jetbrains.kotlin.asJava.builder.LightClassConstructionContext
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolder
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolderImpl
import org.jetbrains.kotlin.asJava.classes.*
import org.jetbrains.kotlin.asJava.classes.KtUltraLightSupport
import org.jetbrains.kotlin.asJava.classes.cleanFromAnonymousTypes
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.asJava.classes.tryGetPredefinedName
import org.jetbrains.kotlin.codegen.ClassBuilderMode
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.load.java.components.JavaDeprecationSettings
import org.jetbrains.kotlin.name.Name
@@ -57,7 +63,8 @@ class CliLightClassGenerationSupport(
private class CliLightClassSupport(
private val project: Project,
override val languageVersionSettings: LanguageVersionSettings
override val languageVersionSettings: LanguageVersionSettings,
private val jvmTarget: JvmTarget
) : KtUltraLightSupport {
// This is the way to untie CliLightClassSupport and CliLightClassGenerationSupport to prevent descriptors leak
@@ -88,7 +95,7 @@ class CliLightClassGenerationSupport(
moduleName,
languageVersionSettings,
useOldInlineClassesManglingScheme = false,
jvmTarget = JvmTarget.JVM_1_8,
jvmTarget = jvmTarget,
typePreprocessor = KotlinType::cleanFromAnonymousTypes,
namePreprocessor = ::tryGetPredefinedName
)
@@ -96,7 +103,7 @@ class CliLightClassGenerationSupport(
}
private val ultraLightSupport: KtUltraLightSupport by lazyPub {
CliLightClassSupport(project, traceHolder.languageVersionSettings)
CliLightClassSupport(project, traceHolder.languageVersionSettings, traceHolder.jvmTarget)
}
override fun getUltraLightClassSupport(element: KtElement): KtUltraLightSupport {
@@ -129,7 +136,9 @@ class CliLightClassGenerationSupport(
}
private fun getContext(): LightClassConstructionContext =
LightClassConstructionContext(traceHolder.bindingContext, traceHolder.module)
LightClassConstructionContext(
traceHolder.bindingContext, traceHolder.module, null /* TODO: traceHolder.languageVersionSettings? */, traceHolder.jvmTarget
)
override fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor? {
return traceHolder.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
@@ -140,4 +149,4 @@ class CliLightClassGenerationSupport(
override fun analyzeAnnotation(element: KtAnnotationEntry) = traceHolder.bindingContext.get(BindingContext.ANNOTATION, element)
override fun analyzeWithContent(element: KtClassOrObject) = traceHolder.bindingContext
}
}

View File

@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.cli.jvm.compiler
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.psi.KtDeclaration
@@ -13,30 +14,32 @@ import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.jvm.JvmCodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
import kotlin.properties.Delegates
class CliTraceHolder : CodeAnalyzerInitializer {
var bindingContext: BindingContext by Delegates.notNull()
class CliTraceHolder : JvmCodeAnalyzerInitializer() {
lateinit var bindingContext: BindingContext
private set
var module: ModuleDescriptor by Delegates.notNull()
lateinit var module: ModuleDescriptor
private set
var languageVersionSettings: LanguageVersionSettings by Delegates.notNull()
lateinit var languageVersionSettings: LanguageVersionSettings
private set
lateinit var jvmTarget: JvmTarget
private set
override fun initialize(
trace: BindingTrace,
module: ModuleDescriptor,
codeAnalyzer: KotlinCodeAnalyzer,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
jvmTarget: JvmTarget
) {
this.bindingContext = trace.bindingContext
this.module = module
this.languageVersionSettings = languageVersionSettings
this.jvmTarget = jvmTarget
if (trace !is CliBindingTrace) {
throw IllegalArgumentException("Shared trace is expected to be subclass of ${CliBindingTrace::class.java.simpleName} class")

View File

@@ -28,11 +28,13 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
import org.jetbrains.kotlin.cli.common.modules.ModuleChunk;
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.jetbrains.kotlin.utils.PathUtil;
import java.io.*;
import java.util.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.jar.*;
import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR;
@@ -60,6 +62,7 @@ public class CompileEnvironmentUtil {
OutputStream fos,
@Nullable FqName mainClass,
boolean includeRuntime,
boolean noReflect,
boolean resetJarTimestamps
) {
try {
@@ -89,6 +92,9 @@ public class CompileEnvironmentUtil {
}
if (includeRuntime) {
writeRuntimeToJar(stream, resetJarTimestamps);
if (!noReflect) {
writeReflectToJar(stream, resetJarTimestamps);
}
}
stream.finish();
}
@@ -98,12 +104,12 @@ public class CompileEnvironmentUtil {
}
public static void writeToJar(
File jarPath, boolean jarRuntime, boolean resetJarTimestamps, FqName mainClass, OutputFileCollection outputFiles
File jarPath, boolean jarRuntime, boolean noReflect, boolean resetJarTimestamps, FqName mainClass, OutputFileCollection outputFiles
) {
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(jarPath);
doWriteToJar(outputFiles, outputStream, mainClass, jarRuntime, resetJarTimestamps);
doWriteToJar(outputFiles, outputStream, mainClass, jarRuntime, noReflect, resetJarTimestamps);
outputStream.close();
}
catch (FileNotFoundException e) {
@@ -125,16 +131,27 @@ public class CompileEnvironmentUtil {
copyJarImpl(stream, stdlibPath, resetJarTimestamps);
}
private static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException {
File reflectPath = PathUtil.getKotlinPathsForCompiler().getReflectPath();
if (!reflectPath.exists()) {
throw new CompileEnvironmentException("Couldn't find kotlin-reflect at " + reflectPath);
}
copyJarImpl(stream, reflectPath, resetJarTimestamps);
}
private static void copyJarImpl(JarOutputStream stream, File jarPath, boolean resetJarTimestamps) throws IOException {
try (JarInputStream jis = new JarInputStream(new FileInputStream(jarPath))) {
while (true) {
JarEntry e = jis.getNextJarEntry();
if (e == null) break;
if (!FileUtilRt.extensionEquals(e.getName(), "class") ||
StringsKt.substringAfterLast(e.getName(), "/", e.getName()).equals("module-info.class")) {
String name = e.getName();
if (!FileUtilRt.extensionEquals(name, "class") &&
!FileUtilRt.extensionEquals(name, BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION) &&
!name.startsWith("META-INF/services/")) {
continue;
}
if (StringsKt.substringAfterLast(name, "/", name).equals("module-info.class")) continue;
if (resetJarTimestamps) {
e.setTime(DOS_EPOCH);
}

View File

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

View File

@@ -86,8 +86,9 @@ object KotlinToJVMBytecodeCompiler {
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
if (jarPath != null) {
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
val noReflect = configuration.get(JVMConfigurationKeys.NO_REFLECT, false)
val resetJarTimestamps = !configuration.get(JVMConfigurationKeys.NO_RESET_JAR_TIMESTAMPS, false)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, resetJarTimestamps, mainClassFqName, outputFiles)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, noReflect, resetJarTimestamps, mainClassFqName, outputFiles)
if (reportOutputFiles) {
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
messageCollector.report(OUTPUT, message)
@@ -404,10 +405,6 @@ object KotlinToJVMBytecodeCompiler {
environment.messageCollector
)
AnalyzerWithCompilerReport.reportBytecodeVersionErrors(
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished()
performanceManager?.notifyGenerationFinished()
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
@@ -606,10 +603,6 @@ object KotlinToJVMBytecodeCompiler {
environment.messageCollector
)
AnalyzerWithCompilerReport.reportBytecodeVersionErrors(
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
)
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
return generationState
}

View File

@@ -21,6 +21,7 @@ import java.io.File
fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArguments) {
put(JVMConfigurationKeys.INCLUDE_RUNTIME, arguments.includeRuntime)
put(JVMConfigurationKeys.NO_REFLECT, arguments.noReflect)
putIfNotNull(JVMConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.asList())
@@ -28,6 +29,12 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
val jvmTarget = JvmTarget.fromString(arguments.jvmTarget!!)
if (jvmTarget != null) {
put(JVMConfigurationKeys.JVM_TARGET, jvmTarget)
if (jvmTarget == JvmTarget.JVM_1_6 && !arguments.suppressDeprecatedJvmTargetWarning) {
messageCollector.report(
STRONG_WARNING,
"JVM target 1.6 is deprecated and will be removed in a future release. Please migrate to JVM target 1.8 or above"
)
}
} else {
messageCollector.report(
ERROR, "Unknown JVM target version: ${arguments.jvmTarget}\n" +
@@ -65,27 +72,37 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
}
}
if (arguments.samConversions != null) {
val samConversions = JvmSamConversions.fromString(arguments.samConversions)
if (samConversions != null) {
put(JVMConfigurationKeys.SAM_CONVERSIONS, samConversions)
if (jvmTarget < samConversions.minJvmTarget) {
handleClosureGenerationSchemeArgument("-Xsam-conversions", arguments.samConversions, JVMConfigurationKeys.SAM_CONVERSIONS, jvmTarget)
handleClosureGenerationSchemeArgument("-Xlambdas", arguments.lambdas, JVMConfigurationKeys.LAMBDAS, jvmTarget)
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
}
private fun CompilerConfiguration.handleClosureGenerationSchemeArgument(
flag: String,
value: String?,
key: CompilerConfigurationKey<JvmClosureGenerationScheme>,
jvmTarget: JvmTarget
) {
if (value != null) {
val parsedValue = JvmClosureGenerationScheme.fromString(value)
if (parsedValue != null) {
put(key, parsedValue)
if (jvmTarget < parsedValue.minJvmTarget) {
messageCollector.report(
WARNING,
"`-Xsam-conversions=${arguments.samConversions}` requires JVM target at least " +
"${samConversions.minJvmTarget.description} and is ignored."
"`$flag=$value` requires JVM target at least " +
"${parsedValue.minJvmTarget.description} and is ignored."
)
}
} else {
messageCollector.report(
ERROR,
"Unknown `-Xsam-conversions` argument: ${arguments.samConversions}\n" +
"Supported arguments: ${JvmSamConversions.values().joinToString { it.description }}"
"Unknown `$flag` argument: ${value}\n." +
"Supported arguments: ${JvmClosureGenerationScheme.values().joinToString { it.description }}"
)
}
}
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
}
fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): Boolean {
@@ -185,11 +202,13 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
// TODO: ignore previous configuration value when we do not need old backend in scripting by default
val useOldBackend = arguments.useOldBackend || (!arguments.useIR && get(JVMConfigurationKeys.IR) == false)
val useIR = arguments.useFir ||
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) {
!arguments.useOldBackend
!useOldBackend
} else {
arguments.useIR && !arguments.useOldBackend
arguments.useIR && !useOldBackend
}
if (arguments.useIR && arguments.useOldBackend) {

View File

@@ -19,7 +19,7 @@ public class KotlinCompilerVersion {
// Binaries produced by this compiler with that language version (or any future language version) are going to be marked
// as "pre-release" and will not be loaded by release versions of the compiler.
// Change this value before and after every major release
private static final boolean IS_PRE_RELEASE = true;
private static final boolean IS_PRE_RELEASE = false;
public static final String TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY = "kotlin.test.is.pre.release";

View File

@@ -114,9 +114,12 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<JvmStringConcat> STRING_CONCAT =
CompilerConfigurationKey.create("Specifies string concatenation scheme");
public static final CompilerConfigurationKey<JvmSamConversions> SAM_CONVERSIONS =
public static final CompilerConfigurationKey<JvmClosureGenerationScheme> SAM_CONVERSIONS =
CompilerConfigurationKey.create("SAM conversions code generation scheme");
public static final CompilerConfigurationKey<JvmClosureGenerationScheme> LAMBDAS =
CompilerConfigurationKey.create("Lambdas code generation scheme");
public static final CompilerConfigurationKey<List<String>> KLIB_PATHS =
CompilerConfigurationKey.create("Paths to .klib libraries");
@@ -146,4 +149,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW =
CompilerConfigurationKey.create("Enable Java language preview features");
public static final CompilerConfigurationKey<Boolean> NO_REFLECT =
CompilerConfigurationKey.create("Don't automatically include kotlin-reflect.jar into the output if the output is a jar");
}

View File

@@ -33,6 +33,9 @@ object JvmAnalysisFlags {
@JvmStatic
val enableJvmPreview by AnalysisFlag.Delegates.Boolean
@JvmStatic
val useIR by AnalysisFlag.Delegates.Boolean
private object Delegates {
object JavaTypeEnhancementStateWarnByDefault {
operator fun provideDelegate(instance: Any?, property: KProperty<*>): AnalysisFlag.Delegate<JavaTypeEnhancementState> =

View File

@@ -5,7 +5,9 @@
package org.jetbrains.kotlin.config
enum class JvmSamConversions(
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
enum class JvmClosureGenerationScheme(
val description: String,
val minJvmTarget: JvmTarget
) {
@@ -17,7 +19,9 @@ enum class JvmSamConversions(
val DEFAULT = CLASS
@JvmStatic
fun fromString(string: String?) =
values().find { it.description == string }
fun fromString(string: String?): JvmClosureGenerationScheme? {
val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null
return values().find { it.description == lowerStr }
}
}
}

View File

@@ -32,11 +32,12 @@ enum class JvmTarget(
JVM_13("13", Opcodes.V12 + 1),
JVM_14("14", Opcodes.V12 + 2),
JVM_15("15", Opcodes.V12 + 3),
JVM_16("16", Opcodes.V12 + 4),
;
companion object {
@JvmField
val DEFAULT = JVM_1_6
val DEFAULT = JVM_1_8
@JvmStatic
fun fromString(string: String) = values().find { it.description == string }

View File

@@ -50,4 +50,7 @@ object AnalysisFlags {
@JvmStatic
val libraryToSourceAnalysis by AnalysisFlag.Delegates.Boolean
@JvmStatic
val extendedCompilerChecks by AnalysisFlag.Delegates.Boolean
}

View File

@@ -29,6 +29,10 @@ inline fun <reified T : Any> StorageComponentContainer.useImpl() {
registerSingleton(T::class.java)
}
inline fun <reified T : Any> StorageComponentContainer.useImplIf(cond: Boolean) {
if (cond) useImpl<T>()
}
inline fun <reified T : Any> ComponentProvider.get(): T {
return getService(T::class.java)
}

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