Compare commits

...

120 Commits

Author SHA1 Message Date
Igor Chevdar
8c81b1760f Bump native compiler version to 1.2-eap-8554 2019-03-14 20:05:51 +03:00
Ilya Matveev
dc4e06c6af Update Kotlin/Native: 1.2-eap-8472 2019-03-13 20:03:47 +07:00
Igor Chevdar
38f6303702 Wrapped descriptors: supported complex annotations 2019-03-13 17:22:48 +07:00
Igor Chevdar
b6353524a0 [IR] Copied functions from IrGenerator to IrBuilder
With that the number of UNDEFINED_OFFSET should be greater reduced
2019-03-13 09:09:29 +03:00
nikita.movshin
2e8d524b19 Add changelog for 1.3.30-eap2 2019-03-12 11:18:27 +03:00
nikita.movshin
75afa63a79 Added changelog for 1.3.30-eap2 2019-03-12 11:04:23 +03:00
Ilya Gorbunov
3cd89c71cd Move UArraysKt into kotlin.collections.unsigned package
Provide UArraysKt class in kotlin.collections for binary compatibility
instead of removed multipart facade class. It contains only non-inline
functions of the latter.

(cherry picked from commit 6ae5e91930)
2019-03-09 00:10:50 +03:00
Ilya Gorbunov
7e376ff3c6 Make JvmPackageName a common internal annotation
(cherry picked from commit db4c4132f6)
2019-03-09 00:10:49 +03:00
Abduqodiri Qurbonzoda
8cc11279d7 Implement min max minOf maxOf functions for unsigned types (KT-30035)
(cherry picked from commit be6c2d8c7d)
2019-03-09 00:10:47 +03:00
Abduqodiri Qurbonzoda
9a01d323aa Implement contains extension functions for URanges (KT-26378)
(cherry picked from commit bf83f0e070)
2019-03-09 00:10:46 +03:00
Abduqodiri Qurbonzoda
a84470c124 Implement sorting extension functions for UArrays
(cherry picked from commit cb587893c0)
2019-03-09 00:10:44 +03:00
Abduqodiri Qurbonzoda
87944cd866 Implement drop, take & filter extension functions for UArrays
(cherry picked from commit c42dbb34ca)
2019-03-09 00:10:43 +03:00
Abduqodiri Qurbonzoda
ff97e1cea9 Implement map, flatMap, zip & groupBy extension functions for UArrays
(cherry picked from commit abb275775e)
2019-03-09 00:10:41 +03:00
Abduqodiri Qurbonzoda
ff38226b01 Implement folding extension functions for UArrays
(cherry picked from commit 503264b996)
2019-03-09 00:10:40 +03:00
Abduqodiri Qurbonzoda
e934478581 Implement sum extension function for UArrays (KT-28779)
(cherry picked from commit 7695b5e575)
2019-03-09 00:10:39 +03:00
Abduqodiri Qurbonzoda
39616479ba Implement reduce, forEach, min & max extension functions for UArrays
(cherry picked from commit 690e35f11a)
2019-03-09 00:10:37 +03:00
Abduqodiri Qurbonzoda
38c5f58be7 Implement asList, slice & sliceArray extension functions for UArrays
(cherry picked from commit fc85781bfc)
2019-03-09 00:10:36 +03:00
Abduqodiri Qurbonzoda
0fe065ba77 Implement reversing extension functions for UArrays
(cherry picked from commit 114736c09b)
2019-03-09 00:10:34 +03:00
Abduqodiri Qurbonzoda
4d601d34d0 Implement first, last & single extension functions for UArrays
(cherry picked from commit 92cd84682c)
2019-03-09 00:10:33 +03:00
Abduqodiri Qurbonzoda
39e22851cd Implement conversion from typed array and collection to UArrays
(cherry picked from commit 299fac8e2d)
2019-03-09 00:10:31 +03:00
Abduqodiri Qurbonzoda
d2cf140965 Implement any, all, none, count & sumBy functions for UArrays
(cherry picked from commit bbaabb90e4)
2019-03-09 00:10:30 +03:00
Abduqodiri Qurbonzoda
b1e2afccb5 Implement index-requesting extension functions for UArrays
Contains implementations of `indexOf`, `lastIndexOf`, `indexOfFirst`,
`indexOfLast`, `lastIndex` and `indices` extension functions.

(cherry picked from commit 512d986006)
2019-03-09 00:10:28 +03:00
Abduqodiri Qurbonzoda
a1d586cfc5 Implement fill extension function for UArrays (KT-28339)
(cherry picked from commit 876dff6d22)
2019-03-09 00:10:27 +03:00
Abduqodiri Qurbonzoda
056f99228f Implement component(N) functions for destructuring UArrays
(cherry picked from commit 6b92190726)
2019-03-09 00:10:25 +03:00
Abduqodiri Qurbonzoda
88bdb7a8b9 Implement binarySearch method for UArrays (KT-27262)
(cherry picked from commit 550c74bb6b)
2019-03-09 00:10:24 +03:00
Abduqodiri Qurbonzoda
9e61c7db7d Specialize plus operator for UArrays (KT-28397)
(cherry picked from commit 6cd9858147)
2019-03-09 00:10:22 +03:00
Abduqodiri Qurbonzoda
572ac40df0 Write docs for unsigned types conversions
(cherry picked from commit 3af6b36401)
2019-03-09 00:10:01 +03:00
Ilya Gorbunov
276aa903db Advance bootstrap to 1.3.30-eap-28 2019-03-07 20:21:55 +03:00
Kirill Shmakov
8df4c48be2 Add key 'module' into interop definitions file 2019-03-07 19:51:46 +03:00
Ilya Matveev
a62d3812f6 Update Kotlin/Native: 1.2-eap-8365 2019-03-07 18:59:26 +03:00
Ilya Matveev
2bd835f008 CocoaPods: Replace '-' with '_' in podspec name 2019-03-07 18:59:26 +03:00
Ilya Matveev
e7cf4fd3f2 CocoaPods: Refactor framework name mangling 2019-03-07 18:59:26 +03:00
Ilya Matveev
320b0f907b CocoaPods: Rename user-visible: Cocoapods -> CocoaPods 2019-03-07 18:59:25 +03:00
Ilya Matveev
7650f63921 CocoaPods: Rename podspec task: generatePodspec -> podspec 2019-03-07 18:59:25 +03:00
Ilya Matveev
419195e608 CocoaPods: Replace dynamic dummy framework with a static one 2019-03-07 18:59:25 +03:00
Ilya Matveev
a616b79cba Refactor kotlin multiplatform extension access 2019-03-07 18:59:25 +03:00
Ilya Matveev
183eca867e CocoaPods: Use regex to split quoted compiler args 2019-03-07 18:59:25 +03:00
Ilya Matveev
7dbd79304d CocoaPods: Add 'native' in the plugin ID
kotlin-cocoapods -> kotlin-native-cocoapods
org.jetbrains.kotlin.cocoapods ->
org.jetbrains.kotlin.native.cocoapods
2019-03-07 18:59:25 +03:00
Ilya Matveev
6e20d4deec Support -Xstatic-framework in DSL
In Kotlin/Native 1.3.30 EAP1 an ability to build
a static ObjC framework has been added. This patch
adds support for this feature in the kotlin-multiplatform
plugin.
2019-03-07 18:59:24 +03:00
Ilya Matveev
068afcacae CocoaPods: Basic support
This patch adds a separate Gradle plugin allowing
a user to import Kotlin/Native modules in Cocoapods
projects and use Cocoapods dependencies in Kotlin
code via cinterop.

The plugin when applied does the following things:

1. Add a framework binary for each supported (iOS
   or macOS) platform in the project.

2. Add a Cocoapods extension allowing one to configure
   Cocoapods dependencies of the project.

3. Create cinterop tasks for each dependency from the
   previous point. The tasks are added for main
   compilations of each supported platform.

4. Add a task to generate a podspec-file which includes
   the framework from the point 1, script to
   build it and dependencies from the point 2.

So the Cocoapods import procedure is the following:

1. A user runs `./gradlew generatePodspec`. The plugin
   creates a podspec-file with all dependencies.

2. The user adds a dependency on this podspec in his Podfile
   and runs `pod install`. Cocoapods downloads dependencies
   and configures user's XCode project.

3. The user runs XCode build. XCode builds dependencies and then
   runs Gradle build. Gradle performs interop processing and
   builds the Kotlin framework. Compiler options and header
   search paths are passed in the Gradle from XCode environment
   variables. After that the final application is built by XCode.

Issue #KT-30269 Fixed
2019-03-07 18:59:24 +03:00
Ilya Matveev
d2d73b5043 Avoid resolution ambiguity for cinterop DSL
Earlier we used to have two methods: cinterops(Container.() -> Unit) and
cinterops(Action<Container>). It's OK for Groovy DSL but causes resolution
ambiguity in Kotlin DSL. This patch removes the first overload to avoid
this situation. The second overload still can be called in Kotlin DSL
as `cinterops { ... }`.
2019-03-07 18:59:24 +03:00
Ilya Matveev
3391530809 Deprecate old DSL method for binary configuration
In 1.3.20 a new binaries DSL was introduced. This
patch deprecates old DSL methods used for binary
configuration in 1.3.0 and 1.3.1x.

Issue #KT-29998 Fixed
2019-03-07 18:59:24 +03:00
Ilya Matveev
4d96bfe089 Add main interop libraries in test interop dependencies
Earlier we added interop libraries built for a main compilation
in dependencies of a corresponding test compilation. But we didn't
add them in dependencies of interop libraries built for the test
compilation. It caused cinterop failures when the test compilation
has interop libraries. This patch fixes it by adding main interop
libraries in dependencies of test ones.

Also earlier interop libraries of test compilations were
unintentionally added in apiElements and publication. This patch
fixes this issue too.

Issue #KT-30290 Fixed
2019-03-07 18:59:24 +03:00
Natalia Selezneva
9d37feab72 Preprocess script dependencies before running UnusedSymbolInspection
^KT-29474

(cherry picked from commit f98429c509)
2019-03-07 18:41:03 +03:00
Natalia Selezneva
feb8b91075 Show notification that script dependencies are not ready yet
(cherry picked from commit 47a4500eaa)
2019-03-07 18:41:03 +03:00
Natalia Selezneva
fbe6c72c46 Show progress for loading script dependencies even show notification is true when there are more than 3 scripts in queue
We are trying to update script dependencies silently when 'Reload script dependencies on file change' is off,
but in case when the queue for update is too long we need to make process visible to user and make it cancelable.

(cherry picked from commit 1d56f44093)
2019-03-07 18:41:02 +03:00
Natalia Selezneva
04a898dd44 Fire one 'roots changed' event after all scripts dependencies loaded
^KT-29474

(cherry picked from commit 8331d9789e)
2019-03-07 18:41:02 +03:00
Natalia Selezneva
8a05e00960 Check project.isDisposed before attaching script reports
(cherry picked from commit 6bc6dea916)
2019-03-07 18:41:02 +03:00
Natalia Selezneva
a690dbefe5 Do not search for text occurrences if this option is switched off
(cherry picked from commit c2dd365158)
2019-03-07 18:41:02 +03:00
Natalia Selezneva
c366433034 Scratch can be modified during execution (KT-30200)
^KT-30200 Fixed

(cherry picked from commit 4a0574dc5f)
2019-03-07 18:41:02 +03:00
Natalia Selezneva
8be1487429 Introduce ScratchPanelListener to set module in the created panel (KT-30049)
^KT-30049 Fixed

(cherry picked from commit 0dbbd8e08c)
2019-03-07 18:41:01 +03:00
Roman Elizarov
7c62ffa9cd Invoke probeCoroutineResumed on each unroll of the frame from heap
Fixes KT-29997
2019-03-07 17:38:38 +03:00
Alexander Udalov
10c71ea2f2 Support JVM target versions up to 12
#KT-26240 Fixed

(cherry picked from commit 518b03125c)
2019-03-07 12:09:11 +01:00
Alexander Udalov
bb98d95186 Minor, remove confusing logic from GenericReplChecker
(cherry picked from commit 9f75fd0d62)
2019-03-07 12:09:10 +01:00
Alexander Udalov
5098171326 Use JvmTarget.DEFAULT instead of JVM_1_6 where applicable
(cherry picked from commit c7c377e1b1)
2019-03-07 12:09:08 +01:00
Alexander Udalov
e9c071aabc Support JvmPackageName with JvmMultifileClass
This is an internal feature of our standard library needed to compile
new API for unsigned types

(cherry picked from commit 59fda8d7ce)
2019-03-06 15:38:31 +01:00
Alexander Udalov
ed7b530513 Reformat MultifileClassCodegen, fix inspections
(cherry picked from commit ea21cda4df)
2019-03-06 15:38:28 +01:00
Yan Zhulanow
65feaf9a4a 191: 191: Fix test compilation, remove deleted test
(cherry picked from commit 7c0233dfeb)
2019-03-06 13:41:52 +03:00
Nicolay Mitropolsky
558d1edd39 Uast: getMaybeLightElement cleanup
(cherry picked from commit f664499708)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
492dd24897 Uast: testing resolve for method called on variables of parametrized types
(cherry picked from commit ec1badf60d)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
710134b4a6 Uast: type-parameter references resolves to type-parameters
(cherry picked from commit 5268cd4663)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
c253404622 Uast: TypeReferences log test added
(cherry picked from commit ec26ea4e36)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
94a88c5c19 Uast: ResolveEverythingTest tests for generics added
(cherry picked from commit adb13b2f9e)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
8ac926d3e2 Uast: resolving references to local function declarations
(cherry picked from commit 337f16194a)
2019-03-06 13:41:51 +03:00
Nicolay Mitropolsky
1dcad35f21 Uast: making KotlinUSimpleReferenceExpression able to resolve to types
(cherry picked from commit 72860fb695)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
6df81c5fc7 Uast: setup for KotlinUastResolveEverythingTest
(cherry picked from commit e1e1e53e4a)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
6c0cec151e Uast: support for KtDelegatedSuperTypeEntry (KT-30033)
(cherry picked from commit 9c674cb7c3)
2019-03-06 13:41:50 +03:00
Nicolay Mitropolsky
22b2fc0c9f Uast multiresolve key description fix
(cherry picked from commit c151be5547)
2019-03-06 13:41:50 +03:00
Natalia Selezneva
48596fe2c7 Add scripting resolver extension to plugin-kotlin-extensions.xml
(cherry picked from commit ae22bdee15)
2019-03-06 13:16:19 +03:00
Natalia Selezneva
7fcc915fc4 Fix saving Kotlin Scripting Setting to xml
^KT-30146 Fixed

(cherry picked from commit bc1e836f01)
2019-03-06 13:14:38 +03:00
Natalia Selezneva
7c4e5dbb09 Do not threat modifications inside lambdas in KtScriptInitializer block as out of code block
(cherry picked from commit 48433110a4)
2019-03-06 13:14:10 +03:00
Natalia Selezneva
4b12826e99 Optimize MemberVisibilityCanBePrivateInspection: check that descriptor is in class before resolving it
(cherry picked from commit 49277bb5e4)
2019-03-06 13:13:51 +03:00
Natalia Selezneva
fab11884cc KtScriptInitializer doesn't has a descriptor
(cherry picked from commit 560acd631c)
2019-03-06 13:13:33 +03:00
Natalia Selezneva
800ccdcc1d Optimize ChangeVisibilityModifierIntention: do not analyze element if declaration isn't local
(cherry picked from commit 3b4d1dd7bf)
2019-03-06 13:13:12 +03:00
Natalia Selezneva
0d16f0de42 Optimize KotlinUFunctionCallExpression.isAnnotationArgumentArrayExpression
(cherry picked from commit 869fb46c0b)
2019-03-06 13:12:52 +03:00
Toshiaki Kameyama
d191510b42 Add intention to replace '!isNotEmpty()' to 'isEmpty()'
#KT-30123 Fixed

(cherry picked from commit 6b35c06d50)
2019-03-06 11:19:18 +03:00
Toshiaki Kameyama
536ab732cd Import members from: suggest on type reference
#KT-29927 Fixed

(cherry picked from commit 6b5ba272a0)
2019-03-06 11:18:25 +03:00
Dmitry Gridin
e100e3ec58 Fix KT-26965
(cherry picked from commit 2a940f5b0a)
2019-03-06 11:15:14 +03:00
Dereck Bridie
e6a560c49c #KT-26965 Add inspection + quickfix for replacing Collection<T>.count() with .size
(cherry picked from commit 4156a76129)
2019-03-06 11:13:48 +03:00
Mikhail Zarechenskiy
f1636cab67 Swap arguments for diagnostic message about incompatible enums
This commit is restoring previous behavior changed in c4b69b65 and
 fixing `DiagnosticMessageTestGenerated.testIncompatibleEnums` test
2019-03-06 10:49:53 +03:00
Mikhail Zarechenskiy
15a60b8640 Gradually prohibit comparison of incompatible enums
#KT-22043 Fixed
2019-03-05 14:23:50 +03:00
Mikhail Zarechenskiy
86395bc6dc Refactoring: move getRepresentativeUpperBound method to core
Plus prettify it a bit
2019-03-05 14:23:32 +03:00
Mikhail Zarechenskiy
a8345c25f0 Increment metadata version and improve message for error type
Follow-up of 617bed1b
2019-03-05 14:23:13 +03:00
Shagen Ogandzhanian
017d99de4c Fix for npm publishing configuration
This reverts commit 0188cd5330.
Turns out it's not a url after all
2019-03-05 11:32:15 +03:00
Toshiaki Kameyama
bb020202aa map.get() with not-null assertion: add quick-fixes
#KT-30010 Fixed

(cherry picked from commit d67c793a9b)
2019-03-05 09:57:14 +03:00
Toshiaki Kameyama
e111863ee2 Add inspection to replace Java Map.forEach with Kotlin's forEach
#KT-17278 Fixed

(cherry picked from commit 1a818970c3)
2019-03-05 09:56:32 +03:00
Mikhail Glukhikh
d940851bdf Fix "make constructor parameter a property" for vararg case
Same should work for annotated parameters
#KT-29312 Fixed

(cherry picked from commit 9e2ee6183c)
2019-03-05 09:55:50 +03:00
Mikhail Glukhikh
868c22b4cf Don't report "Unsafe call with ? extension receiver" with smart-cast
#KT-29499 Fixed

