Commit Graph

373 Commits

Author SHA1 Message Date
Brian Norman 42ebbb937c [FIR] Recursively search dependsOn modules in visibility checks
#KT-59071 Fixed
2023-07-24 14:20:57 +00:00
Mikhail Glukhikh 8c305d6143 K2: introduce infrastructure for LanguageVersionSettings checkers 2023-07-24 12:50:38 +00:00
Roman Efremov b1bdb619d8 [FE] Refactor: provide FirExpectActualMatchingContext as session component
This will be needed in subsequent commits because context must be
accessible from `:fir:checkers` module, but it is in `:fir:resolve`

Intermediate interface `FirExpectActualMatchingContext` is needed
because `FirExpectActualResolver` relies on some FIR-specific methods,
and providing common `ExpectActualMatchingContext` interface is not
enough.

Also in `FirExpectActualMatcherTransformer` context extracted to field
to not create context for each processed element. "session" made
final to calm down warning "accessing non-final property in
constructor".

^KT-58551
2023-07-24 09:48:48 +00:00
Svyatoslav Scherbina ef6dcd9779 Native, K2: add ExperimentalForeignApi to generated forward declarations
cinterop tool should add ExperimentalForeignApi to all generated
declarations, to indicate their experimental status and discourage using
them in public Kotlin API. But the same considerations are applicable
to forward declarations (cnames.*, objcnames.*), which are generated not
by cinterop tool, but directly by the compiler.

This commit adds ExperimentalForeignApi to those compiler-generated
classes.

^KT-58362
2023-07-21 17:44:09 +00:00
Alexander Korepanov 08d158f901 [JS FIR] Support JS module system FE diagnostics
Support CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM diagnostic
^KT-59377 Fixed

Support CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM diagnostic
^KT-59381 Fixed

Support CALL_FROM_UMD_MUST_BE_JS_MODULE_AND_JS_NON_MODULE diagnostic
^KT-59417 Fixed
2023-07-18 14:02:30 +00:00
Ivan Kochurkin 1a28067b76 [FIR] Merge FirBasedKotlinMangler into FirMangler
FirMangler has only one implementation and it's FirBasedKotlinMangler

It looks excessive
2023-07-12 13:11:24 +00:00
Denis.Zharkov e94a0b8483 K2: Suppress "unused" for some methods at DependencyListForCliModule
Because we assume this part as a part of a public API
2023-07-11 13:12:22 +00:00
Denis.Zharkov e98890cece K2: Remove a bunch of unused declarations 2023-07-11 13:12:22 +00:00
Pavel Kunyavskiy ef9413108b [K/N] Consolidate forward declarations handling
This is refactoring in preparation for KT-59764.
Names and layout of forward declarations related classes
was copy-pasted many times over compiler code.

Implementing KT-59764 would require copy-pasting it two more times.
So instead of doing this it was put in single place.

No behaviour changes intended in this commit.
2023-07-10 08:59:16 +00:00
Dmitriy Novozhilov 8e73d5a54a [FIR] Run irGenerationExtensions after IR actualization
^KT-56173 Fixed
2023-07-07 11:26:15 +00:00
Dmitriy Novozhilov 037572ee9f [FIR] Create FirExtensionSyntheticFunctionInterfaceProvider only once for all sessions
This is needed to avoid duplication of symbols for the same classIds

^KT-58539 Fixed
2023-07-06 11:00:38 +00:00
Ivan Kochurkin 43b76f3c24 [FIR] Remove unused declarations 2023-07-05 17:53:51 +00:00
Kirill Rakhman 2cc588d6d8 [RAW FIR] Rename raw FIR builder types for clarity 2023-06-30 12:05:43 +00:00
Svyatoslav Kuzmich 9b3237fff9 [Wasm] Initial K2 support in new test infrastructure (KT-57230)
- Implement FirWasmSessionFactory
- Use new compiler test infra for Wasm K1 and K2
- Delete old Wasm compiler test infra
2023-06-25 10:19:36 +02:00
Mikhail Glukhikh 2a825f8df1 K2: implement FirClassAnySynthesizedMemberScope #KT-54844 Fixed 2023-06-14 07:09:15 +00:00
Dmitriy Novozhilov ba41e8ec38 [IR] Use common expect/actual matching algorithm in IR actualizer
^KT-58578 Fixed
2023-06-10 07:33:29 +00:00
Roman Golyshev b11447ea6b KTIJ-24983 [FIR] Ensure safe publication of configured plugin factories in FirExtensionRegistrar
Previous approach prevented double registration of the plugins, but
might have caused a race condition: atomic flag was set before the
plugins initialization, not after, so another thread could see garbage
data even if it could read the flag set to "true".

This might or might not be a root cause for the KTIJ-24983 exception,
so we'll have to wait for some time before actually closing the issue.
2023-06-01 12:29:34 +00:00
Nikolay Lunyak 70605c84df [FIR Native] KT-58549: Get rid of the builtin provider
According to
`FirNativeCodegenBoxTestGenerated.testNestedClassesInAnnotations`,
the annotation
`kotlin.internal.PlatformDependent` is
unresolved reference.

