Commit Graph

98410 Commits

Author SHA1 Message Date
Zalim Bashorov f3e022e4ca [Wasm] Print an instruction if CompileError was thrown while instantiating a module
#KT-56160 Fixed
2023-02-03 14:06:32 +01:00
Alexander Korepanov 9324cf3360 [JS IR] Support function type interfaces in incremental cache infrastructure
The patch removes logic of generating extra IrFiles (fake file) into
 IrModuleFragment for the function type interfaces during klib deserialization,
 because IC infrastructure can not process files which do not exist in klib.

 Instead of adding extra IrFiles during deserialization, the empty files
 with required packages are added into Kotlin/JS stdlib physically.
 These files are used as containers for function type interface declarations.

 Since Kotlin/WASM uses the same klib loading infrastructure as Kotlin/JS,
 the the empty files are added into Kotlin/WASM stdlib as well.

 The patch also adds a check that IrModuleFagment has files only from klib.

^KT-55720 Fixed
2023-02-03 12:23:48 +00:00
Marco Pennekamp 1c3c5417ad [JVM IR] KTIJ-24335 Fix stub generation of symbols without descriptors
- Symbols without a descriptor (e.g. `IrClassPublicSymbolImpl`) were
  causing exceptions in `DeclarationStubGenerator` after recent changes,
  because their property `irClassSymbol.descriptor` doesn't necessarily
  exist without the symbol having an owner bound to it first.
- `DeclarationStubGenerator` now falls back to its `descriptor` argument
  if `irClassSymbol` doesn't have a descriptor.
2023-02-03 12:23:11 +00:00
Marco Pennekamp e7bf4da796 [JVM IR] KTIJ-24335 Require stubbing for built-in symbol deduplication
- Built-in symbol deduplication has only been tested with stubbing
  enabled. Because there is no current use case for deduplication
  without stubbing, an exception will be thrown to communicate the
  misconfiguration.
2023-02-03 12:23:10 +00:00
Marco Pennekamp d1df6391db [JVM IR] KTIJ-24335 Fix stub generation of deduplicated built-ins
- Some built-in symbols like `OptIn` haven't been created yet by the
  time `irBuiltIns` is bound to `SymbolTableWithBuiltInsDeduplication`.
  This caused an issue where `DeclarationStubGenerator` would get the
  built-in symbol from `referenceClass`, but still stub for the original
  duplicate `descriptor` and its associated own symbol. Because
  `generateClassStub` would check `referenceClass.isBound` for the
  built-in symbol, `isBound` was never checked for the duplicate symbol
  and thus a "symbol already bound" exception occurred if
  `generateClassStub` was invoked twice for a duplicate `descriptor`.
- The solution takes the descriptor from the `IrClassSymbol` returned
  by `referenceClass`.
2023-02-03 12:23:10 +00:00
Marco Pennekamp f11ea92601 [JVM IR] KTIJ-24335 Deduplicate class symbols of duplicate built-ins
- When the IR backend is invoked from the bytecode tool window,
  multiple descriptors may exist of the same built-in. For example,
  there may be multiple descriptors for `Boolean`.
- This caused issues when the `IrClassifierSymbol` of a type was used
  as a key for some built-ins map (such as `primitiveRefProviders` in
  `JvmSharedVariablesManager`). Because while the reference map is
  built from predeclared built-ins, with duplicate descriptors,
  multiple `IrClassifierSymbol`s may exist for the same type. Such a
  duplicated symbol would lead to an exception.
- The solution invents a special symbol table which de-duplicates
  built-ins at the point where `IrClassSymbol`s are created.

I tried other approaches:

- It's possible to fix the symptoms in `JvmSharedVariablesManager` and
  `JvmSymbols` by turning the keys of the requisite maps, i.e.
  `primitiveRefProviders` and `arraysCopyOfFunctions`, from
  `IrClassifierSymbol` to something like a `Name` or `PrimitiveType`.
  This however touches the IR backend beyond the IDE and still leaves
  error potential for all the other possibly duplicated built-ins.
- I tried to handle built-ins in `DeclarationStubGenerator` specially,
  to circumvent the issue of duplicated descriptors, but this is not a
  solution because the duplicated `IrClassSymbol`s will already be part
  of the IR at that point.

