Compare commits

...

347 Commits

Author SHA1 Message Date
nikita.movshin
c5a276ccaf Update Kotlin/Native version 2019-07-03 19:08:42 +03:00
nikita.movshin
1ad91cdf91 Add changelog for 1.3.41 2019-07-02 22:10:12 +03:00
nikita.movshin
791f49d71a Update Kotlin/Native version for testing 2019-07-02 17:01:45 +03:00
Alexey Tsvetkov
270219dfc5 Fix filling Main-Class attribute in manifest file of output jar
Before 5b7cee6221 JVM CLI compiler
was calling `KotlinToJVMBytecodeCompiler.compileBunchOfSources`.
`compileBunchOfSources` detected possible main classes,
and filled the Main-Class attribute in output jar
if if there was only one candidate.

After the change JVM CLI began calling
`KotlinToJVMBytecodeCompiler.compileModules`, which was not searching for a main class.

This change adds searching for main classes to `compileModules`.
We search for a main class only when one module is compiled,
and an output is written a jar file (so the change only affects JVM CLI compilation).

    #KT-32272 Fixed
2019-07-01 15:08:41 +03:00
Leonid Startsev
ffc409673c Export deserialization constructor from JS module
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/443
2019-07-01 14:51:32 +03:00
Mikhail Zarechenskiy
fa9edf0846 [NI] Fix exception on incomplete try/catch block
There was an inconsistency on creating PSI call and corresponding
 descriptor. See variable `catchBlocks` from visitor, it's created
 only if PSI elements are not null, but for descriptor parameters
 there wasn't such check

 #KT-32134 Fixed
 #EA-139748 Fixed
2019-07-01 14:05:32 +03:00
Mikhail Zarechenskiy
98204815f9 [NI] Fix OnlyInputTypes annotation support for top-level captured types
#KT-32157 Fixed
 #KT-32116 Fixed
 #KT-32235 Fixed
 #KT-32218 Fixed
2019-07-01 14:05:30 +03:00
Mikhail Zarechenskiy
bf6b58ddb4 [NI] Move ability to convert standalone SAM-argument under the feature
If new inference is enabled only for IDE analysis, then this feature
 will be disabled to reduce difference between new and old inference,
 but if new inference is enabled in the compiler, then this feature
 will be enabled too to preserve behavior of new inference for
 compilation

 #KT-32175 Fixed
 #KT-32143 Fixed
 #KT-32123 Fixed
 #KT-32230 Fixed
2019-07-01 14:05:24 +03:00
Sergey Rostov
ba192c3601 Gradle, JS: don't project.getTasksByName inside task realization callback
Or project evaluation would be called

#KT-32072 Fixed

(cherry picked from commit bb0f467f63)
2019-06-30 19:56:28 +03:00
Anton Bannykh
5605a7099c JS: fix reified T::class for primitive T (e.g. Int) (KT-32215 fixed)
(cherry picked from commit fadeac083f)
2019-06-28 16:57:02 +03:00
Alexander Gorshenev
240a91c4d0 Bind WrappedVariableDescriptorWithAccessors in IR deserializer
Fix for KT-32170
2019-06-28 14:37:08 +03:00
victor.petukhov
4769a3baa1 Exclude functional types for the warning reporting about implicitly inferred a type parameter to Nothing 2019-06-28 11:27:11 +03:00
Ilya Matveev
f0dcd1f36a Gradle: Add a shortcut DSL method for linuxArm64 target
Issue #KT-32034 Fixed
2019-06-27 15:20:33 +07:00
Mikhail Zarechenskiy
7836bbd1b6 [NI] Record DFI for callable reference arguments
#KT-31941 Fixed
2019-06-26 14:09:31 +03:00
Mikhail Zarechenskiy
00c1d8d20a [NI] Fix composite substitution for stubbed type in builder-inference
#KT-32038 Fixed
2019-06-26 14:09:19 +03:00
Mikhail Zarechenskiy
5db85fdb27 [NI] Coerce to Unit expression in last block with explicit Unit
#KT-32037 Fixed
2019-06-26 14:09:05 +03:00
Mikhail Zarechenskiy
bd4e0b340c [NI] Fix exception for type check callable reference against error type
#KT-32029 Fixed
 #EA-145311 Fixed
2019-06-26 14:08:38 +03:00
Mikhail Zarechenskiy
99ad60fea7 [NI] Support callable references on qualified types with generics
#KT-32154 Fixed
2019-06-26 14:08:12 +03:00
Mikhail Zarechenskiy
6894d8ae2c [NI] Capture receiver of invoke-based call
#KT-32133 Fixed
2019-06-26 14:06:34 +03:00
Mikhail Zarechenskiy
bfc2eb4499 [NI] Fix exception: don't try to compute type depth on null type
#KT-32184 Fixed
2019-06-26 14:06:20 +03:00
Mikhail Zarechenskiy
38336adb40 [NI] Fix exception: callable reference is used with an unresolved LHS
#KT-32187 Fixed
2019-06-26 14:06:05 +03:00
Mikhail Zarechenskiy
4a24e83b4b [NI] Skip fake call for descriptor from object in builder-inference
This call have interesting rules for resolution, see
 `KtQualifiedExpression.elementChain` function and it's usages:
 resolution results for such call can be omitted and be replaced with
 some other information, while diagnostics will be reported from
 builder-inference.

 To mitigate this problem, we'll just skip this call from builder-inference
 as such calls can't have type parameters anyway

 #KT-32094 Fixed
2019-06-26 14:05:53 +03:00
Mikhail Zarechenskiy
337d09ce10 [NI] Added test for KT-32094 2019-06-26 14:05:43 +03:00
Mikhail Zarechenskiy
3777d5dbad [NI] Don't avoid Nothing-like constraints if Nothing was in initial type
#KT-32081 Fixed
 #KT-32951 Fixed
2019-06-26 14:05:02 +03:00
Ilya Chernikov
fabf681d27 Implement main-kts test with command-line compiler 2019-06-25 21:51:18 +02:00
Ilya Chernikov
aed26a5594 Fix custom script definition cashing and script validity check:
- reorder initialization logic, so that script definitions are
  requested only after plugins loading
- clear definitions cache after adding explicit definitions or sources

#KT-32206 fixed
#KT-32169 fixed

Note: any of these modification fix the problem alone, but the second
may prevent other similar problems, while the first fixes actual logic
of the script validity checks as well.
2019-06-25 21:51:18 +02:00
Ilya Chernikov
8267760dc8 Implement command-line REPL smoke test 2019-06-25 21:51:17 +02:00
Ilya Chernikov
b982121b31 Fix jline proguarding in the compiler: fixes cli REPL
#KT-32085 fixed
2019-06-25 21:51:17 +02:00
nikita.movshin
7bfd974e59 Update changelog for 1.3.40 2019-06-19 15:40:27 +03:00
Elena Lepilkina
3ee38f18ef Release version of Kotlin/Native for release of Kotlin 2019-06-18 13:19:29 +03:00
Sergey Igushkin
d693620cda Update Gradle module metadata warnings: don't warn when it's enabled
Also add a suggestion to enable the module metadata publishing in
Gradle 5.3+ projects that consume Gradle module metadata by default but
don't produce it unless explicitly enabled.

Issue #KT-31023 Fixed
2019-06-17 19:10:49 +03:00
Mikhail Zarechenskiy
1b5d28114c Remove "experimental" suffix from IDE settings for NI 2019-06-17 17:13:35 +03:00
Ilya Gorbunov
c193992241 Docs: mark all experimental annotations as MustBeDocumented
So that they are shown in the docs of annotated experimental API