^KT-58549 Fixed
2023-06-01 10:27:54 +00:00
Marco Pennekamp accc9b0eb3 [FIR/LL FIR] Introduce FirSymbolNamesProvider
- In LL FIR, we have increasingly formalized symbol name caches as
  palpable objects. The main reasons for this formalization were the
  need to share implementations of caching between different (LL FIR)
  symbol providers, the need to build composite name caches from
  individual name caches, and the introduction of resolve extensions
  which may provide additional declarations and thus complicate the name
  set construction for Kotlin symbol providers in LL FIR.
- `LLFirSymbolProviderNameCache` also shared a lot of similarities with
  cache handling in FIR providers like
  `FirCachingCompositeSymbolProvider` and
  `AbstractFirDeserializedSymbolProvider`.
- This commit introduces a `FirSymbolNamesProvider` as a component of
  `FirSymbolProvider`. This symbol names provider's task is to provide
  the sets of names which `FirSymbolProvider` previously provided. It
  also allows sharing implementations of `mayHaveTopLevel*` once and for
  all, which is an improvement over the previously scattered
  implementations (the same ideas replicated many times throughout
  different symbol providers).
- `FirSymbolNamesProvider` by design doesn't cache, as many symbol
  providers may not need such a cache. `FirCachedSymbolNamesProvider`
  can be used to cache symbol names if needed. The symbol name provider
  architecture also makes it easier to switch between caching and
  non-caching, without the need to reimplement caches every time.
- Synthetic function types complicate the picture, but this complication
  is now exposed with the rest of the API, instead of being hidden in a
  few implementations here and there. This allows symbol providers to
  more explicitly state whether they can provide generated function
  types, which is an advantage for the correctness of composite symbol
  providers.

Some specific notes:

- In `FirSyntheticFunctionInterfaceProviderBase`, the class ID check has
  been replaced with a full `mayHaveTopLevelClassifier` check so that
  the cache doesn't get filled with `null` entries.
- `LLFirKotlinSymbolProviderNameCache` is turned into a non-caching
  `LLFirKotlinSymbolNamesProvider` so that this symbol names provider
  and those of resolve extensions can be composed into one caching
  symbol provider in `LLFirProviderHelper` without creating layers of
  caches. If the Kotlin symbol names provider was caching out of the
  box, `LLFirProviderHelper.symbolNameCache` would cache the
  names (1) in the combined symbol names cache and (2) in the Kotlin
  symbol names cache.
  - A caching Kotlin symbol names cache can still be created easily with
    the `LLFirKotlinSymbolNamesProvider.cached` constructor function.
2023-05-31 18:34:41 +00:00
Denis.Zharkov 2e5b783cc6 K2: Refine how JDK members are mapped to built-in classes
Previously, the semantic was more-or-less correct for most of the cases
but some corner one, like `sort` in MutableList didn't work properly.

Namely, `sort` should be marked there in a way to forbid to call it
everywhere beside super-calls.
Also, overriding it should be allowed.

Mostly, the logic was re-written to K2 model from K1-related
JvmBuiltInsCustomizer.

^KT-57694 In progress
^KT-57269 Fixed
2023-05-30 10:44:41 +00:00
Nikolay Lunyak 83f2c2e1f0 [FIR] KT-58623: Unify FirInlineDeclarationChecker
> Condition 'isSuspendFunctionType' is always false when reached

The change in the native tests is needed, because K2
doesn't support disabling old language features

^KT-58623 Fixed
2023-05-25 12:19:51 +00:00
Alexander Korepanov 1fb8293968 [JS IR] Change default declaration origin for IC symbols 2023-05-23 10:13:26 +00:00
Pavel Kirpichenkov 2a79643dcf [LL FIR] introduce platform-aware LL FIR session factories
KT-58769
2023-05-18 09:48:40 +00:00
Nikolay Lunyak c57d9097c2 [FIR] Add the syntax tree suffix to buildResolveAndCheckFir 2023-05-16 12:11:47 +00:00
Nikolay Lunyak d72a50b3f5 [FIR] KT-58065: Support LT in K2JsIrCompiler 2023-05-16 12:11:46 +00:00
Sergej Jaskiewicz a74df3b4b4 [IR] Store manglers used for signature computation in IrBackendInput
We will need them in signature dump tests later.
2023-05-04 14:58:06 +00:00
Nikolay Lunyak 360d236b7e [FIR JS] KT-57601: Get rid of the builtin provider
In this example we get 2 variants of `kotlin/toString()`:
one coming from the KLib provider, and the
other coming from the builtins provider.
These are identical deserialized functions.

^KT-57601 Fixed
2023-04-25 11:29:34 +00:00
Dmitriy Novozhilov 2087a7c899 [FIR] Store generated declarations in the session component
Also extract generated declarations for classes from declaration site
  session, not use site