^KTIJ-24335 fixed
2023-02-03 12:23:09 +00:00
Marco Pennekamp ba2e716682 [JVM IR] KTIJ-24206 Stub getters/setters of orphaned expect properties
- Property getters and setters are not marked as `isExpect` even if the
  corresponding property is. This commit fixes the generation of actual
  stubs for such functions.
2023-02-03 12:23:09 +00:00
Marco Pennekamp c9461a3827 [JVM IR] KTIJ-24206 Add an option to stub orphaned expect symbols
- The cause for KTIJ-24206 is that the `expect` function's parent is an
  `IrFile` instead of an `IrClass`. This is because
  `ExpectDeclarationsRemoveLowering` removes `expect` declarations
  before `FileClassLowering` can replace `IrFile` parents.
- That behavior is normally okay, but breaks down when an `expect`
  declaration has no associated `actual` declaration. In such cases,
  `ExpectDeclarationsRemoveLowering` doesn't replace `expect` symbols in
  expressions with their corresponding `actual` symbols, as it normally
  would.
- The solution fills in `ExpectDeclarationsRemoveLowering`'s behavior
  by replacing `expect` symbols for which no `actual` symbols exist with
  stubs. See `stubOrphanedExpectSymbols`.
- To not mess with the lowerings, `stubOrphanedExpectSymbols` is invoked
  during IR generation. It uses the same `ExpectSymbolTransformer`
  as `ExpectDeclarationRemover`.

^KTIJ-24206 fixed
2023-02-03 12:23:09 +00:00
Egor Kulikov 8b1e508740 [FIR] Make check for dangling modifier lists use stubs
Seventh step for ^KT-52615

Merge-request: KT-MR-8651
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-02-03 12:21:58 +00:00
Alexander.Likhachev 0da23d4b9c [Gradle, JS] Remove Gradle version requirements for testJsBothModeWithTests 2023-02-03 11:53:03 +00:00
Alexander.Likhachev 6ab64e0f7c [Gradle, JS] Migrate KotlinWebpack output files configuration to lazy API
#KT-56357 Fixed
2023-02-03 11:53:03 +00:00
Alexander.Likhachev ecc1475cb9 [Gradle, JS] Acquire libsDirectory outside task configuration context
#KT-56357 In Progress
2023-02-03 11:53:03 +00:00
Igor Chevdar 32ce254001 [K/N] Added a filecheck test on suspend lambdas tail calls 2023-02-03 11:14:54 +00:00
Igor Chevdar 707fbe7a6c [K/N] Follow-up for the fix for #KT-55869 2023-02-03 11:14:54 +00:00
Igor Chevdar c871ccc4dd [K/N][IR] Turned off partial tail call optimization
It is difficult to implement properly tail calls for a real coroutine (when there
are other non tail calls), because of continuation interception semantics. And the
benefits aren't clear at this point, so let's turn it off for now.
2023-02-03 11:14:53 +00:00
Igor Chevdar 716853dd00 [K/N][IR] Tail call optimization for suspend lambdas 2023-02-03 11:14:53 +00:00
Marco Pennekamp 5790a32436 [AA] Remove duplicate withValidityAssertion calls 2023-02-03 10:24:05 +00:00
Alexander Korepanov 3a42b9846e [JS IR] Test the incremental rebuild after an error from JS IR BE
Move JS IR BE IC integration tests in a separate file

 Test case for KT-56282
2023-02-03 10:04:43 +00:00
nataliya.valtman 8cfe234140 KT-56352 Add metric filter for build scan
#KT-56352 Fixed
2023-02-03 09:56:27 +00:00
Yan Zhulanow e8570826e6 [LL API] Replace 'FirScript.containingFileSymbol' with 'FirProvider' API 2023-02-03 08:59:37 +00:00
Yan Zhulanow f352f7d5ba [LL API] Recognize scripts in Analysis API
Although the proper support for script resolution is yet to arrive
in K2, some initial steps are required to make LL API understand
such a concept.
2023-02-03 08:59:37 +00:00
Nikolay Lunyak 603b46e531 [FIR] KT-55503: Prefer members-extensions over @HidesMembers extensions
Passing `EXTENSION_RECEIVER` when processing `noReceiver`
looks like a mistake in general. This change is backed
by the `hidesMembers` and
`memberWithHidesMemberAnnotationVsMemberWithout` tests.