(cherry picked from commit a1979677d0)
2019-06-17 04:29:11 +03:00
Ilya Gorbunov
4763c601d9 Docs: suppress docs for newly introduced hidden API
(cherry picked from commit a55563f5ec)
2019-06-17 04:29:10 +03:00
LepilkinaElena
3b3950a541 Update Kotlin/Native version 2019-06-16 13:18:44 +03:00
Nikolay Krasko
6d1c0368b0 Explicitly call virtual method to be compatible with 192 branch 2019-06-15 16:32:16 +03:00
Roman Artemev
c4000a04fb [IR] Support IrLocalDelegatedPropertyReference in klib
(cherry picked from commit 6d2ad63db3)
2019-06-15 00:14:16 +03:00
Alexander Gorshenev
6ad7310df4 Added a test for members of EnumEntry in a library. 2019-06-14 18:56:07 +03:00
Alexander Gorshenev
591ff72d0d Don't serialize descriptor references for EnumEntry members 2019-06-14 18:56:03 +03:00
Kevin Peek
019ce0e430 Add links to Scope Functions docs (PR #2407)
Add links to Scope Functions docs on kotlinlang.org to 'with', 'run', 'let', 'apply', and 'also' extension function docs

(cherry picked from commit 4c91ba90bb)
2019-06-14 17:53:57 +03:00
Andrey Uskov
35ca653558 Fix compatibility with IDEA after unlinking external api from java
#KT-31952 Fixed
2019-06-13 17:40:01 +03:00
Mikhail Zarechenskiy
158514537e [NI] Propagate non-null info on supertypes for capturing from bounds
#KT-31941 Fixed
2019-06-13 14:55:03 +03:00
Sergey Rostov
7a82f522a8 Gradle, tests runner, output stream handler: don't treat flush as new line
#KT-31931 Fixed
2019-06-12 17:00:47 +03:00
nikita.movshin
d989545bdb Update changelog for 1.3.40 eap 3 2019-06-11 20:55:10 +03:00
Sergey Rostov
e74748ed44 Gradle, tests runner: don't use separate thread to parse process output
Or --scan will fail (see KT-31891 for more details).
To do it in same thread we should parse output on output stream calls.
TCServiceMessageOutputStreamHandler will do that.

Also, all new lines now preserved, so TCServiceMessagesClient should
ignore new lines after messages. New ignoreLineEndingAfterMessage setting
will do that.

#KT-31891 Fixed

(cherry picked from commit d0e3ab1beb)
2019-06-11 16:30:00 +03:00
Elena Lepilkina
14c1d20f13 New version of Kotlin/Native EAP 2019-06-10 13:52:46 +03:00
Sergey Rostov
7b8d14718a IDE, wizards, .kts, Kotlin/JS for Node.js: fix DSL
#KT-31895 Fixed

(cherry picked from commit e37c86b85f)
2019-06-10 11:19:10 +03:00
Sergey Rostov
9425c52fa2 IDE, wizards, kotlin jvm server / js client: fix jvmJar configuration
There should be `from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))`
instead of `from(jsBrowserWebpack.outputPath)in jvmJar task configuration`.

`jsBrowserWebpack.outputPath` may be (and will) inside the same dir as
jvmJar. So jvmJar build hangs.
2019-06-09 14:31:13 +03:00
ilgonmic
b4c68307cb KT-31645 Fix yarn downloading on Windows
(cherry picked from commit 16200181cc)
2019-06-09 10:10:00 +03:00
Sergey Rostov
1bcd7cc522 IDE, wizards: update Kotlin/JS support in jvm server / js client
Configure js browser sub target to use new test and application runners.
Rework js linking and packaging:
- get rid of required.js
- use builtin jsBrowserWebpack task, embed js bundle into jvm jar, remove gradle boilerplate
- ktor server: serve js bundle resource, remove boilerplate

#KT-31695 Fixed
#KT-31099 Fixed
2019-06-08 20:59:28 +03:00
Sergey Rostov
1cc977dc77 IDE, wizards: update Kotlin/JS support in mpp lib wizard
Configure js sub targets to use new test and application runners.

#KT-31695
#KT-31099
2019-06-08 20:59:27 +03:00
Sergey Rostov
7fb8f4aa49 IDE, wizards: update Gradle Kotlin/JS support
Split Kotlin/JS configuration for browser and nodejs.
Add corresponding Kotlin/JS sub targets DSL calling.
2019-06-08 20:59:27 +03:00
Sergey Rostov
01049af2c3 Gradle, JS, webpack: add dependency to compile classpath 2019-06-08 20:59:27 +03:00
Sergey Rostov
e35765e742 Gradle, JS, run: don't add dependency from project run task
As js webpack-dev-server will not finish
2019-06-08 20:59:26 +03:00
Sergey Rostov
3beb4071f9 Gradle, js: rename objects to avoid clashing with moowork nodejs plugin
#KT-31834 Fixed
2019-06-08 20:59:26 +03:00
Sergey Rostov
006ab77c43 Gradle, js, karma: useConfigDirectory DSL
#KT-31686 Fixed
2019-06-08 20:59:26 +03:00
Sergey Rostov
c0f92e99d2 Gradle, js, karma: don't run karma if no browsers configured
#KT-31662 Fixed
2019-06-08 20:59:26 +03:00
Sergey Rostov
6dcadb9352 Gradle, js, karma: use ^4.0.0-rc.6 to use webpack 3, require webpack
#KT-31564 Fixed
2019-06-08 20:59:26 +03:00
Sergey Rostov
ccfe1f1814 Gradle, js, npm simple linker: fix creating junction on windows 2019-06-08 20:59:26 +03:00
Sergey Rostov
b200fc9f32 Gradle, js, tests: use compilation runtime classpath as input
#KT-31814 Fixed
2019-06-08 20:59:25 +03:00
Sergey Rostov
a8ac0fa08e Gradle, js, npm: fix resolving transitive npm dependencies using yarn.lock
- already visited transitive npm dependencies should be stored in parent dependencies
- child NpmDependency should search resolved project data in parent NpmDependencies
2019-06-08 20:56:56 +03:00
Sergey Rostov
4d38007083 Gradle, js, npm: fix idea gradle sync for multiproject builds
npm resolver ProjectData stored per project (not in root project)
2019-06-08 20:56:55 +03:00
Sergey Rostov
6f570ab807 Gradle, js, npm: fix reading package.json files
#KT-31788 Fixed
2019-06-08 20:56:54 +03:00
Sergey Rostov
2e03335851 Gradle, js, npm: fix npm aggregated configuration attributes
#KT-31788 Fixed
2019-06-08 20:56:54 +03:00
Sergey Rostov
cc14ceff18 Gradle: provide descriptions for JS tasks
#KT-31560 Fixed
2019-06-08 20:56:53 +03:00
Sergey Rostov
0c3fe83572 Gradle, NPM, windows: creating symlink without administrator privilege
#KT-31694 Fixed
2019-06-08 20:56:53 +03:00
Sergey Rostov
cc5d7da488 Gradle, js, npm: resolve and warn about clashes in packages_imported
#KT-31697 Fixed
2019-06-08 20:56:52 +03:00
Sergey Rostov
4102feabba Gradle, npm: implement semver comparision 2019-06-08 20:56:51 +03:00
Sergey Rostov
fb604b2eb9 Gradle, npm: extract semver utils to separate file 2019-06-08 20:56:51 +03:00
Sergey Rostov
dcd23be673 Gradle, npm, imported packages: import multiple version to different dirs 2019-06-08 20:56:50 +03:00
Sergey Rostov
4f7ae070e6 Gradle, ProcessedFilesCache: delete everything on version change 2019-06-08 20:56:50 +03:00
Sergey Rostov
6ec4e9d083 Gradle, ProcessedFilesCache: report target values clash 2019-06-08 20:56:49 +03:00
Sergey Rostov
13e04590ca Gradle, JS, NpmResolver: save imported packages cache state before calling npm 2019-06-08 20:56:48 +03:00
Sergey Rostov
d494639837 Gradle, js, NPM: select one version between tools and all of compile configurations
#KT-31696 Fixed
2019-06-08 20:56:48 +03:00
Sergey Rostov
d5344bd926 Gradle, minor: remove unused import 2019-06-08 20:56:47 +03:00
Ilya Chernikov
f37568ae1d Fix script compiler options processing 2019-06-07 22:34:37 +02:00
Mikhail Zarechenskiy
3e788049d3 [NI] Introduce flag to change constraint system for overload resolution
This commit doesn't change behaviour of any inference algorithm, it
 introduces opportunity to switch constraint system that is used for
 overload resolution and fix problematic cases by changing one enum
 entry.

 Due to fundamental changes, there are cases where a new inference
 algorithm reports overload resolution ambiguity errors (#KT-31670,
 #KT-31758), which is correct from its point of view. However, this is
 a breaking change and to really make it, we should be very confident
 and have enough motivation for it, therefore, we don't change behavior
 now in order to collect more examples (if there are any). And if we
 find a lot of erroneous examples, we'll be able to change the behavior
 quite simply
2019-06-07 22:36:21 +03:00
Mikhail Zarechenskiy
f9edee22af [NI] Move creation of constraint system under callbacks
This will be needed in the next commit to have access to constraint
 system that is used for old inference
2019-06-07 22:36:19 +03:00
Alexey Tsvetkov
25a14f0476 Add experimental support for bytecode instrumentation with JPS
#KT-13563 Fixed
2019-06-07 21:09:45 +03:00
Mikhail Zarechenskiy
184f01e9ea [NI] Consider explicitly specified type argument as an input type
#KT-31860 Fixed
2019-06-07 17:20:36 +03:00
Mikhail Zarechenskiy
79798cb78d Revert "[NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI"
This reverts commit 8285c9984d.
2019-06-07 17:20:36 +03:00
Mikhail Zarechenskiy
f73daac07d Fix exception on attempt to map inner non-fixed type variable
#KT-31842 Fixed
2019-06-07 17:20:35 +03:00
Alexander Podkhalyuzin
5eff6d412c Do not expect that KDoc reference contains importable fqName
#KT-31768 Fixed

(cherry picked from commit ea86ebf995)
2019-06-07 17:15:06 +03:00
Andrey Uskov
f8b1c67422 Fix memory leak on project reimport
#KT-31843 Fixed

(cherry picked from commit 5efd55f530)
2019-06-07 16:59:46 +03:00
Andrey Uskov
c07482f932 Fix disabling delegated build in gradle projects for IDEA 192 2019-06-07 16:58:41 +03:00
Alexander Udalov
0fed75de04 Minor, add kdoc for typeOf
(cherry picked from commit fec9ee6408)
2019-06-07 13:24:46 +02:00
Dmitry Savvinov
747f22de2f Allow to force-require syntetic SAM-adapters even in NI
This is needed for some IDE clients, particularly, completion: even
though presenting only non-converted member (e.g., 'foo(Consumer<Int>')
is nominally OK, as resolution with NI is smart enough to accept 'foo { }'
for such a call, it is inconvenient for users (for example, hitting
enter would insert round brackets instead of a figure brackets)

This commit adds very-very narrow API (borderline hacky) in
JavaSyntheticScopes, to allow clients explicitly ask for a scopes with
force-enabled synthetic conversions. It fixes several tests, which had
started to fail after corresponding commit about NI and SAM-adapters
(fe5976d7f4), e.g.:
- Java8BasicCompletionTestGenerated.testCollectionMethods
- Java8BasicCompletionTestGenerated.testStreamMethods
- JvmBasicCompletionTestGenerated$Common$StaticMembers.testJavaStaticMethods
- JvmBasicCompletionTestGenerated$Java.testSAMAdaptersStatic
- JvmWithLibBasicCompletionTestGenerated.testSamAdapter
- JvmWithLibBasicCompletionTestGenerated.testSamAdapterAndGenerics

Note that changes are made in ReferenceVariantsHelper, which is used by
several other clients in IDE. Presumably, those changes are needed for
them too.
2019-06-07 01:22:07 +03:00
Ilya Matveev
e2b51c9e2c Gradle, tests: Fix native interop test for Win x86 2019-06-06 17:26:47 +07:00
Ilya Matveev
ec044aeb01 Project wizard tests: Bump Gradle plugin version to use test binaries 2019-06-06 17:26:46 +07:00
Ilya Matveev
eade0a9788 IDEA plugin: Use new test binary getter in project templates
Issue #KT-31724 fixed
2019-06-06 17:26:45 +07:00
Ilya Matveev
8d2f6f732b Gradle, native: Fix creating test binaries for non-host platforms
Issue #KT-31725 fixed
2019-06-06 17:26:44 +07:00
Ivan Gavrilovic
808f5bbf71 KT-31714: Close files after analysis in incremental KAPT
Artifact transform used to analyze classpath was not closing files, which
caused java.nio.file.FileSystemException. This commit fixes that, and all
input streams are closed after use.

Fixes: KT-31714

(cherry picked from commit 7a2332fe36)
2019-06-06 17:43:58 +09:00
Ivan Gavrilovic
971b5645f9 KT-31127: add only generated Java sources to JavaCompile inputs
This commit changes how generated sources are added to the Gradle JavaCompile
task. Previously, directory was added to sources which caused issues with
annotation processors that only generate Kotlin sources. I.e. JavaCompile task
was executed but no java sources existed.

Now, only generated Java sources are added to the JavaCompile task. This
means that if only Kotlin sources are generated JavaCompile task will be
skipped.

Fixes: KT-31127
Test: Kapt3IT.testKotlinProcessorUsingFiler

(cherry picked from commit 695f202e46)
2019-06-06 17:43:58 +09:00
Ivan Gavrilovic
57c3ddd8f3 KAPT: do not discover incremental APs only if cache is not set
KaptFlag.INCREMENTAL_APT is used to indicate that KAPT run
should try to be incremental because changes to input files and
classpath have been detected. However, first run of the Gradle
task will set this flag to false, which means that all APs will be
detected as non-incremental in the first run. Further on, this means
that the dependency caches will be invalid, and all subsequent runs
will be non-incremental as well.

This commit uses existence of dependency cache to determine if incremental
APs should be discovered. The regression was introduced in
72fdc648ff.

Test: ./gradlew :kotlin-gradle-plugin-integration-tests:testAdvanceGradleVersion --tests *KaptIncrementalWith*\
 && ./gradlew :kotlin-gradle-plugin-integration-tests:test --tests *KaptIncrementalWith*

(cherry picked from commit 55ba985cd2)
2019-06-06 17:43:57 +09:00
Ivan Gavrilovic
f3c729a2b9 Support isolating APs that report multiple originating elements from the same file
It is possible for isolating annotation processor to report two or more
originating elements from the same source file when generating
sources/classes/resources. This commit makes sure the source file are
de-duped, so assertion that there is a single source file does not fail.

Test: IsolatingIncrementalProcessorsTest.testIsolatingWithMultipleOriginatingElements

This is improvement to https://youtrack.jetbrains.com/issue/KT-23880

(cherry picked from commit 1fa990b063)
2019-06-06 17:43:57 +09:00
Ivan Gavrilovic
46aab7a638 Improve constants analysis in KAPT
When analyzing source files in KAPT for incremental annotation processing,
avoid creating TreePath instances for initializers that are literals. E.g.
if it is just a boolean/int literal, we do not need to visit the tree nor
create expensive TreePath instance.

For classes that contain only constants (such as R.java for Android projects)
this is a significant improvement. Class that contains 16000 constants took
more than 10 seconds to analyze, now it is 70ms.

(cherry picked from commit 76f62da6ae)
2019-06-06 17:43:57 +09:00
Vyacheslav Gerasimov
d7f1875b00 192: Update 192 plugin to 192.4205.45 2019-06-05 19:51:46 +03:00
Leonid Startsev
d8b6922692 Correctly copy init blocks code to deserialization constructor
Fixes https://github.com/JetBrains/kotlin-native/issues/3019

Workaround problem with proguard and inline reified functions

(cherry picked from commit d3a596e3c2)
2019-06-05 18:32:27 +03:00
Leonid Startsev
9af0d424b4 Correctly reference deserialization constructor added by plugin
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/472

(cherry picked from commit 6370f0b3be)
2019-06-05 18:31:50 +03:00
Mikhail Glukhikh
c886487d25 Introduce Kotlin language substitutor to fix exceptions in velocity files
Related to KT-31470 (should fix the problem or at least soften it)
May be related also to KT-30977
#KT-30886 Fixed

(cherry picked from commit 71590b6735)
2019-06-05 14:06:45 +03:00
Mikhail Zarechenskiy
409e5bddb0 Fix evaluation of local functions for new-inference
Plus, additionally fix evaluation of generic local functions everywhere

 The problem was that in new-inference we create more substituted
 descriptors while old inference tries to preserve original ones.
 Later, backend fails to retrieve those descriptors as it uses originals.
 But, again, this worked only for simple functions, for generic functions
 debugger with new and old inference worked incorrectly

 #KT-31785 Fixed
2019-06-04 19:58:24 +03:00
Sergey Rostov
e05f01d550 Gradle, js, npm: don't setup package manager without npm dependencies
#KT-31729 Fixed

(cherry picked from commit 00f8f09274)
2019-06-04 16:37:39 +03:00
Igor Yakovlev
ad94bad919 Add correct UL-method hasTypeParameters realization (#KT-30970 Fixed)
Incorrect realization is breaking-down of IDEA generic-type inference algorithm that leads to SOE.
2019-06-03 17:04:53 +03:00
Ilya Chernikov
17f3e1f45b Fix classpath detection from classloader resources 2019-06-03 13:38:05 +02:00
Mikhail Zarechenskiy
9b0262a326 Fix exception from UAST on attempt to map non-fixed type variable
#KT-31723 Fixed
 #EA-126269 Fixed
 #EA-143705 Fixed
 #EA-143703 Fixed
 #EA-143694 Fixed
2019-06-03 14:17:47 +03:00
Mikhail Zarechenskiy
4aa748741c Fix UAST tests for new-inference: adapt SAM-converted descriptors 2019-06-03 14:17:46 +03:00
Mikhail Zarechenskiy
a09b75356a Enable new type inference for UAST tests as for IDE tests 2019-06-03 14:17:44 +03:00
Ilya Chernikov
781b6af1d0 Improve classpath extraction from classloader:
- implement opt-in unpacking/caching of the jar collection archives,
  such as spring boot fat jars and WARs, to the temp dir, and creating
  a valid classpath from extracted archive
- turning it on for the new default jsr223 engine
- fallback to extracting classpath from resource URLs if the classloader
  is not known url-based one
- refactor and optimize extraction
- cache the last retrieved classpath in the default JSR-223 script engine
  factory

(cherry picked from commit f986856d03)
2019-05-31 16:19:10 +02:00
nikita.movshin
e977174cb6 Update changelog for 1.3.40 2019-05-30 23:46:59 +03:00
Andrey Uskov
e03ff13a57 Make plugin 191 incompatible with IDEA 192 2019-05-30 13:00:34 +03:00
Andrey Uskov
4a279a2ae2 Disable invocation of GradleSettingsService in IDEA 192
#KT-31693 Fixed
2019-05-30 12:42:58 +03:00
Dmitriy Novozhilov
4d6aee014c [NI] Fix replacing original in PropertyDescriptor 2019-05-29 18:17:37 +03:00
Ilya Gorbunov
eee8621cd9 Fix method reference ambiguity in test after introducing 'capitalize' overload
(cherry picked from commit fe9bd9ee20)
2019-05-29 12:23:31 +03:00
Ilya Gorbunov
f72e62553f Fix titlecase lowering in decapitalize
Replace isUpperCase() with !isLowerCase check to lower both
upper- and titlecased first chars.

(cherry picked from commit 8badfca459)
2019-05-29 12:23:31 +03:00
Ilya Gorbunov
023194b792 capitalize/decapitalize: improve docs, add one test
(cherry picked from commit a921bd04e0)
2019-05-29 12:23:30 +03:00
Jake Wharton
a9dbb3c5b5 Add Locale-accepting overloads for (de)capitalize in JDK stdlib
#KT-28933 fixed

(cherry picked from commit af31794f60)
2019-05-29 12:23:30 +03:00
Alexander Udalov
b7c6313114 Get rid of copy-pasted code from JavaSdkUtil
#KT-30973 Fixed

(cherry picked from commit d2fcb8cc6a)
2019-05-29 10:50:45 +02:00
Dmitriy Novozhilov
42c841caf7 Fix compiler errors in compiler detected after enabling @OnlyInputTypes in NI 2019-05-29 11:40:34 +03:00
Dmitriy Novozhilov
47d8f81ae3 [NI] Support @OnlyInputTypes annotation. #KT-29307 fixed 2019-05-29 11:40:34 +03:00
Dmitriy Novozhilov
224ba97dbe [NI] Add checking @NotNull parameters for candidates 2019-05-29 11:40:34 +03:00
Dmitriy Novozhilov
8285c9984d [NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI 2019-05-29 11:40:34 +03:00
Alexey Tsvetkov
16ba022b4d Fix IC test for multifile part with property
Our JPS and Gradle plugins handle
recompilation of multifile classes differently.

JPS plugin delegates handling to the JPS itself,
which tracks dependencies via bytecode,
and marks classes as dirty when they are affected.
So in JPS other parts of multifile classes are recompiled only
when a part's signature is changed.

In Gradle plugin we handle recompilation ourselves in
simpler way: any change in any part leads to a recompilation
of all parts of the same multifile class.

In future we should improve our Gradle plugin, but for now
I'm changing the test so that both JPS and Gradle tests
recompile all parts.

Also the dummy function is added to make sure that we
don't blindly recompile everything when a part is changed.

(cherry picked from commit 7f1d30058a)
2019-05-29 10:23:40 +02:00
Alexander Udalov
370dcaf0f3 Minor, simplify code in PropertyCodegen
(cherry picked from commit c13bec0e41)
2019-05-29 10:23:38 +02:00
Alexander Udalov
d12711d41a Remove NotNull PSI element parameter from PropertyCodegen.generateBackingField
#KT-31131 Fixed

(cherry picked from commit 967a6bd80d)
2019-05-29 10:23:36 +02:00
Alexander Udalov
e189133357 Try loading PSI from descriptor in OtherOrigin constructor
To simplify several call sites

(cherry picked from commit e9b50157da)
2019-05-29 10:23:35 +02:00
Alexey Tsvetkov
3e764d93fa Add test for KT-31131
(cherry picked from commit 56d5846ef1)
2019-05-29 10:23:32 +02:00
Yan Zhulanow
38c23f5b43 Debugger: Implement error reporting for evaluator 2019-05-29 17:18:36 +09:00
Anton Yalyshev
3769c67bd1 created FUS Group for Debugger Evaluator 2019-05-29 17:18:35 +09:00
Yan Zhulanow
496b74b414 Pill: Fix getSerializedCompilerArguments() 2019-05-29 17:18:35 +09:00
Anton Bannykh
1bfddfef09 JS IR: ignore the new suspend callable reference test
(cherry picked from commit dad334ffcd)
2019-05-29 10:40:23 +03:00
George Gastaldi
31c92c9415 build: add kotlin-compiler-embeddable to BOM
(cherry picked from commit d0d4d00379)
2019-05-29 05:45:36 +03:00
Mikhail Zarechenskiy
53fa11884d [NI] Relax rules for call completion: require at least one constraint
It's enough to have at least one good constraint.

 Note that the whole algorithm can be a bit more general:
 we could check also Out<T>, In<T> and verify that T has good only
 lower constraint or upper constraint, but there are questions for
 types like Inv<Out<T>>, where T should have lower and upper constraints

 #KT-31514 Fixed
2019-05-29 02:15:37 +03:00
Sergey Igushkin
829771231d Make withJava() safe to call repeatedly on same target
(cherry picked from commit 25371734e8)
2019-05-29 01:08:46 +03:00
Anton Bannykh
4879e656ce JS: cache metadata, grouped by package FQN
(cherry picked from commit c3170d1908)
2019-05-28 23:38:23 +03:00
Anton Bannykh
c1455e3da0 JS: prepare to cache package metadata
(cherry picked from commit c1f69ca8d6)
2019-05-28 23:38:23 +03:00
Anton Bannykh
53170e9199 JS: make .meta.js the same as before
(cherry picked from commit fc7fea4863)
2019-05-28 23:38:23 +03:00
Anton Bannykh
e6ebfb96ec JS: merge proto parts as bytes
(cherry picked from commit 145ca7b6a9)
2019-05-28 23:38:23 +03:00
Anton Bannykh
02d1ffe9c7 JS: lazy load special functions and source maps
(cherry picked from commit fbd59ba68a)
2019-05-28 23:38:23 +03:00
Anton Bannykh
42bd1e5811 JS: improve json parsestring
(cherry picked from commit a3aca662c1)
2019-05-28 23:38:23 +03:00
Anton Bannykh
7b34f83429 JS: optimize JSON parser
(cherry picked from commit 56915d1c07)
2019-05-28 23:38:23 +03:00
Sergey Igushkin
c12208ac4f Fix Android 3.3 Gradle integration tests running with low Gradle version
(cherry picked from commit a4069c031e)
2019-05-28 20:57:00 +03:00
Sergey Igushkin
5d68860e9f Fix Android 3.3 Gradle integration tests running with low Gradle version
(cherry picked from commit 8b150d2b07)
2019-05-28 20:56:58 +03:00
Sergey Igushkin
27bb4d0b2e Fix the AGP deprecation warning on usage of getPackageLibrary, KT-30784
Use the new API that returns the task provider, if available.

Issue #KT-30784 Fixed

(cherry picked from commit 71bd88bdb3)
2019-05-28 20:56:24 +03:00
Anton Bannykh
5fc55df31e JS: support callable references on suspend functions (KT-30987 fixed)
(cherry picked from commit 052ddd60ce)
2019-05-28 19:14:24 +03:00
Elena Lepilkina
7def0ccba8 New EAP of Kotlin/Native 2019-05-28 19:03:01 +03:00
Dmitry Gridin
f47ad82a73 Fix KNPE in OptimizedImportsBuilder
#KT-31637 Fixed

(cherry picked from commit aff8a3f97f)
2019-05-28 21:54:01 +07:00
Kirill Shmakov
cfed5b351a Expand acronym for K/N definitions file
(cherry picked from commit 362e056b18)
2019-05-28 17:35:34 +03:00
Alexander Udalov
2e4e2f67bb Make inline+reified functions synthetic instead of private in bytecode
#KT-18563 Fixed

(cherry picked from commit f9d61f2dc7)
2019-05-28 16:18:32 +02:00
Alexander Udalov
dab23322fd Minor, restructure InlineOnly-related utilities
(cherry picked from commit a645b36688)
2019-05-28 16:18:06 +02:00
Alexander Udalov
7c00d2ba82 Restructure bytecode listing tests on InlineOnly/inline+reified
(cherry picked from commit b42adcd73d)
2019-05-28 16:18:05 +02:00
Sergey Rostov
14aab280c2 Gradle, JS: support exotic versions while converting to semver
#KT-31563
2019-05-28 16:41:31 +03:00
Ilmir Usmanov
489d80c249 Wrap result method node with max stack calculator in inliner
#KT-31347 Fixed
2019-05-28 16:38:25 +03:00
Nikolay Krasko
ef50f25db1 Refactoring: drop unused AbstractKotlinReferenceContributor.kt 2019-05-28 16:17:13 +03:00
Nikolay Krasko
a3dfa28374 Don't produce references for Kotlin block 2019-05-28 16:17:13 +03:00
Nikolay Krasko
95cdc94fbb Get Kotlin references through Kotlin contributors only (KT-31129)
Speed up getting references and protect Kotlin from slow
references contributors.

 #KT-31129 Fixed
2019-05-28 16:17:12 +03:00
Nikolay Krasko
ffa298ea34 Minor: move KotlinDefaultAnnotationMethodImplicitReferenceContributor.kt
Need this move to reference contributor from reference provider service.
2019-05-28 16:17:12 +03:00
Natalia Selezneva
ba00df846e Pass environment variables resolving script dependencies
There is no option in UI to enable/disable passing those variables,
but during Gradle Sync environment variables are passed by default
Also Gradle expect that gradleOptions are passed but there is also no option in UI
(during Gradle Sync IDEA add some options but they shouldn't affect dependencies resolution process)
see GradleExeSettings.resolverExtension.getExtraCommandLineArgs

gradleWithConnection was removed because it isn't used by gradle because they need to manage the TAPI project directory

projectRoot was fixed to externalProjectPath because it can be overrided in settings.gradle

^KT-30974 Fixed

(cherry picked from commit b5dbdc53d1)
2019-05-28 16:08:14 +03:00
Eduard Wolf
b8cb533b39 KT-31639: Fix Iterables.drop integer overflow
(cherry picked from commit c885cadde4)
2019-05-28 15:49:12 +03:00
Andrey Uskov
8b6096f312 Fix exception during mpp run task creation due to usage of deprecated api
#KT-31482 Fixed
2019-05-28 15:22:46 +03:00
Andrey Uskov
19f01b98df Fix ClassCastException during search of overriders
#EA-115095 Fixed
2019-05-28 15:21:56 +03:00
Andrey Uskov
cf8184e9c9 Do not show UI dialog from a write action during work of intention
#EA-100676 Fixed
2019-05-28 15:21:18 +03:00
Mikhail Zarechenskiy
eb813678fc Fix debugger tests for new-inference
There is new child of `VariableAsFunctionResolvedCall` in
 new-inference: `NewVariableAsFunctionResolvedCallImpl`. So, in order to
 support both versions, just use parent class
2019-05-28 14:49:34 +03:00
Igor Yakovlev
8c96111e16 Fix render of classpath log message for UL-classes 2019-05-28 14:26:48 +03:00
Alexander Udalov
02fc21b7ff Support fake Java property overrides in function equality in bridges
A synthetic property descriptor created for `B.value` (see the added
test) should not be equal to the normal descriptor created by the fake
override construction algorithm. Otherwise we can't reach this synthetic
non-abstract descriptor when building bridges in `C`, which results in
exception.

 #KT-31367 Fixed

(cherry picked from commit 082c337faa)
2019-05-28 11:51:37 +02:00
Ilya Matveev
f3be367962 Gradle, native: Rename test binary class: Test -> TestExecutable 2019-05-28 10:50:38 +03:00
Ilya Matveev
6d62f21d60 Gradle, native: Don't treat test output as stacktrace
Currently native test runner reports stacktraces using TC
service messages.
2019-05-28 10:50:37 +03:00
Ilya Matveev
54698544d9 Gradle, native: Introduce separate binary type for tests
Earlier native tests were represented by the same binary type as product
executables. We also used to create test tasks in the same manner as run
tasks for product executables. Such tasks could be obtained used a property
of an executable binary with type Exec.

But now we have a separate class for test tasks. Also we probably will want
to create several tasks for the same test. So we cannot use the same run task
property for both test and product executables. Also representing test and
product executables by the same binary type leads to the fact that assemble
task execution causes building not only product binaries but also the test
ones.

This patch solves the issues described above by introducing a separate binary
type for tests. Such a test binary can be created in the same manner as other
binaries:

    kotlin.macosX64 {
        binaries {
            test("integration") { ... }
        }
    }

One test binary and a task executing it is created by the plugin out of the box.
This test binary replaces a test executable used to be created earlier.

Issue #KT-31609 Fixed
2019-05-28 10:50:37 +03:00
Mikhail Zarechenskiy
9365ff6dcf Fix compilation against bootstrap compiler 2019-05-27 17:37:30 +03:00
Mikhail Zarechenskiy
200dde8cb4 [NI] Don't consider Any!-constraint from upper bounds as more specific
#KT-31624 Fixed
2019-05-27 17:37:28 +03:00
Mikhail Zarechenskiy
da06af2fee Duplicate test for NI and OI to avoid mismatch of diagnostics
There is a problem with different order of diagnostics for NI and OI,
 so, in order to fix this test, it was duplicated
2019-05-27 17:37:27 +03:00
Mikhail Zarechenskiy
e3fa388dfe [NI] Avoid forcing resolve for array access expression
#KT-31606 Fixed
 #EA-126523 Fixed
2019-05-27 17:37:25 +03:00
Mikhail Zarechenskiy
9434babe9f [NI] Don't apply SAM-conversion for type that is subtype of function
Plus, don't get synthetic candidates as all candidates are creating
 by conversion

 #KT-31503 Fixed
2019-05-27 17:37:23 +03:00
Mikhail Zarechenskiy
61f48da6e8 [NI] Fix assertion: KotlinTypeMarker -> KotlinType 2019-05-27 01:02:05 +03:00
Mikhail Zarechenskiy
46420d60f0 [NI] Approximate components of raw types separately
This is needed as components can have different type arguments
2019-05-26 21:42:43 +03:00
Mikhail Zarechenskiy
cb3371ba2e [NI] Implement various optimizations for incorporation algorithm
Mostly, these optimisations are picked from the old inference.
 Also, remove exponential complexity for flexible types in approximation,
 note that more correct fix for this would be to introduce new types
 that corresponds just to platform types to avoid nullability problems,
 but due to complexity it will be done later

 #KT-31415 Fixed
2019-05-26 21:35:52 +03:00
Mikhail Zarechenskiy
6b660fe466 Fix exception on star import from typealias
#KT-30983 Fixed
2019-05-26 21:35:50 +03:00
Mikhail Zarechenskiy
d0231351ec Add tests to preserve current behavior for upcoming changes
##KT-30983 In Progress
2019-05-26 21:35:48 +03:00
Mikhail Zarechenskiy
ec8e8cb23c [NI] More accurate handle of capture types from subtyping
#KT-31520 Fixed
2019-05-26 21:35:46 +03:00
Mikhail Zarechenskiy
c0c63bdc98 [NI] Don't loose inference session during property resolve
#KT-31620 Fixed
2019-05-26 21:35:45 +03:00
Toshiaki Kameyama
0786555650 Redundant 'suspend' modifier inspection: don't report when function has suspend operator invoke
#KT-25465 Fixed

(cherry picked from commit 354f8f0bf1)
2019-05-24 23:05:16 +03:00
Ilya Chernikov
b11e31d275 Fix scripting-compiler tests, add them to the global scriptingTest task 2019-05-24 13:43:03 +02:00
Dmitriy Novozhilov
15d28a75a9 Fix compiler testdata broken in d2d603b 2019-05-24 11:02:55 +03:00
Ilya Chernikov
62dcae008c [minor] fixes after review 2019-05-24 08:26:41 +02:00
Ilya Chernikov
fbeded85e6 Implement test run on embeddable jars for jsr223 and scripting host tests...
also:
- add missing tests to the global scriptingTests task
- extract jsr223 tests into separate project
- fix dependency in jsr223 embeddable jar
2019-05-24 08:26:41 +02:00
Ilya Chernikov
5e4ff87244 Refactor default JSR-223 engine implementation:
- rename classes for clarity
- sort out dependencies
- move common pars to jvm-host jar
- switch to configurations only customization
2019-05-24 08:26:41 +02:00
Ilya Chernikov
560c65c50f Add evaluation context passing to the evaluation config refiners 2019-05-24 08:26:40 +02:00
Ilya Chernikov
a23fb03bd9 Fix dependencies to compiler in scripting modules 2019-05-24 08:26:40 +02:00
Ilya Chernikov
b96fcce096 Move scripting jvm host tests to a separate project...
to solve problems with testing with direct dependency on proguarded compiler
2019-05-24 08:26:40 +02:00
Ilya Chernikov
503a042b29 Drop dependencies to script-util from new scripting infrastructure 2019-05-24 08:26:40 +02:00
Ilya Chernikov
649b74ab7f Convert JvmGetScriptingClass to object to simplify (de)serialization 2019-05-24 08:26:40 +02:00
Ilya Chernikov
623c7673e1 Add a link to hostConfiguration from compilation and evaluation ones
also add possibility to supply functional defaults for keys in PropertiesCollection
2019-05-24 08:26:40 +02:00
Ilya Chernikov
76b7dcfdaf Get rid of UsefulTestCase to avoid dependencies, parallelize tests 2019-05-24 08:26:40 +02:00
Ilya Chernikov
73e3cfe3a4 [minor] fix some warnings 2019-05-24 08:26:40 +02:00
Ilya Chernikov
45cbd792ac Add missing scripting tests to the global task, make them parallel 2019-05-24 08:26:39 +02:00
Ilya Chernikov
ebaca7a4d8 Fix main-kts script classpath calculation 2019-05-24 08:26:39 +02:00
Ilya Chernikov
8e45f79a0e Implement JSR-223 functionality on top of the "new" REPL 2019-05-24 08:26:39 +02:00
Ilya Chernikov
d91881acf4 Implement "legacy" REPL wrappers on top of the "new" scripting infrastructure 2019-05-24 08:26:39 +02:00
Ilya Chernikov
206d53d35a Create core environment in test mode properly 2019-05-24 08:26:39 +02:00
Ilya Chernikov
8585f69b27 Prepare scripting infrastructure for REPL:
- refactor script compiler to simplify extending it for repl
- add repl snippet compilation functions to the new scripting compiler
- extract util functions into appropriate files
- extract repl part into separate class
- extract bridge definition and related definitions into separate file
2019-05-24 08:26:39 +02:00
Ilya Chernikov
738108e9c9 Replace message collector with reporting lambda
to simplify usages and slightly reduce dependencies
2019-05-24 08:26:39 +02:00
Ilya Chernikov
c84a4e8640 Add another method for fetching classpath from classloader, refactor 2019-05-24 08:26:38 +02:00
Ilya Gorbunov
0526298b37 Unmute tests for JVM_IR that pass after making assertFailsWith inline
(cherry picked from commit 0a3ebb5780)
2019-05-23 19:40:24 +03:00
Ilya Gorbunov
7e766a1413 Add hidden methods to keep binary compatibility in kotlin-test for JVM
(cherry picked from commit 6632cf5b1d)
2019-05-23 19:40:23 +03:00
Ilya Gorbunov
bb77d673a0 Make assertFails(With) inline-only functions
So that the lambda passed to these functions can capture suspend
function calls.

#KT-31194 Fixed

(cherry picked from commit 22694fa6b0)
2019-05-23 19:40:23 +03:00
Ilya Gorbunov
ed85927abf Remove internal visibility suppressions in kotlin.test
Internal visibility works fine in MPP, so they are no longer required.

(partially cherry picked from commit 18f9b20610)
2019-05-23 19:40:06 +03:00
Benjamin Orsini
690b84e2e8 Add map() documentation sample
* docs: add map() sample
* docs: add samples for Map and CharSequence
* docs: add another sample for Maps.map()

(cherry picked from commit 3e39f26379)
2019-05-23 19:39:33 +03:00
Ivan Gavrilovic
2bba568dd6 If incremental KAPT is disabled, do not analyze classpath
When incremental apt mode in KAPT is disabled, do not analyze
classpath to determine the type of the annotation processors. Instead,
just mark them all as non-incremental.

(cherry picked from commit 72fdc648ff)
2019-05-23 19:19:21 +03:00
Peter Xu
d432ea7df5 Revert obsolete code introduced in KT-12402
The classes being filtered have been renamed months ago. The change
committed in KT-12402 is no longer relevant as the underlying issue has
been fixed.

(cherry picked from commit a639607821)
2019-05-23 19:19:20 +03:00
Ivan Gavrilovic
81f4a090f6 Handle return result of dir creation/deletion in kapt
#KT-31322

(cherry picked from commit b609fe529c)
2019-05-23 19:19:20 +03:00
Ivan Gavrilovic
7a17bccf23 Remove generated sources and classes for full KAPT build
When running incremental annotation processing in KAPT,
even if incremental flag is enabled, and full rebuild should
be performed (e.g. in presence of dynamic non-incremental APs),
make sure generated sources and classes are removed.

 #KT-31322 fixed

(cherry picked from commit f60bfc34c0)
2019-05-23 19:19:19 +03:00
Vladimir Krivosheev
6528826ea7 Do not use constructor injection for app level extension KotlinClassWithDelegatedPropertyRenderer (KT-31266)
(cherry picked from commit 757b4b3910)
2019-05-23 19:19:19 +03:00
Yan Zhulanow
902dfe0815 Revert "Kapt: Always use raw types for annotation parameter types (KT-30346)"
This reverts commit 66754e62

(cherry picked from commit a0778ad703)
2019-05-23 19:19:18 +03:00
Yan Zhulanow
207bd4e1b9 Pill: Recognize 'embedded' configuration as 'compile' in JPS 2019-05-23 19:19:18 +03:00
Dmitriy Novozhilov
d2d603b3bd Add wrappers on KotlinType in EffectSystem
Also that commit removes usages of builtins inside
  effect system and starts refactoring of functor
  composition via composition instead of inheritance.

There are some changes in testdata related to inference of recursive
  functions with implicit return types.

After this commit they all are marked as unresolved. It happens because
  those functions have DeferredType as return type, and computing this
  type produces recursive exception, which provides “typechecker
  recursive problem” diagnostic.

Before this commit, function call was completed successfully, because
  call completer didn’t computed that type, and computation of DeferredType
  were triggered only in `DataFlowAnalyzer.checkType`.
Now, effect system tries to compute that type while wrapping KotlinTypes
  into ESTypes, and effect system itself is triggered in in call completer,
  so, call completion doesn’t finish and function call is marked as unresolved.

#KT-31364
2019-05-23 19:19:17 +03:00
Dmitriy Novozhilov
536e135c66 [NI] Fix recursion in contract declaration analysis.
#KT-30410 Fixed
2019-05-23 19:19:17 +03:00
Dmitriy Novozhilov
56768ff7ea [NI] Add check for non-null argument type in arguments check
#KT-31461 Fixed
2019-05-23 19:19:16 +03:00
Dmitriy Novozhilov
6f05bafeb3 [NI] Remove deep types in commosn super type for recursive types
#KT-30411 Fixed
2019-05-23 19:19:16 +03:00
Dmitriy Novozhilov
ec852452b0 [NI] Fix error type approximation in ILTApproximatorConfiguration
#KT-31441 Fixed
2019-05-23 19:19:15 +03:00
Sergey Rostov
61ba1c875a Gradle, js: fix js test frameworks DSL for groovy
#KT-31566 Fixed
2019-05-23 19:19:15 +03:00
Sergey Rostov
15f9895088 Gradle, test reports: NewMultiplatformIT.testJavaSupportInJvmTargets
"check" task, now creates aggregate report for all gradle versions,
so this test is affected too
2019-05-23 19:19:15 +03:00
Sergey Rostov
95d338db0d Gradle, tests: introduce kotlin.tests.individualTaskReports
This property required for getting individual junit.xml files that is
currently used in test run assertions.
2019-05-23 19:19:14 +03:00
Sergey Rostov
ca065eedce Gradle, js, single platform projects: create single test aggregator
Extract KotlinTestsRegistry service for customizing aggregated test tasks
naming.
2019-05-23 19:19:14 +03:00
Sergey Rostov
61fcc1cbd2 Gradle, js, tests: always create a jsTest task for compatibility
This requires runnable aggregate test task even if there are not tests in it.
That, in turn, requires support aggregate test tasks hierarchy.
Also TestReport integrated in aggregate for all gradle versions (was for 5 only).

#KT-31527 Fixed
2019-05-23 19:19:13 +03:00
Sergey Rostov
0e480fd040 Gradle, libWithTests test: check js tests running, add test results assertion 2019-05-23 19:19:13 +03:00
Sergey Rostov
c8788d93a3 Gradle, testing test execution: support asserting reports from multiple tasks at once 2019-05-23 19:19:12 +03:00
Sergey Rostov
7c24ed6152 Gradle, js, webpack: fix compatibility with older gradle version 2019-05-23 19:19:12 +03:00
Sergey Rostov
d666d2b186 Gradle, js, npm: try fixing project version to semver
JS package managers requires it.

#KT-31563 Fixed
2019-05-23 19:19:11 +03:00
victor.petukhov
91da355f49 Actualize spec tests 2019-05-23 19:19:11 +03:00
victor.petukhov
bdb7683887 Report warning about implicitly inferred nothing only for return position
^KT-31535 Fixed
2019-05-23 19:19:10 +03:00
Ilmir Usmanov
066ce5464a Do not generate $$forInline suffix for enclosing method
in OUTERCLASS field.

The inliner generates two versions of suspend functions/lambdas in
inline functions: with state-machine and without. The former is used
to call the function from Java or via reflection and have ordinary
name, while the latter is used by inliner and have $$forInline suffix.
The inliner throws the state-machine version away, duplicates
$$forInline version and then call state-machine generator.

If these suspend functions/lambdas are not going to be inlined,
$$forInline version is not generated. However, all objects, which are
used in these suspend functions/lambdas, have $$forInline version
written to OUTERCLASS field. This leads to errors by proguard.
Since they are used in both state-machine version and for-inline ones,
we can simply remove $$forInline suffix from OUTERCLASS field and this
fixes the issue.

 #KT-31242 Fixed
2019-05-23 19:19:10 +03:00
Ilmir Usmanov
7bc607c851 Fix Java interop of inline suspend functions with suspend parameters
In 1.3.31 I fixed Java interop for inline function with coroutines
(TL;DR: when we need a state machine, generate two methods: one with
normal name, and the other one with $$forInline suffix, for the inliner
to use, just like inline suspend functions), however, I forgot a case
with inline suspend function with inline suspend function parameter.
In this case, the compiler a generated two functions, as needed, but,
neither of them had a state-machine. This change adds the state-machine
for the method with normal name. Note, that suspend inline functions
with crossinline parameter, which are also supported by the change,
did not cause incorrect behaviour, since until now they were generated
as synthetic.

 #KT-31354 Fixed
2019-05-23 19:19:09 +03:00
Ilmir Usmanov
e12c7c8f59 Remove redundant continuation classes and INNERCLASS nodes
#KT-31339 Fixed
2019-05-23 19:19:09 +03:00
Ilya Matveev
3b2272ce6a Gradle plugin: remove old native binary APIs
This patch removes APIs for native binary configuring
introduced in 1.3.0 and deprecated in 1.3.30.

Issue #KT-31229 Fixed
2019-05-23 19:19:08 +03:00
Sergey Rostov
5c998b7a33 Gradle, js, npm: skip KotlinProjectExtensions from different class loaders 2019-05-23 19:19:08 +03:00
Sergey Rostov
cfbc44f97f Gradle, js: fix supporting sub targets DSL in build.gradle.kts 2019-05-23 19:19:08 +03:00
Sergey Rostov
224360aa2d Gradle, js, npm: skip old Kotlin2JsPlugin compilations 2019-05-23 19:19:07 +03:00
Sergey Rostov
aef162b1d2 Gradle, js: create run task only when project evaluated
As it may be created after js target configuration by java application plugin
2019-05-23 19:19:07 +03:00
Sergey Rostov
2f7eedd568 Gradle, js, npm: fix case when resolver visits dependents projects first 2019-05-23 19:19:06 +03:00
Sergey Rostov
b22102d252 Gradle, js: implement NpmSimpleLinker for cases when there are no npm dependencies 2019-05-23 19:19:06 +03:00
Sergey Rostov
e20fbee48c Gradle, js: fix task input annotations 2019-05-23 19:19:05 +03:00
Sergey Rostov
3ee7134540 Gradle, tests: don't use gradle testing internals by default 2019-05-23 19:19:05 +03:00
Sergey Rostov
462c5dea53 Gradle, tests: fix cleanAllTests task name 2019-05-23 19:19:04 +03:00
Sergey Rostov
0c13f4b1fc Gradle, js: update npm packages versions 2019-05-23 19:19:04 +03:00
Sergey Rostov
9975ec9d0d Gradle: introduce "target" DSL function for single platform plugins 2019-05-23 19:19:04 +03:00
Sergey Rostov
ecb56ebedc Gradle, js: introduce commonJs() dsl function 2019-05-23 19:19:03 +03:00
Sergey Rostov
eb2e37f8d2 Gradle, js, webpack: report progress
#KT-31013
2019-05-23 19:19:03 +03:00
Sergey Rostov
d9e46fef61 Gradle, js, yarn: split into workspaces and simple implementations
#KT-31018
	#KT-31017
2019-05-23 19:19:02 +03:00
Sergey Rostov
1ebb5145de Gradle, js, npm: store imported packages as yarn workspaces
#KT-30530
2019-05-23 19:19:02 +03:00
Sergey Rostov
1db0643460 Gradle, tests: fix type in "prepend" 2019-05-23 19:19:01 +03:00
Sergey Rostov
46ea87217f Gradle, js, karma: source maps support
#KT-31478
	#KT-31011
	#KT-30573
2019-05-23 19:19:01 +03:00
Sergey Rostov
0cc405a02f Gradle, js, tests: don't add prefix if platform and/or sub target name is null 2019-05-23 19:19:00 +03:00
Sergey Rostov
a102cbe469 Gradle, js: create npm packages per compilation
#KT-30530
2019-05-23 19:19:00 +03:00
Sergey Rostov
78b02e5efa Gradle, js: resolve npm dependencies without task only during IDEA import
#KT-30530
2019-05-23 19:18:59 +03:00
Sergey Rostov
277694a733 Gradle, js: create one npmResolve per build (share between subprojects)
#KT-30530
2019-05-23 19:18:59 +03:00
Sergey Rostov
4f0128f3ca Gradle, js, npm: remove hoisted gradle node modules. Split results collection from shared cache.
#KT-30530
2019-05-23 19:18:58 +03:00
Sergey Rostov
5ee77a02ea Gradle, js, npm: resolver between projects
#KT-30530
2019-05-23 19:18:58 +03:00
Sergey Rostov
7146f79bc9 Gradle, js: use project.whenEvaluated instead of project.afterEvaluate 2019-05-23 19:18:57 +03:00
Sergey Rostov
56310ae159 Gradle, js, dsl: use ConfigureUtil.configure for Groovy compatibility 2019-05-23 19:18:57 +03:00
Sergey Rostov
fe72bc494e Gradle, js, krama: use web pack config directory
#KT-31011
2019-05-23 19:18:56 +03:00
Sergey Rostov
4ac8a18367 Gradle, js: don't use any subtarget by default 2019-05-23 19:18:55 +03:00
Sergey Rostov
db7b4e29c4 Gradle, js, run: fix run dependencies on browserRun and nodeRun 2019-05-23 19:18:55 +03:00
Sergey Rostov
9b1d498663 Gradle, js, test: add basic @Input for test frameworks settings 2019-05-23 19:18:54 +03:00
Sergey Rostov
19656f7884 Gradle, js: aggregate jsTest task should work the same way as all tests aggregator
E.g: individual test tasks should not fail build, aggregate reports should be created.
Also this task should not be included in check (as all tests should be already executed
from the all tests aggregated task).
2019-05-23 19:18:54 +03:00
Sergey Rostov
64556720e1 Gradle, js, karma: show output as progress 2019-05-23 19:18:53 +03:00
Sergey Rostov
fa240df089 Gradle, js, yarn: remove outdated warning about yarn workspaces
#KT-31018
	#KT-31017
2019-05-23 19:18:53 +03:00
Sergey Rostov
79dc998331 Gradle, js: fixes for groovy dsl 2019-05-23 19:18:52 +03:00
Sergey Rostov
1c8580109b Gradle, js, browser: best effort for parsing karma suite names
#KT-31011
2019-05-23 19:18:52 +03:00
Sergey Rostov
6d579d59d9 Gradle, js, browser: fix karma.conf.js writer
#KT-31011
2019-05-23 19:18:51 +03:00
Sergey Rostov
93209bf67b Gradle, js, browser: fix run 2019-05-23 19:18:50 +03:00
Sergey Rostov
6c3ab15b03 Gradle, js: fix resolving required dependencies
#KT-31011
2019-05-23 19:18:50 +03:00
Sergey Rostov
3ee521700e Gradle, nodeJs: fix tests 2019-05-23 19:18:49 +03:00
Sergey Rostov
e8a30fb648 Gradle, js: revert to storing compile output inside node_modules
#KT-30530
Currently kotlin JS compiler generated `require('a.js')` for test -> main
dependencies. This is not worked in layout with compile output at project
work dir (will work if compiler will generate `require('a_test.js')`).
2019-05-23 19:18:49 +03:00
Sergey Rostov
734c894d37 Gradle, js: extract NpmProjectModules to separate file
#KT-30530
2019-05-23 19:18:48 +03:00
Sergey Rostov
b5a8258bef Gradle, js, node: fix source map support configuration
#KT-30573 Fixed
2019-05-23 19:18:48 +03:00
Sergey Rostov
4247ecba2e Gradle, js: fix nodejs run target 2019-05-23 19:18:47 +03:00
Sergey Rostov
0aa9edd833 Gradle, js: restore umd by default 2019-05-23 19:18:47 +03:00
Sergey Rostov
57bf604350 Gradle, js: fix karma.conf.js by wrapping config in function
#KT-31011
2019-05-23 19:18:46 +03:00
Sergey Rostov
5102c5b820 Gradle, js: implement resolving node modules according to https://nodejs.org/api/modules.html
#KT-30530
2019-05-23 19:18:46 +03:00
Sergey Rostov
666b23dc92 Gradle, js: fix requiredDependencies resolve 2019-05-23 19:18:45 +03:00
Sergey Rostov
302be0a5d2 Gradle, js: fix NodeJsExec 2019-05-23 19:18:45 +03:00
Sergey Rostov
a4d9f4c112 Gradle, js: use js compilation only after target configuration 2019-05-23 19:18:45 +03:00
Sergey Rostov
299cdf79cd Gradle, JS: make KotlinWebpack.configDirectory optional
#KT-31013
2019-05-23 19:18:44 +03:00
Sergey Rostov
543eabbd5f Gradle, JS: resolve NPM dependencies inside task when possible
#KT-30530
2019-05-23 19:18:44 +03:00
Sergey Rostov
50c25e2852 Gradle, JS: introduce RequiresNpmDependencies
#KT-30530
2019-05-23 19:18:43 +03:00
Sergey Rostov
9e327b932c Gradle, JS: extract npm package constants
#KT-30530
2019-05-23 19:18:42 +03:00
Sergey Rostov
988ee456f5 Gradle, JS: introduce inner browser and nodejs inner targets
#KT-30747 Fixed
2019-05-23 19:18:42 +03:00
Sergey Rostov
a9d32b17ff Gradle, JS: nodejs target 2019-05-23 19:18:41 +03:00
Sergey Rostov
e3429c7997 Gradle, JS, webpack: source maps support
#KT-31013
2019-05-23 19:18:41 +03:00
Sergey Rostov
55a7ae6acb Gradle, JS: new nodejs project layout
#KT-30530
2019-05-23 19:18:40 +03:00
Sergey Rostov
73cead421e Gradle, JS: webpack support
#KT-31013
2019-05-23 19:18:40 +03:00
Sergey Rostov
899917585b Gradle, tests: clean should depend on cleanAllTests 2019-05-23 19:18:39 +03:00
Sergey Rostov
d3fd16a491 Gradle, testsL fix ijListenTestTask 2019-05-23 19:18:39 +03:00
Sergey Rostov
a19790c16a Gradle, npm: resolve node_modules at parents, return local NodeJsExtension at NodeJsPlugin.apply 2019-05-23 19:18:38 +03:00
Sergey Rostov
3d6579e5a5 Gradle, yarn: get recursively resolved dependencies
#KT-31018 Fixed
	#KT-31016 Fixed
	#KT-31017 Fixed
2019-05-23 19:18:38 +03:00
Sergey Rostov
eaca460d80 Gradle: improve tasks registration API, fix test tasks registration
Previously test tasks may be created inside other registration task
lambda which may be called lazily. This is illegal in Gradle.

Also let introduce Project.createOrRegisterTask on Project receiver
and reified type parameter.
2019-05-23 19:18:37 +03:00
Sergey Rostov
686bc8af83 Gradle: webpack
#KT-31013 Fixed
	#KT-31014 Fixed
2019-05-23 19:18:37 +03:00
Sergey Rostov
6c539e6b73 Gradle, tests: remove "Task" suffix from KotlinTest tasks (as for jvm) 2019-05-23 19:18:36 +03:00
Sergey Rostov
8be1aba2c8 Gradle, js: karma
#KT-31011 fixed
2019-05-23 19:18:35 +03:00
Sergey Rostov
b27b22e30f Gradle, js: mocha
#KT-31010 Fixed
2019-05-23 19:18:35 +03:00
Sergey Rostov
2946237005 Gradle, npm: disable manageNodeModules by default
#KT-30530
2019-05-23 19:18:34 +03:00
Sergey Rostov
de242623d7 Gradle, js: run tests using the new project-wide node_modules
#KT-30530
2019-05-23 19:18:34 +03:00
Sergey Rostov
b5dcfb2c5a Gradle: npm integration using yarn
#KT-31018 Fixed
2019-05-23 19:18:33 +03:00
Sergey Rostov
c6d560b2e6 Gradle, Tests runner: update tests, fix tests on Windows 2019-05-23 19:18:33 +03:00
Sergey Rostov
02e38b6e22 Gradle, Native: don't capture output if treatOutputAsStracktrace enabled
#KT-30529
2019-05-23 19:18:32 +03:00
Sergey Rostov
7b662a2fe3 Gradle, tests: cleanAllTests task
#KT-29946
2019-05-23 19:18:31 +03:00
Sergey Rostov
99b6ee5ee3 Gradle, tests: show test results in IDE
#KT-29946
2019-05-23 19:18:31 +03:00
Sergey Rostov
b653d81bfe Gradle: Kotlin/Native stack trace parser
#KT-30526
	#KT-30529
2019-05-23 19:18:30 +03:00
Sergey Rostov
97084112b3 Gradle: JS stack trace parser
#KT-30526
2019-05-23 19:18:29 +03:00
Sergey Rostov
8a54ab3dd2 Gradle, test: allTests task, same class and method names for jvm, js and native
#KT-30691 Fixed
	#KT-31448 Fixed
2019-05-23 19:18:29 +03:00
Elena Lepilkina
ee74bdacc0 New Kotlin/Native version 2019-05-22 18:19:03 +03:00
Vyacheslav Gerasimov
c12b784e5b Build: Fix cache redirector configuration for all projects
Since we forcing project evaluation in root build script cache redirector
should be configured before we do so, otherwise `afterEvaluate` is not called

(cherry picked from commit 40e9f48bd0)
2019-05-20 15:18:25 +03:00
nikita.movshin
f0555ab5df Fix changelog for 1.3.40 2019-05-17 20:59:49 +03:00
nikita.movshin
cac8f3ace3 Add changelog for 1.3.40 2019-05-17 20:57:41 +03:00
Elena Lepilkina
d331c7d376 New EAP buikd of Kotlin/Native 2019-05-17 10:17:53 +03:00
Roman Artemev
ad4671ed5f [IR BE] Delegate coroutine naming strategy to platform part
(cherry picked from commit 02d84bf061)
2019-05-16 19:20:41 +03:00
Alexey Tsvetkov
7cc4c606a1 Do not expose paths with placeholders in JS IC caches
#KT-31310 Fixed
2019-05-16 04:07:14 +03:00
Elena Lepilkina
009e33ed72 Changed Kotlin/Native version (EAP1) 2019-05-15 12:09:26 +03:00
Dmitry Gridin
2d83ceb980 Fix "Unused import" for 'provideDelegate'
#KT-31319 Fixed

(cherry picked from commit eee8d0263d)
2019-05-14 22:02:23 +07:00
Dmitry Gridin
966dd3ee24 Don't delete import from stdlib if alias exists and used
#KT-31414 Fixed

(cherry picked from commit 3914530fa8)
2019-05-14 22:02:07 +07:00
Dmitry Gridin
efdb19772b Optimize Imports shouldn't delete imports with unresolved parts
#KT-10512 Fixed

(cherry picked from commit 32298522dd)
2019-05-14 22:01:42 +07:00
Ilya Gorbunov
7accee269b Add simplified overloads of String<->ByteArray/CharArray conversions
These overloads cover the most common cases of conversion of the entire
String or Byte/CharArray, avoiding extra index check and branching.

#KT-24810, KT-29265

(cherry picked from commit 2c26dc3af6)
2019-05-14 17:54:13 +03:00
Mikhail Glukhikh
012b8f76a0 Fix .inspection file for ConvertNaNEquality tests
(cherry picked from commit 2d5f41cfe3)
2019-05-14 16:50:51 +03:00
Matthew Runo
01551d1bad Migrate RetentionPolicy arguments in deprecated Java quick-fix
#KT-29666 Fixed

(cherry picked from commit 39f576d75c)
2019-05-14 09:28:49 +03:00
Toshiaki Kameyama
be2c670c09 Implicit Nothing? type: don't report when declaration overrides nullable nothing type
#KT-30481 Fixed

(cherry picked from commit 14259ca9e0)
2019-05-14 09:28:23 +03:00
Dereck Bridie
a3ebd0751c KT-26629 Inspection to replace equality check with NaN with isNaN call
(cherry picked from commit 574178882a)
2019-05-14 09:27:58 +03:00
Mikhail Glukhikh
9d013254a4 Add name to argument: support old-style comment deletion
(cherry picked from commit b4a63794e5)
2019-05-14 09:27:36 +03:00
Mikhail Glukhikh
15045d2512 Use candidate descriptor to determine parameter name stability in IDEA
#KT-31349 Fixed

(cherry picked from commit b0d294b50c)
2019-05-14 09:27:12 +03:00
Mikhail Glukhikh
fa9cf694dd Apply "unnamed boolean literal" to idea & J2K + other style fixes
(cherry picked from commit d517276a06)
2019-05-14 09:26:51 +03:00
Mikhail Glukhikh
d849bde003 Introduce "add parameter names to following arguments"
This commit also refactors relevant intentions & inspections,
like "add name to argument", "add names to call arguments",
"unnamed boolean literal argument"

#KT-30622 Fixed

(cherry picked from commit 955bfd6e7b)
2019-05-14 09:26:25 +03:00
Sergey Igushkin
5694726f04 Introduce Java support in JVM MPP targets (KT-26256)
Deprecate the `jvmWithJava` preset, add warning.

Add a function `withJava()` to JVM MPP targets which applies the 'java'
plugin and sets up the Kotlin & Java interoperation.

Issue #KT-26256 Fixed

Signed-off-by: Sergey Igushkin <hotkeytlt@gmail.com>
(cherry picked from commit be05095df5)
2019-05-13 18:11:04 +03:00
Mikhail Zarechenskiy
d277ddb38c [NI] Complete call if return type contains only "good" type variables 2019-05-13 16:21:01 +03:00
Mikhail Zarechenskiy
3d6c735538 [NI] Complete call if return type has proper lower or equal constraints
There was a silly bug: equal constraint is actually a lower and an upper
 constraint, but we checked only presence of lower constraints.

 Test is important as here we have one equal constraint and should
 complete inner call `foo<Int>()` without propagating it to `bar` to
 avoid using `NoInfer` annotation multiple times
2019-05-13 16:20:52 +03:00
Mikhail Zarechenskiy
8165d07346 [NI] Use original implicit receiver for DSL violation check
There is an inconsistency between old and new inference for storing
 receivers of resolved calls. In new inference, for captured types,
 receiver will be changed and to preserve behavior of the old inference,
 we use original one during important checks.
 This is more a workaround than a solution and should be revisited.

 #KT-31356 Fixed
 #KT-29948 Fixed
 #KT-31360 Fixed
2019-05-13 16:20:43 +03:00
Mikhail Zarechenskiy
2a58d137e2 [NI] Preserve annotations during type substitution
#KT-31346 Fixed
2019-05-13 16:20:34 +03:00
Toshiaki Kameyama
b6f2cc125a "Redundant 'requireNotNull' or 'checkNotNull' call": don't remove first argument if function is used as expression
#KT-31404 Fixed

(cherry picked from commit cf4471ba53)
2019-05-13 17:05:02 +07:00
Dmitry Gridin
40f2823278 Fix incorrect quickfix "Replace with Kotlin analog" for conversion to an extension
where the first argument is an expression with an operation
 #KT-31341 Fixed

(cherry picked from commit 07e908f15f)
2019-05-13 17:04:49 +07:00
Natalia Selezneva
aa6d3c3fbe Fix NPE in SLRUMap in ScriptDefinitionsManager
EA-138364 - NPE: LinkedHashMap$Entry.access$

(cherry picked from commit e158875a14)
2019-05-13 12:39:50 +03:00
Natalia Selezneva
469230016e Do not provide 'add dependency' quick fix for unresolved references for non-project files
EA-126105 - NPE: JavaFileManagerImpl$LibSrcExcludingScope.<init> (KotlinAddOrderEntryActionFactory)

(cherry picked from commit 2a2fe6b428)
2019-05-13 12:39:13 +03:00
Natalia Selezneva
ce55ae31b5 Fix 'Invalid file' Exception during script definition search (EA-125840)
EA-125840 - assert: FileManagerImpl.findFile

(cherry picked from commit ba7d66eb4b)
2019-05-13 12:38:49 +03:00
Natalia Selezneva
703dd28553 Do not use canonical paths in OutsidersPsiFileSupportUtils (EA-135551)
EA-135551 - IOE: OutsidersPsiFileSupportUtils$getOutsiderFileOrigin$.invoke

(cherry picked from commit 836006b3f3)
2019-05-13 12:38:28 +03:00
Natalia Selezneva
3249a82f33 Fix notification about highlighting for diff view in build.gradle.kts (KT-30638)
(cherry picked from commit 98235952ad)

^KT-30638 Fixed
2019-05-13 12:38:02 +03:00
Natalia Selezneva
c5d590cbfd Fix highlighting for scripts in diff view (KT-30690)
(cherry picked from commit 495d98f997)

^KT-30690 Fixed
2019-05-13 12:37:00 +03:00
Natalia Selezneva
1fe369bf84 Minor: extract common parts
(cherry picked from commit 88c6ecbbdf)
2019-05-13 12:36:28 +03:00
Natalia Selezneva
33246782dc Run indexes update after typing in script if needed
(cherry picked from commit 89bf7f991a)
2019-05-13 12:36:02 +03:00
Natalia Selezneva
49c539eb39 Refactoring: add isApplicable method to ScriptDependenciesLoader
(cherry picked from commit 9e51f82248)
2019-05-13 12:35:32 +03:00
Natalia Selezneva
1a8dbc07ed Do not start script dependencies update if dependencies are already cached
(cherry picked from commit e990c61b55)
2019-05-13 12:35:08 +03:00
LepilkinaElena
6c0750e975 Version of K/N for MPP is set to EAP0 version 2019-05-07 14:50:59 +03:00
1057 changed files with 29641 additions and 13481 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.metadata.js.JsProtoBuf
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.parentOrNull
import org.jetbrains.kotlin.serialization.deserialization.getClassId
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
import java.io.DataInput
@@ -41,6 +42,7 @@ open class IncrementalJsCache(
private const val TRANSLATION_RESULT_MAP = "translation-result"
private const val INLINE_FUNCTIONS = "inline-functions"
private const val HEADER_FILE_NAME = "header.meta"
private const val PACKAGE_META_FILE = "packages-meta"
fun hasHeaderFile(cachesDir: File) = File(cachesDir, HEADER_FILE_NAME).exists()
}
@@ -49,8 +51,10 @@ open class IncrementalJsCache(
override val dirtyOutputClassesMap = registerMap(DirtyClassesFqNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
private val translationResults = registerMap(TranslationResultMap(TRANSLATION_RESULT_MAP.storageFile, pathConverter))
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile, pathConverter))
private val packageMetadata = registerMap(PackageMetadataMap(PACKAGE_META_FILE.storageFile))
private val dirtySources = hashSetOf<File>()
private val dirtyPackages = hashSetOf<String>()
private val headerFile: File
get() = File(cachesDir, HEADER_FILE_NAME)
@@ -63,6 +67,11 @@ open class IncrementalJsCache(
}
override fun markDirty(removedAndCompiledSources: Collection<File>) {
removedAndCompiledSources.forEach { sourceFile ->
sourceToClassesMap[sourceFile].forEach {
dirtyPackages += it.parentOrNull()?.asString() ?: ""
}
}
super.markDirty(removedAndCompiledSources)
dirtySources.addAll(removedAndCompiledSources)
}
@@ -95,6 +104,11 @@ open class IncrementalJsCache(
for ((srcFile, inlineDeclarations) in incrementalResults.inlineFunctions) {
inlineFunctions.process(srcFile, inlineDeclarations, changesCollector)
}
for ((packageName, metadata) in incrementalResults.packageMetadata) {
packageMetadata.put(packageName, metadata)
dirtyPackages.remove(packageName)
}
}
private fun registerOutputForFile(srcFile: File, name: FqName) {
@@ -108,19 +122,31 @@ open class IncrementalJsCache(
inlineFunctions.remove(it)
}
removeAllFromClassStorage(dirtyOutputClassesMap.getDirtyOutputClasses(), changesCollector)
dirtyPackages.forEach {
packageMetadata.remove(it)
}
dirtySources.clear()
dirtyOutputClassesMap.clean()
dirtyPackages.clear()
}
fun nonDirtyPackageParts(): Map<File, TranslationResultValue> =
hashMapOf<File, TranslationResultValue>().apply {
for (path in translationResults.keys()) {
val file = File(path)
for (file in translationResults.keys()) {
if (file !in dirtySources) {
put(file, translationResults[file]!!)
}
}
}
fun packageMetadata(): Map<String, ByteArray> = hashMapOf<String, ByteArray>().apply {
for (fqNameString in packageMetadata.keys()) {
if (fqNameString !in dirtyPackages) {
put(fqNameString, packageMetadata[fqNameString]!!)
}
}
}
}
private object TranslationResultValueExternalizer : DataExternalizer<TranslationResultValue> {
@@ -155,7 +181,8 @@ private object TranslationResultValueExternalizer : DataExternalizer<Translation
private class TranslationResultMap(
storageFile: File,
private val pathConverter: FileToPathConverter
) : BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
) :
BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
override fun dumpValue(value: TranslationResultValue): String =
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, InlineData: ${value.inlineData.md5()}"
@@ -167,8 +194,8 @@ private class TranslationResultMap(
operator fun get(sourceFile: File): TranslationResultValue? =
storage[pathConverter.toPath(sourceFile)]
fun keys(): Collection<String> =
storage.keys
fun keys(): Collection<File> =
storage.keys.map { pathConverter.toFile(it) }
fun remove(sourceFile: File, changesCollector: ChangesCollector) {
val path = pathConverter.toPath(sourceFile)
@@ -182,7 +209,7 @@ private class TranslationResultMap(
}
}
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
val classes = hashMapOf<ClassId, ProtoData>()
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, JsSerializerProtocol.extensionRegistry)
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
@@ -228,4 +255,35 @@ private class InlineFunctionsMap(
override fun dumpValue(value: Map<String, Long>): String =
value.dumpMap { java.lang.Long.toHexString(it) }
}
private object ByteArrayExternalizer : DataExternalizer<ByteArray> {
override fun save(output: DataOutput, value: ByteArray) {
output.writeInt(value.size)
output.write(value)
}
override fun read(input: DataInput): ByteArray {
val size = input.readInt()
val array = ByteArray(size)
input.readFully(array)
return array
}
}
private class PackageMetadataMap(storageFile: File) : BasicStringMap<ByteArray>(storageFile, ByteArrayExternalizer) {
fun put(packageName: String, newMetadata: ByteArray) {
storage[packageName] = newMetadata
}
fun remove(packageName: String) {
storage.remove(packageName)
}
fun keys() = storage.keys
operator fun get(packageName: String) = storage[packageName]
override fun dumpValue(value: ByteArray): String = "Package metadata: ${value.md5()}"
}

View File

@@ -18,4 +18,7 @@ class IncrementalDataProviderFromCache(private val cache: IncrementalJsCache) :
override val metadataVersion: IntArray
get() = JsMetadataVersion.INSTANCE.toArray() // TODO: store and load correct metadata version
override val packageMetadata: Map<String, ByteArray>
get() = cache.packageMetadata()
}

View File

@@ -205,7 +205,7 @@ private fun kjsmToString(kjsmFile: File): String {
}
private fun sourceMapFileToString(sourceMapFile: File, generatedJsFile: File): String {
val sourceMapParseResult = SourceMapParser.parse(StringReader(sourceMapFile.readText()))
val sourceMapParseResult = SourceMapParser.parse(sourceMapFile.readText())
return when (sourceMapParseResult) {
is SourceMapSuccess -> {
val bytesOut = ByteArrayOutputStream()

View File

@@ -155,10 +155,10 @@ extra["versions.org.springframework"] = "4.2.0.RELEASE"
extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.kotlin-native-shared"] = "1.0-dev-50"
extra["versions.kotlin-native-shared"] = "1.0-dev-89"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.3-dev-9780"
extra["versions.kotlin-native"] = "1.3.1"
}
val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
@@ -381,6 +381,11 @@ allprojects {
dependencies.add(it.name, files(bootstrapCompilerClasspath))
}
}
if (cacheRedirectorEnabled()) {
logger.info("Redirecting repositories for $displayName")
repositories.redirect()
}
}
}
@@ -489,7 +494,12 @@ tasks {
create("scriptingTest") {
dependsOn("dist")
dependsOn(":kotlin-script-util:test")
dependsOn(":kotlin-scripting-jvm-host:test")
dependsOn(":kotlin-scripting-compiler:test")
dependsOn(":kotlin-scripting-jvm-host-test:test")
dependsOn(":kotlin-scripting-jsr223-test:test")
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
dependsOn(":kotlin-main-kts-test:test")
}
create("compilerTest") {
@@ -730,12 +740,3 @@ tasks.create("findShadowJarsInClasspath").doLast {
project.checkConfig("testCompileClasspath")
}
}
allprojects {
afterEvaluate {
if (cacheRedirectorEnabled()) {
logger.info("Redirecting repositories for $displayName")
repositories.redirect()
}
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import org.gradle.api.Project
interface CompatibilityPredicate {
fun matches(ide: Ide): Boolean
operator fun invoke(): Boolean = matches(IdeVersionConfigurator.currentIde)
operator fun invoke(block: () -> Unit): Unit {
if (matches(IdeVersionConfigurator.currentIde)) {
block()
}
}
}
val CompatibilityPredicate.not: CompatibilityPredicate get() = object : CompatibilityPredicate {
override fun matches(ide: Ide) = !this@not.matches(ide)
}
fun CompatibilityPredicate.or(other: CompatibilityPredicate): CompatibilityPredicate = object : CompatibilityPredicate {
override fun matches(ide: Ide) = this@or.matches(ide) || other.matches(ide)
}
enum class Platform : CompatibilityPredicate {
P181, P182, P183, P191, P192;
val version: Int = name.drop(1).toInt()
override fun matches(ide: Ide) = ide.platform == this
companion object {
operator fun get(version: Int): Platform {
return Platform.values().firstOrNull { it.version == version }
?: error("Can't find platform $version")
}
}
}
enum class Ide(val platform: Platform) : CompatibilityPredicate {
IJ181(Platform.P181),
IJ182(Platform.P182),
IJ183(Platform.P183),
IJ191(Platform.P191),
IJ192(Platform.P192),
AS32(Platform.P181),
AS33(Platform.P182),
AS34(Platform.P183),
AS35(Platform.P183);
val kind = Kind.values().first { it.shortName == name.take(2) }
val version = name.dropWhile { !it.isDigit() }.toInt()
override fun matches(ide: Ide) = ide == this
enum class Kind(val shortName: String) {
AndroidStudio("AS"), IntelliJ("IJ")
}
companion object {
val IJ: CompatibilityPredicate = IdeKindPredicate(Kind.IntelliJ)
val AS: CompatibilityPredicate = IdeKindPredicate(Kind.AndroidStudio)
}
}
val Platform.orHigher get() = object : CompatibilityPredicate {
override fun matches(ide: Ide) = ide.platform.version >= version
}
val Platform.orLower get() = object : CompatibilityPredicate {
override fun matches(ide: Ide) = ide.platform.version <= version
}
val Ide.orHigher get() = object : CompatibilityPredicate {
override fun matches(ide: Ide) = ide.kind == kind && ide.version >= version
}
val Ide.orLower get() = object : CompatibilityPredicate {
override fun matches(ide: Ide) = ide.kind == kind && ide.version <= version
}
object IdeVersionConfigurator {
lateinit var currentIde: Ide
fun setCurrentIde(project: Project) {
val platformVersion = project.rootProject.extensions.extraProperties["versions.platform"].toString()
val ideName = if (platformVersion.startsWith("AS")) platformVersion else "IJ$platformVersion"
currentIde = Ide.valueOf(ideName)
}
}
private class IdeKindPredicate(val kind: Ide.Kind) : CompatibilityPredicate {
override fun matches(ide: Ide) = ide.kind == kind
}

View File

@@ -130,7 +130,7 @@ fun parse(project: Project, libraries: List<PLibrary>, context: ParserContext):
*/
private val CONFIGURATION_MAPPING = mapOf(
listOf("runtime") to Scope.RUNTIME,
listOf("compile") to Scope.COMPILE,
listOf("compile", "embedded") to Scope.COMPILE,
listOf("compileOnly") to Scope.PROVIDED
)
@@ -317,7 +317,12 @@ private val SourceSet.isTestSourceSet: Boolean
|| name.endsWith("Tests")
private fun getKotlinOptions(kotlinCompileTask: Any): PSourceRootKotlinOptions? {
val compileArguments = kotlinCompileTask.invokeInternal("getSerializedCompilerArguments") as List<String>
val compileArguments = run {
val method = kotlinCompileTask::class.java.getMethod("getSerializedCompilerArguments")
method.isAccessible = true
method.invoke(kotlinCompileTask) as List<String>
}
fun parseBoolean(name: String) = compileArguments.contains("-$name")
fun parseString(name: String) = compileArguments.dropWhile { it != "-$name" }.drop(1).firstOrNull()

View File

@@ -65,7 +65,8 @@ import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isToArrayFromCollection
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineWithReified;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmSyntheticAnnotation;
@@ -388,7 +389,8 @@ public class AsmUtil {
flags |= getVarargsFlag(functionDescriptor);
flags |= getDeprecatedAccessFlag(functionDescriptor);
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
(functionDescriptor.isSuspend()) && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
isInlineWithReified(functionDescriptor) ||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
flags |= ACC_SYNTHETIC;
}
return flags;
@@ -526,7 +528,7 @@ public class AsmUtil {
return ACC_PRIVATE;
}
if (isEffectivelyInlineOnly(memberDescriptor)) {
if (isInlineOnlyPrivateInBytecode(memberDescriptor)) {
return ACC_PRIVATE;
}

View File

@@ -195,7 +195,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
);
}
else {
propertyCodegen.generatePrimaryConstructorProperty(p, propertyDescriptor);
propertyCodegen.generatePrimaryConstructorProperty(propertyDescriptor);
}
}
}

View File

@@ -134,7 +134,7 @@ public class ConstructorCodegen {
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor, typeMapper);
functionCodegen.generateMethod(
JvmDeclarationOriginKt.OtherOrigin(constructor, constructorDescriptor),
JvmDeclarationOriginKt.OtherOrigin(constructorDescriptor),
constructorDescriptor, constructorContext,
new FunctionGenerationStrategy.CodegenBased(state) {
@Override

View File

@@ -76,6 +76,7 @@ import static org.jetbrains.kotlin.descriptors.ModalityKt.isOverridable;
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.InlineClassManglingRulesKt.shouldHideConstructorDueToInlineClassTypeValueParameters;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
@@ -1153,10 +1154,10 @@ public class FunctionCodegen {
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
// $default methods are never protected to be accessible from subclass nested classes
int visibilityFlag = Visibilities.isPrivate(functionDescriptor.getVisibility()) ||
isEffectivelyInlineOnly(functionDescriptor) ?
AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
int visibilityFlag =
Visibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
if (!(functionDescriptor instanceof ConstructorDescriptor &&
!InlineClassesUtilsKt.isInlineClass(functionDescriptor.getContainingDeclaration()))
) {

View File

@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaForKotlinOverridePropertyDescriptor
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmDefaultAnnotation
import org.jetbrains.kotlin.resolve.jvm.annotations.hasPlatformDependentAnnotation
@@ -42,18 +44,27 @@ class DescriptorBasedFunctionHandleForJvm(
override val mightBeIncorrectCode: Boolean
get() = state.classBuilderMode.mightBeIncorrectCode
override fun hashCode(): Int = descriptor.containerEntityForEqualityAndHashCode().hashCode() + 31 * asmMethod.hashCode()
override fun equals(other: Any?): Boolean {
if (other !is DescriptorBasedFunctionHandleForJvm) return false
override fun hashCode(): Int =
(descriptor.containerEntityForEqualityAndHashCode().hashCode() * 31 +
descriptor.isJavaForKotlinOverrideProperty.hashCode()) * 31 +
asmMethod.hashCode()
return asmMethod == other.asmMethod &&
descriptor.containerEntityForEqualityAndHashCode() == other.descriptor.containerEntityForEqualityAndHashCode()
override fun equals(other: Any?): Boolean {
if (this === other) return true
return other is DescriptorBasedFunctionHandleForJvm &&
asmMethod == other.asmMethod &&
descriptor.containerEntityForEqualityAndHashCode() == other.descriptor.containerEntityForEqualityAndHashCode() &&
descriptor.isJavaForKotlinOverrideProperty == other.descriptor.isJavaForKotlinOverrideProperty
}
}
private fun FunctionDescriptor.containerEntityForEqualityAndHashCode(): Any =
(containingDeclaration as? ClassDescriptor)?.typeConstructor ?: containingDeclaration
private val FunctionDescriptor.isJavaForKotlinOverrideProperty: Boolean
get() = this is PropertyAccessorDescriptor && correspondingProperty is JavaForKotlinOverridePropertyDescriptor
private fun CallableMemberDescriptor.isJvmDefaultOrPlatformDependent() =
hasJvmDefaultAnnotation() || hasPlatformDependentAnnotation()

View File

@@ -106,17 +106,24 @@ public class PropertyCodegen {
);
}
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) variableDescriptor;
genDestructuringDeclaration(entry, propertyDescriptor);
if (!UnderscoreUtilKt.isSingleUnderscore(entry)) {
genDestructuringDeclaration((PropertyDescriptor) variableDescriptor);
}
}
public void generateInPackageFacade(@NotNull DeserializedPropertyDescriptor deserializedProperty) {
assert context instanceof MultifileClassFacadeContext : "should be called only for generating facade: " + context;
gen(null, deserializedProperty, null, null);
genBackingFieldAndAnnotations(deserializedProperty);
if (!isConstOrHasJvmFieldAnnotation(deserializedProperty)) {
generateGetter(deserializedProperty, null);
generateSetter(deserializedProperty, null);
}
}
private void gen(
@Nullable KtProperty declaration,
@NotNull KtProperty declaration,
@NotNull PropertyDescriptor descriptor,
@Nullable KtPropertyAccessor getter,
@Nullable KtPropertyAccessor setter
@@ -125,15 +132,15 @@ public class PropertyCodegen {
kind == OwnerKind.DEFAULT_IMPLS || kind == OwnerKind.ERASED_INLINE_CLASS
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
genBackingFieldAndAnnotations(declaration, descriptor);
genBackingFieldAndAnnotations(descriptor);
boolean isDefaultGetterAndSetter = isDefaultAccessor(getter) && isDefaultAccessor(setter);
if (isAccessorNeeded(declaration, descriptor, getter, isDefaultGetterAndSetter)) {
generateGetter(declaration, descriptor, getter);
generateGetter(descriptor, getter);
}
if (isAccessorNeeded(declaration, descriptor, setter, isDefaultGetterAndSetter)) {
generateSetter(declaration, descriptor, setter);
generateSetter(descriptor, setter);
}
}
@@ -141,29 +148,23 @@ public class PropertyCodegen {
return accessor == null || !accessor.hasBody();
}
private void genDestructuringDeclaration(
@NotNull KtDestructuringDeclarationEntry entry,
@NotNull PropertyDescriptor descriptor
) {
private void genDestructuringDeclaration(@NotNull PropertyDescriptor descriptor) {
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DEFAULT_IMPLS
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
if (UnderscoreUtilKt.isSingleUnderscore(entry)) return;
genBackingFieldAndAnnotations(descriptor);
genBackingFieldAndAnnotations(entry, descriptor);
generateGetter(entry, descriptor, null);
generateSetter(entry, descriptor, null);
generateGetter(descriptor, null);
generateSetter(descriptor, null);
}
private void genBackingFieldAndAnnotations(@Nullable KtNamedDeclaration declaration, @NotNull PropertyDescriptor descriptor) {
private void genBackingFieldAndAnnotations(@NotNull PropertyDescriptor descriptor) {
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
? !(context instanceof MultifileClassPartContext)
: CodegenContextUtil.isImplementationOwner(context, descriptor);
assert declaration != null : "Declaration is null: " + descriptor + " (context=" + context + ")";
generateBackingField(declaration, descriptor, isBackingFieldOwner);
generateBackingField(descriptor, isBackingFieldOwner);
generateSyntheticMethodIfNeeded(descriptor, isBackingFieldOwner);
}
@@ -174,7 +175,7 @@ public class PropertyCodegen {
* @see JvmCodegenUtil#couldUseDirectAccessToProperty
*/
private boolean isAccessorNeeded(
@Nullable KtProperty declaration,
@NotNull KtProperty declaration,
@NotNull PropertyDescriptor descriptor,
@Nullable KtPropertyAccessor accessor,
boolean isDefaultGetterAndSetter
@@ -186,8 +187,6 @@ public class PropertyCodegen {
// Don't generate accessors for interface properties with default accessors in DefaultImpls
if (kind == OwnerKind.DEFAULT_IMPLS && isDefaultAccessor) return false;
if (declaration == null) return true;
// Delegated or extension properties can only be referenced via accessors
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
@@ -203,7 +202,7 @@ public class PropertyCodegen {
}
// Non-const properties from multifile classes have accessors regardless of visibility
if (isNonConstTopLevelPropertyInMultifileClass(declaration, descriptor)) return true;
if (isTopLevelPropertyInMultifileClass(declaration, descriptor)) return true;
// Private class properties have accessors only in cases when those accessors are non-trivial
if (Visibilities.isPrivate(descriptor.getVisibility())) {
@@ -212,6 +211,7 @@ public class PropertyCodegen {
// Non-private properties with private setter should not be generated for trivial properties
// as the class will use direct field access instead
//noinspection ConstantConditions
if (accessor != null && accessor.isSetter() && Visibilities.isPrivate(descriptor.getSetter().getVisibility())) {
return !isDefaultAccessor;
}
@@ -219,12 +219,11 @@ public class PropertyCodegen {
return true;
}
private static boolean isNonConstTopLevelPropertyInMultifileClass(
private static boolean isTopLevelPropertyInMultifileClass(
@NotNull KtProperty declaration,
@NotNull PropertyDescriptor descriptor
) {
return !descriptor.isConst() &&
descriptor.getContainingDeclaration() instanceof PackageFragmentDescriptor &&
return descriptor.getContainingDeclaration() instanceof PackageFragmentDescriptor &&
JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration);
}
@@ -244,12 +243,12 @@ public class PropertyCodegen {
}
}
public void generatePrimaryConstructorProperty(@NotNull KtParameter parameter, @NotNull PropertyDescriptor descriptor) {
genBackingFieldAndAnnotations(parameter, descriptor);
public void generatePrimaryConstructorProperty(@NotNull PropertyDescriptor descriptor) {
genBackingFieldAndAnnotations(descriptor);
if (areAccessorsNeededForPrimaryConstructorProperty(descriptor, context.getContextKind())) {
generateGetter(parameter, descriptor, null);
generateSetter(parameter, descriptor, null);
generateGetter(descriptor, null);
generateSetter(descriptor, null);
}
}
@@ -312,17 +311,14 @@ public class PropertyCodegen {
return null;
}
private void generateBackingField(
@NotNull KtNamedDeclaration p,
@NotNull PropertyDescriptor descriptor,
boolean isBackingFieldOwner
) {
private void generateBackingField(@NotNull PropertyDescriptor descriptor, boolean isBackingFieldOwner) {
if (isJvmInterface(descriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS ||
kind == OwnerKind.ERASED_INLINE_CLASS) {
return;
}
boolean isDelegate = p instanceof KtProperty && ((KtProperty) p).hasDelegate();
@SuppressWarnings("deprecation")
boolean isDelegate = descriptor.isDelegated();
Object defaultValue;
if (isDelegate) {
@@ -341,7 +337,7 @@ public class PropertyCodegen {
return;
}
generateBackingField(p, descriptor, isDelegate, defaultValue, isBackingFieldOwner);
generateBackingField(descriptor, isDelegate, defaultValue, isBackingFieldOwner);
}
// Annotations on properties are stored in bytecode on an empty synthetic method. This way they're still
@@ -364,7 +360,6 @@ public class PropertyCodegen {
}
private void generateBackingField(
@NotNull KtNamedDeclaration element,
@NotNull PropertyDescriptor propertyDescriptor,
boolean isDelegate,
@Nullable Object defaultValue,
@@ -390,8 +385,7 @@ public class PropertyCodegen {
modifiers |= ACC_SYNTHETIC;
}
KotlinType kotlinType = isDelegate ? getDelegateTypeForProperty((KtProperty) element, propertyDescriptor, bindingContext)
: propertyDescriptor.getType();
KotlinType kotlinType = isDelegate ? getDelegateTypeForProperty(propertyDescriptor, bindingContext) : propertyDescriptor.getType();
Type type = typeMapper.mapType(kotlinType);
ClassBuilder builder = v;
@@ -419,7 +413,7 @@ public class PropertyCodegen {
if (isBackingFieldOwner) {
FieldVisitor fv = builder.newField(
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
JvmDeclarationOriginKt.OtherOrigin(propertyDescriptor), modifiers, name, type.getDescriptor(),
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
);
@@ -431,22 +425,25 @@ public class PropertyCodegen {
@NotNull
public static KotlinType getDelegateTypeForProperty(
@NotNull KtProperty p,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull BindingContext bindingContext
) {
KotlinType delegateType = null;
ResolvedCall<FunctionDescriptor> provideDelegateResolvedCall =
bindingContext.get(BindingContext.PROVIDE_DELEGATE_RESOLVED_CALL, propertyDescriptor);
KtExpression delegateExpression = p.getDelegateExpression();
KtProperty property = (KtProperty) DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
KtExpression delegateExpression = property != null ? property.getDelegateExpression() : null;
KotlinType delegateType;
if (provideDelegateResolvedCall != null) {
delegateType = provideDelegateResolvedCall.getResultingDescriptor().getReturnType();
}
else if (delegateExpression != null) {
delegateType = bindingContext.getType(delegateExpression);
}
else {
delegateType = null;
}
if (delegateType == null) {
// Delegation convention is unresolved
@@ -469,51 +466,49 @@ public class PropertyCodegen {
return false;
}
private void generateGetter(
@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor getter
) {
generateAccessor(p, getter, descriptor.getGetter() != null
? descriptor.getGetter()
: DescriptorFactory.createDefaultGetter(descriptor, Annotations.Companion.getEMPTY()));
private void generateGetter(@NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor getter) {
generateAccessor(
getter,
descriptor.getGetter() != null ? descriptor.getGetter() : DescriptorFactory.createDefaultGetter(
descriptor, Annotations.Companion.getEMPTY()
)
);
}
private void generateSetter(
@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor setter
) {
private void generateSetter(@NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor setter) {
if (!descriptor.isVar()) return;
generateAccessor(p, setter, descriptor.getSetter() != null
? descriptor.getSetter()
: DescriptorFactory.createDefaultSetter(
descriptor, Annotations.Companion.getEMPTY(), Annotations.Companion.getEMPTY()
));
generateAccessor(
setter,
descriptor.getSetter() != null ? descriptor.getSetter() : DescriptorFactory.createDefaultSetter(
descriptor, Annotations.Companion.getEMPTY(), Annotations.Companion.getEMPTY()
)
);
}
private void generateAccessor(
@Nullable KtNamedDeclaration p,
@Nullable KtPropertyAccessor accessor,
@NotNull PropertyAccessorDescriptor accessorDescriptor
) {
private void generateAccessor(@Nullable KtPropertyAccessor accessor, @NotNull PropertyAccessorDescriptor descriptor) {
if (context instanceof MultifileClassFacadeContext &&
(Visibilities.isPrivate(accessorDescriptor.getVisibility()) ||
AsmUtil.getVisibilityAccessFlag(accessorDescriptor) == Opcodes.ACC_PRIVATE)) {
(Visibilities.isPrivate(descriptor.getVisibility()) ||
AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE)) {
return;
}
FunctionGenerationStrategy strategy;
if (accessor == null || !accessor.hasBody()) {
if (p instanceof KtProperty && ((KtProperty) p).hasDelegate()) {
strategy = new DelegatedPropertyAccessorStrategy(state, accessorDescriptor);
@SuppressWarnings("deprecation")
boolean isDelegated = descriptor.getCorrespondingProperty().isDelegated();
if (isDelegated) {
strategy = new DelegatedPropertyAccessorStrategy(state, descriptor);
}
else {
strategy = new DefaultPropertyAccessorStrategy(state, accessorDescriptor);
strategy = new DefaultPropertyAccessorStrategy(state, descriptor);
}
}
else {
strategy = new FunctionGenerationStrategy.FunctionDefault(state, accessor);
}
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(accessor != null ? accessor : p, accessorDescriptor), accessorDescriptor, strategy);
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), descriptor, strategy);
}
private static class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {

View File

@@ -27,7 +27,7 @@ import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityAccessFlag;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isNonDefaultInterfaceMember;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.isCallableMemberWithJvmDefaultAnnotation;
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
@@ -693,7 +693,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
boolean withinInline,
boolean isSuperCall
) {
if (isEffectivelyInlineOnly(unwrappedDescriptor)) return false;
if (isInlineOnlyPrivateInBytecode(unwrappedDescriptor)) return false;
return isSuperCall && withinInline ||
(accessFlag & ACC_PRIVATE) != 0 ||

View File

@@ -995,7 +995,7 @@ private fun findSafelyReachableReturns(methodNode: MethodNode, sourceFrames: Arr
if (!insn.isMeaningful || insn.opcode in SAFE_OPCODES || insn.isInvisibleInDebugVarInsn(methodNode) ||
isInlineMarker(insn)) {
setOf()
setOf<Int>()
} else null
}

View File

@@ -30,7 +30,7 @@ open class SuspendFunctionGenerationStrategy(
state: GenerationState,
protected val originalSuspendDescriptor: FunctionDescriptor,
protected val declaration: KtFunction,
private val containingClassInternalName: String,
protected val containingClassInternalName: String,
private val constructorCallNormalizationMode: JVMConstructorCallNormalizationMode,
protected val functionCodegen: FunctionCodegen
) : FunctionGenerationStrategy.CodegenBased(state) {
@@ -53,16 +53,7 @@ open class SuspendFunctionGenerationStrategy(
override fun wrapMethodVisitor(mv: MethodVisitor, access: Int, name: String, desc: String): MethodVisitor {
if (access and Opcodes.ACC_ABSTRACT != 0) return mv
val stateMachineBuilder = CoroutineTransformerMethodVisitor(
mv, access, name, desc, null, null, containingClassInternalName, this::classBuilderForCoroutineState,
isForNamedFunction = true,
element = declaration,
diagnostics = state.diagnostics,
shouldPreserveClassInitialization = constructorCallNormalizationMode.shouldPreserveClassInitialization,
needDispatchReceiver = originalSuspendDescriptor.dispatchReceiverParameter != null,
internalNameForDispatchReceiver = containingClassInternalNameOrNull(),
languageVersionSettings = languageVersionSettings
)
val stateMachineBuilder = createStateMachineBuilder(mv, access, name, desc)
val forInline = state.bindingContext[CodegenBinding.CAPTURES_CROSSINLINE_LAMBDA, originalSuspendDescriptor] == true
// Both capturing and inline functions share the same suffix, however, inline functions can also be capturing
@@ -95,6 +86,24 @@ open class SuspendFunctionGenerationStrategy(
) else stateMachineBuilder
}
protected fun createStateMachineBuilder(
mv: MethodVisitor,
access: Int,
name: String,
desc: String
): CoroutineTransformerMethodVisitor {
return CoroutineTransformerMethodVisitor(
mv, access, name, desc, null, null, containingClassInternalName, this::classBuilderForCoroutineState,
isForNamedFunction = true,
element = declaration,
diagnostics = state.diagnostics,
shouldPreserveClassInitialization = constructorCallNormalizationMode.shouldPreserveClassInitialization,
needDispatchReceiver = originalSuspendDescriptor.dispatchReceiverParameter != null,
internalNameForDispatchReceiver = containingClassInternalNameOrNull(),
languageVersionSettings = languageVersionSettings
)
}
private fun containingClassInternalNameOrNull() =
originalSuspendDescriptor.containingDeclaration.safeAs<ClassDescriptor>()?.let(state.typeMapper::mapClass)?.internalName

View File

@@ -5,20 +5,30 @@
package org.jetbrains.kotlin.codegen.coroutines
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.FunctionCodegen
import org.jetbrains.kotlin.codegen.FunctionGenerationStrategy
import org.jetbrains.kotlin.codegen.TransformationMethodVisitor
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
import org.jetbrains.kotlin.codegen.inline.coroutines.findReceiverOfInvoke
import org.jetbrains.kotlin.codegen.inline.coroutines.surroundInvokesWithSuspendMarkers
import org.jetbrains.kotlin.codegen.inline.isInvokeOnLambda
import org.jetbrains.kotlin.codegen.optimization.common.asSequence
import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.JVMConstructorCallNormalizationMode
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.tree.MethodNode
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter
// For named suspend function we generate two methods:
// 1) to use as noinline function, which have state machine
@@ -44,7 +54,10 @@ class SuspendInlineFunctionGenerationStrategy(
if (access and Opcodes.ACC_ABSTRACT != 0) return mv
return MethodNodeCopyingMethodVisitor(
super.wrapMethodVisitor(mv, access, name, desc), access, name, desc,
SurroundSuspendParameterCallsWithSuspendMarkersMethodVisitor(
createStateMachineBuilder(mv, access, name, desc),
access, name, desc, containingClassInternalName, originalSuspendDescriptor.valueParameters
), access, name, desc,
newMethod = { origin, newAccess, newName, newDesc ->
functionCodegen.newMethod(origin, newAccess, newName, newDesc, null, null)
}, keepAccess = false
@@ -78,3 +91,39 @@ class MethodNodeCopyingMethodVisitor(
else access or Opcodes.ACC_PRIVATE and Opcodes.ACC_PUBLIC.inv() and Opcodes.ACC_PROTECTED.inv()
}
}
private class SurroundSuspendParameterCallsWithSuspendMarkersMethodVisitor(
delegate: MethodVisitor,
access: Int,
name: String,
desc: String,
private val thisName: String,
private val valueParameters: List<ValueParameterDescriptor>
): TransformationMethodVisitor(delegate, access, name, desc, null, null) {
override fun performTransformations(methodNode: MethodNode) {
fun AbstractInsnNode.index() = methodNode.instructions.indexOf(this)
fun AbstractInsnNode.isInlineSuspendParameter(): Boolean {
if (this !is VarInsnNode) return false
val index = `var` - (if (methodNode.access and Opcodes.ACC_STATIC != 0) 0 else 1)
return opcode == Opcodes.ALOAD && index < valueParameters.size && InlineUtil.isInlineParameter(valueParameters[index]) &&
valueParameters[index].type.isSuspendFunctionType
}
FixStackMethodTransformer().transform(thisName, methodNode)
val sourceFrames = MethodTransformer.analyze(thisName, methodNode, SourceInterpreter())
val noinlineInvokes = arrayListOf<Pair<AbstractInsnNode, AbstractInsnNode>>()
for (insn in methodNode.instructions.asSequence()) {
if (insn.opcode != Opcodes.INVOKEINTERFACE) continue
insn as MethodInsnNode
if (!isInvokeOnLambda(insn.owner, insn.name)) continue
val frame = sourceFrames[insn.index()] ?: continue
val aload = findReceiverOfInvoke(frame, insn).takeIf { it?.isInlineSuspendParameter() == true } as? VarInsnNode ?: continue
noinlineInvokes.add(insn to aload)
}
surroundInvokesWithSuspendMarkers(methodNode, noinlineInvokes)
}
}

View File

@@ -10,7 +10,9 @@ import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.coroutines.DEBUG_METADATA_ANNOTATION_ASM_TYPE
import org.jetbrains.kotlin.codegen.coroutines.isCapturedSuspendLambda
import org.jetbrains.kotlin.codegen.coroutines.isCoroutineSuperClass
import org.jetbrains.kotlin.codegen.coroutines.isResumeImplMethodName
import org.jetbrains.kotlin.codegen.inline.coroutines.CoroutineTransformer
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
import org.jetbrains.kotlin.codegen.serialization.JvmCodegenStringTable
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.kotlin.FileBasedKotlinClass
@@ -141,7 +143,7 @@ class AnonymousObjectTransformer(
superClassName,
allCapturedParamBuilder.listCaptured()
)
loop@for (next in methodsToTransform) {
loop@ for (next in methodsToTransform) {
val deferringVisitor =
when {
coroutineTransformer.shouldSkip(next) -> continue@loop
@@ -162,9 +164,15 @@ class AnonymousObjectTransformer(
}
deferringMethods.forEach { method ->
val continuationToRemove = CoroutineTransformer.findFakeContinuationConstructorClassName(method.intermediate)
val oldContinuationName = coroutineTransformer.oldContinuationFrom(method.intermediate)
coroutineTransformer.replaceFakesWithReals(method.intermediate)
removeFinallyMarkers(method.intermediate)
method.visitEnd()
if (continuationToRemove != null && coroutineTransformer.safeToRemoveContinuationClass(method.intermediate)) {
transformationResult.addClassToRemove(continuationToRemove)
innerClassNodes.removeIf { it.name == oldContinuationName }
}
}
SourceMapper.flushToClassBuilder(sourceMapper, classBuilder)
@@ -238,7 +246,14 @@ class AnonymousObjectTransformer(
private fun writeOuterInfo(visitor: ClassVisitor) {
val info = inliningContext.callSiteInfo
visitor.visitOuterClass(info.ownerClassName, info.functionName, info.functionDesc)
// Since $$forInline functions are not generated if retransformation is the last one (i.e. call site is not inline)
// link to the function in OUTERCLASS field becomes invalid. However, since $$forInline function always has no-inline
// companion without the suffix, use it.
if (info.isSuspend && info.isInlineOrInsideInline) {
visitor.visitOuterClass(info.ownerClassName, info.functionName?.removeSuffix(FOR_INLINE_SUFFIX), info.functionDesc)
} else {
visitor.visitOuterClass(info.ownerClassName, info.functionName, info.functionDesc)
}
}
private fun inlineMethodAndUpdateGlobalResult(
@@ -282,7 +297,8 @@ class AnonymousObjectTransformer(
transformationInfo.oldClassName,
sourceNode.name,
if (isConstructor) transformationInfo.newConstructorDescriptor else sourceNode.desc,
inliningContext.callSiteInfo.isInlineOrInsideInline
inliningContext.callSiteInfo.isInlineOrInsideInline,
isSuspendFunctionOrLambda(sourceNode)
), null
)
@@ -292,6 +308,12 @@ class AnonymousObjectTransformer(
return result
}
private fun isSuspendFunctionOrLambda(sourceNode: MethodNode): Boolean =
(sourceNode.desc.endsWith(";Lkotlin/coroutines/Continuation;)Ljava/lang/Object;") ||
sourceNode.desc.endsWith(";Lkotlin/coroutines/experimental/Continuation;)Ljava/lang/Object;")) &&
(CoroutineTransformer.findFakeContinuationConstructorClassName(sourceNode) != null ||
languageVersionSettings.isResumeImplMethodName(sourceNode.name.removeSuffix(FOR_INLINE_SUFFIX)))
private fun generateConstructorAndFields(
classBuilder: ClassBuilder,
allCapturedBuilder: ParametersBuilder,

View File

@@ -1,19 +1,14 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen.inline
class InlineCallSiteInfo(val ownerClassName: String, val functionName: String?, val functionDesc: String?, val isInlineOrInsideInline: Boolean)
class InlineCallSiteInfo(
val ownerClassName: String,
val functionName: String?,
val functionDesc: String?,
val isInlineOrInsideInline: Boolean,
val isSuspend: Boolean
)

View File

@@ -153,7 +153,7 @@ class MethodInliner(
LocalVariablesSorter(
resultNode.access,
resultNode.desc,
resultNode
wrapWithMaxLocalCalc(resultNode)
), AsmTypeRemapper(remapper, result)
)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -122,7 +122,11 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
val signature = codegen.state.typeMapper.mapSignatureSkipGeneric(context.functionDescriptor, context.contextKind)
return InlineCallSiteInfo(
parentCodegen.className, signature.asmMethod.name, signature.asmMethod.descriptor, compilationContextFunctionDescriptor.isInlineOrInsideInline()
parentCodegen.className,
signature.asmMethod.name,
signature.asmMethod.descriptor,
compilationContextFunctionDescriptor.isInlineOrInsideInline(),
compilationContextFunctionDescriptor.isSuspend
)
}
@@ -171,7 +175,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
codegen.parentCodegen.className
else
state.typeMapper.mapImplementationOwner(descriptor).internalName,
if (isLambda) emptyList() else additionalInnerClasses,
if (isLambda) emptyList<ClassDescriptor>() else additionalInnerClasses,
isLambda
)

View File

@@ -215,6 +215,13 @@ class CoroutineTransformer(
fun unregisterClassBuilder(continuationClassName: String) =
(inliningContext as RegeneratedClassContext).continuationBuilders.remove(continuationClassName)
// If tail-call optimization took place, we do not need continuation class anymore, unless it is used by $$forInline method
fun safeToRemoveContinuationClass(method: MethodNode): Boolean = !generateForInline && !isStateMachine(method)
fun oldContinuationFrom(method: MethodNode): String? =
methods.find { it.name == method.name + FOR_INLINE_SUFFIX && it.desc == method.desc }
?.let { findFakeContinuationConstructorClassName(it) }
companion object {
fun findFakeContinuationConstructorClassName(node: MethodNode): String? {
val marker = node.instructions.asSequence().firstOrNull(::isBeforeFakeContinuationConstructorCallMarker) ?: return null

View File

@@ -305,6 +305,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
if (newInference) {
put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED)
put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED)
}
if (legacySmartCastAfterTry) {
@@ -342,11 +343,20 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
private fun HashMap<LanguageFeature, LanguageFeature.State>.configureLanguageFeaturesFromInternalArgs(collector: MessageCollector) {
val featuresThatForcePreReleaseBinaries = mutableListOf<LanguageFeature>()
var standaloneSamConversionFeaturePassedExplicitly = false
for ((feature, state) in internalArguments.filterIsInstance<ManualLanguageFeatureSetting>()) {
put(feature, state)
if (state == LanguageFeature.State.ENABLED && feature.forcesPreReleaseBinariesIfEnabled()) {
featuresThatForcePreReleaseBinaries += feature
}
if (feature == LanguageFeature.SamConversionPerArgument) {
standaloneSamConversionFeaturePassedExplicitly = true
}
}
if (!standaloneSamConversionFeaturePassedExplicitly && this[LanguageFeature.NewInference] == LanguageFeature.State.ENABLED) {
put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED)
}
if (featuresThatForcePreReleaseBinaries.isNotEmpty()) {

View File

@@ -96,5 +96,11 @@ open class AggregatedReplStageState<T1, T2>(val state1: IReplStageState<T1>, val
override fun getNextLineNo() = state1.getNextLineNo()
override val currentGeneration: Int get() = state1.currentGeneration
override fun dispose() {
state2.dispose()
state1.dispose()
super.dispose()
}
}

View File

@@ -60,18 +60,21 @@ open class BasicReplStageHistory<T>(override val lock: ReentrantReadWriteLock =
override fun resetTo(id: ILineId): Iterable<ILineId> {
lock.write {
val idx = indexOfFirst { it.id == id }
if (idx < 0) throw java.util.NoSuchElementException("Cannot rest to inexistent line ${id.no}")
return if (idx < lastIndex) {
val removed = asSequence().drop(idx + 1).map { it.id }.toList()
removeRange(idx + 1, size)
currentGeneration.incrementAndGet()
removed
}
else {
currentGeneration.incrementAndGet()
emptyList()
}
return tryResetTo(id) ?: throw NoSuchElementException("Cannot reset to non-existent line ${id.no}")
}
}
protected fun tryResetTo(id: ILineId): List<ILineId>? {
val idx = indexOfFirst { it.id == id }
if (idx < 0) return null
return if (idx < lastIndex) {
val removed = asSequence().drop(idx + 1).map { it.id }.toList()
removeRange(idx + 1, size)
currentGeneration.incrementAndGet()
removed
} else {
currentGeneration.incrementAndGet()
emptyList()
}
}
}

View File

@@ -20,13 +20,11 @@ import java.io.File
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.write
class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
baseClasspath: Iterable<File>,
baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
private val fallbackScriptArgs: ScriptArgsWithTypes? = null,
repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
open class GenericReplCompilingEvaluatorBase(
val compiler: ReplCompiler,
val evaluator: ReplEvaluator,
private val fallbackScriptArgs: ScriptArgsWithTypes? = null
) : ReplFullEvaluator {
private val evaluator = GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode)
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = AggregatedReplStageState(compiler.createState(lock), evaluator.createState(lock), lock)
@@ -75,7 +73,7 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
}
override fun eval(state: IReplStageState<*>, compileResult: ReplCompileResult.CompiledClasses, scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult =
evaluator.eval(state, compileResult, scriptArgs, invokeWrapper)
evaluator.eval(state, compileResult, scriptArgs, invokeWrapper)
override fun check(state: IReplStageState<*>, codeLine: ReplCodeLine): ReplCheckResult = compiler.check(state, codeLine)
@@ -93,12 +91,24 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
private val evaluator: ReplEvaluator,
private val defaultScriptArgs: ScriptArgsWithTypes?) : Evaluable {
override fun eval(scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult =
evaluator.eval(state, compiledCode, scriptArgs ?: defaultScriptArgs, invokeWrapper)
evaluator.eval(state, compiledCode, scriptArgs ?: defaultScriptArgs, invokeWrapper)
}
}
class GenericReplCompilingEvaluator(
compiler: ReplCompiler,
baseClasspath: Iterable<File>,
baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
fallbackScriptArgs: ScriptArgsWithTypes? = null,
repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
) : GenericReplCompilingEvaluatorBase(
compiler,
GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode),
fallbackScriptArgs
)
private fun AggregatedReplStageState<*, *>.adjustHistories(): Iterable<ILineId>? =
state2.history.peek()?.let {
state1.history.resetTo(it.id)
}
state2.history.peek()?.let {
state1.history.resetTo(it.id)
}
?: state1.history.reset()

View File

@@ -90,7 +90,8 @@ sealed class ReplCompileResult : Serializable {
val classes: List<CompiledClassData>,
val hasResult: Boolean,
val classpathAddendum: List<File>,
val type: String?
val type: String?,
val data: Any? // TODO: temporary; migration to new scripting infrastructure
) : ReplCompileResult() {
companion object { private val serialVersionUID: Long = 2L }
}

View File

@@ -61,6 +61,9 @@ interface IReplStageState<T> {
fun <StateT : IReplStageState<*>> asState(target: Class<out StateT>): StateT =
if (target.isAssignableFrom(this::class.java)) this as StateT
else throw IllegalArgumentException("$this is not an expected instance of IReplStageState")
fun dispose() {
}
}

View File

@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.js.facade.TranslationUnit;
import org.jetbrains.kotlin.js.facade.exceptions.TranslationException;
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver;
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.serialization.js.ModuleKind;
@@ -73,6 +74,7 @@ import org.jetbrains.kotlin.utils.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR;
import static org.jetbrains.kotlin.cli.common.ExitCode.OK;
@@ -144,6 +146,15 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
}
Arrays.sort(allSources);
Set<FqName> dirtyPackages = nonCompiledSources.values().stream().map(KtFile::getPackageFqName).collect(Collectors.toSet());
Map<FqName, byte[]> packageMetadata = new HashMap<>();
for (Map.Entry<String, byte[]> e : incrementalDataProvider.getPackageMetadata().entrySet()) {
FqName name = new FqName(e.getKey());
if (!dirtyPackages.contains(name)) {
packageMetadata.put(name, e.getValue());
}
}
List<TranslationUnit> translationUnits = new ArrayList<>();
for (i = 0; i < allSources.length; i++) {
KtFile nonCompiled = nonCompiledSources.get(allSources[i]);
@@ -155,7 +166,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
translationUnits.add(new TranslationUnit.BinaryAst(translatedValue.getBinaryAst(), translatedValue.getInlineData()));
}
}
return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult);
return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult, packageMetadata);
}
CollectionsKt.sortBy(allKotlinFiles, ktFile -> VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile()));

View File

@@ -122,7 +122,7 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
private fun mapSourcePaths(inputFile: File, targetFile: File): Boolean {
val json = try {
InputStreamReader(FileInputStream(inputFile), "UTF-8").use { parseJson(it) }
parseJson(inputFile)
} catch (e: JsonSyntaxException) {
return false
}

View File

@@ -52,7 +52,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
val sourceMapFile = File(file.parent, file.name + ".map")
if (sourceMapFile.exists()) {
val sourceMapParse = sourceMapFile.reader().use { SourceMapParser.parse(it) }
val sourceMapParse = SourceMapParser.parse(sourceMapFile)
when (sourceMapParse) {
is SourceMapError -> {
System.err.println("Error parsing source map file $sourceMapFile: ${sourceMapParse.message}")
@@ -82,7 +82,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
outputFile.writeText(programText + "\n//# sourceMappingURL=${sourceMapFile.name}\n")
val sourceMapJson = StringReader(sourceMapContent).use { parseJson(it) }
val sourceMapJson = parseJson(sourceMapContent)
val sources = (sourceMapJson as JsonObject).properties["sources"] as JsonArray
sourceMapJson.properties["sourcesContent"] = JsonArray(*sources.elements.map { sourcePath ->

View File

@@ -66,14 +66,14 @@ object KotlinToJVMBytecodeCompiler {
private fun writeOutput(
configuration: CompilerConfiguration,
outputFiles: OutputFileCollection,
mainClass: FqName?
mainClassProvider: MainClassProvider?
) {
val reportOutputFiles = configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)
val jarPath = configuration.get(JVMConfigurationKeys.OUTPUT_JAR)
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
if (jarPath != null) {
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, mainClass, outputFiles)
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, mainClassProvider?.mainClassFqName, outputFiles)
if (reportOutputFiles) {
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
messageCollector.report(OUTPUT, message)
@@ -91,7 +91,7 @@ object KotlinToJVMBytecodeCompiler {
}
return GenerationStateEventCallback { state ->
val currentOutput = SimpleOutputFileCollection(state.factory.currentOutput)
writeOutput(configuration, currentOutput, mainClass = null)
writeOutput(configuration, currentOutput, null)
if (!configuration.get(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, false)) {
state.factory.releaseGeneratedOutput()
}
@@ -167,7 +167,8 @@ object KotlinToJVMBytecodeCompiler {
try {
for ((_, state) in outputs) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
writeOutput(state.configuration, state.factory, null)
val mainClassProvider = if (outputs.size == 1) MainClassProvider(state, environment) else null
writeOutput(state.configuration, state.factory, mainClassProvider)
}
if (projectConfiguration.getBoolean(JVMConfigurationKeys.COMPILE_JAVA)) {
@@ -244,16 +245,20 @@ object KotlinToJVMBytecodeCompiler {
(File(path).takeIf(File::isAbsolute) ?: buildFile.resolveSibling(path)).absolutePath
}
private fun findMainClass(generationState: GenerationState, files: List<KtFile>): FqName? {
val mainFunctionDetector = MainFunctionDetector(generationState.bindingContext, generationState.languageVersionSettings)
return files.asSequence()
.map { file ->
if (mainFunctionDetector.hasMain(file.declarations))
JvmFileClassUtil.getFileClassInfoNoResolve(file).facadeClassFqName
else
null
}
.singleOrNull { it != null }
private class MainClassProvider(generationState: GenerationState, environment: KotlinCoreEnvironment) {
val mainClassFqName: FqName? by lazy { findMainClass(generationState, environment.getSourceFiles()) }
private fun findMainClass(generationState: GenerationState, files: List<KtFile>): FqName? {
val mainFunctionDetector = MainFunctionDetector(generationState.bindingContext, generationState.languageVersionSettings)
return files.asSequence()
.map { file ->
if (mainFunctionDetector.hasMain(file.declarations))
JvmFileClassUtil.getFileClassInfoNoResolve(file).facadeClassFqName
else
null
}
.singleOrNull { it != null }
}
}
fun compileBunchOfSources(environment: KotlinCoreEnvironment): Boolean {
@@ -268,10 +273,8 @@ object KotlinToJVMBytecodeCompiler {
val generationState = analyzeAndGenerate(environment) ?: return false
val mainClass = findMainClass(generationState, environment.getSourceFiles())
try {
writeOutput(environment.configuration, generationState.factory, mainClass)
writeOutput(environment.configuration, generationState.factory, MainClassProvider(generationState, environment))
return true
} finally {
generationState.destroy()

View File

@@ -254,3 +254,11 @@ messages/**)
# used in LazyScriptDescriptor
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
# used in REPL
# TODO: pack jline directly to scripting-compiler jars instead
-keep class org.jline.reader.LineReaderBuilder { *; }
-keep class org.jline.reader.LineReader { *; }
-keep class org.jline.reader.History { *; }
-keep class org.jline.reader.EndOfFileException { *; }
-keep class org.jline.reader.UserInterruptException { *; }

View File

@@ -253,3 +253,11 @@ messages/**)
# used in LazyScriptDescriptor
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
# used in REPL
# TODO: pack jline directly to scripting-compiler jars instead
-keep class org.jline.reader.LineReaderBuilder { *; }
-keep class org.jline.reader.LineReader { *; }
-keep class org.jline.reader.History { *; }
-keep class org.jline.reader.EndOfFileException { *; }
-keep class org.jline.reader.UserInterruptException { *; }

265
compiler/compiler.pro.192 Normal file
View File

@@ -0,0 +1,265 @@
-injars '<kotlin-compiler-jar-before-shrink>'(
!org/apache/log4j/jmx/Agent*,
!org/apache/log4j/net/JMS*,
!org/apache/log4j/net/SMTP*,
!org/apache/log4j/or/jms/MessageRenderer*,
!org/jdom/xpath/Jaxen*,
!org/jline/builtins/ssh/**,
!org/mozilla/javascript/xml/impl/xmlbeans/**,
!net/sf/cglib/**,
!META-INF/maven**,
**.class,**.properties,**.kt,**.kotlin_*,**.jnilib,**.so,**.dll,**.txt,**.caps,
META-INF/services/**,META-INF/native/**,META-INF/extensions/**,META-INF/MANIFEST.MF,
messages/**)
-outjars '<kotlin-compiler-jar>'
-dontnote **
-dontwarn com.intellij.util.ui.IsRetina*
-dontwarn com.intellij.util.ui.UIUtilities
-dontwarn com.intellij.util.RetinaImage*
-dontwarn apple.awt.*
-dontwarn dk.brics.automaton.*
-dontwarn org.fusesource.**
-dontwarn org.imgscalr.Scalr**
-dontwarn org.xerial.snappy.SnappyBundleActivator
-dontwarn com.intellij.util.CompressionUtil
-dontwarn com.intellij.util.SnappyInitializer
-dontwarn com.intellij.util.SVGLoader
-dontwarn com.intellij.util.SVGLoader$MyTranscoder
-dontwarn com.intellij.util.ImageLoader$ImageDesc
-dontwarn net.sf.cglib.**
-dontwarn org.objectweb.asm.** # this is ASM3, the old version that we do not use
-dontwarn com.sun.jna.NativeString
-dontwarn com.sun.jna.WString
-dontwarn com.intellij.psi.util.PsiClassUtil
-dontwarn org.apache.hadoop.io.compress.*
-dontwarn com.google.j2objc.annotations.Weak
-dontwarn org.iq80.snappy.HadoopSnappyCodec$SnappyCompressionInputStream
-dontwarn org.iq80.snappy.HadoopSnappyCodec$SnappyCompressionOutputStream
-dontwarn com.google.common.util.concurrent.*
-dontwarn org.apache.xerces.dom.**
-dontwarn org.apache.xerces.util.**
-dontwarn org.w3c.dom.ElementTraversal
-dontwarn javaslang.match.annotation.Unapply
-dontwarn javaslang.match.annotation.Patterns
-dontwarn javaslang.*
-dontwarn com.google.errorprone.**
-dontwarn com.google.j2objc.**
-dontwarn javax.crypto.**
-dontwarn java.lang.invoke.MethodHandle
-dontwarn org.jline.builtins.Nano$Buffer
-dontwarn org.jetbrains.annotations.ReadOnly
-dontwarn org.jetbrains.annotations.Mutable
-dontwarn com.intellij.util.io.TarUtil
-dontwarn com.intellij.util.io.Compressor$Tar
# Annotations from intellijCore/annotations.jar that not presented in org.jetbrains.annotations
-dontwarn org.jetbrains.annotations.Async*
-dontwarn org.jetbrains.annotations.Nls$Capitalization
# Nullability annotations used in Guava
-dontwarn org.checkerframework.checker.nullness.compatqual.NullableDecl
-dontwarn org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl
-dontwarn org.checkerframework.checker.nullness.qual.Nullable
-dontwarn org.checkerframework.checker.nullness.qual.MonotonicNonNull
# Depends on apache batick which has lots of dependencies
-dontwarn com.intellij.util.SVGLoader*
-dontwarn org.apache.batik.script.rhino.RhinoInterpreter
-dontwarn org.apache.batik.script.rhino.RhinoInterpreterFactory
# The appropriate jar is either loaded separately or added explicitly to the classpath then needed
-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar
-dontwarn org.jdom.xpath.jaxen.*
-dontwarn com.intellij.util.io.Decompressor*
-dontwarn org.w3c.dom.Location
-dontwarn org.w3c.dom.Window
#-libraryjars '<rtjar>'
#-libraryjars '<jssejar>'
#-libraryjars '<bootstrap.runtime>'
#-libraryjars '<bootstrap.reflect>'
#-libraryjars '<bootstrap.script.runtime>'
#-libraryjars '<tools.jar>'
-dontoptimize
-dontobfuscate
-keep class org.fusesource.** { *; }
-keep class com.sun.jna.** { *; }
-keep class org.jetbrains.annotations.** {
public protected *;
}
-keep class javax.inject.** {
public protected *;
}
-keep class org.jetbrains.kotlin.** {
public protected *;
}
-keep class org.jetbrains.kotlin.compiler.plugin.** {
public protected *;
}
-keep class org.jetbrains.kotlin.extensions.** {
public protected *;
}
-keep class org.jetbrains.kotlin.protobuf.** {
public protected *;
}
-keep class org.jetbrains.kotlin.container.** { *; }
-keep class org.jetbrains.org.objectweb.asm.Opcodes { *; }
-keep class org.jetbrains.kotlin.codegen.extensions.** {
public protected *;
}
-keepclassmembers class com.intellij.openapi.vfs.VirtualFile {
public protected *;
}
-keep class com.intellij.openapi.vfs.StandardFileSystems {
public static *;
}
# needed for jar cache cleanup in the gradle plugin and compile daemon
-keepclassmembers class com.intellij.openapi.vfs.impl.ZipHandler {
public static void clearFileAccessorCache();
}
-keep class jet.** {
public protected *;
}
-keep class com.intellij.psi.** {
public protected *;
}
# This is needed so that the platform code which parses XML wouldn't fail, see KT-16968
# This API is used from org.jdom.input.SAXBuilder via reflection.
-keep class org.jdom.input.JAXPParserFactory { public ** createParser(...); }
# Without this class PluginManagerCore.loadDescriptorFromJar fails
-keep class org.jdom.output.XMLOutputter { *; }
# for kdoc & dokka
-keep class com.intellij.openapi.util.TextRange { *; }
-keep class com.intellij.lang.impl.PsiBuilderImpl* {
public protected *;
}
-keep class com.intellij.openapi.util.text.StringHash { *; }
# for j2k
-keep class com.intellij.codeInsight.NullableNotNullManager { public protected *; }
# for gradle (see KT-12549)
-keep class com.intellij.lang.properties.charset.Native2AsciiCharsetProvider { *; }
# for kotlin-build-common (consider repacking compiler together with kotlin-build-common and remove this part afterwards)
-keep class com.intellij.util.io.IOUtil { public *; }
-keep class com.intellij.openapi.util.io.FileUtil { public *; }
-keep class com.intellij.util.SystemProperties { public *; }
-keep class com.intellij.util.containers.hash.LinkedHashMap { *; }
-keep class com.intellij.util.containers.ConcurrentIntObjectMap { *; }
-keep class com.intellij.util.containers.ComparatorUtil { *; }
-keep class com.intellij.util.io.PersistentHashMapValueStorage { *; }
-keep class com.intellij.util.io.PersistentHashMap { *; }
-keep class com.intellij.util.io.BooleanDataDescriptor { *; }
-keep class com.intellij.util.io.EnumeratorStringDescriptor { *; }
-keep class com.intellij.util.io.ExternalIntegerKeyDescriptor { *; }
-keep class com.intellij.util.containers.hash.EqualityPolicy { *; }
-keep class com.intellij.util.containers.hash.EqualityPolicy.* { *; }
-keep class com.intellij.util.containers.Interner { *; }
-keep class gnu.trove.TIntHashSet { *; }
-keep class gnu.trove.TIntIterator { *; }
-keep class org.iq80.snappy.SlowMemory { *; }
-keep class javaslang.match.PatternsProcessor { *; }
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * {
** toString();
** hashCode();
void start();
void stop();
void dispose();
}
-keep class org.jetbrains.org.objectweb.asm.tree.AnnotationNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.ClassNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.LocalVariableNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.MethodNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.FieldNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.ParameterNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.TypeAnnotationNode { *; }
-keep class org.jetbrains.org.objectweb.asm.tree.InsnList { *; }
-keep class org.jetbrains.org.objectweb.asm.signature.SignatureReader { *; }
-keep class org.jetbrains.org.objectweb.asm.signature.SignatureVisitor { *; }
-keep class org.jetbrains.org.objectweb.asm.Type {
public protected *;
}
-keepclassmembers class org.jetbrains.org.objectweb.asm.ClassReader {
*** SKIP_CODE;
*** SKIP_DEBUG;
*** SKIP_FRAMES;
}
-keepclassmembers class com.intellij.openapi.project.Project {
** getBasePath();
}
# for kotlin-android-extensions in maven
-keep class com.intellij.openapi.module.ModuleServiceManager { public *; }
# for building kotlin-build-common-test
-keep class org.jetbrains.kotlin.build.SerializationUtilsKt { *; }
# for tools.jar
-keep class com.sun.tools.javac.** { *; }
-keep class com.sun.source.** { *; }
# for coroutines
-keep class kotlinx.coroutines.** { *; }
# for webdemo
-keep class com.intellij.openapi.progress.ProgressManager { *; }
# for kapt
-keep class com.intellij.openapi.project.Project { *; }
-keepclassmembers class com.intellij.util.PathUtil {
public static java.lang.String getJarPathForClass(java.lang.Class);
}
-keepclassmembers class com.intellij.util.PathUtil {
public static java.lang.String getJarPathForClass(java.lang.Class);
}
# remove when KT-18563 would be fixed
-keep class org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt { *; }
-keep class net.jpountz.lz4.* { *; }
# used in LazyScriptDescriptor
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
# used in REPL
# TODO: pack jline directly to scripting-compiler jars instead
-keep class org.jline.reader.LineReaderBuilder { *; }
-keep class org.jline.reader.LineReader { *; }
-keep class org.jline.reader.History { *; }
-keep class org.jline.reader.EndOfFileException { *; }
-keep class org.jline.reader.UserInterruptException { *; }

View File

@@ -253,3 +253,11 @@ messages/**)
# used in LazyScriptDescriptor
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
# used in REPL
# TODO: pack jline directly to scripting-compiler jars instead
-keep class org.jline.reader.LineReaderBuilder { *; }
-keep class org.jline.reader.LineReader { *; }
-keep class org.jline.reader.History { *; }
-keep class org.jline.reader.EndOfFileException { *; }
-keep class org.jline.reader.UserInterruptException { *; }

View File

@@ -134,6 +134,10 @@ open class CompilerCallbackServicesFacadeServer(
incrementalResultsConsumer!!.processInlineFunctions(functions)
}
override fun incrementalResultsConsumer_processPackageMetadata(packageName: String, metadata: ByteArray) {
incrementalResultsConsumer!!.processPackageMetadata(packageName, metadata)
}
override fun incrementalDataProvider_getHeaderMetadata(): ByteArray = incrementalDataProvider!!.headerMetadata
override fun incrementalDataProvider_getMetadataVersion(): IntArray = incrementalDataProvider!!.metadataVersion
@@ -142,4 +146,9 @@ open class CompilerCallbackServicesFacadeServer(
incrementalDataProvider!!.compiledPackageParts.entries.map {
CompiledPackagePart(it.key.path, it.value.metadata, it.value.binaryAst, it.value.inlineData)
}
override fun incrementalDataProvider_getPackageMetadata(): Collection<PackageMetadata> =
incrementalDataProvider!!.packageMetadata.entries.map { (fqName, metadata) ->
PackageMetadata(fqName, metadata)
}
}

View File

@@ -112,6 +112,9 @@ interface CompilerCallbackServicesFacade : Remote {
@Throws(RemoteException::class)
fun incrementalResultsConsumer_processInlineFunctions(functions: Collection<JsInlineFunctionHash>)
@Throws(RemoteException::class)
fun incrementalResultsConsumer_processPackageMetadata(packageName: String, metadata: ByteArray)
// ---------------------------------------------------
// IncrementalDataProvider (js)
@Throws(RemoteException::class)
@@ -122,6 +125,9 @@ interface CompilerCallbackServicesFacade : Remote {
@Throws(RemoteException::class)
fun incrementalDataProvider_getMetadataVersion(): IntArray
@Throws(RemoteException::class)
fun incrementalDataProvider_getPackageMetadata(): Collection<PackageMetadata>
}
class CompiledPackagePart(
@@ -129,6 +135,17 @@ class CompiledPackagePart(
val metadata: ByteArray, val binaryAst: ByteArray, val inlineData: ByteArray
) : Serializable
class PackageMetadata(
val packageName: String,
val metadata: ByteArray
) : Serializable {
companion object {
// just a random number, but should never be changed to avoid deserialization problems
private val serialVersionUID: Long = 54021986502349756L
}
}
class RmiFriendlyCompilationCanceledException : Exception(), Serializable {
companion object {
// just a random number, but should never be changed to avoid deserialization problems

View File

@@ -32,4 +32,14 @@ class RemoteIncrementalDataProvider(val facade: CompilerCallbackServicesFacade,
get() = rpcProfiler.withMeasure(this) {
facade.incrementalDataProvider_getMetadataVersion()
}
override val packageMetadata: Map<String, ByteArray>
get() = rpcProfiler.withMeasure(this) {
val result = mutableMapOf<String, ByteArray>()
facade.incrementalDataProvider_getPackageMetadata().forEach {
val prev = result.put(it.packageName, it.metadata)
check(prev == null) { "packageMetadata: duplicated entry for package `${it.packageName}`" }
}
result
}
}

View File

@@ -14,6 +14,7 @@ import java.io.File
class RemoteIncrementalResultsConsumer(val facade: CompilerCallbackServicesFacade, eventManager: EventManager, val rpcProfiler: Profiler) :
IncrementalResultsConsumer {
init {
eventManager.onCompilationFinished(this::flush)
}
@@ -40,6 +41,12 @@ class RemoteIncrementalResultsConsumer(val facade: CompilerCallbackServicesFacad
override fun processInlineFunctions(functions: Collection<JsInlineFunctionHash>) = error("Should not be called in Daemon Server")
override fun processPackageMetadata(packageName: String, metadata: ByteArray) {
rpcProfiler.withMeasure(this) {
facade.incrementalResultsConsumer_processPackageMetadata(packageName, metadata)
}
}
fun flush() {
rpcProfiler.withMeasure(this) {
facade.incrementalResultsConsumer_processInlineFunctions(deferInlineFuncs.map {

View File

@@ -300,7 +300,7 @@ class Fir2IrDeclarationStorage(
startOffset, endOffset, origin, symbol,
constructor.name, constructor.visibility,
constructor.returnTypeRef.toIrType(session, this),
false, false, isPrimary
isInline = false, isExternal = false, isPrimary = isPrimary
).bindAndDeclareParameters(constructor, descriptor, setParent, shouldLeaveScope)
}
}

View File

@@ -167,18 +167,18 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
callableName,
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
Flags.IS_EXPECT_PROPERTY.get(flags),
false,
false,
Flags.IS_CONST.get(flags),
Flags.IS_LATEINIT.get(flags),
proto.receiverType(c.typeTable)?.toTypeRef(local),
returnTypeRef,
Flags.IS_VAR.get(flags),
null,
FirDefaultPropertyGetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))),
FirDefaultPropertySetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags))),
null
isExpect = Flags.IS_EXPECT_PROPERTY.get(flags),
isActual = false,
isOverride = false,
isConst = Flags.IS_CONST.get(flags),
isLateInit = Flags.IS_LATEINIT.get(flags),
receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local),
returnTypeRef = returnTypeRef,
isVar = Flags.IS_VAR.get(flags),
initializer = null,
getter = FirDefaultPropertyGetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))),
setter = FirDefaultPropertySetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags))),
delegate = null
).apply {
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.firUnsafe() }
annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver)
@@ -209,16 +209,16 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
Flags.IS_EXPECT_FUNCTION.get(flags),
false,
false,
Flags.IS_OPERATOR.get(flags),
Flags.IS_INFIX.get(flags),
Flags.IS_INLINE.get(flags),
Flags.IS_TAILREC.get(flags),
Flags.IS_EXTERNAL_FUNCTION.get(flags),
Flags.IS_SUSPEND.get(flags),
proto.receiverType(local.typeTable)?.toTypeRef(local),
proto.returnType(local.typeTable).toTypeRef(local)
isActual = false,
isOverride = false,
isOperator = Flags.IS_OPERATOR.get(flags),
isInfix = Flags.IS_INFIX.get(flags),
isInline = Flags.IS_INLINE.get(flags),
isTailRec = Flags.IS_TAILREC.get(flags),
isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags),
isSuspend = Flags.IS_SUSPEND.get(flags),
receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local),
returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local)
).apply {
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.firUnsafe() }
valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList)

View File

@@ -40,6 +40,10 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
return StandardClassIds.Nothing(symbolProvider).constructType(emptyArray(), false)
}
override fun anyType(): SimpleTypeMarker {
return StandardClassIds.Any(symbolProvider).constructType(emptyArray(), false)
}
override fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker {
require(lowerBound is ConeKotlinType)
require(upperBound is ConeKotlinType)
@@ -158,9 +162,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
}
*/
val simpleType = this.asSimpleType() ?: return false
repeat(simpleType.argumentsCount()) { index ->
val argument = simpleType.getArgument(index)
repeat(argumentsCount()) { index ->
val argument = getArgument(index)
if (!argument.isStarProjection() && argument.getType().containsInternal(predicate, visited)) return true
}

View File

@@ -22,7 +22,11 @@ interface SyntheticSymbol : ConeSymbol
class SyntheticPropertySymbol(callableId: CallableId) : FirPropertySymbol(callableId), SyntheticSymbol
class FirSyntheticPropertiesScope(val session: FirSession, val baseScope: FirScope, val typeCalculator: ReturnTypeCalculator) : FirScope {
class FirSyntheticPropertiesScope(
val session: FirSession,
private val baseScope: FirScope,
private val typeCalculator: ReturnTypeCalculator
) : FirScope {
val synthetic: MutableMap<ConeCallableSymbol, ConeVariableSymbol> = mutableMapOf()
@@ -47,18 +51,18 @@ class FirSyntheticPropertiesScope(val session: FirSession, val baseScope: FirSco
name,
fir.visibility,
fir.modality,
false,
false,
false,
false,
false,
null,
returnTypeRef,
true,
null,
FirDefaultPropertyGetter(session, null, returnTypeRef, fir.visibility),
FirDefaultPropertySetter(session, null, returnTypeRef, fir.visibility),
null
isExpect = false,
isActual = false,
isOverride = false,
isConst = false,
isLateInit = false,
receiverTypeRef = null,
returnTypeRef = returnTypeRef,
isVar = true,
initializer = null,
getter = FirDefaultPropertyGetter(session, null, returnTypeRef, fir.visibility),
setter = FirDefaultPropertySetter(session, null, returnTypeRef, fir.visibility),
delegate = null
)
return processor(synthetic)
}

View File

@@ -169,9 +169,9 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider
relativeClassName.shortName(),
Visibilities.PUBLIC,
Modality.OPEN,
false,
false,
ClassKind.CLASS,
isExpect = false,
isActual = false,
classKind = ClassKind.CLASS,
isInner = false,
isCompanion = false,
isData = false,

View File

@@ -435,10 +435,10 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
null,
Name.identifier("it"),
FirResolvedTypeRefImpl(session, null, parameters.single(), emptyList()),
null,
false,
false,
false
defaultValue = null,
isCrossinline = false,
isNoinline = false,
isVararg = false
)
else -> null
}

View File

@@ -144,13 +144,13 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
return typeConstructor
}
override fun SimpleTypeMarker.argumentsCount(): Int {
override fun KotlinTypeMarker.argumentsCount(): Int {
require(this is ConeKotlinType)
return this.typeArguments.size
}
override fun SimpleTypeMarker.getArgument(index: Int): TypeArgumentMarker {
override fun KotlinTypeMarker.getArgument(index: Int): TypeArgumentMarker {
require(this is ConeKotlinType)
return this.typeArguments.getOrNull(index)

View File

@@ -1659,6 +1659,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt");
}
@TestMetadata("correctInfoAfterArrayLikeCall.kt")
public void testCorrectInfoAfterArrayLikeCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/correctInfoAfterArrayLikeCall.kt");
}
@TestMetadata("ea81649_errorPropertyLHS.kt")
public void testEa81649_errorPropertyLHS() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.kt");
@@ -1684,6 +1689,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/callableReference/kt25433.kt");
}
@TestMetadata("kt31981.kt")
public void testKt31981() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/kt31981.kt");
}
@TestMetadata("kt7430_wrongClassOnLHS.kt")
public void testKt7430_wrongClassOnLHS() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/kt7430_wrongClassOnLHS.kt");
@@ -1694,6 +1704,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/callableReference/memberExtensionsImportedFromObjectsUnsupported.kt");
}
@TestMetadata("noExceptionOnRedCodeWithArrayLikeCall.kt")
public void testNoExceptionOnRedCodeWithArrayLikeCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt");
}
@TestMetadata("packageInLhs.kt")
public void testPackageInLhs() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/packageInLhs.kt");
@@ -1704,6 +1719,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.kt");
}
@TestMetadata("propertyOfNestedGenericClass.kt")
public void testPropertyOfNestedGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/propertyOfNestedGenericClass.kt");
}
@TestMetadata("rewriteAtSliceOnGetOperator.kt")
public void testRewriteAtSliceOnGetOperator() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/rewriteAtSliceOnGetOperator.kt");
}
@TestMetadata("sam.kt")
public void testSam() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/sam.kt");
@@ -7757,6 +7782,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/functionLiterals/functionLIteralInBlockInIf.kt");
}
@TestMetadata("functionLiteralAsArgumentForFunction.kt")
public void testFunctionLiteralAsArgumentForFunction() throws Exception {
runTest("compiler/testData/diagnostics/tests/functionLiterals/functionLiteralAsArgumentForFunction.kt");
}
@TestMetadata("functionLiteralInIf.kt")
public void testFunctionLiteralInIf() throws Exception {
runTest("compiler/testData/diagnostics/tests/functionLiterals/functionLiteralInIf.kt");
@@ -9267,6 +9297,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/incompleteCode/incompleteEquals.kt");
}
@TestMetadata("incompleteTryCatchBlock.kt")
public void testIncompleteTryCatchBlock() throws Exception {
runTest("compiler/testData/diagnostics/tests/incompleteCode/incompleteTryCatchBlock.kt");
}
@TestMetadata("kt1955.kt")
public void testKt1955() throws Exception {
runTest("compiler/testData/diagnostics/tests/incompleteCode/kt1955.kt");
@@ -9703,6 +9738,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt");
}
@TestMetadata("recursiveTypes.kt")
public void testRecursiveTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/recursiveTypes.kt");
}
@TestMetadata("reportAboutUnresolvedReferenceAsUnresolved.kt")
public void testReportAboutUnresolvedReferenceAsUnresolved() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
@@ -9810,6 +9850,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.kt");
}
@TestMetadata("invokeCallWithCapturedReceiver.kt")
public void testInvokeCallWithCapturedReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/invokeCallWithCapturedReceiver.kt");
}
@TestMetadata("kt25302.kt")
public void testKt25302() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/kt25302.kt");
@@ -9850,6 +9895,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt");
}
@TestMetadata("propagateNullailityOnSupertypesWhenCaptureTypes.kt")
public void testPropagateNullailityOnSupertypesWhenCaptureTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt");
}
@TestMetadata("starProjectionRegression.kt")
public void testStarProjectionRegression() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/starProjectionRegression.kt");
@@ -9878,6 +9928,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitForIfAsLastExpressionInLambda.kt");
}
@TestMetadata("coercionToUnitForLastLambdaInLambda.kt")
public void testCoercionToUnitForLastLambdaInLambda() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitForLastLambdaInLambda.kt");
}
@TestMetadata("coercionWithExpectedType.kt")
public void testCoercionWithExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedType.kt");
@@ -10004,11 +10059,21 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/constraints"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("constraintFromVariantTypeWithNestedProjection.kt")
public void testConstraintFromVariantTypeWithNestedProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/constraintFromVariantTypeWithNestedProjection.kt");
}
@TestMetadata("constraintOnFunctionLiteral.kt")
public void testConstraintOnFunctionLiteral() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/constraintOnFunctionLiteral.kt");
}
@TestMetadata("earlyCompletionForCalls.kt")
public void testEarlyCompletionForCalls() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/earlyCompletionForCalls.kt");
}
@TestMetadata("equalityConstraintOnNullableType.kt")
public void testEqualityConstraintOnNullableType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt");
@@ -10024,6 +10089,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt");
}
@TestMetadata("inferTypeFromCapturedStarProjection.kt")
public void testInferTypeFromCapturedStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/inferTypeFromCapturedStarProjection.kt");
}
@TestMetadata("kt6320.kt")
public void testKt6320() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt");
@@ -10044,6 +10114,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/constraints/kt8879.kt");
}
@TestMetadata("manyConstraintsDueToFlexibleRawTypes.kt")
public void testManyConstraintsDueToFlexibleRawTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/manyConstraintsDueToFlexibleRawTypes.kt");
}
@TestMetadata("manyConstraintsDueToRecursiveFlexibleTypesWithWildcards.kt")
public void testManyConstraintsDueToRecursiveFlexibleTypesWithWildcards() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/manyConstraintsDueToRecursiveFlexibleTypesWithWildcards.kt");
}
@TestMetadata("notNullConstraintOnNullableType.kt")
public void testNotNullConstraintOnNullableType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt");
@@ -10175,6 +10255,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt24490.kt");
}
@TestMetadata("kt32051.kt")
public void testKt32051() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32051.kt");
}
@TestMetadata("kt32081.kt")
public void testKt32081() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt");
}
@TestMetadata("lambdaNothingAndExpectedType.kt")
public void testLambdaNothingAndExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.kt");
@@ -10189,6 +10279,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
public void testNothingWithCallableReference() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/nothingWithCallableReference.kt");
}
@TestMetadata("platformNothingAsUsefulConstraint.kt")
public void testPlatformNothingAsUsefulConstraint() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/platformNothingAsUsefulConstraint.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveCalls")
@@ -12358,6 +12453,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/j+k/sam/privateCandidatesWithWrongArguments.kt");
}
@TestMetadata("recursiveSamsAndInvoke.kt")
public void testRecursiveSamsAndInvoke() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/recursiveSamsAndInvoke.kt");
}
@TestMetadata("samOnTypeParameter.kt")
public void testSamOnTypeParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/samOnTypeParameter.kt");
@@ -17470,6 +17570,21 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/insideTopLevelExtensionAnnotatedType.kt");
}
@TestMetadata("kt29948.kt")
public void testKt29948() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt29948.kt");
}
@TestMetadata("kt31360.kt")
public void testKt31360() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/kt31360.kt");
}
@TestMetadata("markedReceiverWithCapturedTypeArgument.kt")
public void testMarkedReceiverWithCapturedTypeArgument() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/markedReceiverWithCapturedTypeArgument.kt");
}
@TestMetadata("markersIntersection.kt")
public void testMarkersIntersection() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/dslMarker/markersIntersection.kt");
@@ -17835,6 +17950,26 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt10640.kt");
}
@TestMetadata("kt31670.kt")
public void testKt31670() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt31670.kt");
}
@TestMetadata("kt31670_compat.kt")
public void testKt31670_compat() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt31670_compat.kt");
}
@TestMetadata("kt31758.kt")
public void testKt31758() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt31758.kt");
}
@TestMetadata("kt31758_compat.kt")
public void testKt31758_compat() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt31758_compat.kt");
}
@TestMetadata("numberOfDefaults.kt")
public void testNumberOfDefaults() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/numberOfDefaults.kt");
@@ -17845,6 +17980,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/originalExamples.kt");
}
@TestMetadata("overloadResolutionOnNullableContravariantParameter.kt")
public void testOverloadResolutionOnNullableContravariantParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/overloadResolutionOnNullableContravariantParameter.kt");
}
@TestMetadata("overloadResolutionOnNullableContravariantParameter_compat.kt")
public void testOverloadResolutionOnNullableContravariantParameter_compat() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/overloadResolutionOnNullableContravariantParameter_compat.kt");
}
@TestMetadata("varargWithMoreSpecificSignature.kt")
public void testVarargWithMoreSpecificSignature() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/varargWithMoreSpecificSignature.kt");
@@ -22203,9 +22348,9 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameter.kt");
}
@TestMetadata("implicitNothingAsTypeParameterNI.kt")
public void testImplicitNothingAsTypeParameterNI() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameterNI.kt");
@TestMetadata("implicitNothingOnDelegates.kt")
public void testImplicitNothingOnDelegates() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@TestMetadata("misplacedConstraints.kt")
@@ -22346,6 +22491,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/typealias/importFromTypeAliasObject.kt");
}
@TestMetadata("importMemberFromJavaViaAlias.kt")
public void testImportMemberFromJavaViaAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt");
}
@TestMetadata("inGenerics.kt")
public void testInGenerics() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/inGenerics.kt");
@@ -22516,6 +22666,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/typealias/simpleTypeAlias.kt");
}
@TestMetadata("starImportOnTypeAlias.kt")
public void testStarImportOnTypeAlias() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/starImportOnTypeAlias.kt");
}
@TestMetadata("starProjection.kt")
public void testStarProjection() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/starProjection.kt");
@@ -22681,6 +22836,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/typealias/typeAliasShouldExpandToClass.kt");
}
@TestMetadata("typeAliasesInImportDirectives.kt")
public void testTypeAliasesInImportDirectives() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt");
}
@TestMetadata("typeAliasesInQualifiers.kt")
public void testTypeAliasesInQualifiers() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt");
}
@TestMetadata("typealiasRhsAnnotations.kt")
public void testTypealiasRhsAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/typealiasRhsAnnotations.kt");