^KT-57821 Fixed
2023-04-24 09:22:30 +00:00
Anton Bannykh c839fdca3e [JS IR] initial support for KLIB incremental compilation with K2 2023-04-23 14:47:48 +02:00
Dmitrii Gridin 7b91cd0ff3 [FIR] calculate java Target annotation on COMPILER_REQUIRED_ANNOTATIONS phase
^KT-57849
^KT-57949
2023-04-21 10:14:05 +00:00
Dmitriy Novozhilov 0f8c797d7c [FIR] Introduce caching service for metadata declarations provided by extensions
This is needed to allow to call for provided declarations multiple times
  with only one real invocation of plugins
2023-04-20 09:27:07 +00:00
Ivan Kylchik fe989d0ba7 [K2] Add languageVersionSettings to Fir2IrConfiguration class 2023-04-19 13:52:42 +00:00
Ivan Kylchik e16231104e [K2] Add Fir2IrConfiguration class to store configuration parameters
One example of such parameter is `linkViaSignatures`. There is
`Psi2IrConfiguration` as an analog for K1.
2023-04-19 13:52:41 +00:00
Ilya Chernikov 8cc9f911d5 FIR: temp: make klib symbol provider know parent packages
Current qualified access resolving algo rely (likely incorrectly,
see #KT-58037) on a providers' "knowledge" about parent packages.
This commit adds this "knowledge" to k-lib based provider.
#KT-57353 fixed
2023-04-19 11:42:03 +00:00
Ivan Kochurkin 3a60b30dae Minor: IrActualizationResult -> IrActualizedResult 2023-04-17 19:55:35 +00:00
Ivan Kochurkin 9a5cc39588 [FIR] Use FirDefaultOverridesBackwardCompatibilityHelper with common metadata compilation
Also, use it with JS compilation

^KT-57735 Fixed
2023-04-06 22:27:24 +02:00
Kirill Rakhman d6e14f37a7 [FIR] Let FirTopLevelFunctionsChecker run on all platforms
Use a session component to control platform specific suppression logic.
2023-04-04 10:36:40 +00:00
Dmitriy Novozhilov 88d61173b6 [FIR] Don't run platform checkers during compilation to metadata
^KT-57376 Fixed
2023-03-31 09:59:51 +00:00
Vladimir Sukharev b9633375b4 [K2/N] KT-56030: Support Objective-C overloading by param names only
Merge-request: KT-MR-8901
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-30 09:37:57 +00:00
Dmitriy Novozhilov 336b6ba9f0 [FIR] Extract extension functional type from an annotated functional type during deserialization
^KT-57140 Fixed
2023-03-27 10:44:51 +00:00
Dmitriy Novozhilov 8ca7b32577 [FIR] Register type related extensions in libraries sessions
^KT-57140
2023-03-27 10:44:50 +00:00
Kirill Rakhman 60b227c519 [FIR] Sort HMPP dependencies topologically for symbol providers
This fixes an issue where an actual class from an intermediate module
has more supertypes than its expect declaration which leads to a
false-positive resolution error because a type reference resolves to the
expect class. The fix is to sort the dependencies topologically from
"most actual" to "most expect" when creating the list of symbol
providers.

#KT-57369 Fixed
2023-03-27 07:41:05 +00:00
Ivan Kochurkin ee73e4774b [K2, MPP] Remove redundant expect declarations from klib metadata
^KT-57250 Fixed

Introduce flat Fir2IrActualizedResult

It contains output from Fir2Ir and IrActualizer
2023-03-24 14:48:26 +00:00
Dmitrii Gridin 706ff6b61f [FIR] pre-resolve some scope callables before creating a scope
In a lot of cases, when we want to process the
declaration in scope, it should be resolved to at least TYPES phase.

To avoid doing it manually in all our variety of scopes, we do it when the scope it created.
It was implicitly working manually before as lazy resolve did a lot of extra work
on resolving a declaration it was not supposed to resolve.
Now it's not the case, and we have to explicitly resolve all the declarations we need.

^KT-56543

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2023-03-24 09:57:46 +00:00
Ilya Chernikov 59b88f33b2 [K2, MPP] implement IR errors reporting and test infrastructure
Fix test data

^KT-56344 Fixed
2023-03-22 01:28:16 +00:00
Marco Pennekamp 4981a52904 [FIR] Extensions symbol provider: Rename create to createIfNeeded 2023-03-21 16:08:43 +00:00
Marco Pennekamp d9f515fbb8 [FIR] KT-57220 Avoid creating useless synthetic function providers
- This optimization applied to LL FIR can be extended to K2 as a whole.
  Likely, there won't be any performance benefits in CLI runs, but it's
  still better to avoid useless symbol providers.
2023-03-21 16:08:43 +00:00
Ilya Chernikov be2a85be71 K2: support implicit integer to unsigned conversions...
with dedicated opt-in language feature and special
annotation or module capability.
Not intended for a general use, solves specific K/N
scenario with interop libs.
#KT-55902 fixed
2023-03-17 08:57:51 +00:00
Alexander Korepanov e3402fcc87 [K2 JS] Do not load transitive dependencies for building K2/JS klibs
^KT-57262 Fixed
2023-03-15 10:49:54 +00:00
Alexander Udalov d96112b944 Remove dependency of fir2ir/fir.entrypoint on psi2ir 2023-03-10 17:49:35 +00:00