Commit Graph

6926 Commits

Author SHA1 Message Date
Roman Efremov e79851910e [FE, IR] Check annotations compatibility on expect and actual getters and setters
^KT-60671
2023-09-15 14:41:38 +00:00
Roman Efremov 420dceb7d8 [FE, IR] Store PsiElement for mismatched annotation's actual target
There is IDE quick fix which suggests to copy mismatched annotation
from `expect` to `actual` (see KTIJ-26633). It needs to find
`actual` PsiElement where to add annotation. Before previous commit, it
was easy - just get source of `Incompatibility.actualSymbol`.
After previous commit, the problem might be in value parameter, while
`actualSymbol` would contain function symbol. This is solved by adding
new field `Incompatibility.actualAnnotationTargetElement`.

`SourceElementMarker` introduced, because it's needed to be used in
abstract checker. Existing `DeclarationSymbolMarker` doesn't fit
because in next PR for this issue annotations set on types will be reported,
and types are not declarations.

^KT-60671
2023-09-15 14:41:37 +00:00
Alexander Udalov fda47c45ec IR: do not change overrides for lazy IR in FakeOverrideRebuilder
`FakeOverrideBuilder.provideFakeOverrides` recursively changes overrides
for all superclasses in the hierarchy, including lazy IR, which is a lot
of extra work.

Also it leads to some tests failing in the IR fake override builder mode
because it changes correct fake overrides of Java classes to incorrect
ones. Those tests are unmuted but it doesn't mean they are fixed -- most
likely we'll generate fake overrides via IR for lazy IR too, at which
point they'll start to fail again.
2023-09-15 12:55:33 +00:00
Alexander Udalov 216d2b50f7 IR: remove FakeOverrideCopier.makeExternal
Make the declaration external at the call site instead of creating two
instances of FakeOverrideCopier. It's possible because IR elements are
mutable, in particular isExternal is a var.

Maybe the same should be done to IrUnimplementedOverridesStrategy, but
that is postponed for another time.
2023-09-15 12:55:33 +00:00
Alexander Udalov 019836e9c7 IR: use origin DEFINED for value parameters of fake overrides
Fake overrides created by K1, as well as fir2ir in K2, use DEFINED. So
this gets rid of a lot of differences in IR text dumps between the K2
normal mode and K2 with IR fake overrides, and will ultimately help in
implementing and testing KT-61360.

The change in AddContinuationLowering is needed to fix tests like
kt47549. When creating anonymous classes for SAM implementations, we're
reusing the same fake override building machinery. And since we can't
extract any meaningful information from the fake override parameter's
origin anymore, we have to get the parameter from the original symbol.
2023-09-15 12:52:57 +00:00
Alexander Udalov 9f9287fb2e IR: keep flexible type annotations when building fake overrides
#KT-61751 Fixed
2023-09-15 09:40:45 +00:00
Alexander Udalov cadbc87dfd JVM IR: add flag to avoid loading dependency module headers
This is an addition to d16f33cf5b. Apparently there's another call site
of JvmIrCodegenFactory in intellij besides Evaluate Expression, namely
Android LiveEdit plugin, where it seems needed to collect all dependency
modules and resolve them via linker. LiveEdit also uses
shouldStubAndNotLinkUnboundSymbols = true, so we need to differentiate
between it and Evaluate Expression, hence the new flag. This new flag
will be set to true only for Evaluate Expression in intellij.

 #IDEA-329915