The exact reason with `memberWithHidesMemberAnnotationVsMemberWithout`
is that it first checks `@HidesMembers` candidates,
only takes the `kotlin/collections/Iterable<T>.forEach`,
but then yields `InapplicableWrongReceiver`,
because `explicitReceiverKind = EXTENSION_RECEIVER`
(which is strange, because we really don't have an explicit receiver).
Then we visit the same scope once more (now for all candidates)
and take 2 functions:

- `kotlin/collections/Iterable<T>.forEach`
- `kotlin/sequence/Sequence<T>.forEach`

...and they both result in `RESOLVED`,
because this time `explicitReceiverKind = NO_EXPLICIT_RECEIVER`.

This change ensures the first candidate we see
while checking `@HidesMembers` is taken as `RESOLVED`.

^KT-55503 Fixed
2023-02-03 08:26:17 +00:00
Nikolay Lunyak 906b16b41e [FIR] KT-55503: Fix current behavior 2023-02-03 08:26:17 +00:00
Ilya Kirillov 8b286577c7 [Analysis API] do not throw exception when KtCall is improperly resolved
Log the exception instead. This way the analysis of the file will not be stuck after finding an improperly resolved call
2023-02-03 07:06:07 +00:00
Jinseong Jeon 4a872928dd AA standalone: use IJ platform in headless mode 2023-02-03 07:56:37 +01:00
Svyatoslav Kuzmich 2e26b0956e [Wasm] Improve stability of wasm import names across compiler runs
Remove code generation for external fake overrides
Fake overrides are resolved to real declaration on call sites
This also removes generation of unused
"equals", "hashCode" and "toString" methods.
Avoid using hashes of IrType in generated code
because they are unstable

Merge-request: KT-MR-8658
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-03 06:55:59 +00:00
Alexander.Likhachev 35e39e9e10 [Gradle] Ignore non-existent directories in compile task outputs backup
#KT-56047 Fixed
2023-02-02 22:27:38 +00:00
Alexander.Likhachev 3cc69f691e [Gradle] Add test for KT-56047 2023-02-02 22:27:38 +00:00
Svyatoslav Kuzmich 81072ac9b4 [Wasm] Fix parsing D8 CLI arguments in kotlin.test
`@JsFun("code")` is now executed inside a JS function which brings its
`arguments` into the scope shadowing D8's CLI `arguments`.
 Accessing arguments through `globalThis` fixes the problem.

Merge-request: KT-MR-8630
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-02 16:37:32 +00:00
mvicsokolova bc612fa1c6 Atomicfu-plugin (JVM IR): fix visibility of wrapper classes generated for static atomics.
Fixes https://github.com/Kotlin/kotlinx-atomicfu/issues/272
2023-02-02 16:37:06 +00:00
Ilmir Usmanov 901ff06e90 JVM IR: Copy type parameters from class to suspendImpl
These type parameters where used in function parameters,
but since suspendImpl is static function, it has no access
to class type parameters. Solution is to copy them to
the function itself.

 #KT-55125 Fixed
2023-02-02 15:48:10 +00:00
Alexander Udalov 94f1c579df Kapt+JVM_IR: do not generate SuspendFunction supertypes
#KT-54380 Fixed
2023-02-02 15:01:43 +00:00
Sebastian Sellmair 93e92cbf74 [Gradle] Implement KT37051CInteropArtifactTest
^KT-37051 Verification Pending
2023-02-02 13:14:15 +00:00
Sebastian Sellmair 5a14c11ae7 [Gradle] Implement MppCompositeBuildIT for KT-37051 (with cinterop)
^KT-37051 Verification Pending
2023-02-02 13:14:14 +00:00
Sebastian Sellmair 8a62523ffc [Gradle] Streamline how cinterop artifacts are exposed within a Gradle project
Before:
- The cinterop task's output files were added as file dependency
to the declaring target's apiElementsConfiguration
- A 'copy' task was created for the cinterop artifact that was added
to the apiElements configuration as artifact (and therefore also
to the apiElements-published). This copy task placed the
same klib into the 'libs' folder
- Before passing libraries to the compiler the, all files
that are likely to be the result of the 'copy' task (in any libs dir) were
filtered

After:
- The cinterop task's output files are *not* added as file dependency
- The cinterop task's output is added as artifact directly to
the 'apiElements' configuration
- There is no more need for a copy task
- There is no more need for manually filtering the 'libs' artifacts

Tested:
project to project dependencies,
project to project dependencies (with KGP based dependency resolution)
project to repository
project to repository (with KGP based dependency resolution)

^KT-37051 Verification Pending
2023-02-02 13:14:14 +00:00
Artem Kobzar e401c29c26 [K/JS] Add separate test configuration just for the ES6 test ^KTI-1098 Fixed 2023-02-02 11:35:05 +00:00
Nikita Bobko ae661dd11b Fix :kotlin-native:backend.native compilation on CI
This commit fixes:
```
./gradlew :kotlin-native:backend.native:compileCompilerKotlin -PdeployVersion=1.9.0-dev-900
```

`-PdeployVersion=1.9.0-dev-900` is important for reproducibility (it's
not necessarily `1.9.0-dev-900` any version starting with `1.9.0-dev`
will reproduce the problem)
2023-02-02 10:56:20 +01:00
Mikhail Glukhikh 6d642c88f5 FIR2IR: make enum with abstract members from interfaces abstract
Related to KT-55828
2023-02-02 10:53:20 +01:00
Dmitriy Novozhilov 89c42e20c9 [FIR] Consistently use _function_ instead of _functional_ in names of classes and functions 2023-02-02 08:24:52 +00:00
Dmitriy Novozhilov f268ab8858 [FIR plugin prototype] Implement Composable-like extension 2023-02-02 08:24:52 +00:00
Dmitriy Novozhilov 1c8587f82d [FIR] Extract functional type kind from annotation on lambda literal 2023-02-02 08:24:51 +00:00
Dmitriy Novozhilov b48751ec9c [FIR] Add ability to extract functional type kind from annotation on functional literal type 2023-02-02 08:24:51 +00:00
Dmitriy Novozhilov d1b797ed97 [FIR] Generify resolution and inference of arguments of functional types 2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov 67aa80562d [FE] Completely replace FunctionClassKind with FunctionalTypeKind
FunctionalTypeKind can be used in FE 1.0 too, so there is no need to
  keep both classes. Also, removal of FunctionClassKind simplifies work
  with FunctionalTypeKind in common code, like Analysis Api
2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov 87a9103cc6 [FIR] Extract SyntheticFunctionsCache from builtins provider into separate one
This is needed because now set of available synthetic functional interfaces
  depends on session, because each module can contain different plugins,
  which provide different kinds of functional types
2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov e0c8f2354a [FIR] Properly implement FirFunctionalTypeKindService
This implementation takes additional functional type kinds from compiler
  plugins into account
2023-02-02 08:24:49 +00:00
Dmitriy Novozhilov c86495dcae [FIR] Introduce ConeFunctionalTypeKind as a replacement of FunctionClassKind
This is needed to provide an ability to extend different kinds of
  functional types

Also, cleanup and rename utilities related to functional types to avoid
  possible confusions
2023-02-02 08:24:49 +00:00
Dmitriy Novozhilov c98c8d3682 [FIR] Introduce utility searching for classifier symbol by ClassId
There were places which created lookupTag from classId just to call
  `lookupTag.toSymbol(session)`
2023-02-02 08:24:48 +00:00
Dmitriy Novozhilov 125b773205 [FIR] Introduce utility for creating ConeClassLikeLookupTagImpl from ClassId
`classId.toLookupTag()` looks much cleaner than `ConeClassLikeLookupTagImpl(classId)`
2023-02-02 08:24:48 +00:00
Sergey Bogolepov 6c449e29cd [K/N] Add a link for the target deprecation message 2023-02-02 08:24:02 +00:00