(cherry picked from commit c714e599ea)
2019-03-05 09:55:19 +03:00
Mikhail Glukhikh
a8755cef36 Don't report "main parameter not necessary" in objects #KT-29414 Fixed
(cherry picked from commit 4d19120d84)
2019-03-05 09:55:01 +03:00
Mikhail Glukhikh
1629c46177 MPP web builder: upgrade Ktor version to 1.1.3 #KT-29918 Fixed
(cherry picked from commit 022c625d2d)
2019-03-05 09:54:16 +03:00
Wil
3dfd560470 Minor: typo fix in Writer.buffered docs
(cherry picked from commit d3ac50f694)
2019-03-04 21:03:15 +03:00
Ilya Gorbunov
f745c84574 Do not expose internal copyOfUninitializedElements and copyOfNulls
(cherry picked from commit 640699e076)
2019-03-04 21:03:06 +03:00
Ilya Gorbunov
502a6086d6 Rewrite copyOfUninitializedElements with templates without using copyRangeTo
(cherry picked from commit 2e9497f8f8)
2019-03-04 21:03:05 +03:00
Ilya Gorbunov
1050b9d19b Rewrite copyInto without using copyRangeTo
Rename array copying implementation to arrayCopy

(cherry picked from commit c1a51d44a4)
2019-03-04 21:03:04 +03:00
Ilya Gorbunov
7954c1fced Move sorting implementations for Native to kotlin.collections
- Move Array.sortWith to generated code

(cherry picked from commit b8d9e896c2)
2019-03-04 21:03:02 +03:00
Ilya Gorbunov
5454bed997 Swap mismatched docs for Result.onSuccess/onFailure KT-30109
(cherry picked from commit 19bd326810)
2019-03-04 20:59:51 +03:00
Ilya Gorbunov
c361b184d9 Improve double-to-ulong conversion tests
#KT-27108

(cherry picked from commit 908009bf42)
2019-03-04 20:59:50 +03:00
Mikhail Glukhikh
4b1c847863 Remove FIR provider from IDE to prevent exceptions like KT-30243
This commit is a work-around for 1.3.30
2019-03-04 14:44:47 +03:00
Dmitry Gridin
1162c1be5f Fix KNPE from "Create" quick fix
#KT-27289 Fixed

(cherry picked from commit dce2139eb0)
2019-03-04 13:57:40 +03:00
Dmitry Gridin
b55d69c36b Refactoring
(cherry picked from commit 78bee70946)
2019-03-04 13:56:27 +03:00
Dmitry Gridin
0af1dc35a4 Fix "Introduce import alias" on extensions
#KT-30214 Fixed

(cherry picked from commit 5927032143)
2019-03-04 13:55:04 +03:00
Dmitry Gridin
ef27fe4e0e Fix caret position in "Convert function to property" intention
#KT-19944 Fixed

(cherry picked from commit 41f3316981)
2019-03-04 13:53:13 +03:00
Dmitry Gridin
614c68280f Refactoring & fix warnings
(cherry picked from commit 29a63ae58c)
2019-03-04 13:52:20 +03:00
Dmitry Gridin
bfbdd3f2fb Fix false positive "Redundant companion reference"
#KT-30166 Fixed

(cherry picked from commit 304007f602)
2019-03-04 13:51:24 +03:00
Dmitry Gridin
157ad173ec Add inspection to remove redundant qualifier name
#KT-12134 Fixed

(cherry picked from commit 3756b6f54d)
2019-03-04 13:50:54 +03:00
Dmitry Gridin
dfbe43fe16 Move canBePossibleToDropReceiver to Companion object & fix warnings
(cherry picked from commit d0c3a28996)
2019-03-04 13:50:28 +03:00
Andrey Uskov
3dc42d2525 Fix memory leak in gradle import
#KT-30076 Fixed

(cherry picked from commit 25dc81c2bd)
2019-03-04 01:46:59 +03:00
Andrey Uskov
919d527aa7 Minor. Reformat code in multiplatform project importer
(cherry picked from commit 3919898d19)
2019-03-04 01:46:10 +03:00
Andrey Uskov
45991a69ff Fix creation of KotlinSDK. GradleFacetImportTest fixed
(cherry picked from commit 735f86a50e)
2019-03-04 01:45:38 +03:00
Andrey Uskov
a134e568f2 Change class hierarchy of KotlinSourceRootType. Deadlock during concurrent classloading fixed
#KT-30137 Fixed

(cherry picked from commit 325ed8eb32)
2019-03-04 01:45:03 +03:00
Vyacheslav Gerasimov
3af23f2d3f Build: Add diagnostic for publish() helper
(cherry picked from commit f7428e7161)
2019-03-02 18:50:58 +03:00
Vyacheslav Gerasimov
7572ee4122 Build: Fix artifacts signing for maven central
With gradle > 5.0 `publish()` helper call should be done before
`noDefaultJar()` or any other artifact hacks, otherwise singing plugin doesn't sign any jars

(cherry picked from commit a42f607ecf)
2019-03-02 18:50:44 +03:00
Vyacheslav Gerasimov
41f3415b4a Build: Apply java plugin in kotlin-annotation-processing-embeddable
Otherwise artifact signature works incorrectly for this project

(cherry picked from commit df3aa48c9b)
2019-03-02 18:50:28 +03:00
Vyacheslav Gerasimov
9dbd7269cb Build: properly remove artifact from archives in runtimeJar helper
(cherry picked from commit f4c157a9bc)
2019-03-02 18:50:16 +03:00
Alexander Udalov
dd3d2311a8 Prohibit type parameters in class literals in annotation arguments
#KT-27799 Fixed

(cherry picked from commit 736ac12374)
2019-03-01 11:37:05 +01:00
Alexander Udalov
b28e71730b Support non-trivial default argument values in expected functions on JVM
#KT-22818 Fixed

(cherry picked from commit b8bc79e17c)
2019-03-01 11:35:22 +01:00
nikita.movshin
5e91bc5697 Added changelog for 1.3.30 2019-02-28 12:23:00 +03:00
Stanislav Erokhin
ef209999f7 Update Kotlin/Native: 1.2-eap-8089 2019-02-28 11:32:58 +03:00
Igor Chevdar
d364505652 Fixes of wrapped descriptors
Supported complex annotations
Supported type parameters in classes
2019-02-27 17:53:38 +03:00
Alexander Podkhalyuzin
30d2a1ae2a Do not go to the same type twice during contains search
This fixes exponent in algorithm for scala.FunctionN.curried, where N can be up to 22.

#KT-29435 Fixed

(cherry picked from commit 6098e97ae5)
2019-02-27 14:19:36 +03:00
517 changed files with 17857 additions and 10254 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,8 @@ sourceSets {
"test" { projectDefault() }
}
publish()
runtimeJar()
sourcesJar()
javadocJar()
@@ -39,5 +41,3 @@ javadocJar()
testsJar()
projectTest()
publish()

View File