View File

@@ -1,19 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.jvm
interface GlobalSearchScopeWithModuleSources

View File

@@ -44,7 +44,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.asJava.KtLightClassMarker;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.load.java.JavaClassFinder;
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl;
import org.jetbrains.kotlin.load.java.structure.JavaClass;
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl;
import org.jetbrains.kotlin.name.ClassId;
@@ -126,30 +125,7 @@ public class KotlinJavaPsiFacade {
}
else {
PsiClass aClass = finder.findClass(qualifiedName, scope);
if (aClass != null) {
if (scope instanceof JavaClassFinderImpl.FilterOutKotlinSourceFilesScope) {
GlobalSearchScope baseScope = ((JavaClassFinderImpl.FilterOutKotlinSourceFilesScope) scope).getBase();
boolean isSourcesScope = baseScope instanceof GlobalSearchScopeWithModuleSources;
if (!isSourcesScope) {
Object originalFinder = (finder instanceof KotlinPsiElementFinderWrapperImpl)
? ((KotlinPsiElementFinderWrapperImpl) finder).getOriginal()
: finder;
// Temporary fix for #KT-12402
boolean isAndroidDataBindingClassWriter = originalFinder.getClass().getName()
.equals("com.android.tools.idea.databinding.DataBindingClassFinder");
boolean isAndroidDataBindingComponentClassWriter = originalFinder.getClass().getName()
.equals("com.android.tools.idea.databinding.DataBindingComponentClassFinder");
if (isAndroidDataBindingClassWriter || isAndroidDataBindingComponentClassWriter) {
continue;
}
}
}
return createJavaClass(classId, aClass);
}
if (aClass != null) return createJavaClass(classId, aClass);
}
}
@@ -341,10 +317,6 @@ public class KotlinJavaPsiFacade {
this.finder = finder;
}
public PsiElementFinder getOriginal() {
return finder;
}
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
return finder.findClass(qualifiedName, scope);

