Commit Graph

38355 Commits

Author SHA1 Message Date
Ilya Muradyan 7283ea86af [scripting] Fix Kotlin reflection metadata for script constructors 2021-12-02 01:49:58 +03:00
Ian Lynagh 176803689a Add js/js.tests/build as exclusions for CodeConformanceTest
If the "jsCompilerTest"s are run before this, then we get spurious
failures due to e.g. js/js.tests/build/node_modules/mocha/mocha.js
2021-12-02 00:40:02 +03:00
Mikhail Glukhikh f09fc9a473 Optimize FirImportsChecker using lazy evaluation 2021-12-01 23:45:20 +03:00
Tianyu Geng 18f7a760bb FIR checker: report unresolved reference in imports
Compared to FE1.0, instead of using UNRESOLVED_REFERENCE, a new
UNRESOLVED_IMPORT diagnostic is introduced. This is so that we can use a
different positioning strategy to highlight the last part of the import
if the entire import is passed.

Also, this change fixed some incorrectly rejected imports in FIR. Such
cases are covered the newly added test file staticFunAndPropertyImport.kt
2021-12-01 23:45:18 +03:00
Tianyu Geng f51b108821 FIR: fix PsiElementFinderByType
Current implementation would return the input node if the type matches.
This is clear wrong since the method is supposed to return children.
2021-12-01 23:45:17 +03:00
mvicsokolova 93561a1a55 kotlinx.atomicfu compiler plugin for JS_IR backend (#4581)
* kotlinx.atomicfu compiler plugin for JS_IR

Support transformations of atomic operations introduced by the kotlinx.atomicfu library for the JS_IR backend. Compiler plugin is applied externally by the kotlinx.atomicfu gradle plugin.

* Apply compiler plugin for JS platform only

* New plugin test structure

* testGroupOutputDirPrefix changed
2021-12-01 22:33:13 +03:00
Steven Schäfer 05695761ec jvm-abi-gen: Add test to check the declaration order in interface jars 2021-12-01 19:20:47 +01:00
Mads Ager d89680b30d [FIR] Serialize annotations for type parameters properly 2021-12-01 18:25:06 +03:00
Leonid Startsev de128a5406 kotlinx.serialization: Support @Serializable on sealed interfaces.
Interfaces (regular and sealed) are by default polymorphic. To benefit
from sealing (i.e. knowledge of all inheritors in compile-time), @Serializable
annotation may be added on sealed interface, generating the same serializer
that can be used for sealed classes.

Synthetic nested classes are not generated in DEFAULT_IMPLS mode because
it causes problems when adding a synthetic companion to an interface.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1576
2021-12-01 14:14:47 +00:00
Anton Bannykh e6a5614321 [JS IR] don't hash module names 2021-12-01 16:50:30 +03:00
Anton Bannykh e90ad8b53b [JS IR] fix cross-module reference of interface default methods 2021-12-01 16:50:24 +03:00
Anton Bannykh a9b99a8eea [JS TESTS] fix moduleDescriptor dependency configuration
The dependency list doesn't get copied in the `setDependencies` API
which leads to all modules depending on each other.
2021-12-01 16:50:23 +03:00
Anton Bannykh 9c4c798fe7 [JS IR] mute tests with wrong linkage 2021-12-01 16:50:16 +03:00
Sergej Jaskiewicz e13b6b2a90 [JS IR] [runtime] Remove valueOf method from Long
This method was used for coercing `Long` values to JavaScript
`number`. However, it caused issues when `Long` values were
concatenated to a string (see KT-8666, KT-26706).
2021-12-01 12:36:34 +00:00
Dmitry Petrov 52a3713c9c JVM small optimization in temporary vals elimination 2021-12-01 12:13:17 +03:00
Dmitry Petrov f3ca0afd34 JVM run temporary variable elimination before inlining 2021-12-01 12:13:16 +03:00
Dmitry Petrov de3203ee48 JVM KT-49903 prohibit reordering of 'getstatic System.out' 2021-12-01 12:13:13 +03:00
Denis.Zharkov 6082f0b712 FIR2IR: Postpone binding overrides for lazy classes until sources processed 2021-12-01 08:32:20 +00:00
Denis.Zharkov 78ba49ddd8 FIR2IR: Make a component for Fir2IrConverter 2021-12-01 08:32:20 +00:00
Denis.Zharkov 60073239bb FIR2IR: Introduce non-static main conversion method to Fir2IrConverter 2021-12-01 08:32:20 +00:00
Kristoffer Andersen 0dd5ad08f3 [EE-IR] Support inline functions in IR evaluator
Inline functions called by the fragment is detected by the fragment
frontend and the PSI for them is supplied to the compiler backend.

For the purpose of compilation, the inline function is considered as
part of the same source module as the fragment, and then discarded
upon loading the compiled fragment for evaluation.
2021-12-01 00:52:46 +01:00
Kristoffer Andersen 39fee12f32 [IR/FE] BindingContext: Change USED_AS_EXPRESSION to Basic Slice
This commit changes the slice implementation used for
`USED_AS_EXPRESSION`.

Here is the problem as identified and mitigated by this commit:

Slices are key-value maps. They are not total over the domain of keys,
so "looking up" a key not in the slice is a valid operation, yielding
`null`.

A binding context is a collection of slices.

Binding contexts can be stacked as composite binding contexts to
e.g. facilitate scoped analyses. Looking up a key proceeds down the
stack, yielding the first non-null value, or `null` if no slice in the
stack of binding contexts contain that key.

A slice made by `createSimpleSetSlice` models a "set" of keys that can
be enlarged by inclusion: adding `(k, true)` to the slice indicates
`k` belongs to the set. `(k, false)` indicates non-membership.

However, looking up a key _not in_ the slice yields _false_, rather
than null.

Hence, simple set slices do not compose in composite binding traces.

This was encountered porting the expression evaluator to the IR
backend. PSI2IR uses `USED_AS_EXPRESSION` to generate expression body
functions properly. The frontend analysis of the fragment is layered
ontop of the binding context from the editor's analysis of the
underlying project being debugged, which contains speficially the
analysis results of inline functions called from the fragment.
2021-12-01 00:52:46 +01:00
Ilmir Usmanov 8e8a6e6108 Do not count receivers in default parameters mask
If we implement default function with default parameters in inline
class, the receivers will be added to parameter list
(see ac7538a269). But since they
are not present in source parameters, we should not count them when we
compute mask for default parameters.

 #KT-49977 Fixed
2021-11-30 15:09:16 +00:00
Mikhail Glukhikh 7ccd1309e6 FirToConstantValueTransformer: extract lazy dispatchReceiverValue 2021-11-30 18:00:02 +03:00
Mads Ager f220e4a5ed [FIR] Fix a couple of issues in annotation serialization. 2021-11-30 18:00:00 +03:00
Dmitriy Novozhilov f12a010fc8 [Test] Fix file separators in generated spec tests on windows
^KTI-713 Fixed
2021-11-30 17:02:55 +03:00
Hung Nguyen 6ba1b2cc08 KT-45777: Don't include classpath snapshot dir in task output backup
for performance reasons: (1) the snapshots are too big, and (2) they are
usually updated only at the end of the task execution--in a failed task
run, they are usually unchanged and therefore don't need to be restored.
2021-11-30 13:59:19 +03:00
Hung Nguyen 062a8fe56f KT-45777: Ignore Kotlin synthetic classes when computing classpath changes 2021-11-30 13:59:17 +03:00
Hung Nguyen 2b65d673bb KT-45777: Also collect added classes/class members as classpath changes
as they can impact recompilation (examples shown in the code comments).

Test: Updated ClasspathChangesComputerTest
2021-11-30 13:59:17 +03:00
Hung Nguyen 6bee7948e7 KT-45777: Don't compute snapshots for inaccessible classes
Also visit a class file with ASM once to extract all information we need
in advance, instead of visiting the class file each time some piece of
info is needed.
2021-11-30 13:59:14 +03:00
Hung Nguyen f52be5f471 KT-45777: Move classpath diffing to incremental Kotlin compiler (2/2)
as we need access to the lookup tracker to compute classpath changes
more efficiently and reduce the size of the saved classpath snapshot.

The previous commit only changed the files' paths, this
commit actually updates the files' contents.

Note that classpath snapshotting still happens in Gradle artifact
transforms. (However, the previous commit also moved the code for
classpath snapshotting together with the code for classpath diffing as
they are closely related.)
2021-11-30 13:59:13 +03:00
Hung Nguyen dfaf195e1d KT-45777: Move classpath diffing to incremental Kotlin compiler (1/2)
This commit only changes the files' paths, the next commit will update
the files' contents.

See the next commit for more context.
2021-11-30 13:59:12 +03:00
Dmitriy Novozhilov c46e9943cc [FIR] Get rid of FirExtension.key
In reality plugin key was used only in two ways:
- found corresponding generator for member scope of generated class
- pass it to declaration origin so it can be read in backend IR plugin

Because of first usage plugin key was required to be an object, which
  reduces functionality of second usage, because there was no way to
  pass any additional info via key to IR (in future this usecase will be
  covered with IR declaration attributes, but right now we don't have
  them)

So now generator which created some class is now saved in its attributes
  and plugins can use any keys they want. And since there is no other
  usages of `FirExtension.key` it removed from FirExtension API at all
2021-11-30 12:57:53 +03:00
Dmitriy Novozhilov e7af50fe2b [FIR] Allow all extensions register declaration predicates 2021-11-30 12:57:52 +03:00
Dmitriy Novozhilov ce218b8a0b [FIR] Make FirExtensionRegistrar a proper extension point
After that commit it's allowed to register any FIR plugin using
  existing extension infrastructure (`-Xplugin` CLI argument,
  plugin.xml for IDE plugins, etc)
2021-11-30 12:57:50 +03:00
Ilya Muradyan 6917ff7d2a [scripting] Move earlierScripts to the frontend descriptor
^KT-20488 fixed
2021-11-30 09:11:59 +03:00
Mads Ager 09da67767e [JVM_IR] Fix mangling of inline class inherited interface methods.
^KT-49864 Fixed
2021-11-30 03:33:56 +03:00
Sergej Jaskiewicz 887e91328f [JS IR] Allow value classes in external decls
Instances of value classes are passed unboxed, unless the instance is
nullable _and_ the value class wraps another nullable value.

#KT-43224 Fixed
2021-11-29 21:51:29 +00:00
Alexander Udalov 3f47725eb9 Add regression test for coroutines issue KT-49294 2021-11-29 22:09:59 +01:00
Anton Bannykh 5b66c4cdc3 [JS IR] speed up temporary name resolving 2021-11-29 21:09:35 +03:00
Anton Bannykh 2259c6f75d [JS IR IC] assert cross-file tag are not null and fix tests 2021-11-29 21:09:35 +03:00
Anton Bannykh 33cd7e982c [IR] support storing signatures for non-public symbols 2021-11-29 21:09:34 +03:00
Anton Bannykh d74ab1538b [JS IR] fix IC pipeline and unmute tests 2021-11-29 21:09:33 +03:00
Anton Bannykh 3be44a3540 [JS IR] fix missing signature 2021-11-29 21:09:33 +03:00
Anton Bannykh ef4ef8c930 [JS IR] switch to the IC Ir2Js and fix tests 2021-11-29 21:09:31 +03:00
Mikhail Glukhikh cebe25ff39 FE: don't create KtFile stubs on virtual files without ids
This commit is kinda revert of the change in platform 203:
https://github.com/JetBrains/intellij-community/commit/5d91f7bf2e5718d715c0d90ed1a212ea845fb2a3

#KT-49833 Fixed
2021-11-29 18:42:23 +03:00
Mikhail Glukhikh d16b5c8bd8 FE: make error message more precise #KT-49598 Fixed 2021-11-28 11:32:11 +03:00
Mikhail Glukhikh 0290ca07af FE: fix some error messages (filed -> field)
#KT-49600 Fixed
2021-11-28 11:32:10 +03:00
Mikhail Glukhikh 7fe08d5a38 FE: fix some error messages (must have only -> must only have)
#KT-49609 Fixed
2021-11-28 11:32:10 +03:00
Mikhail Glukhikh c15c7f7dc8 FE: fix visibility check in LazyImportScope #KT-23727 Fixed 2021-11-28 11:32:07 +03:00