@@ -10,7 +10,7 @@ import org.gradle.kotlin.dsl.*
buildscript {
extra["defaultSnapshotVersion"] = "1.3-SNAPSHOT"
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.3.30-dev-1945", onlySuccessBootstrap = false))
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.3.30-eap-28", projectExtId = "Kotlin_1330_Compiler", onlySuccessBootstrap = false))
repositories.withRedirector(project) {
bootstrapKotlinRepo?.let(::maven)

View File

@@ -35,14 +35,26 @@ fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
}
}
var Project.artifactsRemovedDiagnosticFlag: Boolean
get() = extra.has("artifactsRemovedDiagnosticFlag") && extra["artifactsRemovedDiagnosticFlag"] == true
set(value) {
extra["artifactsRemovedDiagnosticFlag"] = value
}
fun Project.removeArtifacts(configuration: Configuration, task: Task) {
configuration.artifacts.removeAll { artifact ->
artifact.file in task.outputs.files
}
artifactsRemovedDiagnosticFlag = true
}
fun Project.noDefaultJar() {
tasks.findByName("jar")?.let { defaultJarTask ->
defaultJarTask.enabled = false
defaultJarTask.actions = emptyList()
configurations.forEach { cfg ->
cfg.artifacts.removeAll { artifact ->
artifact.file in defaultJarTask.outputs.files
}
removeArtifacts(cfg, defaultJarTask)
}
}
}
@@ -58,8 +70,7 @@ fun Project.runtimeJarArtifactBy(task: Task, artifactRef: Any, body: Configurabl
fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
extra["runtimeJarTask"] = task
tasks.findByName("jar")?.let { defaultJarTask ->
configurations.getOrCreate("archives")
.artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
}
return task.apply {
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
@@ -109,6 +120,10 @@ fun Project.standardPublicJars() {
fun Project.publish(body: Upload.() -> Unit = {}): Upload {
apply<plugins.PublishedKotlinModule>()
if (artifactsRemovedDiagnosticFlag) {
error("`publish()` should be called before removing artifacts typically done in `noDefaultJar()` of `runtimeJar()` calls")
}
afterEvaluate {
if (configurations.findByName("classes-dirs") != null)
throw GradleException("classesDirsArtifact() is incompatible with publish(), see sources comments for details")

View File

@@ -244,6 +244,10 @@ public abstract class AnnotationCodegen {
annotationTargetMaps.put(JvmTarget.JVM_1_6, jvm6);
annotationTargetMaps.put(JvmTarget.JVM_1_8, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_9, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_10, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_11, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_12, jvm8);
}
private void generateTargetAnnotation(

View File

@@ -100,7 +100,8 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.*;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.*;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.isBoxedLocalCapturedInClosure;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionExpression;
@@ -2900,7 +2901,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
while (cur != null) {
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
if (!isSuper && thisDescriptor == thisOrOuterClass) {
// We use equals on type constructors (instead of reference equality on classes) to support the case where default parameter
// values of actual functions loaded from the expected function refer to the expected class.
if (!isSuper && thisDescriptor.getTypeConstructor().equals(thisOrOuterClass.getTypeConstructor())) {
return result;
}

View File

@@ -21,10 +21,9 @@ import com.intellij.openapi.util.Trinity
import gnu.trove.TObjectIntHashMap
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.org.objectweb.asm.Type
import java.util.*
import java.util.ArrayList
class FrameMap : FrameMapBase<DeclarationDescriptor>()
open class FrameMap : FrameMapBase<DeclarationDescriptor>()
open class FrameMapBase<T : Any> {
private val myVarIndex = TObjectIntHashMap<T>()
@@ -61,7 +60,7 @@ open class FrameMapBase<T : Any> {
currentSize -= type.size
}
fun getIndex(descriptor: T): Int {
open fun getIndex(descriptor: T): Int {
return if (myVarIndex.contains(descriptor)) myVarIndex.get(descriptor) else -1
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
/**
* This [FrameMap] subclass substitutes values declared in the expected declaration with the corresponding value in the actual declaration,
* which is needed for the case when expected function declares parameters with default values, which refer to other parameters.
*/
class FrameMapWithExpectActualSupport(private val module: ModuleDescriptor) : FrameMap() {
override fun getIndex(descriptor: DeclarationDescriptor): Int {
val tmp = if (descriptor is ParameterDescriptor) findActualParameter(descriptor) ?: descriptor else descriptor
return super.getIndex(tmp)
}
private fun findActualParameter(parameter: ParameterDescriptor): ParameterDescriptor? {
val container = parameter.containingDeclaration
if (container !is CallableMemberDescriptor || !container.isExpect) return null
// Generation of value parameters is supported by the fact that FunctionCodegen.generateDefaultImplBody substitutes value parameters
// of the generated actual function with the parameters of the expected declaration in the first place.
// Generation of dispatch receiver parameters (this and outer receiver values) is supported
// in ExpressionCodegen.generateThisOrOuterFromContext by comparing classes by type constructor equality.
if (parameter !is ReceiverParameterDescriptor || parameter.value !is ExtensionReceiver) return null
val actual = with(ExpectedActualResolver) {
container.findCompatibleActualForExpected(module).firstOrNull()
}
return (actual as? CallableDescriptor)?.extensionReceiverParameter
}
}

View File

@@ -1360,7 +1360,7 @@ public class FunctionCodegen {
@NotNull List<ValueParameterDescriptor> valueParameters,
boolean isStatic
) {
FrameMap frameMap = new FrameMap();
FrameMap frameMap = new FrameMapWithExpectActualSupport(state.getModule());
if (!isStatic) {
frameMap.enterTemp(OBJECT_TYPE);
}

View File

@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.codegen
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.util.ArrayUtil
import com.intellij.util.SmartList
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext
import org.jetbrains.kotlin.codegen.context.MethodContext
@@ -41,6 +39,7 @@ import org.jetbrains.kotlin.psi.KtTypeAlias
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClassPart
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
@@ -67,20 +66,20 @@ class MultifileClassCodegenImpl(
) : MultifileClassCodegen {
private val facadeClassType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(facadeFqName)
private val packageFragment = getOnlyPackageFragment(facadeFqName.parent(), files, state.module)
private val packageFragment = getOnlyPackageFragment(files, state.module)
private val compiledPackageFragment = getCompiledPackageFragment(facadeFqName, state)
private val previouslyCompiledCallables =
if (compiledPackageFragment == null)
emptyList<DeserializedCallableMemberDescriptor>()
else
getDeserializedCallables(compiledPackageFragment)
if (compiledPackageFragment == null)
emptyList()
else
getDeserializedCallables(compiledPackageFragment)
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
compiledPackageFragment.getMemberScope()
.getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER)
.filterIsInstance<DeserializedCallableMemberDescriptor>()
compiledPackageFragment.getMemberScope()
.getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER)
.filterIsInstance<DeserializedCallableMemberDescriptor>()
private val shouldGeneratePartHierarchy =
state.languageVersionSettings.getFlag(JvmAnalysisFlags.inheritMultifileParts)
@@ -100,7 +99,7 @@ class MultifileClassCodegenImpl(
private val superClassForInheritedPart = run {
val result = hashMapOf<String, String>()
for (i in 1 ..partInternalNamesSorted.size - 1) {
for (i in 1 until partInternalNamesSorted.size) {
result[partInternalNamesSorted[i]] = partInternalNamesSorted[i - 1]
}
result
@@ -115,29 +114,23 @@ class MultifileClassCodegenImpl(
J_L_OBJECT
private val classBuilder = ClassBuilderOnDemand {
val originFile = files.firstOrNull()
val actualPackageFragment = packageFragment
?: compiledPackageFragment
?: throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
val declarationOrigin = MultifileClass(originFile, actualPackageFragment)
?: compiledPackageFragment
?: throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
val singleSourceFile =
if (previouslyCompiledCallables.isEmpty())
files.singleOrNull { it.hasDeclarationsForPartClass() }
else
null
if (previouslyCompiledCallables.isEmpty())
files.singleOrNull { it.hasDeclarationsForPartClass() }
else
null
val superClassForFacade =
if (shouldGeneratePartHierarchy)
partInternalNamesSorted.last()
else
J_L_OBJECT
val superClassForFacade = if (shouldGeneratePartHierarchy) partInternalNamesSorted.last() else J_L_OBJECT
state.factory.newVisitor(declarationOrigin, facadeClassType, files).apply {
defineClass(singleSourceFile, state.classFileVersion, FACADE_CLASS_ATTRIBUTES,
facadeClassType.internalName, null, superClassForFacade, ArrayUtil.EMPTY_STRING_ARRAY)
state.factory.newVisitor(MultifileClass(files.firstOrNull(), actualPackageFragment), facadeClassType, files).apply {
defineClass(
singleSourceFile, state.classFileVersion, FACADE_CLASS_ATTRIBUTES,
facadeClassType.internalName, null, superClassForFacade, emptyArray()
)
if (singleSourceFile != null) {
visitSource(singleSourceFile.name, null)
}
@@ -162,7 +155,7 @@ class MultifileClassCodegenImpl(
generateDelegatesToPreviouslyCompiledParts()
if (!partInternalNamesSorted.isEmpty()) {
if (partInternalNamesSorted.isNotEmpty()) {
generateMultifileFacadeClass()
}
@@ -175,16 +168,12 @@ class MultifileClassCodegenImpl(
try {
generatePart(file)
state.afterIndependentPart()
}
catch (e: ProcessCanceledException) {
} catch (e: ProcessCanceledException) {
throw e
}
catch (e: Throwable) {
val vFile = file.virtualFile
errorHandler.reportException(e, if (vFile == null) "no file" else vFile.url)
} catch (e: Throwable) {
errorHandler.reportException(e, file.virtualFile?.url ?: "no file")
DiagnosticUtils.throwIfRunningOnServer(e)
if (ApplicationManager.getApplication().isInternal) {
//noinspection CallToPrintStackTrace
e.printStackTrace()
}
}
@@ -205,7 +194,7 @@ class MultifileClassCodegenImpl(
private fun generatePart(file: KtFile) {
val packageFragment = this.packageFragment
?: throw AssertionError("File part $file of $facadeFqName: no package fragment")
?: throw AssertionError("File part $file of $facadeFqName: no package fragment")
val partType = Type.getObjectType(JvmFileClassUtil.getFileClassInternalName(file))
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
@@ -219,10 +208,7 @@ class MultifileClassCodegenImpl(
val builder = state.factory.newVisitor(MultifileClassPart(file, packageFragment), partType, file)
MultifileClassPartCodegen(
builder, file, packageFragment,
getSuperClassForPart(partType.internalName),
shouldGeneratePartHierarchy,
partContext, state
builder, file, packageFragment, getSuperClassForPart(partType.internalName), shouldGeneratePartHierarchy, partContext, state
).generate()
addDelegateGenerationTasksForDeclarationsInFile(file, packageFragment, partType)
@@ -284,14 +270,14 @@ class MultifileClassCodegenImpl(
val partFqName = JvmFileClassUtil.getPartFqNameForDeserialized(callable)
val partType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(partFqName)
addDelegateGenerationTaskIfNeeded(callable, { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) })
addDelegateGenerationTaskIfNeeded(callable) { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) }
}
}
private fun generateDelegateToCompiledMember(
member: CallableMemberDescriptor,
compiledPackageFragment: PackageFragmentDescriptor,
partType: Type
member: CallableMemberDescriptor,
compiledPackageFragment: PackageFragmentDescriptor,
partType: Type
) {
val context = state.rootContext.intoMultifileClass(compiledPackageFragment, facadeClassType, partType)
@@ -302,7 +288,8 @@ class MultifileClassCodegenImpl(
memberCodegen.functionCodegen.generateMethod(OtherOrigin(member), member, DelegateToCompiledMemberGenerationStrategy)
memberCodegen.functionCodegen.generateDefaultIfNeeded(
context.intoFunction(member), member, OwnerKind.PACKAGE, DefaultParameterValueLoader.DEFAULT, null)
context.intoFunction(member), member, OwnerKind.PACKAGE, DefaultParameterValueLoader.DEFAULT, null
)
memberCodegen.functionCodegen.generateOverloadsWithDefaultValues(null, member, member)
}
@@ -310,7 +297,7 @@ class MultifileClassCodegenImpl(
memberCodegen.propertyCodegen.generateInPackageFacade(member)
}
else -> {
throw IllegalStateException("Unexpected member: " + member)
throw IllegalStateException("Unexpected member: $member")
}
}
}
@@ -320,7 +307,9 @@ class MultifileClassCodegenImpl(
throw IllegalStateException("shouldn't be called")
}
override fun generateBody(mv: MethodVisitor, frameMap: FrameMap, signature: JvmMethodSignature, context: MethodContext, parentCodegen: MemberCodegen<*>) {
override fun generateBody(
mv: MethodVisitor, frameMap: FrameMap, signature: JvmMethodSignature, context: MethodContext, parentCodegen: MemberCodegen<*>
) {
throw IllegalStateException("shouldn't be called")
}
}
@@ -340,15 +329,29 @@ class MultifileClassCodegenImpl(
arv.visit(null, internalName)
}
arv.visitEnd()
val kotlinPackageFqName =
packageFragment?.fqName ?: compiledPackageFragment?.fqName
?: error("Either source package or compiled package should not be null: $facadeClassType ($files)")
if (files.any { it.packageFqName != kotlinPackageFqName })
throw UnsupportedOperationException(
"Multi-file parts of a facade with JvmPackageName should all lie in the same Kotlin package:\n " +
files.joinToString("\n ") { file -> "$file: package ${file.packageFqName}" }
)
if (kotlinPackageFqName != JvmClassName.byInternalName(facadeClassType.internalName).packageFqName) {
av.visit(JvmAnnotationNames.METADATA_PACKAGE_NAME_FIELD_NAME, kotlinPackageFqName.asString())
}
}
}
private fun createCodegenForDelegatesInMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
object : MemberCodegen<KtFile>(state, null, facadeContext, null, classBuilder) {
override fun generateDeclaration() = throw UnsupportedOperationException()
override fun generateBody() = throw UnsupportedOperationException()
override fun generateKotlinMetadataAnnotation() = throw UnsupportedOperationException()
}
object : MemberCodegen<KtFile>(state, null, facadeContext, null, classBuilder) {
override fun generateDeclaration() = throw UnsupportedOperationException()
override fun generateBody() = throw UnsupportedOperationException()
override fun generateKotlinMetadataAnnotation() = throw UnsupportedOperationException()
}
private fun done() {
classBuilder.done()
@@ -359,19 +362,12 @@ class MultifileClassCodegenImpl(
companion object {
private val J_L_OBJECT = AsmTypes.OBJECT_TYPE.internalName
private val FACADE_CLASS_ATTRIBUTES = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL or Opcodes.ACC_SUPER
private const val FACADE_CLASS_ATTRIBUTES = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL or Opcodes.ACC_SUPER
private fun getOnlyPackageFragment(packageFqName: FqName, files: Collection<KtFile>, moduleDescriptor: ModuleDescriptor): PackageFragmentDescriptor? {
val fragments = SmartList<PackageFragmentDescriptor>()
for (file in files) {
val fragment = moduleDescriptor.findPackageFragmentForFile(file)
?: throw AssertionError("package fragment is null for " + file + "\n" + file.text)
assert(packageFqName == fragment.fqName) { "expected package fq name: " + packageFqName + ", actual: " + fragment.fqName }
if (!fragments.contains(fragment)) {
fragments.add(fragment)
}
private fun getOnlyPackageFragment(files: Collection<KtFile>, moduleDescriptor: ModuleDescriptor): PackageFragmentDescriptor? {
val fragments = files.mapTo(linkedSetOf()) { file ->
moduleDescriptor.findPackageFragmentForFile(file)
?: throw AssertionError("package fragment is null for " + file + "\n" + file.text)
}
if (fragments.size > 1) {
throw IllegalStateException("More than one package fragment, files: $files | fragments: $fragments")
@@ -383,16 +379,15 @@ class MultifileClassCodegenImpl(
CodegenUtil.getMemberDeclarationsToGenerate(this).isNotEmpty()
private fun getCompiledPackageFragment(
facadeFqName: FqName, state: GenerationState
facadeFqName: FqName, state: GenerationState
): IncrementalPackageFragmentProvider.IncrementalMultifileClassPackageFragment? {
if (!IncrementalCompilation.isEnabledForJvm()) return null
val packageFqName = facadeFqName.parent()
val incrementalPackageFragment = state.module.getPackage(packageFqName).fragments.firstOrNull { fragment ->
fragment is IncrementalPackageFragmentProvider.IncrementalPackageFragment &&
fragment.target == state.targetId
} as IncrementalPackageFragmentProvider.IncrementalPackageFragment?
fragment is IncrementalPackageFragmentProvider.IncrementalPackageFragment && fragment.target == state.targetId
} as IncrementalPackageFragmentProvider.IncrementalPackageFragment?
return incrementalPackageFragment?.getPackageFragmentForMultifileClass(facadeFqName)
}

View File

@@ -22,20 +22,22 @@ import org.jetbrains.kotlin.codegen.context.MultifileClassPartContext
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.METADATA_PACKAGE_NAME_FIELD_NAME
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.org.objectweb.asm.Opcodes
class MultifileClassPartCodegen(
v: ClassBuilder,
file: KtFile,
private val packageFragment: PackageFragmentDescriptor,
private val superClassInternalName: String,
private val shouldGeneratePartHierarchy: Boolean,
partContext: MultifileClassPartContext,
state: GenerationState
v: ClassBuilder,
file: KtFile,
private val packageFragment: PackageFragmentDescriptor,
private val superClassInternalName: String,
private val shouldGeneratePartHierarchy: Boolean,
partContext: MultifileClassPartContext,
state: GenerationState
) : MemberCodegen<KtFile>(state, null, partContext, file, v) {
private val partType = partContext.filePartType
private val facadeClassType = partContext.multifileClassType
@@ -97,6 +99,11 @@ class MultifileClassPartCodegen(
writeKotlinMetadata(v, state, KotlinClassHeader.Kind.MULTIFILE_CLASS_PART, extraFlags) { av ->
AsmUtil.writeAnnotationData(av, serializer, packageProto)
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, facadeClassType.internalName)
val kotlinPackageFqName = element.packageFqName
if (kotlinPackageFqName != JvmClassName.byInternalName(partType.internalName).packageFqName) {
av.visit(METADATA_PACKAGE_NAME_FIELD_NAME, kotlinPackageFqName.asString())
}
}
}

View File

@@ -6,11 +6,11 @@
package org.jetbrains.kotlin.codegen.state
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.jvm.*
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
import java.security.MessageDigest
import java.util.*
@@ -44,7 +44,7 @@ private fun getSignatureElementForMangling(type: KotlinType): String = buildStri
}
is TypeParameterDescriptor -> {
append(getSignatureElementForMangling(getRepresentativeUpperBound(descriptor)))
append(getSignatureElementForMangling(descriptor.representativeUpperBound))
}
}
}

View File

@@ -62,7 +62,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(
value = "-jvm-target",
valueDescription = "<version>",
description = "Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6"
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11 or 12), default is 1.6"
)
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)

View File

@@ -140,7 +140,7 @@ object TopDownAnalyzerFacadeForJVM {
val sourceScope = if (separateModules) sourceModuleSearchScope else GlobalSearchScope.allScope(project)
val moduleClassResolver = SourceOrBinaryModuleClassResolver(sourceScope)
val jvmTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.JVM_1_6
val jvmTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET, JvmTarget.DEFAULT)
val languageVersionSettings = configuration.languageVersionSettings
val optionalBuiltInsModule =

View File

@@ -56,7 +56,8 @@ open class GenericReplChecker(
if (get(JVMConfigurationKeys.JVM_TARGET) == null) {
put(JVMConfigurationKeys.JVM_TARGET,
System.getProperty(KOTLIN_REPL_JVM_TARGET_PROPERTY)?.let { JvmTarget.fromString(it) }
?: if (getJavaVersion() >= 0x10008) JvmTarget.JVM_1_8 else JvmTarget.JVM_1_6)
?: System.getProperty("java.specification.version")?.let { JvmTarget.fromString(it) }
?: JvmTarget.DEFAULT)
}
}
KotlinCoreEnvironment.createForProduction(disposable, compilerConfiguration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
@@ -97,21 +98,3 @@ open class GenericReplChecker(
}
}
}
// initially taken from libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt
// fixed according to JEP 223 - http://openjdk.java.net/jeps/223
// TODO: consider to place it to some common place
private fun getJavaVersion(): Int {
val default = 0x10006
val version = System.getProperty("java.specification.version") ?: return default
val components = version.split('.')
return try {
when (components.size) {
0 -> default
1 -> components[0].toInt() * 0x10000
else -> components[0].toInt() * 0x10000 + components[1].toInt()
}
} catch (e: NumberFormatException) {
default
}
}

View File

@@ -25,10 +25,10 @@ sourceSets {
"test" {}
}
publish()
val jar: Jar by tasks
runtimeJar(rewriteDepsToShadedCompiler(jar))
sourcesJar()
javadocJar()
publish()

View File

@@ -41,6 +41,8 @@ sourceSets {
"test" {}
}
publish()
noDefaultJar()
runtimeJar(task<ShadowJar>("shadowJar")) {
@@ -55,5 +57,3 @@ javadocJar()
dist()
ideaPlugin()
publish()

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.config
import org.jetbrains.org.objectweb.asm.Opcodes
@@ -21,10 +22,13 @@ import org.jetbrains.org.objectweb.asm.Opcodes
enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_1_6("1.6"),
JVM_1_8("1.8"),
JVM_9("9"),
JVM_10("10"),
JVM_11("11"),
JVM_12("12"),
;
val bytecodeVersion: Int by lazy {
@Suppress("DEPRECATION")
when (this) {
JVM_1_6 -> Opcodes.V1_6
JVM_1_8 ->
@@ -33,6 +37,10 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
java.lang.Boolean.valueOf(System.getProperty("kotlin.test.substitute.bytecode.1.8.to.1.9")) -> Opcodes.V9
else -> Opcodes.V1_8
}
JVM_9 -> Opcodes.V9
JVM_10 -> Opcodes.V9 + 1
JVM_11 -> Opcodes.V9 + 2
JVM_12 -> Opcodes.V9 + 3
}
}
@@ -44,16 +52,13 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
fun fromString(string: String) = values().find { it.description == string }
fun getDescription(bytecodeVersion: Int): String {
@Suppress("DEPRECATION")
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?:
when (bytecodeVersion) {
Opcodes.V1_7 -> "1.7"
Opcodes.V9 -> "1.9"
else -> null
}
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?: when (bytecodeVersion) {
Opcodes.V1_7 -> "1.7"
else -> null
}
return if (platformDescription != null) "JVM target $platformDescription"
else "JVM bytecode version $bytecodeVersion"
else "JVM bytecode version $bytecodeVersion"
}
}
}

View File

@@ -82,7 +82,7 @@ object JvmAnalyzerFacade : ResolverForModuleFactory() {
resolverForModule.componentProvider.get<JavaDescriptorResolver>()
}
val jvmTarget = targetPlatformVersion as? JvmTarget ?: JvmTarget.JVM_1_6
val jvmTarget = targetPlatformVersion as? JvmTarget ?: JvmTarget.DEFAULT
val trace = CodeAnalyzerInitializer.getInstance(project).createTrace()
val lookupTracker = LookupTracker.DO_NOTHING

View File

@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
val supportDefaults = jvmTarget == JvmTarget.JVM_1_8
val supportDefaults = jvmTarget >= JvmTarget.JVM_1_8
val descriptor = resolvedCall.resultingDescriptor as? CallableMemberDescriptor ?: return
if (descriptor is JavaPropertyDescriptor) return

View File

@@ -28,7 +28,10 @@ import org.jetbrains.kotlin.resolve.AdditionalAnnotationChecker
import org.jetbrains.kotlin.resolve.AnnotationChecker
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.descriptorUtil.*
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
@@ -81,12 +84,8 @@ object FileClassAnnotationsChecker: AdditionalAnnotationChecker {
if (classDescriptor.getAnnotationRetention() != KotlinRetention.SOURCE) {
trace.report(ErrorsJvm.ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES.on(entry, classFqName))
}
if (classFqName == JvmFileClassUtil.JVM_PACKAGE_NAME) {
trace.report(ErrorsJvm.JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES.on(entry))
}
}
}
else {
} else {
for ((entry, classDescriptor) in fileAnnotationsToCheck) {
if (classDescriptor.fqNameSafe != JvmFileClassUtil.JVM_PACKAGE_NAME) continue
@@ -97,13 +96,11 @@ object FileClassAnnotationsChecker: AdditionalAnnotationChecker {
val value = (stringTemplateEntries.singleOrNull() as? KtLiteralStringTemplateEntry)?.text
if (value == null) {
trace.report(ErrorsJvm.JVM_PACKAGE_NAME_CANNOT_BE_EMPTY.on(entry))
}
else if (!isValidJavaFqName(value)) {
} else if (!isValidJavaFqName(value)) {
trace.report(ErrorsJvm.JVM_PACKAGE_NAME_MUST_BE_VALID_NAME.on(entry))
}
else if (entry.containingKtFile.declarations.any {
it !is KtFunction && it !is KtProperty && it !is KtTypeAlias
}) {
} else if (entry.containingKtFile.declarations.any {
it !is KtFunction && it !is KtProperty && it !is KtTypeAlias
}) {
trace.report(ErrorsJvm.JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES.on(entry))
}
}

View File

@@ -67,7 +67,6 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(NON_SOURCE_REPEATED_ANNOTATION, "Repeatable annotations with non-SOURCE retention are not yet supported");
MAP.put(ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES, "Annotation ''@{0}'' is not applicable to the multi-file classes", TO_STRING);
MAP.put(JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES, "''@JvmPackageName'' annotation is not supported in multi-file classes");
MAP.put(JVM_PACKAGE_NAME_CANNOT_BE_EMPTY, "''@JvmPackageName'' annotation value cannot be empty");
MAP.put(JVM_PACKAGE_NAME_MUST_BE_VALID_NAME, "''@JvmPackageName'' annotation value must be a valid dot-qualified name of a package");
MAP.put(JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES, "''@JvmPackageName'' annotation is not supported for files with class declarations");

View File

@@ -68,7 +68,6 @@ public interface ErrorsJvm {
DiagnosticFactory0<KtAnnotationEntry> NON_SOURCE_REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<KtAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_CANNOT_BE_EMPTY = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_MUST_BE_VALID_NAME = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES = DiagnosticFactory0.create(ERROR);

View File

@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContext.*
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
@@ -736,7 +737,9 @@ class ControlFlowInformationProvider private constructor(
return
}
!languageVersionSettings.supportsFeature(LanguageFeature.WarningOnMainUnusedParameter) -> {
trace.record(UNUSED_MAIN_PARAMETER, element)
if (owner.containingClassOrObject == null) {
trace.record(UNUSED_MAIN_PARAMETER, element)
}
return
}
}

View File

@@ -231,6 +231,8 @@ public interface Errors {
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_CONST = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtExpression> ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtAnnotatedExpression> ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtAnnotationEntry> ANNOTATION_USED_AS_ANNOTATION_ARGUMENT = DiagnosticFactory0.create(ERROR);
@@ -798,6 +800,8 @@ public interface Errors {
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_ENUM_COMPARISON =
DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_ENUM_COMPARISON_ERROR =
DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);

View File

@@ -741,6 +741,7 @@ public class DefaultErrorMessages {
}, RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_ENUM_COMPARISON, "Comparison of incompatible enums ''{0}'' and ''{1}'' is always unsuccessful", RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_ENUM_COMPARISON_ERROR, "Comparison of incompatible enums ''{0}'' and ''{1}'' is always unsuccessful", RENDER_TYPE, RENDER_TYPE);
MAP.put(SENSELESS_COMPARISON, "Condition ''{0}'' is always ''{1}''", ELEMENT_TEXT, TO_STRING);
MAP.put(SENSELESS_NULL_IN_WHEN, "Expression under 'when' is never equal to null");
@@ -866,6 +867,8 @@ public class DefaultErrorMessages {
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_CONST, "An annotation argument must be a compile-time constant");
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST, "An enum annotation argument must be a enum constant");
MAP.put(ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL, "An annotation argument must be a class literal (T::class)");
MAP.put(ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER, "Type parameter in a class literal is not allowed in an annotation argument");
MAP.put(ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR, "Type parameter in a class literal is deprecated in an annotation argument");
MAP.put(ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT, "Default value of annotation parameter must be a compile-time constant");
MAP.put(ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE,

View File

@@ -127,7 +127,13 @@ class ConstantExpressionEvaluator(
val descriptor = expressionType.constructor.declarationDescriptor
val diagnosticFactory = when {
DescriptorUtils.isEnumClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST
descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL
descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> {
if (isTypeParameterOrArrayOfTypeParameter(expressionType.arguments.singleOrNull()?.type)) {
Errors.ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR
} else {
Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL
}
}
else -> Errors.ANNOTATION_ARGUMENT_MUST_BE_CONST
}
@@ -177,6 +183,8 @@ class ConstantExpressionEvaluator(
} else {
trace.report(Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL.on(argumentExpression))
}
} else if (doubleColonLhs is DoubleColonLHS.Type && isTypeParameterOrArrayOfTypeParameter(doubleColonLhs.type)) {
trace.report(Errors.ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER.on(argumentExpression))
}
}
}
@@ -324,6 +332,13 @@ class ConstantExpressionEvaluator(
fun getPossiblyErrorConstant(expression: KtExpression, bindingContext: BindingContext): CompileTimeConstant<*>? {
return bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression)
}
internal fun isTypeParameterOrArrayOfTypeParameter(type: KotlinType?): Boolean =
when {
type == null -> false
KotlinBuiltIns.isArray(type) -> isTypeParameterOrArrayOfTypeParameter(type.arguments.singleOrNull()?.type)
else -> type.constructor.declarationDescriptor is TypeParameterDescriptor
}
}
}
@@ -336,6 +351,7 @@ private class ConstantExpressionEvaluatorVisitor(
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
private val trace: BindingTrace
) : KtVisitor<CompileTimeConstant<*>?, KotlinType>() {
private val languageVersionSettings = constantExpressionEvaluator.languageVersionSettings
private val builtIns = constantExpressionEvaluator.module.builtIns
fun evaluate(expression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
@@ -613,7 +629,8 @@ private class ConstantExpressionEvaluatorVisitor(
trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression))
if ((isIntegerType(argumentForReceiver.value) && isIntegerType(argumentForParameter.value)) ||
!constantExpressionEvaluator.languageVersionSettings.supportsFeature(LanguageFeature.DivisionByZeroInConstantExpressions)) {
!languageVersionSettings.supportsFeature(LanguageFeature.DivisionByZeroInConstantExpressions)
) {
return ErrorValue.create("Division by zero").wrap()
}
}
@@ -883,11 +900,19 @@ private class ConstantExpressionEvaluatorVisitor(
}
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
val type = trace.getType(expression)!!
if (type.isError) return null
val descriptor = type.constructor.declarationDescriptor
val kClassType = trace.getType(expression)!!
if (kClassType.isError) return null
val descriptor = kClassType.constructor.declarationDescriptor
if (descriptor !is ClassDescriptor || !KotlinBuiltIns.isKClass(descriptor)) return null
return KClassValue.create(type.arguments.first().type)?.wrap()
val type = kClassType.arguments.singleOrNull()?.type ?: return null
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitTypeParametersInClassLiteralsInAnnotationArguments) &&
ConstantExpressionEvaluator.isTypeParameterOrArrayOfTypeParameter(type)
) {
return null
}
return KClassValue.create(type)?.wrap()
}
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>?> {
@@ -983,12 +1008,7 @@ private class ConstantExpressionEvaluatorVisitor(
parameters: CompileTimeConstant.Parameters,
expectedType: KotlinType
): CompileTimeConstant<*>? {
if (parameters.isUnsignedNumberLiteral &&
!checkAccessibilityOfUnsignedTypes(
constantExpressionEvaluator.module,
constantExpressionEvaluator.languageVersionSettings
)
) {
if (parameters.isUnsignedNumberLiteral && !checkAccessibilityOfUnsignedTypes()) {
return UnsignedErrorValueTypeConstant(value, parameters)
}
@@ -1019,8 +1039,8 @@ private class ConstantExpressionEvaluatorVisitor(
}.wrap(parameters)
}
private fun checkAccessibilityOfUnsignedTypes(module: ModuleDescriptor, languageVersionSettings: LanguageVersionSettings): Boolean {
val uInt = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) ?: return false
private fun checkAccessibilityOfUnsignedTypes(): Boolean {
val uInt = constantExpressionEvaluator.module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.uInt) ?: return false
val accessibility = uInt.checkSinceKotlinVersionAccessibility(languageVersionSettings)
// Case `NotAccessibleButWasExperimental` will be checked later in `checkExperimentalityOfConstantLiteral`
return accessibility is SinceKotlinAccessibility.Accessible

View File

@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.CallHandle;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
import java.util.*;
@@ -41,11 +40,6 @@ public class TypeIntersector {
return intersectTypes(new LinkedHashSet<>(Arrays.asList(typeA, typeB))) == null;
}
public static boolean isIncompatibleEnums(@NotNull KotlinType typeA, @NotNull KotlinType typeB) {
if (!TypeUtilsKt.isEnum(typeA) || !TypeUtilsKt.isEnum(typeB)) return false;
return !typeA.getConstructor().equals(typeB.getConstructor());
}
@Nullable
public static KotlinType intersectTypes(@NotNull Collection<KotlinType> types) {
assert !types.isEmpty() : "Attempting to intersect empty collection of types, this case should be dealt with on the call site.";

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. 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.types
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
import org.jetbrains.kotlin.types.typeUtil.*
fun checkEnumsForCompatibility(context: ExpressionTypingContext, reportOn: KtElement, typeA: KotlinType, typeB: KotlinType) {
if (isIncompatibleEnums(typeA, typeB)) {
val diagnostic = if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitComparisonOfIncompatibleEnums)) {
Errors.INCOMPATIBLE_ENUM_COMPARISON_ERROR
} else {
Errors.INCOMPATIBLE_ENUM_COMPARISON
}
context.trace.report(diagnostic.on(reportOn, typeA, typeB))
}
}
private fun isIncompatibleEnums(typeA: KotlinType, typeB: KotlinType): Boolean {
if (!typeA.isEnum() && !typeB.isEnum()) return false
if (TypeUtils.isNullableType(typeA) && TypeUtils.isNullableType(typeB)) return false
// TODO: remove this line once KT-30266 will be fixed
// For now, this check is needed as isSubClass contains bug wrt Nothing
if (typeA.isNothingOrNullableNothing() || typeB.isNothingOrNullableNothing()) return false
val representativeTypeA = typeA.representativeTypeForTypeParameter()
val representativeTypeB = typeB.representativeTypeForTypeParameter()
val classA = representativeTypeA.constructor.declarationDescriptor as? ClassDescriptor ?: return false
val classB = representativeTypeB.constructor.declarationDescriptor as? ClassDescriptor ?: return false
return !DescriptorUtils.isSubclass(classA, classB) && !DescriptorUtils.isSubclass(classB, classA)
}
private fun KotlinType.representativeTypeForTypeParameter(): KotlinType {
val descriptor = constructor.declarationDescriptor
return if (descriptor is TypeParameterDescriptor) descriptor.representativeUpperBound else this
}

View File

@@ -1430,10 +1430,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (rightType != null) {
if (TypeIntersector.isIntersectionEmpty(leftType, rightType)) {
context.trace.report(EQUALITY_NOT_APPLICABLE.on(expression, expression.getOperationReference(), leftType, rightType));
} else {
EnumCompatibilityCheckerKt.checkEnumsForCompatibility(context, expression, leftType, rightType);
}
else if (TypeIntersector.isIncompatibleEnums(leftType, rightType)) {
context.trace.report(INCOMPATIBLE_ENUM_COMPARISON.on(expression, leftType, rightType));
}
SenselessComparisonChecker.checkSenselessComparisonWithNull(
expression, left, right, context,

View File

@@ -684,9 +684,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
return
}
if (TypeIntersector.isIncompatibleEnums(type, subjectType)) {
context.trace.report(INCOMPATIBLE_ENUM_COMPARISON.on(reportErrorOn, subjectType, type))
}
checkEnumsForCompatibility(context, reportErrorOn, subjectType, type)
// check if the pattern is essentially a 'null' expression
if (KotlinBuiltIns.isNullableNothing(type) && !TypeUtils.isNullableType(subjectType)) {

View File

@@ -6,18 +6,18 @@
package org.jetbrains.kotlin.backend.common.descriptors
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.toKotlinType
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.isAnnotationClass
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.constants.*
@@ -41,13 +41,20 @@ abstract class WrappedDeclarationDescriptor<T : IrDeclaration>(annotations: Anno
private val annotationsFromOwner by lazy {
val ownerAnnotations = (owner as? IrAnnotationContainer)?.annotations ?: return@lazy Annotations.EMPTY
Annotations.create(ownerAnnotations.map { call ->
AnnotationDescriptorImpl(
call.symbol.owner.parentAsClass.defaultType.toKotlinType(),
call.symbol.owner.valueParameters.associate { it.name to call.getValueArgument(it.index)!!.toConstantValue() },
/*TODO*/ SourceElement.NO_SOURCE
)
})
Annotations.create(ownerAnnotations.map { it.toAnnotationDescriptor() })
}
private fun IrCall.toAnnotationDescriptor(): AnnotationDescriptor {
assert(symbol.owner is IrConstructor && symbol.owner.parentAsClass.isAnnotationClass) {
"Expected call to constructor of annotation class but was: ${this.dump()}"
}
return AnnotationDescriptorImpl(
symbol.owner.parentAsClass.defaultType.toKotlinType(),
symbol.owner.valueParameters.map { it.name to getValueArgument(it.index) }
.filter { it.second != null }
.associate { it.first to it.second!!.toConstantValue() },
/*TODO*/ SourceElement.NO_SOURCE
)
}
private fun IrElement.toConstantValue(): ConstantValue<*> {
@@ -77,7 +84,9 @@ abstract class WrappedDeclarationDescriptor<T : IrDeclaration>(annotations: Anno
this is IrClassReference -> KClassValue(classType.classifierOrFail.descriptor.classId!!, /*TODO*/0)
else -> error("$this is not expected")
this is IrCall -> AnnotationValue(this.toAnnotationDescriptor())
else -> error("$this is not expected: ${this.dump()}")
}
}
@@ -583,7 +592,7 @@ open class WrappedClassDescriptor(
private val _typeConstructor: TypeConstructor by lazy {
LazyTypeConstructor(
this,
{ emptyList() },
{ owner.typeParameters.map { it.descriptor } },
{ owner.superTypes.map { it.toKotlinType() } },
LockBasedStorageManager.NO_LOCKS
)

View File

@@ -271,3 +271,42 @@ fun IrBuilderWithScope.irSetField(receiver: IrExpression, irField: IrField, valu
value = value,
type = context.irBuiltIns.unitType
)
inline fun IrBuilderWithScope.irBlock(
startOffset: Int = this.startOffset,
endOffset: Int = this.endOffset,
origin: IrStatementOrigin? = null,
resultType: IrType? = null,
body: IrBlockBuilder.() -> Unit
): IrExpression =
IrBlockBuilder(
context, scope,
startOffset,
endOffset,
origin, resultType
).block(body)
inline fun IrBuilderWithScope.irComposite(
startOffset: Int = this.startOffset,
endOffset: Int = this.endOffset,
origin: IrStatementOrigin? = null,
resultType: IrType? = null,
body: IrBlockBuilder.() -> Unit
): IrExpression =
IrBlockBuilder(
context, scope,
startOffset,
endOffset,
origin, resultType, true
).block(body)
inline fun IrBuilderWithScope.irBlockBody(
startOffset: Int = this.startOffset,
endOffset: Int = this.endOffset,
body: IrBlockBodyBuilder.() -> Unit
): IrBlockBody =
IrBlockBodyBuilder(
context, scope,
startOffset,
endOffset
).blockBody(body)

View File

@@ -143,8 +143,7 @@ fun <T : IrBuilder> T.at(startOffset: Int, endOffset: Int) = apply {
}
inline fun IrGeneratorWithScope.irBlock(
startOffset: Int = UNDEFINED_OFFSET,
endOffset: Int = UNDEFINED_OFFSET,
startOffset: Int, endOffset: Int,
origin: IrStatementOrigin? = null,
resultType: IrType? = null,
body: IrBlockBuilder.() -> Unit
@@ -157,8 +156,7 @@ inline fun IrGeneratorWithScope.irBlock(
).block(body)
inline fun IrGeneratorWithScope.irComposite(
startOffset: Int = UNDEFINED_OFFSET,
endOffset: Int = UNDEFINED_OFFSET,
startOffset: Int, endOffset: Int,
origin: IrStatementOrigin? = null,
resultType: IrType? = null,
body: IrBlockBuilder.() -> Unit
@@ -171,7 +169,7 @@ inline fun IrGeneratorWithScope.irComposite(
).block(body)
inline fun IrGeneratorWithScope.irBlockBody(
startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET,
startOffset: Int, endOffset: Int,
body: IrBlockBodyBuilder.() -> Unit
): IrBlockBody =
IrBlockBodyBuilder(

View File

@@ -431,6 +431,9 @@ fun PsiElement.before(element: PsiElement) = textRange.endOffset <= element.text
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRow() = parents.takeWhile { it is T }.lastOrNull() as? T
inline fun <reified T : PsiElement> PsiElement.getLastParentOfTypeInRowWithSelf() = parentsWithSelf
.takeWhile { it is T }.lastOrNull() as? T
fun KtModifierListOwner.hasExpectModifier() = hasModifier(KtTokens.HEADER_KEYWORD) || hasModifier(KtTokens.EXPECT_KEYWORD)
fun KtModifierList.hasExpectModifier() = hasModifier(KtTokens.HEADER_KEYWORD) || hasModifier(KtTokens.EXPECT_KEYWORD)

View File

@@ -5,7 +5,7 @@ where possible options include:
-include-runtime Include Kotlin runtime in to resulting .jar
-java-parameters Generate metadata for Java 1.8 reflection on method parameters
-jdk-home <path> Path to JDK home directory to include into classpath, if differs from default JAVA_HOME
-jvm-target <version> Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6
-jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11 or 12), default is 1.6
-module-name <name> Name of the generated .kotlin_module file
-no-jdk Don't include Java runtime into classpath
-no-reflect Don't include kotlin-reflect.jar into classpath

View File

@@ -1,3 +1,3 @@
error: unknown JVM target version: 1.5
Supported versions: 1.6, 1.8
Supported versions: 1.6, 1.8, 9, 10, 11, 12
COMPILATION_ERROR

View File

@@ -0,0 +1,41 @@
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: A1.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
@file:JvmName("Facade")
@file:JvmMultifileClass
package foo.bar
val g: S? get() = f().substring(0, 0) + "K"
// FILE: A2.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
@file:JvmName("Facade")
@file:JvmMultifileClass
package foo.bar
inline fun <T> i(block: () -> T): T = block()
// FILE: A3.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
@file:JvmName("Facade")
@file:JvmMultifileClass
package foo.bar
typealias S = String
fun f(): String = "O"
// FILE: B.kt
import foo.bar.*
fun box(): S = i { f() + g }

View File

@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
expect class C {
val value: String
fun test(result: String = value): String
}
// FILE: platform.kt
actual class C(actual val value: String) {
actual fun test(result: String): String = result
}
fun box() = C("Fail").test("OK")

View File

@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
class Receiver(val value: String)
expect fun Receiver.test(result: String = value): String
// FILE: platform.kt
actual fun Receiver.test(result: String): String {
return result
}
fun box() = Receiver("Fail").test("OK")

View File

@@ -0,0 +1,17 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JVM_IR
// FILE: common.kt
class B(val value: Int)
expect fun test(a: Int = 2, b: Int = B(a * 2).value, c: String = "${b}$a"): String
// FILE: platform.kt
actual fun test(a: Int, b: Int, c: String): String = c
fun box(): String {
val result = test()
return if (result == "42") "OK" else "Fail: $result"
}

View File

@@ -0,0 +1,31 @@
// !LANGUAGE: +MultiPlatformProjects
// NO_CHECK_LAMBDA_INLINING
// IGNORE_BACKEND: JVM_IR
// FILE: 1.kt
class C(val s1: String, val s2: String)
expect fun C.test(r1: () -> String = { s1 }, r2: () -> String = this::s2): String
actual inline fun C.test(r1: () -> String, r2: () -> String): String = r1() + r2()
expect class D {
val s1: String
val s2: String
fun test(r1: () -> String = { s1 }, r2: () -> String = this::s2): String
}
actual class D(actual val s1: String, actual val s2: String) {
actual inline fun test(r1: () -> String, r2: () -> String): String = r1() + r2()
}
// FILE: 2.kt
fun box(): String {
if (C("O", "K").test() != "OK") return "Fail extension receiver"
if (D("O", "K").test() != "OK") return "Fail dispatch receiver"
return "OK"
}

View File

@@ -0,0 +1,25 @@
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: A.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
@file:JvmName("Facade")
@file:JvmMultifileClass
package foo.bar
typealias S = String
fun f(): String = "O"
val g: S? get() = f().substring(0, 0) + "K"
inline fun <T> i(block: () -> T): T = block()
// FILE: B.kt
import foo.bar.*
fun box(): S = i { f() + g }

View File

@@ -1,4 +1,4 @@
// WITH_REFLECT
// !LANGUAGE: +ProhibitTypeParametersInClassLiteralsInAnnotationArguments
import kotlin.reflect.KClass
@@ -35,4 +35,11 @@ fun test7() {}
fun test8() {}
inline val <reified T> T.test9
get() = @Ann(T::class) object {}
get() = @AnnArray(<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>arrayOf(
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>T::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>Array<T>::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>Array<Array<Array<T>>>::class<!>
)<!>) object {}
inline val <reified T> T.test10
get() = @AnnArray(<!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>[<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR!>T::class<!>]<!>) object {}

View File

@@ -1,5 +1,6 @@
package
public val </*0*/ reified T> T.test10: kotlin.Any
public val </*0*/ reified T> T.test9: kotlin.Any
public fun foo(): kotlin.String
@Ann(k = kotlin.String::class) public fun test1(): kotlin.Unit

View File

@@ -0,0 +1,12 @@
// !LANGUAGE: -ProhibitTypeParametersInClassLiteralsInAnnotationArguments
import kotlin.reflect.KClass
annotation class Ann(vararg val k: KClass<*>)
inline val <reified T> T.test
get() = @Ann(
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>T::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>Array<T>::class<!>,
<!ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER!>Array<Array<Array<T>>>::class<!>
) object {}

View File

@@ -0,0 +1,11 @@
package
public val </*0*/ reified T> T.test: kotlin.Any
public final annotation class Ann : kotlin.Annotation {
public constructor Ann(/*0*/ vararg k: kotlin.reflect.KClass<*> /*kotlin.Array<out kotlin.reflect.KClass<*>>*/)
public final val k: kotlin.Array<out kotlin.reflect.KClass<*>>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -1,3 +1,5 @@
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
enum class E1 {
A, B
}
@@ -56,3 +58,88 @@ fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
else -> {}
}
}
interface MyInterface
open class MyOpenClass
fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == i<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>i == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == c<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>c == e1<!>
when (e1) {
<!INCOMPATIBLE_ENUM_COMPARISON!>i<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON!>c<!> -> {}
else -> {}
}
}
enum class E3 : MyInterface { X, Y }
fun foo5(i: MyInterface, a: Any) {
E3.X == E3.Y
E3.X == i
E3.X == a
}
fun foo6(e1: E1?, e2: E2) {
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E2.A == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == e1<!>
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
e1 == e2 // There should be an IDE-inspection for such cases
}
fun <T> foo8(e1: E1?, e2: E2, t: T) {
e1 == t
t == e1
e2 == t
t == e2
E1.A == t
t == E1.A
}
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
<!INCOMPATIBLE_ENUM_COMPARISON!>e1 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>e2 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E1.A == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>t == E1.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON!>E3.X == t<!>
E3.X == k
k == E3.X
}
interface Inv<T>
enum class E4 : Inv<Int> { A }
fun foo10(e4: E4, invString: Inv<String>) {
e4 == invString
invString == e4
E4.A == invString
invString == E4.A
}

View File

@@ -1,8 +1,15 @@
package
public fun foo1(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo10(/*0*/ e4: E4, /*1*/ invString: Inv<kotlin.String>): kotlin.Unit
public fun foo2(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo3(/*0*/ e1: kotlin.Enum<E1>, /*1*/ e2: kotlin.Enum<E2>, /*2*/ e: kotlin.Enum<*>): kotlin.Unit
public fun foo4(/*0*/ e1: E1, /*1*/ i: MyInterface, /*2*/ c: MyOpenClass): kotlin.Unit
public fun foo5(/*0*/ i: MyInterface, /*1*/ a: kotlin.Any): kotlin.Unit
public fun foo6(/*0*/ e1: E1?, /*1*/ e2: E2): kotlin.Unit
public fun foo7(/*0*/ e1: E1?, /*1*/ e2: E2?): kotlin.Unit
public fun </*0*/ T> foo8(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T): kotlin.Unit
public fun </*0*/ T : MyInterface, /*1*/ K : MyInterface> foo9(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T, /*3*/ k: K): kotlin.Unit where T : MyOpenClass
public final enum class E1 : kotlin.Enum<E1> {
enum entry A
@@ -45,3 +52,62 @@ public final enum class E2 : kotlin.Enum<E2> {
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E2
public final /*synthesized*/ fun values(): kotlin.Array<E2>
}
public final enum class E3 : kotlin.Enum<E3>, MyInterface {
enum entry X
enum entry Y
private constructor E3()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E3): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E3!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E3
public final /*synthesized*/ fun values(): kotlin.Array<E3>
}
public final enum class E4 : kotlin.Enum<E4>, Inv<kotlin.Int> {
enum entry A
private constructor E4()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E4): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E4!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E4
public final /*synthesized*/ fun values(): kotlin.Array<E4>
}
public interface Inv</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface MyInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class MyOpenClass {
public constructor MyOpenClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -0,0 +1,145 @@
// !LANGUAGE: +ProhibitComparisonOfIncompatibleEnums
enum class E1 {
A, B
}
enum class E2 {
A, B
}
fun foo1(e1: E1, e2: E2) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 != e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.B == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.A == E2.B<!>
e1 == E1.A
E1.A == e1
e2 == E2.B
E2.B == e2
}
fun foo2(e1: E1, e2: E2) {
when (e1) {
E1.A -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.A<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.B<!> -> {}
e1 -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2<!> -> {}
else -> {}
}
}
fun foo3(e1: Enum<E1>, e2: Enum<E2>, e: Enum<*>) {
e1 == e
e1 == e2
e1 == E1.A
e1 == E2.A
when (e1) {
e1 -> {}
e2 -> {}
e -> {}
E1.A -> {}
E2.A -> {}
else -> {}
}
when (e) {
e -> {}
e2 -> {}
E1.A -> {}
E2.A -> {}
else -> {}
}
}
interface MyInterface
open class MyOpenClass
fun foo4(e1: E1, i: MyInterface, c: MyOpenClass) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == i<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>i == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == c<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c == e1<!>
when (e1) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>i<!> -> {}
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>c<!> -> {}
else -> {}
}
}
enum class E3 : MyInterface { X, Y }
fun foo5(i: MyInterface, a: Any) {
E3.X == E3.Y
E3.X == i
E3.X == a
}
fun foo6(e1: E1?, e2: E2) {
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == E2.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E2.A == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2 == e1<!>
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
e1 == e2 // There should be an IDE-inspection for such cases
}
fun <T> foo8(e1: E1?, e2: E2, t: T) {
e1 == t
t == e1
e2 == t
t == e2
E1.A == t
t == E1.A
}
fun <T, K> foo9(e1: E1?, e2: E2, t: T, k: K) where T : MyInterface, T : MyOpenClass, K : MyInterface {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == e1<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2 == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E1.A == t<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>t == E1.A<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>E3.X == t<!>
E3.X == k
k == E3.X
}
interface Inv<T>
enum class E4 : Inv<Int> { A }
fun foo10(e4: E4, invString: Inv<String>) {
e4 == invString
invString == e4
E4.A == invString
invString == E4.A
}

View File

@@ -0,0 +1,113 @@
package
public fun foo1(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo10(/*0*/ e4: E4, /*1*/ invString: Inv<kotlin.String>): kotlin.Unit
public fun foo2(/*0*/ e1: E1, /*1*/ e2: E2): kotlin.Unit
public fun foo3(/*0*/ e1: kotlin.Enum<E1>, /*1*/ e2: kotlin.Enum<E2>, /*2*/ e: kotlin.Enum<*>): kotlin.Unit
public fun foo4(/*0*/ e1: E1, /*1*/ i: MyInterface, /*2*/ c: MyOpenClass): kotlin.Unit
public fun foo5(/*0*/ i: MyInterface, /*1*/ a: kotlin.Any): kotlin.Unit
public fun foo6(/*0*/ e1: E1?, /*1*/ e2: E2): kotlin.Unit
public fun foo7(/*0*/ e1: E1?, /*1*/ e2: E2?): kotlin.Unit
public fun </*0*/ T> foo8(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T): kotlin.Unit
public fun </*0*/ T : MyInterface, /*1*/ K : MyInterface> foo9(/*0*/ e1: E1?, /*1*/ e2: E2, /*2*/ t: T, /*3*/ k: K): kotlin.Unit where T : MyOpenClass
public final enum class E1 : kotlin.Enum<E1> {
enum entry A
enum entry B
private constructor E1()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E1): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E1!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E1
public final /*synthesized*/ fun values(): kotlin.Array<E1>
}
public final enum class E2 : kotlin.Enum<E2> {
enum entry A
enum entry B
private constructor E2()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E2): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E2!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E2
public final /*synthesized*/ fun values(): kotlin.Array<E2>
}
public final enum class E3 : kotlin.Enum<E3>, MyInterface {
enum entry X
enum entry Y
private constructor E3()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E3): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E3!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E3
public final /*synthesized*/ fun values(): kotlin.Array<E3>
}
public final enum class E4 : kotlin.Enum<E4>, Inv<kotlin.Int> {
enum entry A
private constructor E4()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E4): kotlin.Int
public final override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E4!>!
public final override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E4
public final /*synthesized*/ fun values(): kotlin.Array<E4>
}
public interface Inv</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface MyInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class MyOpenClass {
public constructor MyOpenClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -1,11 +1,5 @@
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE
// FILE: a.kt
<!JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES!>@file:JvmPackageName("a")<!>
@file:JvmMultifileClass
package a
fun a() {}
// FILE: b.kt
<!JVM_PACKAGE_NAME_CANNOT_BE_EMPTY!>@file:JvmPackageName("")<!>
package b

View File

@@ -1,9 +1,5 @@
package
package a {
public fun a(): kotlin.Unit
}
package b {
public fun b(): kotlin.Unit
}

View File

@@ -0,0 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j1")
@file:JvmName("K1")
@file:JvmMultifileClass
package k1
fun f1() {}

View File

@@ -0,0 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j1")
@file:JvmName("K1")
@file:JvmMultifileClass
package k1
val v2 = Unit

View File

@@ -0,0 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j1")
@file:JvmName("K1")
@file:JvmMultifileClass
package k1
typealias T3 = List<String>

View File

@@ -0,0 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j2")
@file:JvmName("K2")
@file:JvmMultifileClass
package k2
fun f1() {}

View File

@@ -0,0 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j3")
@file:JvmName("K2")
@file:JvmMultifileClass
package k2
val v2 = Unit

View File

@@ -0,0 +1,5 @@
@file:JvmName("K2")
@file:JvmMultifileClass
package k2
typealias T3 = List<String>

View File

@@ -0,0 +1,8 @@
k1
j1/K1__K1_AKt (j1/K1)
j1/K1__K1_BKt (j1/K1)
j1/K1__K1_CKt (j1/K1)
k2
k2/K2__K2_CKt (k2/K2)
j2/K2__K2_AKt (j2/K2)
j3/K2__K2_BKt (j3/K2)

View File

@@ -286,7 +286,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
}
}
return result ?: JvmTarget.JVM_1_6
return result ?: JvmTarget.DEFAULT
}
private fun checkDynamicCallDescriptors(expectedFile: File, testFiles: List<TestFile>) {

View File

@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.expressions.FakeCallResolver
fun createContainerForTests(project: Project, module: ModuleDescriptor): ContainerForTests {
return ContainerForTests(createContainer("Tests", JvmPlatform) {
configureModule(ModuleContext(module, project), JvmPlatform, JvmTarget.JVM_1_6)
configureModule(ModuleContext(module, project), JvmPlatform, JvmTarget.DEFAULT)
useInstance(LanguageVersionSettingsImpl.DEFAULT)
useImpl<AnnotationResolverImpl>()
useImpl<ExpressionTypingServices>()

View File

@@ -2991,6 +2991,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt");
}
@TestMetadata("inAnnotationArguments_noTypeParams.kt")
public void testInAnnotationArguments_noTypeParams() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments_noTypeParams.kt");
}
@TestMetadata("integerValueType.kt")
public void testIntegerValueType() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt");
@@ -6928,6 +6933,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums.kt");
}
@TestMetadata("incompatibleEnums_1_4.kt")
public void testIncompatibleEnums_1_4() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums_1_4.kt");
}
@TestMetadata("inheritFromEnumEntry.kt")
public void testInheritFromEnumEntry() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/inheritFromEnumEntry.kt");

View File

@@ -2986,6 +2986,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt");
}
@TestMetadata("inAnnotationArguments_noTypeParams.kt")
public void testInAnnotationArguments_noTypeParams() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments_noTypeParams.kt");
}
@TestMetadata("integerValueType.kt")
public void testIntegerValueType() throws Exception {
runTest("compiler/testData/diagnostics/tests/classLiteral/integerValueType.kt");
@@ -6923,6 +6928,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums.kt");
}
@TestMetadata("incompatibleEnums_1_4.kt")
public void testIncompatibleEnums_1_4() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/incompatibleEnums_1_4.kt");
}
@TestMetadata("inheritFromEnumEntry.kt")
public void testInheritFromEnumEntry() throws Exception {
runTest("compiler/testData/diagnostics/tests/enum/inheritFromEnumEntry.kt");

View File

@@ -14655,6 +14655,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvmPackageName/metadataField.kt");
}
@TestMetadata("multifileClass.kt")
public void testMultifileClass() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/multifileClass.kt");
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
@@ -15875,6 +15880,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/delegatedExpectedInterface.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15930,6 +15945,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
@TestMetadata("superCall.kt")
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");

View File

@@ -1890,6 +1890,37 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -1890,6 +1890,37 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractCompileKotlinAgainstInlineKotlinTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractCompileKotlinAgainstInlineKotlinTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -188,6 +188,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmPackageNameInRootPackage.kt");
}
@TestMetadata("jvmPackageNameMultifileClass.kt")
public void testJvmPackageNameMultifileClass() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmPackageNameMultifileClass.kt");
}
@TestMetadata("jvmPackageNameWithJvmName.kt")
public void testJvmPackageNameWithJvmName() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/jvmPackageNameWithJvmName.kt");

View File

@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
import org.jetbrains.kotlin.load.kotlin.loadModuleMapping
@@ -31,28 +30,28 @@ import java.io.File
class JvmModuleProtoBufTest : KtUsefulTestCase() {
private fun doTest(
relativeDirectory: String,
compileWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
loadWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
extraOptions: List<String> = emptyList()
relativeDirectory: String,
compileWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
loadWith: LanguageVersion = LanguageVersion.LATEST_STABLE,
extraOptions: List<String> = emptyList()
) {
val directory = KotlinTestUtils.getTestDataPathBase() + relativeDirectory
val tmpdir = KotlinTestUtils.tmpDir(this::class.simpleName)
val moduleName = "main"
CompilerTestUtil.executeCompilerAssertSuccessful(K2JVMCompiler(), listOf(
CompilerTestUtil.executeCompilerAssertSuccessful(
K2JVMCompiler(), listOf(
directory,
"-d", tmpdir.path,
"-module-name", moduleName,
"-language-version", compileWith.versionString
) + extraOptions)
) + extraOptions
)
val mapping = ModuleMapping.loadModuleMapping(
File(tmpdir, "META-INF/$moduleName.${ModuleMapping.MAPPING_FILE_EXT}").readBytes(), "test",
CompilerDeserializationConfiguration(
LanguageVersionSettingsImpl(loadWith, ApiVersion.createByLanguageVersion(loadWith))
),
::error
File(tmpdir, "META-INF/$moduleName.${ModuleMapping.MAPPING_FILE_EXT}").readBytes(), "test",
CompilerDeserializationConfiguration(LanguageVersionSettingsImpl(loadWith, ApiVersion.createByLanguageVersion(loadWith))),
::error
)
val result = buildString {
for (annotationClassId in mapping.moduleData.annotations) {
@@ -82,18 +81,19 @@ class JvmModuleProtoBufTest : KtUsefulTestCase() {
}
fun testJvmPackageName() {
doTest("/moduleProtoBuf/jvmPackageName",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_2)
doTest("/moduleProtoBuf/jvmPackageName")
}
fun testJvmPackageNameManyParts() {
doTest("/moduleProtoBuf/jvmPackageNameManyParts",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_2)
doTest("/moduleProtoBuf/jvmPackageNameManyParts")
}
fun testJvmPackageNameLanguageVersion11() {
doTest("/moduleProtoBuf/jvmPackageNameLanguageVersion11",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_1)
doTest("/moduleProtoBuf/jvmPackageNameLanguageVersion11", loadWith = LanguageVersion.KOTLIN_1_1)
}
fun testJvmPackageNameMultifileClass() {
doTest("/moduleProtoBuf/jvmPackageNameMultifileClass")
}
fun testExperimental() {

View File

@@ -14655,6 +14655,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvmPackageName/metadataField.kt");
}
@TestMetadata("multifileClass.kt")
public void testMultifileClass() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/multifileClass.kt");
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
@@ -15880,6 +15885,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/constructor.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15934,6 +15949,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt23739() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
}
}

View File

@@ -14660,6 +14660,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvmPackageName/metadataField.kt");
}
@TestMetadata("multifileClass.kt")
public void testMultifileClass() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/multifileClass.kt");
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
runTest("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
@@ -15880,6 +15885,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/delegatedExpectedInterface.kt");
}
@TestMetadata("dispatchReceiverValue.kt")
public void testDispatchReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/dispatchReceiverValue.kt");
}
@TestMetadata("extensionReceiverValue.kt")
public void testExtensionReceiverValue() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/extensionReceiverValue.kt");
}
@TestMetadata("function.kt")
public void testFunction() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/function.kt");
@@ -15935,6 +15950,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/kt23739.kt");
}
@TestMetadata("parametersInArgumentValues.kt")
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
@TestMetadata("superCall.kt")
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");

View File

@@ -1890,6 +1890,37 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
}
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Multiplatform extends AbstractIrBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("compiler/testData/codegen/boxInline/multiplatform/defaultArguments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractIrBlackBoxInlineCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/multiplatform/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("receiversAndParametersInLambda.kt")
public void testReceiversAndParametersInLambda() throws Exception {
runTest("compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/noInline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -100,6 +100,8 @@ enum class LanguageFeature(
ProperInlineFromHigherPlatformDiagnostic(KOTLIN_1_4, kind = BUG_FIX),
ProhibitRepeatedUseSiteTargetAnnotations(KOTLIN_1_4, kind = BUG_FIX),
ProhibitUseSiteTargetAnnotationsOnSuperTypes(KOTLIN_1_4, kind = BUG_FIX),
ProhibitTypeParametersInClassLiteralsInAnnotationArguments(KOTLIN_1_4, kind = BUG_FIX),
ProhibitComparisonOfIncompatibleEnums(KOTLIN_1_4, kind = BUG_FIX),
ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX),
// Temporarily disabled, see KT-27084/KT-22379

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
import org.jetbrains.kotlin.utils.DO_NOTHING_3
interface JvmTypeFactory<T : Any> {
@@ -181,7 +182,7 @@ fun <T : Any> mapType(
descriptor is TypeParameterDescriptor -> {
val type = mapType(
getRepresentativeUpperBound(descriptor),
descriptor.representativeUpperBound,
factory,
mode,
typeMappingConfiguration,
@@ -255,7 +256,7 @@ internal fun computeUnderlyingType(inlineClassType: KotlinType): KotlinType? {
val descriptor = inlineClassType.unsubstitutedUnderlyingType()?.constructor?.declarationDescriptor ?: return null
return if (descriptor is TypeParameterDescriptor)
getRepresentativeUpperBound(descriptor)
descriptor.representativeUpperBound
else
inlineClassType.substitutedUnderlyingType()
}
@@ -270,7 +271,7 @@ internal fun computeExpandedTypeInner(kotlinType: KotlinType, visitedClassifiers
return when {
classifier is TypeParameterDescriptor ->
computeExpandedTypeInner(getRepresentativeUpperBound(classifier), visitedClassifiers)
computeExpandedTypeInner(classifier.representativeUpperBound, visitedClassifiers)
?.let { expandedUpperBound ->
if (expandedUpperBound.isNullable() || !kotlinType.isMarkedNullable)
expandedUpperBound
@@ -338,16 +339,6 @@ fun computeInternalName(
private fun getContainer(container: DeclarationDescriptor?): DeclarationDescriptor? =
container as? ClassDescriptor ?: container as? PackageFragmentDescriptor ?: container?.let { getContainer(it.containingDeclaration) }
fun getRepresentativeUpperBound(descriptor: TypeParameterDescriptor): KotlinType {
val upperBounds = descriptor.upperBounds
assert(!upperBounds.isEmpty()) { "Upper bounds should not be empty: $descriptor" }
return upperBounds.firstOrNull {
val classDescriptor = it.constructor.declarationDescriptor as? ClassDescriptor ?: return@firstOrNull false
classDescriptor.kind != ClassKind.INTERFACE && classDescriptor.kind != ClassKind.ANNOTATION_CLASS
} ?: upperBounds.first()
}
open class JvmDescriptorTypeWriter<T : Any>(private val jvmTypeFactory: JvmTypeFactory<T>) {
private var jvmCurrentTypeArrayLevel: Int = 0
protected var jvmCurrentType: T? = null

View File

@@ -6,15 +6,11 @@
package org.jetbrains.kotlin.resolve.jvm
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.kotlin.getRepresentativeUpperBound
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.isInlineClass
import org.jetbrains.kotlin.resolve.isInlineClassType
import org.jetbrains.kotlin.types.KotlinType
import java.security.MessageDigest
import java.util.*
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
fun shouldHideConstructorDueToInlineClassTypeValueParameters(descriptor: CallableMemberDescriptor): Boolean {
val constructorDescriptor = descriptor as? ClassConstructorDescriptor ?: return false
@@ -45,5 +41,5 @@ private fun isDontMangleClass(classDescriptor: ClassDescriptor) =
private fun KotlinType.isTypeParameterWithUpperBoundThatRequiresMangling(): Boolean {
val descriptor = constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false
return getRepresentativeUpperBound(descriptor).requiresFunctionNameMangling()
return descriptor.representativeUpperBound.requiresFunctionNameMangling()
}

View File

@@ -214,10 +214,10 @@ class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(value) {
KClassValue(classId, arrayDimensions)
}
is TypeParameterDescriptor -> {
// This is possible if a reified type parameter is used in annotation on a local class / anonymous object.
// This is possible before 1.4 if a reified type parameter is used in annotation on a local class / anonymous object.
// In JVM class file, we can't represent such literal properly, so we're writing java.lang.Object instead.
// This has no effect on the compiler front-end or other back-ends, so we use kotlin.Any for simplicity here.
// Overall, it looks like such code should be disallowed: https://youtrack.jetbrains.com/issue/KT-27799
// See LanguageFeature.ProhibitTypeParametersInClassLiteralsInAnnotationArguments
KClassValue(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.any.toSafe()), 0)
}
else -> null

View File

@@ -384,20 +384,30 @@ public class TypeUtils {
public static boolean contains(
@Nullable KotlinType type,
@NotNull Function1<UnwrappedType, Boolean> isSpecialType
) {
return contains(type, isSpecialType, new HashSet<KotlinType>());
}
private static boolean contains(
@Nullable KotlinType type,
@NotNull Function1<UnwrappedType, Boolean> isSpecialType,
HashSet<KotlinType> visited
) {
if (type == null) return false;
if (visited.contains(type)) return false;
visited.add(type);
UnwrappedType unwrappedType = type.unwrap();
if (isSpecialType.invoke(unwrappedType)) return true;
FlexibleType flexibleType = unwrappedType instanceof FlexibleType ? (FlexibleType) unwrappedType : null;
if (flexibleType != null
&& (contains(flexibleType.getLowerBound(), isSpecialType) || contains(flexibleType.getUpperBound(), isSpecialType))) {
&& (contains(flexibleType.getLowerBound(), isSpecialType, visited) || contains(flexibleType.getUpperBound(), isSpecialType, visited))) {
return true;
}
if (unwrappedType instanceof DefinitelyNotNullType &&
contains(((DefinitelyNotNullType) unwrappedType).getOriginal(), isSpecialType)) {
contains(((DefinitelyNotNullType) unwrappedType).getOriginal(), isSpecialType, visited)) {
return true;
}
@@ -405,13 +415,13 @@ public class TypeUtils {
if (typeConstructor instanceof IntersectionTypeConstructor) {
IntersectionTypeConstructor intersectionTypeConstructor = (IntersectionTypeConstructor) typeConstructor;
for (KotlinType supertype : intersectionTypeConstructor.getSupertypes()) {
if (contains(supertype, isSpecialType)) return true;
if (contains(supertype, isSpecialType, visited)) return true;
}
return false;
}
for (TypeProjection projection : type.getArguments()) {
if (!projection.isStarProjection() && contains(projection.getType(), isSpecialType)) return true;
if (!projection.isStarProjection() && contains(projection.getType(), isSpecialType, visited)) return true;
}
return false;
}

View File

@@ -54,6 +54,7 @@ fun KotlinType.supertypes(): Collection<KotlinType> = TypeUtils.getAllSupertypes
fun KotlinType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this)
fun KotlinType.isNullableNothing(): Boolean = KotlinBuiltIns.isNullableNothing(this)
fun KotlinType.isNothingOrNullableNothing(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this)
fun KotlinType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this)
fun KotlinType.isAnyOrNullableAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this)
fun KotlinType.isNullableAny(): Boolean = KotlinBuiltIns.isNullableAny(this)
@@ -228,3 +229,14 @@ fun UnwrappedType.canHaveUndefinedNullability(): Boolean =
constructor is NewTypeVariableConstructor ||
constructor.declarationDescriptor is TypeParameterDescriptor ||
this is NewCapturedType
val TypeParameterDescriptor.representativeUpperBound: KotlinType
get() {
assert(upperBounds.isNotEmpty()) { "Upper bounds should not be empty: $this" }
return upperBounds.firstOrNull {
val classDescriptor = it.constructor.declarationDescriptor as? ClassDescriptor ?: return@firstOrNull false
classDescriptor.kind != ClassKind.INTERFACE && classDescriptor.kind != ClassKind.ANNOTATION_CLASS
} ?: upperBounds.first()
}

View File

@@ -25,6 +25,7 @@ class TypeDeserializer(
private val parent: TypeDeserializer?,
typeParameterProtos: List<ProtoBuf.TypeParameter>,
private val debugName: String,
private val containerPresentableName: String,
var experimentalSuspendFunctionTypeEncountered: Boolean = false
) {
private val classDescriptors: (Int) -> ClassDescriptor? = c.storageManager.createMemoizedFunctionWithNullableValues { fqNameIndex ->
@@ -112,7 +113,9 @@ class TypeDeserializer(
proto.hasClassName() -> (classDescriptors(proto.className) ?: notFoundClass(proto.className)).typeConstructor
proto.hasTypeParameter() ->
typeParameterTypeConstructor(proto.typeParameter)
?: ErrorUtils.createErrorTypeConstructor("Unknown type parameter ${proto.typeParameter}")
?: ErrorUtils.createErrorTypeConstructor(
"Unknown type parameter ${proto.typeParameter}. Please try recompiling module containing \"$containerPresentableName\""
)
proto.hasTypeParameterName() -> {
val container = c.containingDeclaration
val name = c.nameResolver.getString(proto.typeParameterName)

View File

@@ -80,7 +80,8 @@ class DeserializationContext(
) {
val typeDeserializer: TypeDeserializer = TypeDeserializer(
this, parentTypeDeserializer, typeParameters,
"Deserializer for ${containingDeclaration.name}"
"Deserializer for \"${containingDeclaration.name}\"",
containerSource?.presentableString ?: "[container not found]"
)
val memberDeserializer: MemberDeserializer = MemberDeserializer(this)

View File

@@ -41,11 +41,13 @@ message Module {
}
message PackageParts {
// Dot-separated Kotlin FQ name of the package.
required string package_fq_name = 1;
// Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
// (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
// Kotlin package name (i.e. it has not been changed with @JvmPackageName) are listed here.
// Kotlin package name (i.e. it has not been changed with @JvmPackageName) are listed here, the rest are listed in
// class_with_jvm_package_name_short_name.
repeated string short_class_name = 2;
// For each name in short_class_name, index of the name of the corresponding multi-file facade class in multifile_facade_short_name + 1,
@@ -54,12 +56,24 @@ message PackageParts {
repeated int32 multifile_facade_short_name_id = 3 [packed = true];
// Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -> facade mapping.
//
// The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by @JvmPackageName,
// and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
// otherwise behavior is unspecified.
repeated string multifile_facade_short_name = 4;
// Short names of files (single file facades), whose JVM package differs from the Kotlin package because of @JvmPackageName.
// The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
// Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
// @JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
repeated string class_with_jvm_package_name_short_name = 5;
// This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
// multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
// names of multi-file facades whose JVM package differs from the Kotlin package because of @JvmPackageName.
//
// For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
// multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];
// For each name in class_with_jvm_package_name_short_name, the index (into PackageTable#jvm_package_name) of the JVM package name.
// This list should have at least one element, otherwise classes with JVM package names are going to be ignored completely.
//

View File

@@ -1702,14 +1702,26 @@ public final class JvmModuleProtoBuf {
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
boolean hasPackageFqName();
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
java.lang.String getPackageFqName();
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ByteString
getPackageFqNameBytes();
@@ -1720,7 +1732,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -1731,7 +1744,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
int getShortClassNameCount();
@@ -1741,7 +1755,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
java.lang.String getShortClassName(int index);
@@ -1751,7 +1766,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ByteString
@@ -1793,6 +1809,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -1802,6 +1821,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
int getMultifileFacadeShortNameCount();
@@ -1810,6 +1832,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
java.lang.String getMultifileFacadeShortName(int index);
@@ -1818,6 +1843,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ByteString
@@ -1827,8 +1855,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -1837,8 +1865,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
int getClassWithJvmPackageNameShortNameCount();
@@ -1846,8 +1874,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
java.lang.String getClassWithJvmPackageNameShortName(int index);
@@ -1855,13 +1883,50 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
org.jetbrains.kotlin.protobuf.ByteString
getClassWithJvmPackageNameShortNameBytes(int index);
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
java.util.List<java.lang.Integer> getClassWithJvmPackageNameMultifileFacadeShortNameIdList();
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
int getClassWithJvmPackageNameMultifileFacadeShortNameIdCount();
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
int getClassWithJvmPackageNameMultifileFacadeShortNameId(int index);
/**
* <code>repeated int32 class_with_jvm_package_name_package_id = 6 [packed = true];</code>
*
@@ -2004,9 +2069,9 @@ public final class JvmModuleProtoBuf {
break;
}
case 48: {
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
classWithJvmPackageNamePackageId_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000020;
mutable_bitField0_ |= 0x00000040;
}
classWithJvmPackageNamePackageId_.add(input.readInt32());
break;
@@ -2014,9 +2079,9 @@ public final class JvmModuleProtoBuf {
case 50: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020) && input.getBytesUntilLimit() > 0) {
if (!((mutable_bitField0_ & 0x00000040) == 0x00000040) && input.getBytesUntilLimit() > 0) {
classWithJvmPackageNamePackageId_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000020;
mutable_bitField0_ |= 0x00000040;
}
while (input.getBytesUntilLimit() > 0) {
classWithJvmPackageNamePackageId_.add(input.readInt32());
@@ -2024,6 +2089,27 @@ public final class JvmModuleProtoBuf {
input.popLimit(limit);
break;
}
case 56: {
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
classWithJvmPackageNameMultifileFacadeShortNameId_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000020;
}
classWithJvmPackageNameMultifileFacadeShortNameId_.add(input.readInt32());
break;
}
case 58: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020) && input.getBytesUntilLimit() > 0) {
classWithJvmPackageNameMultifileFacadeShortNameId_ = new java.util.ArrayList<java.lang.Integer>();
mutable_bitField0_ |= 0x00000020;
}
while (input.getBytesUntilLimit() > 0) {
classWithJvmPackageNameMultifileFacadeShortNameId_.add(input.readInt32());
}
input.popLimit(limit);
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -2044,9 +2130,12 @@ public final class JvmModuleProtoBuf {
if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
classWithJvmPackageNameShortName_ = classWithJvmPackageNameShortName_.getUnmodifiableView();
}
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
classWithJvmPackageNamePackageId_ = java.util.Collections.unmodifiableList(classWithJvmPackageNamePackageId_);
}
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.unmodifiableList(classWithJvmPackageNameMultifileFacadeShortNameId_);
}
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -2077,12 +2166,20 @@ public final class JvmModuleProtoBuf {
private java.lang.Object packageFqName_;
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public boolean hasPackageFqName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public java.lang.String getPackageFqName() {
java.lang.Object ref = packageFqName_;
@@ -2100,6 +2197,10 @@ public final class JvmModuleProtoBuf {
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
getPackageFqNameBytes() {
@@ -2123,7 +2224,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -2136,7 +2238,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public int getShortClassNameCount() {
@@ -2148,7 +2251,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public java.lang.String getShortClassName(int index) {
@@ -2160,7 +2264,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -2216,6 +2321,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -2227,6 +2335,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public int getMultifileFacadeShortNameCount() {
@@ -2237,6 +2348,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public java.lang.String getMultifileFacadeShortName(int index) {
@@ -2247,6 +2361,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -2260,8 +2377,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -2272,8 +2389,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public int getClassWithJvmPackageNameShortNameCount() {
@@ -2283,8 +2400,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public java.lang.String getClassWithJvmPackageNameShortName(int index) {
@@ -2294,8 +2411,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -2303,6 +2420,53 @@ public final class JvmModuleProtoBuf {
return classWithJvmPackageNameShortName_.getByteString(index);
}
public static final int CLASS_WITH_JVM_PACKAGE_NAME_MULTIFILE_FACADE_SHORT_NAME_ID_FIELD_NUMBER = 7;
private java.util.List<java.lang.Integer> classWithJvmPackageNameMultifileFacadeShortNameId_;
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public java.util.List<java.lang.Integer>
getClassWithJvmPackageNameMultifileFacadeShortNameIdList() {
return classWithJvmPackageNameMultifileFacadeShortNameId_;
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public int getClassWithJvmPackageNameMultifileFacadeShortNameIdCount() {
return classWithJvmPackageNameMultifileFacadeShortNameId_.size();
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public int getClassWithJvmPackageNameMultifileFacadeShortNameId(int index) {
return classWithJvmPackageNameMultifileFacadeShortNameId_.get(index);
}
private int classWithJvmPackageNameMultifileFacadeShortNameIdMemoizedSerializedSize = -1;
public static final int CLASS_WITH_JVM_PACKAGE_NAME_PACKAGE_ID_FIELD_NUMBER = 6;
private java.util.List<java.lang.Integer> classWithJvmPackageNamePackageId_;
/**
@@ -2356,6 +2520,7 @@ public final class JvmModuleProtoBuf {
multifileFacadeShortNameId_ = java.util.Collections.emptyList();
multifileFacadeShortName_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY;
classWithJvmPackageNameShortName_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY;
classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.emptyList();
classWithJvmPackageNamePackageId_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
@@ -2401,6 +2566,13 @@ public final class JvmModuleProtoBuf {
for (int i = 0; i < classWithJvmPackageNamePackageId_.size(); i++) {
output.writeInt32NoTag(classWithJvmPackageNamePackageId_.get(i));
}
if (getClassWithJvmPackageNameMultifileFacadeShortNameIdList().size() > 0) {
output.writeRawVarint32(58);
output.writeRawVarint32(classWithJvmPackageNameMultifileFacadeShortNameIdMemoizedSerializedSize);
}
for (int i = 0; i < classWithJvmPackageNameMultifileFacadeShortNameId_.size(); i++) {
output.writeInt32NoTag(classWithJvmPackageNameMultifileFacadeShortNameId_.get(i));
}
output.writeRawBytes(unknownFields);
}
@@ -2469,6 +2641,20 @@ public final class JvmModuleProtoBuf {
}
classWithJvmPackageNamePackageIdMemoizedSerializedSize = dataSize;
}
{
int dataSize = 0;
for (int i = 0; i < classWithJvmPackageNameMultifileFacadeShortNameId_.size(); i++) {
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32SizeNoTag(classWithJvmPackageNameMultifileFacadeShortNameId_.get(i));
}
size += dataSize;
if (!getClassWithJvmPackageNameMultifileFacadeShortNameIdList().isEmpty()) {
size += 1;
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32SizeNoTag(dataSize);
}
classWithJvmPackageNameMultifileFacadeShortNameIdMemoizedSerializedSize = dataSize;
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -2573,8 +2759,10 @@ public final class JvmModuleProtoBuf {
bitField0_ = (bitField0_ & ~0x00000008);
classWithJvmPackageNameShortName_ = org.jetbrains.kotlin.protobuf.LazyStringArrayList.EMPTY;
bitField0_ = (bitField0_ & ~0x00000010);
classWithJvmPackageNamePackageId_ = java.util.Collections.emptyList();
classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000020);
classWithJvmPackageNamePackageId_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000040);
return this;
}
@@ -2623,9 +2811,14 @@ public final class JvmModuleProtoBuf {
}
result.classWithJvmPackageNameShortName_ = classWithJvmPackageNameShortName_;
if (((bitField0_ & 0x00000020) == 0x00000020)) {
classWithJvmPackageNamePackageId_ = java.util.Collections.unmodifiableList(classWithJvmPackageNamePackageId_);
classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.unmodifiableList(classWithJvmPackageNameMultifileFacadeShortNameId_);
bitField0_ = (bitField0_ & ~0x00000020);
}
result.classWithJvmPackageNameMultifileFacadeShortNameId_ = classWithJvmPackageNameMultifileFacadeShortNameId_;
if (((bitField0_ & 0x00000040) == 0x00000040)) {
classWithJvmPackageNamePackageId_ = java.util.Collections.unmodifiableList(classWithJvmPackageNamePackageId_);
bitField0_ = (bitField0_ & ~0x00000040);
}
result.classWithJvmPackageNamePackageId_ = classWithJvmPackageNamePackageId_;
result.bitField0_ = to_bitField0_;
return result;
@@ -2677,11 +2870,21 @@ public final class JvmModuleProtoBuf {
classWithJvmPackageNameShortName_.addAll(other.classWithJvmPackageNameShortName_);
}
}
if (!other.classWithJvmPackageNameMultifileFacadeShortNameId_.isEmpty()) {
if (classWithJvmPackageNameMultifileFacadeShortNameId_.isEmpty()) {
classWithJvmPackageNameMultifileFacadeShortNameId_ = other.classWithJvmPackageNameMultifileFacadeShortNameId_;
bitField0_ = (bitField0_ & ~0x00000020);
} else {
ensureClassWithJvmPackageNameMultifileFacadeShortNameIdIsMutable();
classWithJvmPackageNameMultifileFacadeShortNameId_.addAll(other.classWithJvmPackageNameMultifileFacadeShortNameId_);
}
}
if (!other.classWithJvmPackageNamePackageId_.isEmpty()) {
if (classWithJvmPackageNamePackageId_.isEmpty()) {
classWithJvmPackageNamePackageId_ = other.classWithJvmPackageNamePackageId_;
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000040);
} else {
ensureClassWithJvmPackageNamePackageIdIsMutable();
classWithJvmPackageNamePackageId_.addAll(other.classWithJvmPackageNamePackageId_);
@@ -2723,12 +2926,20 @@ public final class JvmModuleProtoBuf {
private java.lang.Object packageFqName_ = "";
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public boolean hasPackageFqName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public java.lang.String getPackageFqName() {
java.lang.Object ref = packageFqName_;
@@ -2746,6 +2957,10 @@ public final class JvmModuleProtoBuf {
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
getPackageFqNameBytes() {
@@ -2762,6 +2977,10 @@ public final class JvmModuleProtoBuf {
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public Builder setPackageFqName(
java.lang.String value) {
@@ -2775,6 +2994,10 @@ public final class JvmModuleProtoBuf {
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public Builder clearPackageFqName() {
bitField0_ = (bitField0_ & ~0x00000001);
@@ -2784,6 +3007,10 @@ public final class JvmModuleProtoBuf {
}
/**
* <code>required string package_fq_name = 1;</code>
*
* <pre>
* Dot-separated Kotlin FQ name of the package.
* </pre>
*/
public Builder setPackageFqNameBytes(
org.jetbrains.kotlin.protobuf.ByteString value) {
@@ -2809,7 +3036,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -2822,7 +3050,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public int getShortClassNameCount() {
@@ -2834,7 +3063,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public java.lang.String getShortClassName(int index) {
@@ -2846,7 +3076,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -2859,7 +3090,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public Builder setShortClassName(
@@ -2878,7 +3110,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public Builder addShortClassName(
@@ -2897,7 +3130,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public Builder addAllShortClassName(
@@ -2914,7 +3148,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public Builder clearShortClassName() {
@@ -2929,7 +3164,8 @@ public final class JvmModuleProtoBuf {
* <pre>
* Short names of files, without extension, present in this package. Only single file facades and multi-file _parts_ are listed here
* (multi-file facades are not present in this list, they are defined below). Only files whose JVM package name is equal to the
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here.
* Kotlin package name (i.e. it has not been changed with &#64;JvmPackageName) are listed here, the rest are listed in
* class_with_jvm_package_name_short_name.
* </pre>
*/
public Builder addShortClassNameBytes(
@@ -3063,6 +3299,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -3074,6 +3313,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public int getMultifileFacadeShortNameCount() {
@@ -3084,6 +3326,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public java.lang.String getMultifileFacadeShortName(int index) {
@@ -3094,6 +3339,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -3105,6 +3353,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public Builder setMultifileFacadeShortName(
@@ -3122,6 +3373,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public Builder addMultifileFacadeShortName(
@@ -3139,6 +3393,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public Builder addAllMultifileFacadeShortName(
@@ -3154,6 +3411,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public Builder clearMultifileFacadeShortName() {
@@ -3167,6 +3427,9 @@ public final class JvmModuleProtoBuf {
*
* <pre>
* Short names of multi-file facades, used in multifile_facade_short_name_id to store the part -&gt; facade mapping.
* The package name of the multi-file facade is package_fq_name if this multi-file facade is not affected by &#64;JvmPackageName,
* and the JVM package name of any multi-file part otherwise. Note that in the latter case, all parts must have the same JVM package name,
* otherwise behavior is unspecified.
* </pre>
*/
public Builder addMultifileFacadeShortNameBytes(
@@ -3191,8 +3454,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ProtocolStringList
@@ -3203,8 +3466,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public int getClassWithJvmPackageNameShortNameCount() {
@@ -3214,8 +3477,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public java.lang.String getClassWithJvmPackageNameShortName(int index) {
@@ -3225,8 +3488,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public org.jetbrains.kotlin.protobuf.ByteString
@@ -3237,8 +3500,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public Builder setClassWithJvmPackageNameShortName(
@@ -3255,8 +3518,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public Builder addClassWithJvmPackageNameShortName(
@@ -3273,8 +3536,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public Builder addAllClassWithJvmPackageNameShortName(
@@ -3289,8 +3552,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public Builder clearClassWithJvmPackageNameShortName() {
@@ -3303,8 +3566,8 @@ public final class JvmModuleProtoBuf {
* <code>repeated string class_with_jvm_package_name_short_name = 5;</code>
*
* <pre>
* Short names of files (single file facades), whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* Short names of files (single file facades and multi-file _parts_), whose JVM package differs from the Kotlin package because of
* &#64;JvmPackageName. The JVM package name of each file is stored at the same index in class_with_jvm_package_name_package_id.
* </pre>
*/
public Builder addClassWithJvmPackageNameShortNameBytes(
@@ -3318,11 +3581,133 @@ public final class JvmModuleProtoBuf {
return this;
}
private java.util.List<java.lang.Integer> classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.emptyList();
private void ensureClassWithJvmPackageNameMultifileFacadeShortNameIdIsMutable() {
if (!((bitField0_ & 0x00000020) == 0x00000020)) {
classWithJvmPackageNameMultifileFacadeShortNameId_ = new java.util.ArrayList<java.lang.Integer>(classWithJvmPackageNameMultifileFacadeShortNameId_);
bitField0_ |= 0x00000020;
}
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public java.util.List<java.lang.Integer>
getClassWithJvmPackageNameMultifileFacadeShortNameIdList() {
return java.util.Collections.unmodifiableList(classWithJvmPackageNameMultifileFacadeShortNameId_);
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public int getClassWithJvmPackageNameMultifileFacadeShortNameIdCount() {
return classWithJvmPackageNameMultifileFacadeShortNameId_.size();
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public int getClassWithJvmPackageNameMultifileFacadeShortNameId(int index) {
return classWithJvmPackageNameMultifileFacadeShortNameId_.get(index);
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public Builder setClassWithJvmPackageNameMultifileFacadeShortNameId(
int index, int value) {
ensureClassWithJvmPackageNameMultifileFacadeShortNameIdIsMutable();
classWithJvmPackageNameMultifileFacadeShortNameId_.set(index, value);
return this;
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public Builder addClassWithJvmPackageNameMultifileFacadeShortNameId(int value) {
ensureClassWithJvmPackageNameMultifileFacadeShortNameIdIsMutable();
classWithJvmPackageNameMultifileFacadeShortNameId_.add(value);
return this;
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public Builder addAllClassWithJvmPackageNameMultifileFacadeShortNameId(
java.lang.Iterable<? extends java.lang.Integer> values) {
ensureClassWithJvmPackageNameMultifileFacadeShortNameIdIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, classWithJvmPackageNameMultifileFacadeShortNameId_);
return this;
}
/**
* <code>repeated int32 class_with_jvm_package_name_multifile_facade_short_name_id = 7 [packed = true];</code>
*
* <pre>
* This list is an addition to class_with_jvm_package_name_short_name exactly almost in the same way as
* multifile_facade_short_name_id is an addition to short_class_name. The only difference is that this list contains _full_ internal
* names of multi-file facades whose JVM package differs from the Kotlin package because of &#64;JvmPackageName.
* For each name in class_with_jvm_package_name_short_name, index of the name of the corresponding multi-file facade class in
* multifile_facade_short_name + 1, or 0 if the class is not a multi-file part.
* </pre>
*/
public Builder clearClassWithJvmPackageNameMultifileFacadeShortNameId() {
classWithJvmPackageNameMultifileFacadeShortNameId_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000020);
return this;
}
private java.util.List<java.lang.Integer> classWithJvmPackageNamePackageId_ = java.util.Collections.emptyList();
private void ensureClassWithJvmPackageNamePackageIdIsMutable() {
if (!((bitField0_ & 0x00000020) == 0x00000020)) {
if (!((bitField0_ & 0x00000040) == 0x00000040)) {
classWithJvmPackageNamePackageId_ = new java.util.ArrayList<java.lang.Integer>(classWithJvmPackageNamePackageId_);
bitField0_ |= 0x00000020;
bitField0_ |= 0x00000040;
}
}
/**
@@ -3435,7 +3820,7 @@ public final class JvmModuleProtoBuf {
*/
public Builder clearClassWithJvmPackageNamePackageId() {
classWithJvmPackageNamePackageId_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000040);
return this;
}

View File

@@ -27,7 +27,7 @@ class JvmMetadataVersion(versionArray: IntArray, val isStrictSemantics: Boolean)
companion object {
@JvmField
val INSTANCE = JvmMetadataVersion(1, 1, 13)
val INSTANCE = JvmMetadataVersion(1, 1, 15)
@JvmField
val INVALID_VERSION = JvmMetadataVersion()

View File

@@ -75,10 +75,12 @@ class ModuleMapping private constructor(
val packageParts = result.getOrPut(packageFqName) { PackageParts(packageFqName) }
for ((index, partShortName) in proto.shortClassNameList.withIndex()) {
val multifileFacadeId = proto.multifileFacadeShortNameIdList.getOrNull(index)?.minus(1)
val facadeShortName = multifileFacadeId?.let(proto.multifileFacadeShortNameList::getOrNull)
val facadeInternalName = facadeShortName?.let { internalNameOf(packageFqName, it) }
packageParts.addPart(internalNameOf(packageFqName, partShortName), facadeInternalName)
packageParts.addPart(
internalNameOf(packageFqName, partShortName),
loadMultiFileFacadeInternalName(
proto.multifileFacadeShortNameIdList, proto.multifileFacadeShortNameList, index, packageFqName
)
)
}
if (isJvmPackageNameSupported) {
@@ -87,7 +89,16 @@ class ModuleMapping private constructor(
?: proto.classWithJvmPackageNamePackageIdList.lastOrNull()
?: continue
val jvmPackageName = moduleProto.jvmPackageNameList.getOrNull(packageId) ?: continue
packageParts.addPart(internalNameOf(jvmPackageName, partShortName), null)
packageParts.addPart(
internalNameOf(jvmPackageName, partShortName),
loadMultiFileFacadeInternalName(
proto.classWithJvmPackageNameMultifileFacadeShortNameIdList,
proto.multifileFacadeShortNameList,
index,
jvmPackageName
)
)
}
}
}
@@ -103,6 +114,17 @@ class ModuleMapping private constructor(
return ModuleMapping(result, BinaryModuleData(annotations), debugName)
}
private fun loadMultiFileFacadeInternalName(
multifileFacadeIds: List<Int>,
multifileFacadeShortNames: List<String>,
index: Int,
packageFqName: String
): String? {
val multifileFacadeId = multifileFacadeIds.getOrNull(index)?.minus(1)
val facadeShortName = multifileFacadeId?.let(multifileFacadeShortNames::getOrNull)
return facadeShortName?.let { internalNameOf(packageFqName, it) }
}
}
}
@@ -140,9 +162,10 @@ class PackageParts(val packageFqName: String) {
partInternalName.packageName == packageInternalName
}
writePartsWithinPackage(partsWithinPackage)
writePartsOutsidePackage(partsOutsidePackage, builder)
val facadeNameToId = mutableMapOf<String, Int>()
writePartsWithinPackage(partsWithinPackage, facadeNameToId)
writePartsOutsidePackage(partsOutsidePackage, facadeNameToId, builder)
writeMultifileFacadeNames(facadeNameToId)
})
}
@@ -154,26 +177,24 @@ class PackageParts(val packageFqName: String) {
}
}
private fun JvmModuleProtoBuf.PackageParts.Builder.writePartsWithinPackage(parts: List<String>) {
val facadeNameToId = mutableMapOf<String, Int>()
private fun JvmModuleProtoBuf.PackageParts.Builder.writePartsWithinPackage(
parts: List<String>,
facadeNameToId: MutableMap<String, Int>
) {
for ((facadeInternalName, partInternalNames) in parts.groupBy { getMultifileFacadeName(it) }.toSortedMap(nullsLast())) {
for (partInternalName in partInternalNames.sorted()) {
addShortClassName(partInternalName.className)
if (facadeInternalName != null) {
addMultifileFacadeShortNameId(1 + facadeNameToId.getOrPut(facadeInternalName.className) { facadeNameToId.size })
addMultifileFacadeShortNameId(getMultifileFacadeShortNameId(facadeInternalName, facadeNameToId))
}
}
}
for ((facadeId, facadeName) in facadeNameToId.values.zip(facadeNameToId.keys).sortedBy(Pair<Int, String>::first)) {
assert(facadeId == multifileFacadeShortNameCount) { "Multifile facades are loaded incorrectly: $facadeNameToId" }
addMultifileFacadeShortName(facadeName)
}
}
// Writes information about package parts which have a different JVM package from the Kotlin package (with the help of @JvmPackageName)
private fun JvmModuleProtoBuf.PackageParts.Builder.writePartsOutsidePackage(
parts: List<String>,
facadeNameToId: MutableMap<String, Int>,
packageTableBuilder: JvmModuleProtoBuf.Module.Builder
) {
val packageIds = mutableListOf<Int>()
@@ -183,9 +204,16 @@ class PackageParts(val packageFqName: String) {
packageTableBuilder.addJvmPackageName(packageFqName)
}
val packageId = packageTableBuilder.jvmPackageNameList.indexOf(packageFqName)
for (part in partsInPackage.map { it.className }.sorted()) {
addClassWithJvmPackageNameShortName(part)
packageIds.add(packageId)
for ((facadeInternalName, partInternalNames) in partsInPackage.groupBy { getMultifileFacadeName(it) }.toSortedMap(nullsLast())) {
for (partInternalName in partInternalNames.sorted()) {
addClassWithJvmPackageNameShortName(partInternalName.className)
if (facadeInternalName != null) {
addClassWithJvmPackageNameMultifileFacadeShortNameId(
getMultifileFacadeShortNameId(facadeInternalName, facadeNameToId)
)
}
packageIds.add(packageId)
}
}
}
@@ -197,6 +225,17 @@ class PackageParts(val packageFqName: String) {
addAllClassWithJvmPackageNamePackageId(packageIds)
}
private fun getMultifileFacadeShortNameId(facadeInternalName: String, facadeNameToId: MutableMap<String, Int>): Int {
return 1 + facadeNameToId.getOrPut(facadeInternalName.className) { facadeNameToId.size }
}
private fun JvmModuleProtoBuf.PackageParts.Builder.writeMultifileFacadeNames(facadeNameToId: Map<String, Int>) {
for ((facadeId, facadeName) in facadeNameToId.values.zip(facadeNameToId.keys).sortedBy(Pair<Int, String>::first)) {
assert(facadeId == multifileFacadeShortNameCount) { "Multifile facades are loaded incorrectly: $facadeNameToId" }
addMultifileFacadeShortName(facadeName)
}
}
private val String.packageName: String get() = substringBeforeLast('/', "")
private val String.className: String get() = substringAfterLast('/')

View File

@@ -48,6 +48,7 @@ enum class UnsignedType {
val asSigned: PrimitiveType = PrimitiveType.valueOf(name.substring(1))
val byteSize = (1 shl ordinal)
val bitSize = byteSize * 8
val mask = "0x${List(byteSize) { "FF" }.chunked(2).joinToString("_") { it.joinToString("") }}"
}

View File

@@ -199,9 +199,37 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
out.println()
}
private fun lsb(count: Int) = "least significant $count bits"
private fun msb(count: Int) = "most significant $count bits"
private fun generateMemberConversions() {
for (otherType in UnsignedType.values()) {
val signed = otherType.asSigned.capitalized
out.println(" /**\n * Converts this [$className] value to [$signed].\n *")
when {
otherType < type -> {
out.println(" * If this value is less than or equals to [$signed.MAX_VALUE], the resulting `$signed` value represents")
out.println(" * the same numerical value as this `$className`.")
out.println(" *")
out.println(" * The resulting `$signed` value is represented by the ${lsb(otherType.bitSize)} of this `$className` value.")
out.println(" * Note that the resulting `$signed` value may be negative.")
}
otherType == type -> {
out.println(" * If this value is less than or equals to [$signed.MAX_VALUE], the resulting `$signed` value represents")
out.println(" * the same numerical value as this `$className`. Otherwise the result is negative.")
out.println(" *")
out.println(" * The resulting `$signed` value has the same binary representation as this `$className` value.")
}
else -> {
out.println(" * The resulting `$signed` value represents the same numerical value as this `$className`.")
out.println(" *")
out.println(" * The ${lsb(type.bitSize)} of the resulting `$signed` value are the same as the binary representation of this `$className` value,")
out.println(" * whereas the ${msb(otherType.bitSize - type.bitSize)} are filled with zeros.")
}
}
out.println(" */")
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline fun to$signed(): $signed = ")
out.println(when {
@@ -214,6 +242,28 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
for (otherType in UnsignedType.values()) {
val name = otherType.capitalized
if (type == otherType)
out.println(" /** Returns this value. */")
else {
out.println(" /**\n * Converts this [$className] value to [$name].\n *")
when {
otherType < type -> {
out.println(" * If this value is less than or equals to [$name.MAX_VALUE], the resulting `$name` value represents")
out.println(" * the same numerical value as this `$className`.")
out.println(" *")
out.println(" * The resulting `$name` value is represented by the ${lsb(otherType.bitSize)} of this `$className` value.")
}
else -> {
out.println(" * The resulting `$name` value represents the same numerical value as this `$className`.")
out.println(" *")
out.println(" * The ${lsb(type.bitSize)} of the resulting `$name` value are the same as the binary representation of this `$className` value,")
out.println(" * whereas the ${msb(otherType.bitSize - type.bitSize)} are filled with zeros.")
}
}
out.println(" */")
}
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline fun to$name(): $name = ")
out.println(when {
@@ -228,6 +278,17 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
private fun generateFloatingConversions() {
for (otherType in PrimitiveType.floatingPoint) {
val otherName = otherType.capitalized
out.println(" /**\n * Converts this [$className] value to [$otherName].\n *")
if (type == UnsignedType.ULONG || type == UnsignedType.UINT && otherType == PrimitiveType.FLOAT) {
out.println(" * The resulting value is the closest `$otherName` to this `$className` value.")
out.println(" * In case when this `$className` value is exactly between two `$otherName`s,")
out.println(" * the one with zero at least significant bit of mantissa is selected.")
} else {
out.println(" * The resulting `$otherName` value represents the same numerical value as this `$className`.")
}
out.println(" */")
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline fun to$otherName(): $otherName = ")
when (type) {
@@ -244,6 +305,28 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
for (otherType in UnsignedType.values()) {
val otherSigned = otherType.asSigned.capitalized
val thisSigned = type.asSigned.capitalized
out.println("/**\n * Converts this [$otherSigned] value to [$className].\n *")
when {
otherType < type -> {
out.println(" * If this value is positive, the resulting `$className` value represents the same numerical value as this `$otherSigned`.")
out.println(" *")
out.println(" * The ${lsb(otherType.bitSize)} of the resulting `$className` value are the same as the binary representation of this `$otherSigned` value,")
out.println(" * whereas the ${msb(type.bitSize - otherType.bitSize)} are filled with the sign bit of this value.")
}
otherType == type -> {
out.println(" * If this value is positive, the resulting `$className` value represents the same numerical value as this `$otherSigned`.")
out.println(" *")
out.println(" * The resulting `$className` value has the same binary representation as this `$otherSigned` value.")
}
else -> {
out.println(" * If this value is positive and less than or equals to [$className.MAX_VALUE], the resulting `$className` value represents")
out.println(" * the same numerical value as this `$otherSigned`.")
out.println(" *")
out.println(" * The resulting `$className` value is represented by the ${lsb(type.bitSize)} of this `$otherSigned` value.")
}
}
out.println(" */")
out.println("@SinceKotlin(\"1.3\")")
out.println("@ExperimentalUnsignedTypes")
out.println("@kotlin.internal.InlineOnly")
@@ -257,6 +340,17 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
for (otherType in PrimitiveType.floatingPoint) {
val otherName = otherType.capitalized
out.println(
"""
/**
* Converts this [$otherName] value to [$className].
*
* The fractional part, if any, is rounded down.
* Returns zero if this `$otherName` value is negative or `NaN`, [$className.MAX_VALUE] if it's bigger than `$className.MAX_VALUE`.
*/
""".trimIndent()
)
out.println("@SinceKotlin(\"1.3\")")
out.println("@ExperimentalUnsignedTypes")
out.println("@kotlin.internal.InlineOnly")
@@ -360,8 +454,7 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn
}
override fun containsAll(elements: Collection<$elementType>): Boolean {
if ((elements as Collection<Any?>).any { it as? $elementType == null }) return false
return elements.all { storage.contains(it.to$storageElementType()) }
return (elements as Collection<*>).all { it is $elementType && storage.contains(it.to$storageElementType()) }
}
override fun isEmpty(): Boolean = this.storage.size == 0"""

View File

@@ -527,7 +527,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -518,7 +518,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {
@@ -627,10 +627,6 @@ fun main(args: Array<String>) {
model("debugger/smartStepInto")
}
testClass<AbstractBeforeExtractFunctionInsertionTest> {
model("debugger/insertBeforeExtractFunction", extension = "kt")
}
testClass<AbstractKotlinSteppingTest> {
model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest", testClassName = "StepInto")
model("debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doSmartStepIntoTest", testClassName = "SmartStepInto")

View File

@@ -515,7 +515,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -507,7 +507,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -507,7 +507,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractOutOfBlockModificationTest> {
model("codeInsight/outOfBlock")
model("codeInsight/outOfBlock", pattern = KT_OR_KTS)
}
testClass<AbstractDataFlowValueRenderingTest> {

View File

@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.analyzer.TrackableModuleInfo
import org.jetbrains.kotlin.caches.project.LibraryModuleInfo
import org.jetbrains.kotlin.caches.resolve.resolution
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.util.enlargedSearchScope
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
@@ -210,8 +210,8 @@ fun Module.testSourceInfo(): ModuleTestSourceInfo? = if (hasTestRoots()) ModuleT
internal fun Module.correspondingModuleInfos(): List<ModuleSourceInfo> = listOf(testSourceInfo(), productionSourceInfo()).filterNotNull()
private fun Module.hasProductionRoots() = hasRootsOfType(JavaSourceRootType.SOURCE) || hasRootsOfType(KotlinSourceRootType.Source) || (isNewMPPModule && sourceType == SourceType.PRODUCTION)
private fun Module.hasTestRoots() = hasRootsOfType(JavaSourceRootType.TEST_SOURCE) || hasRootsOfType(KotlinSourceRootType.TestSource) || (isNewMPPModule && sourceType == SourceType.TEST)
private fun Module.hasProductionRoots() = hasRootsOfType(JavaSourceRootType.SOURCE) || hasRootsOfType(SourceKotlinRootType) || (isNewMPPModule && sourceType == SourceType.PRODUCTION)
private fun Module.hasTestRoots() = hasRootsOfType(JavaSourceRootType.TEST_SOURCE) || hasRootsOfType(TestSourceKotlinRootType) || (isNewMPPModule && sourceType == SourceType.TEST)
private fun Module.hasRootsOfType(sourceRootType: JpsModuleSourceRootType<*>): Boolean =
rootManager.contentEntries.any { it.getSourceFolders(sourceRootType).isNotEmpty() }

View File

@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.idea.caches.project.NotUnderContentRootModuleInfo
import org.jetbrains.kotlin.idea.caches.project.getModuleInfo
import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionsManager
import org.jetbrains.kotlin.idea.core.script.scriptDependencies
import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesUpdater
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
import org.jetbrains.kotlin.idea.util.isRunningInCidrIde
import org.jetbrains.kotlin.psi.KtCodeFragment
@@ -67,7 +67,7 @@ object KotlinHighlightingUtil {
@Suppress("DEPRECATION")
private fun shouldHighlightScript(ktFile: KtFile): Boolean {
if (isRunningInCidrIde) return false // There is no Java support in CIDR. So do not highlight errors in KTS if running in CIDR.
if (ktFile.virtualFile.scriptDependencies == null) return false
if (!ScriptDependenciesUpdater.areDependenciesCached(ktFile)) return false
if (ktFile.virtualFile.getUserData(IdeScriptReportSink.Reports)?.any { it.severity == ScriptReport.Severity.FATAL } == true) {
return false
}

View File

@@ -38,6 +38,7 @@ import com.intellij.psi.PsiFile
import com.intellij.util.ui.UIUtil
import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionsManager
import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesUpdater
import org.jetbrains.kotlin.psi.KtFile
import kotlin.script.experimental.dependencies.ScriptReport
@@ -53,18 +54,17 @@ class ScriptExternalHighlightingPass(
if (!file.isScript()) return
if (!ScriptDefinitionsManager.getInstance(file.project).isReady()) {
UIUtil.invokeLaterIfNeeded {
val ideFrame = WindowManager.getInstance().getIdeFrame(file.project)
if (ideFrame != null) {
val statusBar = ideFrame.statusBar as StatusBarEx
statusBar.notifyProgressByBalloon(
MessageType.WARNING,
"Highlighting in scripts is not available until all Script Definitions are loaded",
null,
null
)
}
}
showNotification(
file,
"Highlighting in scripts is not available until all Script Definitions are loaded"
)
}
if (!ScriptDependenciesUpdater.areDependenciesCached(file)) {
showNotification(
file,
"Highlighting in scripts is not available until all Script Dependencies are loaded"
)
}
val reports = file.virtualFile.getUserData(IdeScriptReportSink.Reports) ?: return
@@ -118,6 +118,21 @@ class ScriptExternalHighlightingPass(
}
}
private fun showNotification(file: KtFile, message: String) {
UIUtil.invokeLaterIfNeeded {
val ideFrame = WindowManager.getInstance().getIdeFrame(file.project)
if (ideFrame != null) {
val statusBar = ideFrame.statusBar as StatusBarEx
statusBar.notifyProgressByBalloon(
MessageType.WARNING,
message,
null,
null
)
}
}
}
class Factory(registrar: TextEditorHighlightingPassRegistrar) : ProjectComponent,
TextEditorHighlightingPassFactory {
init {

View File

@@ -39,7 +39,6 @@ import org.jetbrains.kotlin.idea.caches.project.cached
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.psi.psiUtil.parents
val KOTLIN_CONSOLE_KEY = Key.create<Boolean>("kotlin.console")
@@ -128,8 +127,8 @@ class KotlinCodeBlockModificationListener(
?.let { return it }
}
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) ?: return null
if (blockDeclaration.parents.any { it !is KtClassBody && it !is KtClassOrObject && it !is KtFile }) return null // should not be local declaration
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) as? KtDeclaration ?: return null
if (KtPsiUtil.isLocal(blockDeclaration)) return null // should not be local declaration
when (blockDeclaration) {
is KtNamedFunction -> {
@@ -151,6 +150,13 @@ class KotlinCodeBlockModificationListener(
}
}
is KtScriptInitializer -> {
return (blockDeclaration.body as? KtCallExpression)
?.lambdaArguments?.last()
?.getLambdaExpression()
?.takeIf { it.isAncestor(element) }
}
else -> throw IllegalStateException()
}
@@ -163,7 +169,8 @@ class KotlinCodeBlockModificationListener(
private val BLOCK_DECLARATION_TYPES = arrayOf<Class<out KtDeclaration>>(
KtProperty::class.java,
KtNamedFunction::class.java
KtNamedFunction::class.java,
KtScriptInitializer::class.java
)
fun getInstance(project: Project) = project.getComponent(KotlinCodeBlockModificationListener::class.java)

View File

@@ -19,9 +19,7 @@ package org.jetbrains.kotlin.idea.search
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.fileTypes.FileTypeRegistry
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.FileIndexFacade
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
@@ -32,15 +30,17 @@ import com.intellij.psi.search.LocalSearchScope
import com.intellij.psi.search.PsiSearchHelper
import com.intellij.psi.search.SearchScope
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.util.Processor
import com.intellij.util.CommonProcessors
import com.intellij.util.indexing.FileBasedIndex
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.idea.util.compat.psiSearchHelperInstance
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.script.findScriptDefinition
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import java.util.*
infix fun SearchScope.and(otherScope: SearchScope): SearchScope = intersectWith(otherScope)
infix fun SearchScope.or(otherScope: SearchScope): SearchScope = union(otherScope)
@@ -121,32 +121,23 @@ fun PsiSearchHelper.isCheapEnoughToSearchConsideringOperators(
return PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES
}
if (!isCheapToSearchUsagesInScripts(scope.restrictToKotlinSources(), name)) {
return PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES
}
return isCheapEnoughToSearch(name, scope, fileToIgnoreOccurrencesIn, progress)
}
private fun isCheapToSearchUsagesInScripts(scope: GlobalSearchScope, name: String): Boolean {
val project = scope.project ?: return true
fun findScriptsWithUsages(declaration: KtNamedDeclaration): List<VirtualFile> {
val project = declaration.project
val scope = psiSearchHelperInstance(project).getUseScope(declaration) as? GlobalSearchScope
?: return emptyList()
var scriptsCount = 0
val processor = object : Processor<VirtualFile> {
override fun process(file: VirtualFile): Boolean {
ProgressManager.checkCanceled()
if (findScriptDefinition(file, project) == null) return true
return scriptsCount++ < 3
}
}
val index = FileIndexFacade.getInstance(project)
return runReadAction {
FileBasedIndex.getInstance().processFilesContainingAllKeys(
val name = declaration.name.takeIf { it?.isNotBlank() == true } ?: return emptyList()
val collector = CommonProcessors.CollectProcessor(ArrayList<VirtualFile>())
runReadAction {
FileBasedIndex.getInstance().getFilesWithKey(
IdIndex.NAME,
listOf(IdIndexEntry(name, true)),
scope,
null,
{ file -> !index.shouldBeFound(scope, file) || processor.process(file) })
setOf(IdIndexEntry(name, true)),
collector,
scope
)
}
return collector.results.filter { findScriptDefinition(it, project) != null }.toList()
}

View File

@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.*
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
@@ -36,7 +39,6 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.scopes.utils.findFirstClassifierWithDeprecationStatus
import org.jetbrains.kotlin.resolve.scopes.utils.findPackage
import org.jetbrains.kotlin.resolve.source.getPsi
import java.lang.IllegalStateException
import java.util.*
class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT }) {
@@ -49,7 +51,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
) {
companion object {
val DEFAULT = Options()
val ALL_ENABLED = Options(true, true)
val ALL_ENABLED = Options(removeThisLabels = true, removeThis = true)
}
}
@@ -59,6 +61,30 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
val RETAIN_COMPANION = ShortenReferences { Options(removeExplicitCompanion = false) }
fun canBePossibleToDropReceiver(element: KtDotQualifiedExpression, bindingContext: BindingContext): Boolean {
val receiver = element.receiverExpression
val nameRef = when (receiver) {
is KtThisExpression -> return true
is KtNameReferenceExpression -> receiver
is KtDotQualifiedExpression -> receiver.selectorExpression as? KtNameReferenceExpression ?: return false
else -> return false
}
val targetDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, nameRef]
when (targetDescriptor) {
is ClassDescriptor -> {
if (targetDescriptor.kind != ClassKind.OBJECT) return true
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object) or not a receiver at all
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
val receiverKind = resolvedCall.explicitReceiverKind
return receiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER || receiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
}
is PackageViewDescriptor -> return true
else -> return false
}
}
private fun DeclarationDescriptor.asString() = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(this)
private fun KtReferenceExpression.targets(context: BindingContext) = getImportableTargets(context)
@@ -85,7 +111,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
rangeMarker.isGreedyToLeft = true
rangeMarker.isGreedyToRight = true
try {
process(listOf(file), { element ->
process(listOf(file)) { element ->
if (rangeMarker.isValid) {
val range = TextRange(rangeMarker.startOffset, rangeMarker.endOffset)
@@ -111,7 +137,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
} else {
FilterResult.SKIP
}
})
}
} finally {
rangeMarker.dispose()
}
@@ -172,7 +198,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
// step 2: analyze collected elements with resolve and decide which can be shortened now and which need descriptors to be imported before shortening
val allElementsToAnalyze = visitors.flatMap { it.getElementsToAnalyze().map { it.element } }
val allElementsToAnalyze = visitors.flatMap { visitor -> visitor.getElementsToAnalyze().map { it.element } }
val bindingContext = file.getResolutionFacade().analyze(allElementsToAnalyze, BodyResolveMode.PARTIAL_WITH_CFA)
processors.forEach { it.analyzeCollectedElements(bindingContext) }
@@ -363,7 +389,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
val referenceExpression = element.referenceExpression ?: return AnalyzeQualifiedElementResult.Skip
val target = referenceExpression.targets(bindingContext).singleOrNull()
?: return AnalyzeQualifiedElementResult.Skip
?: return AnalyzeQualifiedElementResult.Skip
val scope = element.getResolutionScope(bindingContext, resolutionFacade)
val name = target.name
@@ -449,7 +475,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (PsiTreeUtil.getParentOfType(
element,
KtImportDirective::class.java, KtPackageDirective::class.java
) != null) return AnalyzeQualifiedElementResult.Skip
) != null
) return AnalyzeQualifiedElementResult.Skip
val selector = element.selectorExpression ?: return AnalyzeQualifiedElementResult.Skip
val callee = selector.getCalleeExpressionIfAny() as? KtReferenceExpression ?: return AnalyzeQualifiedElementResult.Skip
@@ -536,30 +563,6 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
}
private fun canBePossibleToDropReceiver(element: KtDotQualifiedExpression, bindingContext: BindingContext): Boolean {
val receiver = element.receiverExpression
val nameRef = when (receiver) {
is KtThisExpression -> return true
is KtNameReferenceExpression -> receiver
is KtDotQualifiedExpression -> receiver.selectorExpression as? KtNameReferenceExpression ?: return false
else -> return false
}
val targetDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, nameRef]
when (targetDescriptor) {
is ClassDescriptor -> {
if (targetDescriptor.kind != ClassKind.OBJECT) return true
// for object receiver we should additionally check that it's dispatch receiver (that is the member is inside the object) or not a receiver at all
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
val receiverKind = resolvedCall.explicitReceiverKind
return receiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER || receiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
}
is PackageViewDescriptor -> return true
else -> return false
}
}
private fun copyShortenAndAnalyze(
element: KtDotQualifiedExpression,
bindingContext: BindingContext
@@ -673,7 +676,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (PsiTreeUtil.getParentOfType(
element,
KtImportDirective::class.java, KtPackageDirective::class.java
) != null) return AnalyzeQualifiedElementResult.Skip
) != null
) return AnalyzeQualifiedElementResult.Skip
val receiverTarget = receiver.singleTarget(bindingContext) as? ClassDescriptor ?: return AnalyzeQualifiedElementResult.Skip
@@ -683,7 +687,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (receiverTarget.companionObjectDescriptor != selectorTarget) return AnalyzeQualifiedElementResult.Skip
val selectorsSelector = (parent as? KtDotQualifiedExpression)?.selectorExpression
?: return AnalyzeQualifiedElementResult.ShortenNow
?: return AnalyzeQualifiedElementResult.ShortenNow
val selectorsSelectorTarget = selectorsSelector.singleTarget(bindingContext) ?: return AnalyzeQualifiedElementResult.Skip
if (selectorsSelectorTarget is ClassDescriptor) return AnalyzeQualifiedElementResult.Skip
@@ -693,7 +697,8 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
if (source != null && isEnumCompanionPropertyWithEntryConflict(
source,
source.name ?: ""
)) return AnalyzeQualifiedElementResult.Skip
)
) return AnalyzeQualifiedElementResult.Skip
}
return AnalyzeQualifiedElementResult.ShortenNow

View File

@@ -10,23 +10,22 @@ import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.config.KotlinResourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.idea.caches.project.SourceType
import org.jetbrains.kotlin.idea.util.isInSourceContentWithoutInjected
private val testRootTypes: Set<JpsModuleSourceRootType<*>> = setOf(
JavaSourceRootType.TEST_SOURCE,
JavaResourceRootType.TEST_RESOURCE,
KotlinSourceRootType.TestSource,
KotlinResourceRootType.TestResource
TestSourceKotlinRootType,
TestResourceKotlinRootType
)
private val sourceRootTypes = setOf<JpsModuleSourceRootType<*>>(
JavaSourceRootType.SOURCE,
JavaResourceRootType.RESOURCE,
KotlinSourceRootType.Source,
KotlinResourceRootType.Resource
SourceKotlinRootType,
ResourceKotlinRootType
)
fun JpsModuleSourceRootType<*>.getSourceType(): SourceType? = when(this) {

View File

@@ -19,7 +19,8 @@ import com.intellij.util.Query
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes
import org.jetbrains.jps.model.java.JavaSourceRootProperties
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.config.KotlinSourceRootType
import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.config.TestSourceKotlinRootType
import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService
import org.jetbrains.kotlin.idea.roots.invalidateProjectRoots
import org.jetbrains.kotlin.idea.util.rootManager
@@ -79,7 +80,7 @@ private fun findLongestExistingPackage(module: Module, packageName: String): Psi
}
private val kotlinSourceRootTypes: Set<JpsModuleSourceRootType<JavaSourceRootProperties>> =
setOf(KotlinSourceRootType.Source, KotlinSourceRootType.TestSource) + JavaModuleSourceRootTypes.SOURCES
setOf(SourceKotlinRootType, TestSourceKotlinRootType) + JavaModuleSourceRootTypes.SOURCES
private fun Module.getNonGeneratedKotlinSourceRoots(): List<VirtualFile> {
val result = mutableListOf<VirtualFile>()

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