2023-09-14 15:45:47 +00:00
Artem Kobzar 878452bd2b [K/JS] Implement file merging for clashed file during per-file compilation 2023-09-14 13:14:15 +00:00
Ivan Kylchik ede6eb0b34 [IR] Print exception's class in error message from interpreter 2023-09-14 08:47:06 +00:00
Ivan Kylchik 2df5b48474 [IR] Report error from IR interpreter on field recursive initialization
#KT-59890
#KT-61802 Fixed
2023-09-14 08:47:06 +00:00
Sergej Jaskiewicz 14e23a7d84 [K/N] Cache FqNames computed from ClassIds in KonanMangler 2023-09-13 14:25:13 +00:00
Sergej Jaskiewicz 9eba17d631 [K/N] Move Native-specific mangle constants to more suitable places
They shouldn't be mixed with target-independent constants.
2023-09-13 14:25:12 +00:00
Sergej Jaskiewicz 08a9e7eae9 [IR] Outline the main logic in annotation-related helpers
Prefer smaller inline functions, because otherwise if they become
hot spots, they will complicate performance analysis, and actually
might make everything slower because of low inlining threshold in
HotSpot.
2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz 157ab48fde [K/N] Delete unused methods in ObjCInterop.kt 2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz e3b5dc509c [K/N] De-duplicate code for mangling objc interop function names
Extract the duplicated functionality to the
`ObjCFunctionNameMangleComputer` class.
2023-09-13 14:25:11 +00:00
Sergej Jaskiewicz 0fd4f10f6c [K/N] Avoid magic strings in KonanMangler 2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz ddfd94b3b2 [K/N] Move KonanMangler to a new common module
^KT-61248 Fixed
2023-09-13 14:25:10 +00:00
Sergej Jaskiewicz d1127f1a31 [K/N] Move IR-related ObjC interop helpers to a new common module
This is a step towards KT-61248. We need those helpers to be available
in non-Native-specific code.
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz 5cb252fe49 [descriptors] Move DeclarationDescriptor#findPackage helper to core
There is nothing serialization-specific about this function
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz 56cb0bf071 [utils] Move atMostOne to core/util.runtime
There is nothing backend-specific about this helper function.
2023-09-13 14:25:08 +00:00
Alexander Udalov f9712597e1 IR: support IrExternalOverridabilityCondition in IrOverrideChecker
The code is analogous to OverridingUtil and
ExternalOverridabilityCondition.
2023-09-13 15:04:53 +02:00
Alexander Udalov 86eb79e095 IR: extract IrOverrideChecker to separate file 2023-09-13 15:03:41 +02:00
Alexander Udalov 57c1df7875 IR: extract FakeOverrideBuilderStrategy to separate file 2023-09-13 15:01:52 +02:00
Alexander Udalov 0afee8685a IR: remove unused parameter of IrOverridingUtil.isOverridableBy
The value of checkReturnType is false at all call sites.
2023-09-13 15:01:52 +02:00
Alexander Udalov b650f0ce8e IR: slightly refactor FakeOverrideRebuilder
Deduplicate some code, improve assertion messages, fix grammar in
comments.
2023-09-13 15:01:52 +02:00
Artem Kobzar 2578bfefd5 [K/JS] Add useEsClasses to list of compiler arguments that invalidate IC cache ^KT-61795 Fixed 2023-09-13 09:50:24 +00:00
Igor Chevdar 93dea12efe [IR] Supported top level local classes in names inventor
Such classes might appear after local objects extraction from inline bodies
2023-09-13 09:18:20 +03:00
Artem Kobzar 7bc521ab92 [K/JS] Reset exceptionState inside coroutines with a finally block ^KT-58685 Fixed 2023-09-12 15:18:16 +00:00
Alexander Udalov d16f33cf5b JVM IR: do not collect all dependency modules in IDE
Collecting all modules takes a lot of time in Evaluate Expression in
IDE, and it's useless because we then invoke JvmIrLinker to load module
headers, but that linker is discarded in the IDE (see `val irProviders`
below).

 #IDEA-329915