View File

@@ -59,7 +59,8 @@ fun OtherOrigin(element: PsiElement?, descriptor: DeclarationDescriptor? = null)
fun OtherOriginFromPure(element: KtPureElement?, descriptor: DeclarationDescriptor? = null) =
OtherOrigin(element?.psiOrParent, descriptor)
fun OtherOrigin(descriptor: DeclarationDescriptor) = JvmDeclarationOrigin(OTHER, null, descriptor)
fun OtherOrigin(descriptor: DeclarationDescriptor): JvmDeclarationOrigin =
JvmDeclarationOrigin(OTHER, DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
fun Bridge(
descriptor: DeclarationDescriptor,

View File

@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.synthetic
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
@@ -28,34 +29,62 @@ import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
import org.jetbrains.kotlin.storage.StorageManager
class JavaSyntheticScopes(
private val project: Project,
private val moduleDescriptor: ModuleDescriptor,
storageManager: StorageManager,
lookupTracker: LookupTracker,
languageVersionSettings: LanguageVersionSettings,
samConventionResolver: SamConversionResolver,
deprecationResolver: DeprecationResolver
): SyntheticScopes {
override val scopes = run {
val javaSyntheticPropertiesScope = JavaSyntheticPropertiesScope(storageManager, lookupTracker)
private val project: Project,
private val moduleDescriptor: ModuleDescriptor,
storageManager: StorageManager,
lookupTracker: LookupTracker,
languageVersionSettings: LanguageVersionSettings,
samConventionResolver: SamConversionResolver,
deprecationResolver: DeprecationResolver
) : SyntheticScopes {
override val scopes: Collection<SyntheticScope>
// New Inference disables SAM-adapters scope, because it knows how to perform SAM-conversion in resolution
// However, some outer clients (mostly in IDE) sometimes would like to look at synthetic SAM-produced descriptors
// (e.g., completion)
val scopesWithForceEnabledSamAdapters: Collection<SyntheticScope>
init {
val samConversionPerArgumentIsEnabled =
languageVersionSettings.supportsFeature(LanguageFeature.SamConversionPerArgument)
val javaSyntheticPropertiesScope = JavaSyntheticPropertiesScope(storageManager, lookupTracker)
val scopesFromExtensions = SyntheticScopeProviderExtension
.getInstances(project)
.flatMap { it.getScopes(moduleDescriptor, javaSyntheticPropertiesScope) }
listOf(
javaSyntheticPropertiesScope,
SamAdapterFunctionsScope(
storageManager, languageVersionSettings, samConventionResolver, deprecationResolver,
lookupTracker
val samAdapterFunctionsScope = SamAdapterFunctionsScope(
storageManager,
samConventionResolver,
deprecationResolver,
lookupTracker,
samViaSyntheticScopeDisabled = samConversionPerArgumentIsEnabled
)
scopes = listOf(javaSyntheticPropertiesScope, samAdapterFunctionsScope) + scopesFromExtensions
if (samConversionPerArgumentIsEnabled) {
val forceEnabledSamAdapterFunctionsScope = SamAdapterFunctionsScope(
storageManager,
samConventionResolver,
deprecationResolver,
lookupTracker,
samViaSyntheticScopeDisabled = false
)
) + scopesFromExtensions
scopesWithForceEnabledSamAdapters =
listOf(javaSyntheticPropertiesScope, forceEnabledSamAdapterFunctionsScope) + scopesFromExtensions
} else {
scopesWithForceEnabledSamAdapters = scopes
}
}
}
interface SyntheticScopeProviderExtension {
companion object : ProjectExtensionDescriptor<SyntheticScopeProviderExtension>(
"org.jetbrains.kotlin.syntheticScopeProviderExtension", SyntheticScopeProviderExtension::class.java)
"org.jetbrains.kotlin.syntheticScopeProviderExtension", SyntheticScopeProviderExtension::class.java
)
fun getScopes(moduleDescriptor: ModuleDescriptor, javaSyntheticPropertiesScope: JavaSyntheticPropertiesScope): List<SyntheticScope>
}

View File

@@ -55,13 +55,11 @@ val SAM_LOOKUP_NAME = Name.special("<SAM-CONSTRUCTOR>")
class SamAdapterFunctionsScope(
storageManager: StorageManager,
private val languageVersionSettings: LanguageVersionSettings,
private val samResolver: SamConversionResolver,
private val deprecationResolver: DeprecationResolver,
private val lookupTracker: LookupTracker
private val lookupTracker: LookupTracker,
private val samViaSyntheticScopeDisabled: Boolean
) : SyntheticScope.Default() {
private val samViaSyntheticScopeDisabled = languageVersionSettings.supportsFeature(LanguageFeature.NewInference) &&
languageVersionSettings.supportsFeature(LanguageFeature.SamConversionForKotlinFunctions)
private val extensionForFunction =
storageManager.createMemoizedFunctionWithNullableValues<FunctionDescriptor, FunctionDescriptor> { function ->

View File

@@ -19,6 +19,10 @@ package org.jetbrains.kotlin.synthetic
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.load.java.sam.SamAdapterDescriptor
import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
fun FunctionDescriptor.hasJavaOriginInHierarchy(): Boolean {
@@ -55,3 +59,14 @@ fun syntheticVisibility(originalDescriptor: DeclarationDescriptorWithVisibility,
}
}
fun <D : CallableDescriptor> ResolvedCall<D>.isResolvedWithSamConversions(): Boolean {
if (this is NewResolvedCallImpl<D> && resolvedCallAtom.argumentsWithConversion.isNotEmpty()) {
return true
}
// Feature SamConversionPerArgument is disabled
return this.resultingDescriptor is SamAdapterDescriptor<*> ||
this.resultingDescriptor is SamConstructorDescriptor ||
this.resultingDescriptor is SamAdapterExtensionFunctionDescriptor
}

View File

@@ -508,7 +508,7 @@ class ControlFlowInformationProvider private constructor(
}
}
if (descriptor == null) {
val descriptors = trace.get(BindingContext.AMBIGUOUS_REFERENCE_TARGET, operationReference) ?: emptyList()
val descriptors = trace.get(AMBIGUOUS_REFERENCE_TARGET, operationReference) ?: emptyList<DeclarationDescriptor>()
for (referenceDescriptor in descriptors) {
if ((referenceDescriptor as? FunctionDescriptor)?.returnType?.let { KotlinBuiltIns.isUnit(it) } == true) {
hasReassignMethodReturningUnit = true

View File

@@ -29,4 +29,7 @@ object AnalysisFlags {
@JvmStatic
val allowResultReturnType by AnalysisFlag.Delegates.Boolean
@JvmStatic
val constraintSystemForOverloadResolution by AnalysisFlag.Delegates.ConstraintSystemForOverloadResolution
}

View File

@@ -67,7 +67,7 @@ private fun ESValue.toDataFlowValue(builtIns: KotlinBuiltIns): DataFlowValue? =
is ESDataFlowValue -> dataFlowValue
is ESConstant -> when (constantReference) {
ConstantReference.NULL -> DataFlowValue.nullValue(builtIns)
else -> DataFlowValue(IdentifierInfo.NO, type)
else -> DataFlowValue(IdentifierInfo.NO, type.toKotlinType(builtIns))
}
else -> null
}

View File

@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.contracts.model.Computation
import org.jetbrains.kotlin.contracts.model.ESComponents
import org.jetbrains.kotlin.contracts.model.ESEffect
import org.jetbrains.kotlin.contracts.model.MutableContextInfo
import org.jetbrains.kotlin.contracts.model.functors.EqualsFunctor
@@ -46,13 +45,6 @@ class EffectSystem(
val dataFlowValueFactory: DataFlowValueFactory,
val builtIns: KotlinBuiltIns
) {
// Lazy because this code is executed when the container is set up (before any resolution starts),
// so builtins are not fully functional yet at that moment
val components: ESComponents by lazy(LazyThreadSafetyMode.NONE) { ESComponents(builtIns) }
val constants: ESConstants
get() = components.constants
fun getDataFlowInfoForFinishedCall(
resolvedCall: ResolvedCall<*>,
bindingTrace: BindingTrace,
@@ -64,7 +56,7 @@ class EffectSystem(
val callExpression = resolvedCall.call.callElement as? KtCallExpression ?: return DataFlowInfo.EMPTY
if (callExpression is KtDeclaration) return DataFlowInfo.EMPTY
val resultContextInfo = getContextInfoWhen(ESReturns(constants.wildcard), callExpression, bindingTrace, moduleDescriptor)
val resultContextInfo = getContextInfoWhen(ESReturns(ESConstants.wildcard), callExpression, bindingTrace, moduleDescriptor)
return resultContextInfo.toDataFlowInfo(languageVersionSettings, builtIns)
}
@@ -83,10 +75,10 @@ class EffectSystem(
val rightComputation =
getNonTrivialComputation(rightExpression, bindingTrace, moduleDescriptor) ?: return ConditionalDataFlowInfo.EMPTY
val effects = EqualsFunctor(constants, false).invokeWithArguments(leftComputation, rightComputation)
val effects = EqualsFunctor(false).invokeWithArguments(leftComputation, rightComputation)
val equalsContextInfo = InfoCollector(ESReturns(constants.trueValue), constants).collectFromSchema(effects)
val notEqualsContextInfo = InfoCollector(ESReturns(constants.falseValue), constants).collectFromSchema(effects)
val equalsContextInfo = InfoCollector(ESReturns(ESConstants.trueValue), builtIns).collectFromSchema(effects)
val notEqualsContextInfo = InfoCollector(ESReturns(ESConstants.falseValue), builtIns).collectFromSchema(effects)
return ConditionalDataFlowInfo(
equalsContextInfo.toDataFlowInfo(languageVersionSettings, builtIns),
@@ -101,7 +93,7 @@ class EffectSystem(
val callExpression = resolvedCall.call.callElement as? KtCallExpression ?: return
if (callExpression is KtDeclaration) return
val resultingContextInfo = getContextInfoWhen(ESReturns(constants.wildcard), callExpression, bindingTrace, moduleDescriptor)
val resultingContextInfo = getContextInfoWhen(ESReturns(ESConstants.wildcard), callExpression, bindingTrace, moduleDescriptor)
for (effect in resultingContextInfo.firedEffects) {
val callsEffect = effect as? ESCalls ?: continue
val lambdaExpression = (callsEffect.callable as? ESLambda)?.lambda ?: continue
@@ -118,7 +110,7 @@ class EffectSystem(
if (!languageVersionSettings.supportsFeature(LanguageFeature.UseReturnsEffect)) return DataFlowInfo.EMPTY
if (condition == null) return DataFlowInfo.EMPTY
return getContextInfoWhen(ESReturns(constants.booleanValue(value)), condition, bindingTrace, moduleDescriptor)
return getContextInfoWhen(ESReturns(ESConstants.booleanValue(value)), condition, bindingTrace, moduleDescriptor)
.toDataFlowInfo(languageVersionSettings, moduleDescriptor.builtIns)
}
@@ -133,11 +125,11 @@ class EffectSystem(
}
if (isInContractBlock) return MutableContextInfo.EMPTY
val computation = getNonTrivialComputation(expression, bindingTrace, moduleDescriptor) ?: return MutableContextInfo.EMPTY
return InfoCollector(observedEffect, constants).collectFromSchema(computation.effects)
return InfoCollector(observedEffect, builtIns).collectFromSchema(computation.effects)
}
private fun getNonTrivialComputation(expression: KtExpression, trace: BindingTrace, moduleDescriptor: ModuleDescriptor): Computation? {
val visitor = EffectsExtractingVisitor(trace, moduleDescriptor, dataFlowValueFactory, constants, languageVersionSettings)
val visitor = EffectsExtractingVisitor(trace, moduleDescriptor, dataFlowValueFactory, languageVersionSettings)
return visitor.extractOrGetCached(expression).takeUnless { it == UNKNOWN_COMPUTATION }
}
}

View File

@@ -25,10 +25,8 @@ import org.jetbrains.kotlin.contracts.model.ConditionalEffect
import org.jetbrains.kotlin.contracts.model.ESEffect
import org.jetbrains.kotlin.contracts.model.Functor
import org.jetbrains.kotlin.contracts.model.functors.*
import org.jetbrains.kotlin.contracts.model.structure.CallComputation
import org.jetbrains.kotlin.contracts.model.structure.ESConstants
import org.jetbrains.kotlin.contracts.model.structure.UNKNOWN_COMPUTATION
import org.jetbrains.kotlin.contracts.model.structure.isReturns
import org.jetbrains.kotlin.contracts.model.structure.*
import org.jetbrains.kotlin.contracts.model.visitors.Reducer
import org.jetbrains.kotlin.contracts.parsing.isEqualsDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
@@ -58,10 +56,10 @@ class EffectsExtractingVisitor(
private val trace: BindingTrace,
private val moduleDescriptor: ModuleDescriptor,
private val dataFlowValueFactory: DataFlowValueFactory,
private val constants: ESConstants,
private val languageVersionSettings: LanguageVersionSettings
) : KtVisitor<Computation, Unit>() {
private val builtIns: KotlinBuiltIns get() = moduleDescriptor.builtIns
private val reducer: Reducer = Reducer(builtIns)
fun extractOrGetCached(element: KtElement): Computation {
trace[BindingContext.EXPRESSION_EFFECTS, element]?.let { return it }
@@ -77,17 +75,20 @@ class EffectsExtractingVisitor(
val descriptor = resolvedCall.resultingDescriptor
return when {
descriptor.isEqualsDescriptor() -> CallComputation(
builtIns.booleanType,
EqualsFunctor(constants, false).invokeWithArguments(arguments)
ESBooleanType,
EqualsFunctor(false).invokeWithArguments(arguments, reducer)
)
descriptor is ValueDescriptor -> ESVariableWithDataFlowValue(
descriptor,
(element as KtExpression).createDataFlowValue() ?: return UNKNOWN_COMPUTATION
)
descriptor is FunctionDescriptor -> CallComputation(
descriptor.returnType,
descriptor.getFunctor()?.invokeWithArguments(arguments) ?: emptyList()
)
descriptor is FunctionDescriptor -> {
val esType = descriptor.returnType?.toESType()
CallComputation(
esType,
descriptor.getFunctor()?.invokeWithArguments(arguments, reducer) ?: emptyList()
)
}
else -> UNKNOWN_COMPUTATION
}
}
@@ -111,18 +112,18 @@ class EffectsExtractingVisitor(
val value: Any? = compileTimeConstant.getValue(type)
return when (value) {
is Boolean -> constants.booleanValue(value)
null -> constants.nullValue
is Boolean -> ESConstants.booleanValue(value)
null -> ESConstants.nullValue
else -> UNKNOWN_COMPUTATION
}
}
override fun visitIsExpression(expression: KtIsExpression, data: Unit): Computation {
val rightType: KotlinType = trace[BindingContext.TYPE, expression.typeReference] ?: return UNKNOWN_COMPUTATION
val rightType = trace[BindingContext.TYPE, expression.typeReference]?.toESType() ?: return UNKNOWN_COMPUTATION
val arg = extractOrGetCached(expression.leftHandSide)
return CallComputation(
builtIns.booleanType,
IsFunctor(constants, rightType, expression.isNegated).invokeWithArguments(listOf(arg))
ESBooleanType,
IsFunctor(rightType, expression.isNegated).invokeWithArguments(listOf(arg), reducer)
)
}
@@ -134,7 +135,7 @@ class EffectsExtractingVisitor(
// null bypassing function's contract, so we have to filter them out
fun ESEffect.containsReturnsNull(): Boolean =
isReturns { value == constants.nullValue } || this is ConditionalEffect && this.simpleEffect.containsReturnsNull()
isReturns { value == ESConstants.nullValue } || this is ConditionalEffect && this.simpleEffect.containsReturnsNull()
val effectsWithoutReturnsNull = computation.effects.filter { !it.containsReturnsNull() }
return CallComputation(computation.type, effectsWithoutReturnsNull)
@@ -147,10 +148,10 @@ class EffectsExtractingVisitor(
val args = listOf(left, right)
return when (expression.operationToken) {
KtTokens.EXCLEQ -> CallComputation(builtIns.booleanType, EqualsFunctor(constants, true).invokeWithArguments(args))
KtTokens.EQEQ -> CallComputation(builtIns.booleanType, EqualsFunctor(constants, false).invokeWithArguments(args))
KtTokens.ANDAND -> CallComputation(builtIns.booleanType, AndFunctor(constants).invokeWithArguments(args))
KtTokens.OROR -> CallComputation(builtIns.booleanType, OrFunctor(constants).invokeWithArguments(args))
KtTokens.EXCLEQ -> CallComputation(ESBooleanType, EqualsFunctor(true).invokeWithArguments(args, reducer))
KtTokens.EQEQ -> CallComputation(ESBooleanType, EqualsFunctor(false).invokeWithArguments(args, reducer))
KtTokens.ANDAND -> CallComputation(ESBooleanType, AndFunctor().invokeWithArguments(args, reducer))
KtTokens.OROR -> CallComputation(ESBooleanType, OrFunctor().invokeWithArguments(args, reducer))
else -> UNKNOWN_COMPUTATION
}
}
@@ -158,7 +159,7 @@ class EffectsExtractingVisitor(
override fun visitUnaryExpression(expression: KtUnaryExpression, data: Unit): Computation {
val arg = extractOrGetCached(expression.baseExpression ?: return UNKNOWN_COMPUTATION)
return when (expression.operationToken) {
KtTokens.EXCL -> CallComputation(builtIns.booleanType, NotFunctor(constants).invokeWithArguments(arg))
KtTokens.EXCL -> CallComputation(ESBooleanType, NotFunctor().invokeWithArguments(arg))
else -> UNKNOWN_COMPUTATION
}
}

View File

@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.calls.CallResolver;
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
@@ -303,7 +304,9 @@ public class BodyResolver {
if (delegateExpression != null) {
LexicalScope scope = scopeForConstructor == null ? scopeForMemberResolution : scopeForConstructor;
KotlinType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE;
typeInferrer.getType(scope, delegateExpression, expectedType, outerDataFlowInfo, trace);
typeInferrer.getType(
scope, delegateExpression, expectedType, outerDataFlowInfo, InferenceSession.Companion.getDefault(), trace
);
}
if (descriptor.isExpect()) {
@@ -660,7 +663,8 @@ public class BodyResolver {
PreliminaryDeclarationVisitor.Companion.createForDeclaration(
(KtDeclaration) anonymousInitializer.getParent().getParent(), trace, languageVersionSettings);
expressionTypingServices.getTypeInfo(
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace, /*isStatement = */true
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo,
InferenceSession.Companion.getDefault(), trace, /*isStatement = */true
);
}
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
@@ -864,6 +868,7 @@ public class BodyResolver {
propertyDescriptor,
delegateExpression,
propertyHeaderScope,
InferenceSession.Companion.getDefault(),
trace);
}
@@ -878,7 +883,7 @@ public class BodyResolver {
KotlinType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
if (propertyDescriptor.getCompileTimeInitializer() == null) {
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
outerDataFlowInfo, trace);
outerDataFlowInfo, InferenceSession.Companion.getDefault(), trace);
}
}

View File

@@ -53,14 +53,14 @@ class DelegatedPropertyInferenceSession(
?: builtIns.nullableNothingType
val valueParameterForThis = descriptor.valueParameters.getOrNull(0) ?: return
val substitutedType = substitutor.substituteKeepAnnotations(valueParameterForThis.type.unwrap())
val substitutedType = substitutor.safeSubstitute(valueParameterForThis.type.unwrap())
commonSystem.addSubtypeConstraint(typeOfThis.unwrap(), substitutedType, DelegatedPropertyConstraintPosition(atom))
}
private fun ResolvedCallAtom.addConstraintsForGetValueMethod(commonSystem: ConstraintSystemBuilder) {
if (expectedType != null) {
val unsubstitutedReturnType = candidateDescriptor.returnType?.unwrap() ?: return
val substitutedReturnType = substitutor.substituteKeepAnnotations(unsubstitutedReturnType)
val substitutedReturnType = substitutor.safeSubstitute(unsubstitutedReturnType)
commonSystem.addSubtypeConstraint(substitutedReturnType, expectedType, DelegatedPropertyConstraintPosition(atom))
}
@@ -71,7 +71,7 @@ class DelegatedPropertyInferenceSession(
private fun ResolvedCallAtom.addConstraintsForSetValueMethod(commonSystem: ConstraintSystemBuilder) {
if (expectedType != null) {
val unsubstitutedParameterType = candidateDescriptor.valueParameters.getOrNull(2)?.type?.unwrap() ?: return
val substitutedParameterType = substitutor.substituteKeepAnnotations(unsubstitutedParameterType)
val substitutedParameterType = substitutor.safeSubstitute(unsubstitutedParameterType)
commonSystem.addSubtypeConstraint(expectedType, substitutedParameterType, DelegatedPropertyConstraintPosition(atom))
}
@@ -84,7 +84,7 @@ class DelegatedPropertyInferenceSession(
initialStorage: ConstraintStorage
): Map<TypeConstructor, UnwrappedType> = emptyMap()
override fun writeOnlyStubs(): Boolean = false
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean = false
}
object InferenceSessionForExistingCandidates : InferenceSession {
@@ -102,6 +102,6 @@ object InferenceSessionForExistingCandidates : InferenceSession {
initialStorage: ConstraintStorage
): Map<TypeConstructor, UnwrappedType> = emptyMap()
override fun writeOnlyStubs(): Boolean = false
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean = false
override fun callCompleted(resolvedAtom: ResolvedAtom): Boolean = false
}

View File

@@ -72,6 +72,7 @@ class DelegatedPropertyResolver(
variableDescriptor: VariableDescriptorWithAccessors,
delegateExpression: KtExpression,
propertyHeaderScope: LexicalScope,
inferenceSession: InferenceSession,
trace: BindingTrace
) {
property.getter?.let { getter ->
@@ -86,8 +87,9 @@ class DelegatedPropertyResolver(
ScopeUtils.makeScopeForPropertyInitializer(propertyHeaderScope, variableDescriptor)
else propertyHeaderScope
val byExpressionType =
resolveDelegateExpression(delegateExpression, property, variableDescriptor, initializerScope, trace, outerDataFlowInfo)
val byExpressionType =resolveDelegateExpression(
delegateExpression, property, variableDescriptor, initializerScope, trace, outerDataFlowInfo, inferenceSession
)
resolveProvideDelegateMethod(variableDescriptor, delegateExpression, byExpressionType, trace, initializerScope, outerDataFlowInfo)
val delegateType = getResolvedDelegateType(variableDescriptor, delegateExpression, byExpressionType, trace)
@@ -455,7 +457,8 @@ class DelegatedPropertyResolver(
variableDescriptor: VariableDescriptorWithAccessors,
scopeForDelegate: LexicalScope,
trace: BindingTrace,
dataFlowInfo: DataFlowInfo
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession
): KotlinType {
val traceToResolveDelegatedProperty = TemporaryBindingTrace.create(trace, "Trace to resolve delegated property")
@@ -475,12 +478,13 @@ class DelegatedPropertyResolver(
}
val delegatedPropertyTypeFromNI =
resolveWithNewInference(delegateExpression, variableDescriptor, scopeForDelegate, trace, dataFlowInfo)
resolveWithNewInference(delegateExpression, variableDescriptor, scopeForDelegate, trace, dataFlowInfo, inferenceSession)
val delegateType = expressionTypingServices.safeGetType(
scopeForDelegate,
delegateExpression,
delegatedPropertyTypeFromNI ?: NO_EXPECTED_TYPE,
dataFlowInfo,
inferenceSession,
traceToResolveDelegatedProperty
)
@@ -494,7 +498,8 @@ class DelegatedPropertyResolver(
variableDescriptor: VariableDescriptorWithAccessors,
scopeForDelegate: LexicalScope,
trace: BindingTrace,
dataFlowInfo: DataFlowInfo
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession
): KotlinType? {
if (!languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) return null
@@ -503,7 +508,7 @@ class DelegatedPropertyResolver(
val traceToResolveDelegatedProperty = TemporaryBindingTrace.create(trace, "Trace to resolve delegated property")
val delegateTypeInfo = expressionTypingServices.getTypeInfo(
scopeForDelegate, delegateExpression, NO_EXPECTED_TYPE, dataFlowInfo,
scopeForDelegate, delegateExpression, NO_EXPECTED_TYPE, dataFlowInfo, inferenceSession,
traceToResolveDelegatedProperty, false, delegateExpression, ContextDependency.DEPENDENT
)

View File

@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfoFactory;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
@@ -798,7 +799,8 @@ public class DescriptorResolver {
@NotNull LexicalScope scopeForInitializerResolution,
@NotNull KtDestructuringDeclarationEntry entry,
@NotNull BindingTrace trace,
@NotNull DataFlowInfo dataFlowInfo
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession
) {
KtDestructuringDeclaration destructuringDeclaration = (KtDestructuringDeclaration) entry.getParent();
KtExpression initializer = destructuringDeclaration.getInitializer();
@@ -819,6 +821,7 @@ public class DescriptorResolver {
entry,
trace,
dataFlowInfo,
inferenceSession,
VariableAsPropertyInfo.Companion.createFromDestructuringDeclarationEntry(componentType));
}
@@ -842,7 +845,8 @@ public class DescriptorResolver {
@NotNull LexicalScope scopeForInitializerResolution,
@NotNull KtProperty property,
@NotNull BindingTrace trace,
@NotNull DataFlowInfo dataFlowInfo
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession
) {
return resolveAsPropertyDescriptor(
containingDeclaration,
@@ -851,6 +855,7 @@ public class DescriptorResolver {
property,
trace,
dataFlowInfo,
inferenceSession,
VariableAsPropertyInfo.Companion.createFromProperty(property));
}
@@ -862,6 +867,7 @@ public class DescriptorResolver {
@NotNull KtVariableDeclaration variableDeclaration,
@NotNull BindingTrace trace,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession,
@NotNull VariableAsPropertyInfo propertyInfo
) {
KtModifierList modifierList = variableDeclaration.getModifierList();
@@ -962,7 +968,8 @@ public class DescriptorResolver {
KotlinType propertyType = propertyInfo.getVariableType();
KotlinType typeIfKnown = propertyType != null ? propertyType : variableTypeAndInitializerResolver.resolveTypeNullable(
propertyDescriptor, scopeForInitializer,
variableDeclaration, dataFlowInfo, /* local = */ trace, false
variableDeclaration, dataFlowInfo, inferenceSession,
trace, /* local = */ false
);
PropertyGetterDescriptorImpl getter = resolvePropertyGetterDescriptor(
@@ -980,7 +987,7 @@ public class DescriptorResolver {
assert type != null : "At least getter type must be initialized via resolvePropertyGetterDescriptor";
variableTypeAndInitializerResolver.setConstantForVariableIfNeeded(
propertyDescriptor, scopeForInitializer, variableDeclaration, dataFlowInfo, type, trace
propertyDescriptor, scopeForInitializer, variableDeclaration, dataFlowInfo, type, inferenceSession, trace
);
propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(container), receiverDescriptor);

View File

@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.psi.KtVariableDeclaration
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
@@ -74,7 +75,8 @@ class LocalVariableResolver(
context.trace.report(LOCAL_VARIABLE_WITH_SETTER.on(setter))
}
val propertyDescriptor = resolveLocalVariableDescriptor(scope, property, context.dataFlowInfo, context.trace)
val propertyDescriptor =
resolveLocalVariableDescriptor(scope, property, context.dataFlowInfo, context.inferenceSession, context.trace)
val delegateExpression = property.delegateExpression
if (delegateExpression != null) {
@@ -94,6 +96,7 @@ class LocalVariableResolver(
propertyDescriptor,
delegateExpression,
typingContext.scope,
typingContext.inferenceSession,
typingContext.trace
)
propertyDescriptor.getter?.updateAccessorFlagsFromResolvedCallForDelegatedProperty(typingContext.trace)
@@ -153,6 +156,7 @@ class LocalVariableResolver(
scope: LexicalScope,
variable: KtVariableDeclaration,
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace
): VariableDescriptor {
val containingDeclaration = scope.ownerDescriptor
@@ -176,7 +180,9 @@ class LocalVariableResolver(
variable is KtProperty && variable.hasDelegate()
)
// For a local variable the type must not be deferred
type = variableTypeAndInitializerResolver.resolveType(propertyDescriptor, scope, variable, dataFlowInfo, trace, local = true)
type = variableTypeAndInitializerResolver.resolveType(
propertyDescriptor, scope, variable, dataFlowInfo, inferenceSession, trace, local = true
)
val receiverParameter = (containingDeclaration as ScriptDescriptor).thisAsReceiverParameter
propertyDescriptor.setType(type, emptyList<TypeParameterDescriptor>(), receiverParameter, null)
@@ -186,11 +192,14 @@ class LocalVariableResolver(
} else {
val variableDescriptor = resolveLocalVariableDescriptorWithType(scope, variable, null, trace)
// For a local variable the type must not be deferred
type = variableTypeAndInitializerResolver.resolveType(variableDescriptor, scope, variable, dataFlowInfo, trace, local = true)
type = variableTypeAndInitializerResolver.resolveType(
variableDescriptor, scope, variable, dataFlowInfo, inferenceSession, trace, local = true
)
variableDescriptor.setOutType(type)
result = variableDescriptor
}
variableTypeAndInitializerResolver.setConstantForVariableIfNeeded(result, scope, variable, dataFlowInfo, type, trace)
variableTypeAndInitializerResolver
.setConstantForVariableIfNeeded(result, scope, variable, dataFlowInfo, type, inferenceSession, trace)
// Type annotations also should be resolved
ForceResolveUtil.forceResolveAllContents(type.annotations)
return result

View File

@@ -231,7 +231,7 @@ class QualifiedExpressionResolver {
val packageOrClassDescriptor = resolveToPackageOrClass(
path, moduleDescriptor, trace, packageFragmentForCheck,
scopeForFirstPart = null, position = QualifierPosition.IMPORT
) ?: return null
).classDescriptorFromTypeAlias() ?: return null
if (packageOrClassDescriptor is ClassDescriptor && packageOrClassDescriptor.kind.isSingleton && lastPart.expression != null) {
trace.report(
@@ -249,6 +249,10 @@ class QualifiedExpressionResolver {
}
}
private fun DeclarationDescriptor?.classDescriptorFromTypeAlias(): DeclarationDescriptor? {
return if (this is TypeAliasDescriptor) classDescriptor else this
}
private fun computePackageFragmentToCheck(
containingFile: KtFile,
packageFragmentForVisibilityCheck: PackageFragmentDescriptor?

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.contracts.description.ContractProviderKey
import org.jetbrains.kotlin.contracts.description.LazyContractProvider
import org.jetbrains.kotlin.contracts.parsing.isContractCallDescriptor
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.psiUtil.isContractDescriptionCallPsiCheck
import org.jetbrains.kotlin.psi.psiUtil.isFirstStatement
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
/*
* See KT-26386 and KT-30410
*/
fun disableContractsInsideContractsBlock(call: Call, descriptor: CallableDescriptor?, scope: LexicalScope, trace: BindingTrace) {
call.callElement.safeAs<KtExpression>()?.let { callExpression ->
if (callExpression.isFirstStatement() && callExpression.isContractDescriptionCallPsiCheck()) {
if (descriptor?.isContractCallDescriptor() != true) {
scope.ownerDescriptor
.safeAs<FunctionDescriptor>()
?.getUserData(ContractProviderKey)
?.safeAs<LazyContractProvider>()
?.setContractDescription(null)
} else {
trace.record(BindingContext.IS_CONTRACT_DECLARATION_BLOCK, callExpression, true)
}
}
}
}

View File

@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtVariableDeclaration
import org.jetbrains.kotlin.resolve.DescriptorResolver.transformAnonymousTypeIfNeeded
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
@@ -44,10 +45,13 @@ class VariableTypeAndInitializerResolver(
scopeForInitializer: LexicalScope,
variable: KtVariableDeclaration,
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace,
local: Boolean
): KotlinType {
resolveTypeNullable(variableDescriptor, scopeForInitializer, variable, dataFlowInfo, trace, local)?.let { return it }
resolveTypeNullable(
variableDescriptor, scopeForInitializer, variable, dataFlowInfo, inferenceSession, trace, local
)?.let { return it }
if (local) {
trace.report(VARIABLE_WITH_NO_TYPE_NO_INITIALIZER.on(variable))
@@ -61,6 +65,7 @@ class VariableTypeAndInitializerResolver(
scopeForInitializer: LexicalScope,
variable: KtVariableDeclaration,
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace,
local: Boolean
): KotlinType? {
@@ -70,7 +75,9 @@ class VariableTypeAndInitializerResolver(
!variable.hasInitializer() && variable is KtProperty && variableDescriptor is VariableDescriptorWithAccessors &&
variable.hasDelegateExpression() ->
resolveDelegatedPropertyType(variable, variableDescriptor, scopeForInitializer, dataFlowInfo, trace, local)
resolveDelegatedPropertyType(
variable, variableDescriptor, scopeForInitializer, dataFlowInfo, inferenceSession, trace, local
)
variable.hasInitializer() -> when {
!local ->
@@ -81,12 +88,13 @@ class VariableTypeAndInitializerResolver(
variable, trace,
expressionTypingServices.languageVersionSettings
)
val initializerType =
resolveInitializerType(scopeForInitializer, variable.initializer!!, dataFlowInfo, trace, local)
val initializerType = resolveInitializerType(
scopeForInitializer, variable.initializer!!, dataFlowInfo, inferenceSession, trace, local
)
transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace, anonymousTypeTransformers)
}
else -> resolveInitializerType(scopeForInitializer, variable.initializer!!, dataFlowInfo, trace, local)
else -> resolveInitializerType(scopeForInitializer, variable.initializer!!, dataFlowInfo, inferenceSession, trace, local)
}
else -> null
@@ -99,6 +107,7 @@ class VariableTypeAndInitializerResolver(
variable: KtVariableDeclaration,
dataFlowInfo: DataFlowInfo,
variableType: KotlinType,
inferenceSession: InferenceSession,
trace: BindingTrace
) {
if (!variable.hasInitializer() || variable.isVar) return
@@ -111,7 +120,8 @@ class VariableTypeAndInitializerResolver(
)) return@computeInitializer null
val initializer = variable.initializer
val initializerType = expressionTypingServices.safeGetType(scope, initializer!!, variableType, dataFlowInfo, trace)
val initializerType =
expressionTypingServices.safeGetType(scope, initializer!!, variableType, dataFlowInfo, inferenceSession, trace)
val constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType)
?: return@computeInitializer null
@@ -131,12 +141,13 @@ class VariableTypeAndInitializerResolver(
variableDescriptor: VariableDescriptorWithAccessors,
scopeForInitializer: LexicalScope,
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace,
local: Boolean
) = wrappedTypeFactory.createRecursionIntolerantDeferredType(trace) {
val delegateExpression = property.delegateExpression!!
val type = delegatedPropertyResolver.resolveDelegateExpression(
delegateExpression, property, variableDescriptor, scopeForInitializer, trace, dataFlowInfo
delegateExpression, property, variableDescriptor, scopeForInitializer, trace, dataFlowInfo, inferenceSession
)
val getterReturnType = delegatedPropertyResolver.getGetValueMethodReturnType(
@@ -153,10 +164,13 @@ class VariableTypeAndInitializerResolver(
scope: LexicalScope,
initializer: KtExpression,
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace,
local: Boolean
): KotlinType {
val inferredType = expressionTypingServices.safeGetType(scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, trace)
val inferredType = expressionTypingServices.safeGetType(
scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, inferenceSession, trace
)
val approximatedType = approximateType(inferredType, local)
return declarationReturnTypeSanitizer.sanitizeReturnType(approximatedType, wrappedTypeFactory, trace, languageVersionSettings)
}

View File

@@ -135,19 +135,7 @@ class CallCompleter(
context: BasicCallResolutionContext,
tracing: TracingStrategy
) {
context.call.callElement.safeAs<KtExpression>()?.let { callExpression ->
if (callExpression.isFirstStatement() && callExpression.isContractDescriptionCallPsiCheck()) {
if (resolvedCall?.resultingDescriptor?.isContractCallDescriptor() != true) {
context.scope.ownerDescriptor
.safeAs<FunctionDescriptor>()
?.getUserData(ContractProviderKey)
?.safeAs<LazyContractProvider>()
?.setContractDescription(null)
} else {
context.trace.record(BindingContext.IS_CONTRACT_DECLARATION_BLOCK, callExpression, true)
}
}
}
disableContractsInsideContractsBlock(context.call, resolvedCall?.resultingDescriptor, context.scope, context.trace)
if (resolvedCall == null || resolvedCall.isCompleted || resolvedCall.constraintSystem == null) {
completeArguments(context, results)

View File

@@ -350,7 +350,7 @@ public class CallResolver {
);
}
KotlinType calleeType = expressionTypingServices.safeGetType(
context.scope, calleeExpression, expectedType, context.dataFlowInfo, context.trace);
context.scope, calleeExpression, expectedType, context.dataFlowInfo, context.inferenceSession, context.trace);
ExpressionReceiver expressionReceiver = ExpressionReceiver.Companion.create(calleeExpression, calleeType, context.trace.getBindingContext());
Call call = new CallTransformer.CallForImplicitInvoke(context.call.getExplicitReceiver(), expressionReceiver, context.call,

View File

@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.resolve.calls
import com.intellij.psi.util.PsiUtil
import org.jetbrains.kotlin.builtins.UnsignedTypes
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
@@ -14,6 +15,7 @@ import org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.INVOKE_ON
import org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.NON_KOTLIN_FUNCTION
import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.isNull
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
@@ -60,6 +62,12 @@ class DiagnosticReporterByTrackingStrategy(
val reportOn = (diagnostic as NonApplicableCallForBuilderInferenceDiagnostic).kotlinCall
trace.reportDiagnosticOnce(Errors.NON_APPLICABLE_CALL_FOR_BUILDER_INFERENCE.on(reportOn.psiKotlinCall.psiCall.callElement))
}
OnlyInputTypesDiagnostic::class.java -> {
val typeVariable = (diagnostic as OnlyInputTypesDiagnostic).typeVariable as? TypeVariableFromCallableDescriptor ?: return
psiKotlinCall.psiCall.calleeExpression?.let {
trace.report(TYPE_INFERENCE_ONLY_INPUT_TYPES.on(it, typeVariable.originalTypeParameter))
}
}
}
}
@@ -128,6 +136,17 @@ class DiagnosticReporterByTrackingStrategy(
trace.report(UNRESOLVED_REFERENCE.on(it.callableReference, it.callableReference))
}
}
ArgumentTypeMismatchDiagnostic::class.java -> {
require(diagnostic is ArgumentTypeMismatchDiagnostic)
reportIfNonNull(callArgument.safeAs<PSIKotlinCallArgument>()?.valueArgument?.getArgumentExpression()) {
if (it.isNull()) {
trace.reportDiagnosticOnce(NULL_FOR_NONNULL_TYPE.on(it, diagnostic.expectedType))
} else {
trace.report(TYPE_MISMATCH.on(it, diagnostic.expectedType, diagnostic.actualType))
}
}
}
}
}
@@ -219,7 +238,7 @@ class DiagnosticReporterByTrackingStrategy(
argument?.let {
it.safeAs<LambdaKotlinCallArgument>()?.let lambda@{ lambda ->
val parameterTypes = lambda.parametersTypes?.toList() ?: return@lambda
val index = parameterTypes.indexOf(constraintError.upperType)
val index = parameterTypes.indexOf(constraintError.upperKotlinType.unwrap())
val lambdaExpression = lambda.psiExpression as? KtLambdaExpression ?: return@lambda
val parameter = lambdaExpression.valueParameters.getOrNull(index) ?: return@lambda
trace.report(Errors.EXPECTED_PARAMETER_TYPE_MISMATCH.on(parameter, constraintError.upperKotlinType.unCapture()))

View File

@@ -31,7 +31,12 @@ object DslScopeViolationCallChecker : CallChecker {
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.DslMarkersSupport)) return
val callImplicitReceivers = resolvedCall.getImplicitReceivers()
for (callImplicitReceiver in callImplicitReceivers) {
val originalReceivers = if (context.languageVersionSettings.supportsFeature(LanguageFeature.NewInference))
callImplicitReceivers.map { it.original }
else
callImplicitReceivers
for (callImplicitReceiver in originalReceivers) {
checkCallImplicitReceiver(callImplicitReceiver, resolvedCall, reportOn, context)
}
}

View File

@@ -6,11 +6,15 @@
package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
import org.jetbrains.kotlin.builtins.isFunctionType
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.types.DeferredType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils
import org.jetbrains.kotlin.types.typeUtil.isNothing
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
object ImplicitNothingAsTypeParameterCallChecker : CallChecker {
private val SPECIAL_FUNCTION_NAMES = ControlStructureTypingUtils.ResolveConstruct.values().map { it.specialFunctionName }.toSet()
@@ -32,16 +36,24 @@ object ImplicitNothingAsTypeParameterCallChecker : CallChecker {
* }
*/
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
if (resolvedCall.candidateDescriptor.name !in SPECIAL_FUNCTION_NAMES && resolvedCall.call.typeArguments.isEmpty()) {
val resultingDescriptor = resolvedCall.resultingDescriptor
val inferredReturnType = resultingDescriptor.returnType
val isBuiltinFunctionalType =
resolvedCall.resultingDescriptor.dispatchReceiverParameter?.value?.type?.isBuiltinFunctionalType == true
if (inferredReturnType is DeferredType || isBuiltinFunctionalType)
return
if (resultingDescriptor.name !in SPECIAL_FUNCTION_NAMES && resolvedCall.call.typeArguments.isEmpty()) {
val lambdasFromArgumentsReturnTypes =
resolvedCall.candidateDescriptor.valueParameters.filter { it.type.isFunctionType }
.map { it.returnType?.arguments?.last()?.type }.toSet()
val unsubstitutedReturnType = resultingDescriptor.original.returnType
val expectedType = context.resolutionContext.expectedType
val hasImplicitNothing = inferredReturnType?.isNothing() == true &&
unsubstitutedReturnType?.isTypeParameter() == true &&
(TypeUtils.noExpectedType(expectedType) || !expectedType.isNothing())
val hasImplicitNothingExceptLambdaReturnTypes = resolvedCall.typeArguments.any { (unsubstitutedType, resultingType) ->
resultingType.isNothing() && unsubstitutedType.defaultType !in lambdasFromArgumentsReturnTypes
}
if (hasImplicitNothingExceptLambdaReturnTypes) {
if (hasImplicitNothing && unsubstitutedReturnType !in lambdasFromArgumentsReturnTypes) {
context.trace.report(Errors.IMPLICIT_NOTHING_AS_TYPE_PARAMETER.on(reportOn))
}
}

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImp
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.tower.*
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
import org.jetbrains.kotlin.types.StubType
import org.jetbrains.kotlin.types.TypeConstructor
@@ -58,6 +59,8 @@ class CoroutineInferenceSession(
override fun addCompletedCallInfo(callInfo: CompletedCallInfo) {
require(callInfo is PSICompletedCallInfo) { "Wrong instance of callInfo: $callInfo" }
if (skipCall(callInfo.callResolutionResult)) return
commonCalls.add(callInfo)
val isApplicableCall =
@@ -71,8 +74,15 @@ class CoroutineInferenceSession(
}
}
override fun writeOnlyStubs(): Boolean {
return true
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean {
return !skipCall(callInfo)
}
private fun skipCall(callInfo: SingleCallResolutionResult): Boolean {
// FakeCallableDescriptorForObject can't introduce new information for inference, so it's safe to complete it fully
if (callInfo.resultCallAtom.candidateDescriptor is FakeCallableDescriptorForObject) return true
return false
}
override fun currentConstraintSystem(): ConstraintStorage {
@@ -217,6 +227,8 @@ class CoroutineInferenceSession(
class ComposedSubstitutor(val left: NewTypeSubstitutor, val right: NewTypeSubstitutor) : NewTypeSubstitutor {
override fun substituteNotNullTypeWithConstructor(constructor: TypeConstructor): UnwrappedType? {
return left.safeSubstitute(right.substituteNotNullTypeWithConstructor(constructor) ?: return null)
return left.substituteNotNullTypeWithConstructor(
right.substituteNotNullTypeWithConstructor(constructor)?.constructor ?: constructor
)
}
}

View File

@@ -91,6 +91,7 @@ class KotlinResolutionCallbacksImpl(
receiverType: UnwrappedType?,
parameters: List<UnwrappedType>,
expectedReturnType: UnwrappedType?,
annotations: Annotations,
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
): Pair<List<KotlinCallArgument>, InferenceSession?> {
val psiCallArgument = lambdaArgument.psiCallArgument as PSIFunctionKotlinCallArgument
@@ -130,7 +131,7 @@ class KotlinResolutionCallbacksImpl(
val builtIns = outerCallContext.scope.ownerDescriptor.builtIns
val expectedType = createFunctionType(
builtIns, Annotations.EMPTY, receiverType, parameters, null,
builtIns, annotations, receiverType, parameters, null,
lambdaInfo.expectedType, isSuspend
)
@@ -264,4 +265,10 @@ class KotlinResolutionCallbacksImpl(
trace.record(BindingContext.CAST_TYPE_USED_AS_EXPECTED_TYPE, binaryParent)
return resultType
}
override fun disableContractsIfNecessary(resolvedAtom: ResolvedCallAtom) {
val atom = resolvedAtom.atom as? PSIKotlinCall ?: return
val context = topLevelCallContext ?: return
disableContractsInsideContractsBlock(atom.psiCall, resolvedAtom.candidateDescriptor, context.scope, trace)
}
}

View File

@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
@@ -27,11 +29,15 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionStatelessCallbacks
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
import org.jetbrains.kotlin.resolve.calls.inference.components.SimpleConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.isCoroutineCallWithAdditionalInference
import org.jetbrains.kotlin.resolve.calls.model.CallableReferenceKotlinCallArgument
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallArgument
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinCallArgument
import org.jetbrains.kotlin.resolve.calls.results.SimpleConstraintSystem
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -80,4 +86,13 @@ class KotlinResolutionStatelessCallbacksImpl(
): Boolean {
return org.jetbrains.kotlin.resolve.calls.inference.isApplicableCallForBuilderInference(descriptor, languageVersionSettings)
}
override fun createConstraintSystemForOverloadResolution(
constraintInjector: ConstraintInjector, builtIns: KotlinBuiltIns
): SimpleConstraintSystem {
return if (languageVersionSettings.getFlag(AnalysisFlags.constraintSystemForOverloadResolution).forNewInference())
SimpleConstraintSystemImpl(constraintInjector, builtIns)
else
ConstraintSystemBuilderImpl.forSpecificity()
}
}

View File

@@ -110,7 +110,7 @@ class KotlinToResolvedCallTransformer(
val candidate = (baseResolvedCall as SingleCallResolutionResult).resultCallAtom
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor(typeSystemContext)
if (context.inferenceSession.writeOnlyStubs()) {
if (context.inferenceSession.writeOnlyStubs(baseResolvedCall)) {
val stub = createStubResolvedCallAndWriteItToTrace<CallableDescriptor>(
candidate,
context.trace,

View File

@@ -477,7 +477,7 @@ class PSICallResolver(
variableReceiver,
context.dataFlowInfo.getCollectedTypes(dataFlowValue, context.languageVersionSettings),
dataFlowValue.isStable
)
).prepareReceiverRegardingCaptureTypes()
}
}
@@ -683,10 +683,7 @@ class PSICallResolver(
is DoubleColonLHS.Type -> {
val qualifiedExpression = ktExpression.receiverExpression!!.let { it.referenceExpression() ?: it }
val qualifier = expressionTypingContext.trace.get(BindingContext.QUALIFIER, qualifiedExpression)
when (qualifier) {
is ClassQualifier, is TypeAliasQualifier -> LHSResult.Type(qualifier, lhsResult.type.unwrap())
else -> LHSResult.Error
}
LHSResult.Type(qualifier, lhsResult.type.unwrap())
}
}

View File

@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
import org.jetbrains.kotlin.types.typeUtil.isUnit
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -128,7 +129,7 @@ class ResolvedAtomCompleter(
val substitutedTypes = returnTypes.filterNotNull()
// we have some unsubstituted types
if (substitutedTypes.isEmpty()) return false
val commonReturnType = CommonSupertypes.commonSupertype(returnTypes)
val commonReturnType = CommonSupertypes.commonSupertype(substitutedTypes)
return commonReturnType.isUnit()
}
@@ -191,8 +192,8 @@ class ResolvedAtomCompleter(
val substitutedFunctionalType = createFunctionType(
builtIns,
existingLambdaType.annotations,
lambda.receiver?.let { resultSubstitutor.substituteKeepAnnotations(it) },
lambda.parameters.map { resultSubstitutor.substituteKeepAnnotations(it) },
lambda.receiver?.let { resultSubstitutor.safeSubstitute(it) },
lambda.parameters.map { resultSubstitutor.safeSubstitute(it) },
null, // parameter names transforms to special annotations, so they are already taken from parameter types
returnType,
lambda.isSuspend
@@ -208,7 +209,7 @@ class ResolvedAtomCompleter(
}
val valueType = receiver.value.type.unwrap()
val newValueType = resultSubstitutor.substituteKeepAnnotations(valueType)
val newValueType = resultSubstitutor.safeSubstitute(valueType)
if (valueType !== newValueType) {
val newReceiverValue = receiver.value.replaceType(newValueType)
@@ -288,7 +289,8 @@ class ResolvedAtomCompleter(
}
// TODO: probably we should also record key 'DATA_FLOW_INFO_BEFORE', see ExpressionTypingVisitorDispatcher.getTypeInfo
topLevelTrace.recordType(callableReferenceExpression, resultType)
val typeInfo = createTypeInfo(resultType, resolvedAtom.atom.psiCallArgument.dataFlowInfoAfterThisArgument)
topLevelTrace.record(BindingContext.EXPRESSION_TYPE_INFO, callableReferenceExpression, typeInfo)
topLevelTrace.record(BindingContext.PROCESSED, callableReferenceExpression)
doubleColonExpressionResolver.checkReferenceIsToAllowedMember(

View File

@@ -181,7 +181,9 @@ class InlineAnalyzerExtension(
}
if (hasInlineArgs) return
if (functionDescriptor.isInlineOnlyOrReifiable() || functionDescriptor.isExpect || functionDescriptor.isSuspend) return
if (functionDescriptor.isInlineWithReified() || functionDescriptor.isInlineOnly() || functionDescriptor.isExpect ||
functionDescriptor.isSuspend
) return
if (reasonableInlineRules.any { it.isInlineReasonable(functionDescriptor, function, trace.bindingContext) }) return

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -14,17 +14,30 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
private val INLINE_ONLY_ANNOTATION_FQ_NAME = FqName("kotlin.internal.InlineOnly")
fun MemberDescriptor.isInlineOnlyOrReifiable(): Boolean =
this is CallableMemberDescriptor && (isReifiable() || DescriptorUtils.getDirectMember(this).isReifiable() || isInlineOnly())
/**
* @return true if it's impossible to observe a call instruction referencing this member in the bytecode.
*/
fun MemberDescriptor.isEffectivelyInlineOnly(): Boolean =
isInlineOnlyOrReifiable() || (this is FunctionDescriptor && isSuspend && isInline &&
(valueParameters.any { it.isCrossinline } || visibility == Visibilities.PRIVATE))
isInlineWithReified() || isInlineOnlyPrivateInBytecode()
/**
* @return true if this member should be private in bytecode because it's effectively inline-only.
*/
fun MemberDescriptor.isInlineOnlyPrivateInBytecode(): Boolean =
isInlineOnly() || isPrivateInlineSuspend()
fun MemberDescriptor.isInlineOnly(): Boolean =
this is FunctionDescriptor && isInline &&
(hasInlineOnlyAnnotation() || DescriptorUtils.getDirectMember(this).hasInlineOnlyAnnotation())
private fun CallableMemberDescriptor.isReifiable() = typeParameters.any { it.isReified }
private fun MemberDescriptor.isPrivateInlineSuspend(): Boolean =
this is FunctionDescriptor && isSuspend && isInline && visibility == Visibilities.PRIVATE
private fun CallableMemberDescriptor.hasInlineOnlyAnnotation() = annotations.hasAnnotation(INLINE_ONLY_ANNOTATION_FQ_NAME)
fun MemberDescriptor.isInlineWithReified(): Boolean =
this is CallableMemberDescriptor && (hasReifiedParameters() || DescriptorUtils.getDirectMember(this).hasReifiedParameters())
private fun CallableMemberDescriptor.hasReifiedParameters(): Boolean =
typeParameters.any { it.isReified }
private fun CallableMemberDescriptor.hasInlineOnlyAnnotation(): Boolean =
annotations.hasAnnotation(INLINE_ONLY_ANNOTATION_FQ_NAME)

View File

@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext
import org.jetbrains.kotlin.resolve.lazy.declarations.AbstractPsiBasedDeclarationProvider
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider
@@ -129,7 +130,8 @@ protected constructor(
getScopeForInitializerResolution(propertyDeclaration),
propertyDeclaration,
trace,
c.declarationScopeProvider.getOuterDataFlowInfoForDeclaration(propertyDeclaration)
c.declarationScopeProvider.getOuterDataFlowInfoForDeclaration(propertyDeclaration),
InferenceSession.default
)
result.add(propertyDescriptor)
}
@@ -141,7 +143,8 @@ protected constructor(
getScopeForInitializerResolution(entry),
entry,
trace,
c.declarationScopeProvider.getOuterDataFlowInfoForDeclaration(entry)
c.declarationScopeProvider.getOuterDataFlowInfoForDeclaration(entry),
InferenceSession.default
)
result.add(propertyDescriptor)
}

View File

@@ -1717,15 +1717,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
context, call, arrayAccessExpression, isGet ? OperatorNameConventions.GET : OperatorNameConventions.SET);
List<KtExpression> indices = arrayAccessExpression.getIndexExpressions();
// The accumulated data flow info of all index expressions is saved on the last index
KotlinTypeInfo resultTypeInfo = arrayTypeInfo;
if (!indices.isEmpty()) {
resultTypeInfo = facade.getTypeInfo(indices.get(indices.size() - 1), context);
}
if (!isGet) {
resultTypeInfo = facade.getTypeInfo(rightHandSide, context);
}
KotlinTypeInfo resultTypeInfo =
computeAccumulatedInfoForArrayAccessExpression(arrayTypeInfo, indices, rightHandSide, isGet, context, facade);
if ((isImplicit && !functionResults.isSuccess()) || !functionResults.isSingleResult()) {
traceForResolveResult.report(isGet ? NO_GET_METHOD.on(arrayAccessExpression) : NO_SET_METHOD.on(arrayAccessExpression));
@@ -1735,4 +1729,40 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
functionResults.getResultingCall());
return resultTypeInfo.replaceType(functionResults.getResultingDescriptor().getReturnType());
}
private static KotlinTypeInfo computeAccumulatedInfoForArrayAccessExpression(
@NotNull KotlinTypeInfo arrayTypeInfo,
@NotNull List<KtExpression> indices,
@Nullable KtExpression rightHandSide,
boolean isGet,
@NotNull ExpressionTypingContext context,
@NotNull ExpressionTypingInternals facade
) {
KotlinTypeInfo accumulatedTypeInfo = null;
boolean forceResolve = !context.languageVersionSettings.supportsFeature(LanguageFeature.NewInference);
// The accumulated data flow info of all index expressions is saved on the last index
if (!indices.isEmpty()) {
accumulatedTypeInfo = getTypeInfo(indices.get(indices.size() - 1), facade, context, forceResolve);
}
if (!isGet && rightHandSide != null) {
accumulatedTypeInfo = getTypeInfo(rightHandSide, facade, context, forceResolve);
}
return accumulatedTypeInfo != null ? accumulatedTypeInfo : arrayTypeInfo;
}
private static KotlinTypeInfo getTypeInfo(
@NotNull KtExpression expression,
@NotNull ExpressionTypingInternals facade,
@NotNull ExpressionTypingContext context,
boolean forceExpressionResolve
) {
if (forceExpressionResolve) {
return facade.getTypeInfo(expression, context);
} else {
return BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext());
}
}
}

View File

@@ -123,24 +123,30 @@ public class ControlStructureTypingUtils {
/*package*/ ResolvedCall<FunctionDescriptor> resolveTryAsCall(
@NotNull Call call,
@NotNull KtTryExpression tryExpression,
@NotNull List<Pair<KtExpression, VariableDescriptor>> catchedExceptions,
@NotNull ExpressionTypingContext context,
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
) {
List<String> argumentNames = Lists.newArrayList("tryBlock");
List<Boolean> argumentsNullability = Lists.newArrayList(false);
for (int i = 0; i < tryExpression.getCatchClauses().size(); i++) {
argumentNames.add("catchBlock" + i);
argumentsNullability.add(false);
}
SimpleFunctionDescriptorImpl function =
createFunctionDescriptorForSpecialConstruction(ResolveConstruct.TRY, argumentNames, argumentsNullability);
int counter = 0;
for (Pair<KtExpression, VariableDescriptor> descriptorPair : catchedExceptions) {
// catchedExceptions are corresponding to PSI arguments that were used to create a call
// therefore, it's important to use only them to have consistent parameters
argumentNames.add("catchBlock" + counter);
argumentsNullability.add(false);
KtExpression catchBlock = descriptorPair.getFirst();
VariableDescriptor catchedExceptionDescriptor = descriptorPair.getSecond();
context.trace.record(BindingContext.NEW_INFERENCE_CATCH_EXCEPTION_PARAMETER, catchBlock, Ref.create(catchedExceptionDescriptor));
counter++;
}
SimpleFunctionDescriptorImpl function =
createFunctionDescriptorForSpecialConstruction(ResolveConstruct.TRY, argumentNames, argumentsNullability);
return resolveSpecialConstructionAsCall(call, function, ResolveConstruct.TRY, context, dataFlowInfoForArguments);
}

View File

@@ -611,7 +611,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
dataFlowInfoForArguments = createDataFlowInfoForArgumentsOfTryCall(callForTry, dataFlowInfoBeforeTry, dataFlowInfoBeforeTry);
}
ResolvedCall<FunctionDescriptor> resolvedCall = components.controlStructureTypingUtils
.resolveTryAsCall(callForTry, tryExpression, catchClausesBlocksAndParameters, tryInputContext, dataFlowInfoForArguments);
.resolveTryAsCall(callForTry, catchClausesBlocksAndParameters, tryInputContext, dataFlowInfoForArguments);
KotlinType resultType = resolvedCall.getResultingDescriptor().getReturnType();
BindingContext bindingContext = tryInputContext.trace.getBindingContext();

View File

@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession;
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency;
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
@@ -71,9 +72,10 @@ public class ExpressionTypingServices {
@NotNull KtExpression expression,
@NotNull KotlinType expectedType,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession,
@NotNull BindingTrace trace
) {
KotlinType type = getType(scope, expression, expectedType, dataFlowInfo, trace);
KotlinType type = getType(scope, expression, expectedType, dataFlowInfo, inferenceSession, trace);
return type != null ? type : ErrorUtils.createErrorType("Type for " + expression.getText());
}
@@ -84,10 +86,14 @@ public class ExpressionTypingServices {
@NotNull KtExpression expression,
@NotNull KotlinType expectedType,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession,
@NotNull BindingTrace trace,
boolean isStatement
) {
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace, isStatement, expression, ContextDependency.INDEPENDENT);
return getTypeInfo(
scope, expression, expectedType, dataFlowInfo, inferenceSession,
trace, isStatement, expression, ContextDependency.INDEPENDENT
);
}
@NotNull
@@ -96,6 +102,7 @@ public class ExpressionTypingServices {
@NotNull KtExpression expression,
@NotNull KotlinType expectedType,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession,
@NotNull BindingTrace trace,
boolean isStatement,
@NotNull KtExpression contextExpression,
@@ -103,7 +110,7 @@ public class ExpressionTypingServices {
) {
ExpressionTypingContext context = ExpressionTypingContext.newContext(
trace, scope, dataFlowInfo, expectedType, contextDependency, statementFilter, getLanguageVersionSettings(),
expressionTypingComponents.dataFlowValueFactory
expressionTypingComponents.dataFlowValueFactory, inferenceSession
);
if (contextExpression != expression) {
context = context.replaceExpressionContextProvider(arg -> arg == expression ? contextExpression : null);
@@ -122,9 +129,10 @@ public class ExpressionTypingServices {
@NotNull KtExpression expression,
@NotNull KotlinType expectedType,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull InferenceSession inferenceSession,
@NotNull BindingTrace trace
) {
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace, false).getType();
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, inferenceSession, trace, false).getType();
}
/////////////////////////////////////////////////////////

View File

@@ -2014,6 +2014,11 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
runTest("jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/");
}
@TestMetadata("multifilePartsWithProperties")
public void testMultifilePartsWithProperties() throws Exception {
runTest("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/");
}
@TestMetadata("optionalParameter")
public void testOptionalParameter() throws Exception {
runTest("jps-plugin/testData/incremental/withJava/other/optionalParameter/");
@@ -2322,6 +2327,19 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
}
}
@TestMetadata("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MultifilePartsWithProperties extends AbstractIncrementalJvmCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInMultifilePartsWithProperties() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
}
@TestMetadata("jps-plugin/testData/incremental/withJava/other/optionalParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -342,6 +342,35 @@ open class WrappedVariableDescriptor(
}
}
open class WrappedVariableDescriptorWithAccessor() : VariableDescriptorWithAccessors, WrappedCallableDescriptor<IrLocalDelegatedProperty>(Annotations.EMPTY, SourceElement.NO_SOURCE) {
override fun getName(): Name = owner.name
override fun substitute(substitutor: TypeSubstitutor): VariableDescriptor {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun isVar() = owner.isVar
override fun getCompileTimeInitializer(): ConstantValue<*>? {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getType(): KotlinType = owner.type.toKotlinType()
override fun isConst(): Boolean = false
override fun getContainingDeclaration() = (owner.parent as IrFunction).descriptor
override fun isLateInit(): Boolean = false
override val getter: VariableAccessorDescriptor?
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override val setter: VariableAccessorDescriptor?
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override val isDelegated: Boolean = true
}
open class WrappedSimpleFunctionDescriptor(
annotations: Annotations = Annotations.EMPTY,
sourceElement: SourceElement = SourceElement.NO_SOURCE

View File

@@ -33,7 +33,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
protected abstract val stateMachineMethodName: Name
protected abstract fun getCoroutineBaseClass(function: IrFunction): IrClassSymbol
protected abstract fun nameForCoroutineClass(function: IrFunction): Name
protected abstract fun buildStateMachine(
originalBody: IrBody, stateMachineFunction: IrFunction,
@@ -258,8 +258,6 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
val stateMachineFunction: IrFunction
)
private var coroutineId = 0
private inner class CoroutineBuilder(val irFunction: IrFunction, val functionReference: IrFunctionReference?) {
private val startOffset = irFunction.startOffset
@@ -273,7 +271,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
startOffset, endOffset,
DECLARATION_ORIGIN_COROUTINE_IMPL,
IrClassSymbolImpl(d),
"${irFunction.name}COROUTINE\$${coroutineId++}".synthesizedName,
nameForCoroutineClass(irFunction),
ClassKind.CLASS,
irFunction.visibility,
Modality.FINAL,

View File

@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.ir.backend.js.lower.coroutines
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.common.ir.isSuspend
import org.jetbrains.kotlin.backend.common.lower.AbstractSuspendFunctionsLowering
import org.jetbrains.kotlin.ir.IrElement
@@ -34,10 +35,13 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
private val coroutineImplResultSymbolSetter = ctx.coroutineImplResultSymbolSetter
private var exceptionTrapId = -1
private var coroutineId = 0
override val stateMachineMethodName = Name.identifier("doResume")
override fun getCoroutineBaseClass(function: IrFunction) = context.ir.symbols.coroutineImpl
override fun nameForCoroutineClass(function: IrFunction) = "${function.name}COROUTINE\$${coroutineId++}".synthesizedName
override fun buildStateMachine(
originalBody: IrBody,
stateMachineFunction: IrFunction,

View File

@@ -444,7 +444,7 @@ class StateMachineBuilder(
private fun transformArguments(arguments: Array<IrExpression?>): Array<IrExpression?> {
var suspendableCount = arguments.fold(0) { r, n -> if (n in suspendableNodes) r + 1 else r }
var suspendableCount = arguments.fold(0) { r, n -> if (n != null && n in suspendableNodes) r + 1 else r }
val newArguments = arrayOfNulls<IrExpression>(arguments.size)

View File

@@ -359,11 +359,8 @@ private val Modality.flags: Int
private val Visibility.flags: Int
get() = AsmUtil.getVisibilityAccessFlag(this) ?: throw AssertionError("Unsupported visibility $this")
private val IrField.OtherOrigin: JvmDeclarationOrigin
get() = OtherOrigin(descriptor.psiElement, this.descriptor)
internal val IrFunction.OtherOrigin: JvmDeclarationOrigin
get() = OtherOrigin(descriptor.psiElement, this.descriptor)
internal val IrDeclaration.OtherOrigin: JvmDeclarationOrigin
get() = OtherOrigin(descriptor)
private fun IrClass.getSuperClassInfo(typeMapper: IrTypeMapper): IrSuperClassInfo {
if (isInterface) {
@@ -378,4 +375,4 @@ private fun IrClass.getSuperClassInfo(typeMapper: IrTypeMapper): IrSuperClassInf
}
return IrSuperClassInfo(AsmTypes.OBJECT_TYPE, null)
}
}

View File

@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.backend.jvm.codegen
@@ -66,7 +55,7 @@ class IrSourceCompilerForInline(
get() = OwnerKind.getMemberOwnerKind(callElement.descriptor.containingDeclaration)
override val inlineCallSiteInfo: InlineCallSiteInfo
get() = InlineCallSiteInfo("TODO", null, null, false)
get() = InlineCallSiteInfo("TODO", null, null, false, false)
override val lazySourceMapper: DefaultSourceMapper
get() = codegen.classCodegen.getOrCreateSourceMapper()

View File

@@ -157,7 +157,11 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
private fun generateRetentionAnnotation(irClass: IrClass) {
if (irClass.hasAnnotation(FqName("java.lang.annotation.Retention"))) return
val kotlinRetentionPolicy = irClass.getAnnotation(FqName("kotlin.annotation.Retention"))
val javaRetentionPolicy = annotationRetentionMap[kotlinRetentionPolicy] ?: rpRuntime
val javaRetentionPolicy = if (kotlinRetentionPolicy is KotlinRetention) {
annotationRetentionMap[kotlinRetentionPolicy] ?: rpRuntime
} else {
rpRuntime
}
irClass.annotations.add(
IrConstructorCallImpl.fromSymbolOwner(

View File

@@ -61,7 +61,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
get() = context.state.typeMapper.mapSignatureSkipGeneric(collectRealOverrides().first().descriptor).toString()
private val IrMemberAccessExpression.signature: String
get() = localPropertyIndices[getter]?.let { "<v#$it>" }
get() = getter?.let { getter -> localPropertyIndices[getter]?.let { "<v#$it>" } }
?: (getter?.owner as? IrSimpleFunction)?.signature
// Plain Java fields do not have a getter, but can be referenced nonetheless. The signature should be
// the one that a getter would have, if it existed.

View File

@@ -128,6 +128,7 @@ enum IrSymbolKind {
STANDALONE_FIELD_SYMBOL = 11; // For fields without properties. WrappedFieldDescriptor, rather than WrappedPropertyDescriptor.
RECEIVER_PARAMETER_SYMBOL = 12; // ReceiverParameterDescriptor rather than ValueParameterDescriptor.
PROPERTY_SYMBOL = 13;
LOCAL_DELEGATED_PROPERTY_SYMBOL = 14;
}
message IrSymbolData {

View File

@@ -44,7 +44,8 @@ abstract class DeclarationTable(val builtIns: IrBuiltIns, val descriptorTable: D
|| value is IrVariable
|| (value is IrTypeParameter && value.parent !is IrClass)
|| value is IrValueParameter
|| value is IrAnonymousInitializerImpl
|| value is IrAnonymousInitializer
|| value is IrLocalDelegatedProperty
) {
UniqId(currentIndex++, true)
} else {

View File

@@ -1321,6 +1321,7 @@ abstract class IrModuleDeserializer(
is IrProperty -> (descriptor as WrappedPropertyDescriptor).bind(declaration)
is IrEnumEntry -> (descriptor as WrappedEnumEntryDescriptor).bind(declaration)
is IrSimpleFunction -> (descriptor as WrappedSimpleFunctionDescriptor).bind(declaration)
is IrLocalDelegatedProperty -> (descriptor as WrappedVariableDescriptorWithAccessor).bind(declaration)
}
}
logger.log { "### Deserialized declaration: ${descriptor} -> ${ir2string(declaration)}" }

View File

@@ -122,6 +122,8 @@ open class IrModuleSerializer(
KotlinIr.IrSymbolKind.FIELD_SYMBOL
is IrPropertySymbol ->
KotlinIr.IrSymbolKind.PROPERTY_SYMBOL
is IrLocalDelegatedPropertySymbol ->
KotlinIr.IrSymbolKind.LOCAL_DELEGATED_PROPERTY_SYMBOL
else ->
TODO("Unexpected symbol kind: $symbol")
}

View File

@@ -363,6 +363,10 @@ public final class KotlinIr {
* <code>PROPERTY_SYMBOL = 13;</code>
*/
PROPERTY_SYMBOL(12, 13),
/**
* <code>LOCAL_DELEGATED_PROPERTY_SYMBOL = 14;</code>
*/
LOCAL_DELEGATED_PROPERTY_SYMBOL(13, 14),
;
/**
@@ -425,6 +429,10 @@ public final class KotlinIr {
* <code>PROPERTY_SYMBOL = 13;</code>
*/
public static final int PROPERTY_SYMBOL_VALUE = 13;
/**
* <code>LOCAL_DELEGATED_PROPERTY_SYMBOL = 14;</code>
*/
public static final int LOCAL_DELEGATED_PROPERTY_SYMBOL_VALUE = 14;
public final int getNumber() { return value; }
@@ -444,6 +452,7 @@ public final class KotlinIr {
case 11: return STANDALONE_FIELD_SYMBOL;
case 12: return RECEIVER_PARAMETER_SYMBOL;
case 13: return PROPERTY_SYMBOL;
case 14: return LOCAL_DELEGATED_PROPERTY_SYMBOL;
default: return null;
}
}
@@ -1029,7 +1038,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -2353,7 +2362,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -2799,7 +2808,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -3236,7 +3245,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -3640,7 +3649,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -4053,7 +4062,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -4596,7 +4605,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -5097,7 +5106,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -5689,7 +5698,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -6792,7 +6801,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -7759,7 +7768,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -8129,7 +8138,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -8609,7 +8618,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -9455,7 +9464,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -9820,7 +9829,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -10313,7 +10322,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -10806,7 +10815,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -11294,7 +11303,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -11655,7 +11664,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -12155,7 +12164,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -12751,7 +12760,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -13561,7 +13570,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -13965,7 +13974,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -14387,7 +14396,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -15090,7 +15099,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -15578,7 +15587,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -15947,7 +15956,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -16438,7 +16447,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -17078,7 +17087,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -17960,7 +17969,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -18889,7 +18898,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -19509,7 +19518,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -20187,7 +20196,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -21108,7 +21117,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -22115,7 +22124,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -22732,7 +22741,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -23338,7 +23347,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -24485,7 +24494,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -24971,7 +24980,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -25496,7 +25505,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -25909,7 +25918,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -26434,7 +26443,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -26838,7 +26847,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -27260,7 +27269,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -27907,7 +27916,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -28437,7 +28446,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -28958,7 +28967,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -29362,7 +29371,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -29802,7 +29811,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -30643,7 +30652,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -31186,7 +31195,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -31846,7 +31855,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -32497,7 +32506,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -33027,7 +33036,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -33515,7 +33524,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -33942,7 +33951,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -34689,7 +34698,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -35315,7 +35324,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -35936,7 +35945,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -36526,7 +36535,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -37134,7 +37143,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -37547,7 +37556,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -38095,7 +38104,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -39386,7 +39395,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -43645,7 +43654,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -44291,7 +44300,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -44685,7 +44694,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -45029,7 +45038,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -46157,7 +46166,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -47655,7 +47664,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -48320,7 +48329,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -49489,7 +49498,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -50666,7 +50675,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -52189,7 +52198,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -53246,7 +53255,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -54407,7 +54416,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -55386,7 +55395,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -56004,7 +56013,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -57827,7 +57836,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -58595,7 +58604,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -59224,7 +59233,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -61040,7 +61049,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -61816,7 +61825,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -62346,7 +62355,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -62843,7 +62852,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -63368,7 +63377,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -63796,7 +63805,7 @@ public final class KotlinIr {
org.jetbrains.kotlin.protobuf.ByteString.newOutput();
org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput =
org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance(
unknownFieldsOutput);
unknownFieldsOutput, 1);
try {
boolean done = false;
while (!done) {
@@ -64943,4 +64952,4 @@ public final class KotlinIr {
}
// @@protoc_insertion_point(outer_class_scope)
}
}

View File

@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrLoopBase
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.*
import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IrDeserializer
@@ -129,6 +126,8 @@ abstract class KotlinIrLinker(
symbolTable.referenceProperty(
descriptor as PropertyDescriptor? ?: WrappedPropertyDescriptor()
)
KotlinIr.IrSymbolKind.LOCAL_DELEGATED_PROPERTY_SYMBOL ->
IrLocalDelegatedPropertySymbolImpl(descriptor as? VariableDescriptorWithAccessors ?: WrappedVariableDescriptorWithAccessor())
else -> TODO("Unexpected classifier symbol kind: ${proto.kind}")
}

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