2023-09-12 09:11:44 +00:00
Ivan Kylchik 386d69018d [JVM] Rename JvmLower to JvmLoweringPhases
This is done to unify the way how we name file
that contains lowerings in different backends.
2023-09-11 10:04:50 +00:00
Johan Bay a1c2ded8a3 [K/N] Header klibs: Keep private properties in value classes
^KT-61767 Fixed
2023-09-08 13:13:19 +00:00
Nikita Bobko 6868c95263 KMP: Put "prohbit expect/actual different annotations" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Ivan Kylchik 6048d52a97 [K2] Avoid field inlining during FIR2IR phase
Before const inlining for fields, we actually want to remember a given
field in `InlineConstTracker`. We are doing it already in const
evaluation. So we just need to ignore const inlining in
`CallAndReferenceGenerator` and delegate it to const evaluation.

#KT-60737
2023-09-07 19:12:18 +00:00
strangepleasures 88453a05f1 KT-53551 KT-52213 KT-58476 Fix handling of suspend functional types with context receivers 2023-09-07 12:40:01 +00:00
Artem Kobzar bff433f4e9 [K/JS] Support eager initialization for per-file granularity 2023-09-06 09:27:28 +00:00
Ivan Kylchik c2076a0227 [Native] Move hasNonConstInitializer from IrUtils2
This function could be useful for other backends.
2023-09-05 11:21:51 +00:00
Ivan Kylchik ddde95bd78 [Native] Move irByte from IrUtils2
We already have similar functions in `ExpressionHelpers`. Makes
sense to keep them together.
2023-09-05 11:21:51 +00:00
Ivan Kylchik 583a5496d5 [Native] Drop irCall from IrUtils2
We can reuse the same function from common `ExpressionHelpers`
2023-09-05 11:21:50 +00:00
Ivan Kylchik d0a5738499 [Native] Drop addChild from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 5661316d7a [Native] Use FORWARD_DECLARATIONS_MODULE_NAME instead of hardcoded value 2023-09-05 08:35:47 +00:00
Ivan Kylchik dfa60ee092 [IR] Drop TODO from IrModuleFragmentImpl
This TODO doesn't have any description, and it is already
hard to understand what the author meant.
2023-09-05 08:35:46 +00:00
Iaroslav Postovalov 059046a2b1 [JVM] Micro-optimize method signature mapping
This commit optimizes functions related to method signature mapping on
the JVM backend. The most significant change is avoiding re-allocations
in StringBuilder when building internal names. The commit also includes
minor optimizations, such as removing redundant allocations of strings
and other objects.
2023-09-01 20:26:17 +00:00
Pavel Kunyavskiy bf9cae6410 [Fir2Ir] Support rebuilding fake overrides over IR
^KT-61514
2023-08-31 13:12:15 +00:00
Pavel Kunyavskiy 44c2a749c9 [Ir common] Introduce symbol table api to remove entries
^KT-61514
2023-08-31 13:12:15 +00:00
Evgeniy.Zhelenskiy 6ede1bcf85 [IR] Reduce unnecessary allocations 2023-08-31 10:43:30 +00:00
Kirill Rakhman ac102dedac [IR Actualizer] Fix fake-override generation in actual A -> common B -> actual C hierarchy
...  where C defines a member x and A overrides the member x

#KT-61166 Fixed
2023-08-31 07:52:02 +00:00
Alexander Udalov 12bbdebed2 JVM IR: support value classes only when feature is enabled
Remove NeedsToVisit because it doesn't really help with performance, and
it significantly increases code complexity.
2023-08-30 15:35:43 +00:00
Alexander Udalov 2dee47a8c1 JVM IR: simplify JvmValueClassAbstractLowering.visitReturn
Change the existing IrReturn object instead of returning a new one.
2023-08-30 15:35:43 +00:00
Alexander Udalov d1f884bad9 JVM IR: micro-optimization in IrType.erasedUpperBound
Avoid `is` on interfaces, use classes instead.
2023-08-30 15:35:43 +00:00
Alexander Udalov 35d498847e JVM IR: reorder some resolveFakeOverride calls 2023-08-30 15:35:43 +00:00