Commit Graph

109329 Commits

Author SHA1 Message Date
Yan Zhulanow c7aedd932c [Analysis API] Support compiler plugins in code fragments
Compiler plugins are currently only supported in source modules.
This commit makes them also available in code fragments with source
context.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 5179462632 [Analysis API] Support non-JVM platforms in code fragments
The 'evalJs' test is not available, as there is no proper support for
klib loading in non-standalone Analysis API yet.

^KT-64197 Fixed
2024-01-05 16:04:14 +00:00
Yan Zhulanow 75abae23d8 [Analysis API] Fix WITH_STDLIB for common modules in Analysis API tests
The previous implementation in 'TestModuleStructureFactory' had very
custom and redundant logic for binary dependency collection.
In particular, JDK and kotlin-stdlib were specifically computed,
although both already were in the module classpath, which was handled in
'createLibrariesByCompilerConfigurators()'. In addition, there was no
support for common modules.

The new behavior is much closer to what happens in production.
2024-01-05 16:04:14 +00:00
Yan Zhulanow 1a5b9ad79c [Analysis API] Support multi-module projects in compiler facility tests 2024-01-05 16:04:14 +00:00
strangepleasures 894df8f641 KT-64719 K2 KAPT stub generation should fail on syntax errors 2024-01-05 15:58:41 +00:00
Marco Pennekamp bace053ea9 [AA decompiler] Store sealed modifiers in interface stubs
- If the `sealed` modifier is not kept in the interface's stub, a
  sealed interface will have an `abstract` modality instead, which
  causes issues with `when` exhaustiveness analysis in K2.
- This issue also affected K1, but it was less visible there because
  `when` exhaustiveness analysis in K1 uses deserialized descriptors.

^KT-62895
2024-01-05 15:55:29 +00:00
Marco Pennekamp 5797b4877c [FIR/AA decompiler] Add tests for sealed interfaces
^KT-62895
2024-01-05 15:55:29 +00:00
Dmitrii Gridin 7c8aff963f [SLC] do not create light classes for expect declarations
We shouldn't build expect declarations as they do not
exist. We can omit check on member declarations as we
won't request them as we skip expect classes

^KT-57536 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin c14c12479c [SLC] fix multifile-classes in multiplatform case
Multifile-class can contain not only files from the same
module, but also files from the common part.
This commit also fixes KotlinByModulesResolutionScopeProvider as
it should provide all transitive dependencies

^KT-64714 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin fc519b2339 [SLC] add test on multiplatform facade
^KT-64714
2024-01-05 15:07:55 +00:00
Mikhail Glukhikh 3d560cd92c K2: use correct scope for overrides calculation in ObjCName checker
To call retrieveDirectOverriddenOf,
one must use directly the owner scope of a callable symbol we consider,
and not a scope of some derived class.

#KT-64276 Fixed
2024-01-05 14:39:05 +00:00
Artem Kobzar e4c244d5db [K/Wasm] Generate source-map for WAT-files 2024-01-05 14:16:32 +00:00
Nikolay Lunyak aea2e8052a [FIR] Ensure KT-64089 works
Make sure SENSELESS_COMPARISON
is absent in this case.

^KT-64089 Obsolete


Merge-request: KT-MR-13754
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 14:15:06 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Alexander Shabalin 3f2584bb02 [K/N] Move calls checker into separate module ^KT-62091 2024-01-05 13:35:35 +00:00
Nikolay Lunyak 8cd87059c8 [FIR] Fix the failing test after merging 533ed5c6
It started failing because of other
changes having been merged right before it

^KT-64644 Fixed

Merge-request: KT-MR-13755
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 13:34:43 +00:00
Alexander Shabalin d7929f93f2 [K/N] Fix samples compilation 2024-01-05 13:31:53 +00:00
Yahor Berdnikau 41003732b1 [Gradle] Add JVM toolchain configure method to Kotlin target
These methods are only added to provide more user-friendly error
when user tries to configure JVM toolchain in Kotlin target DSL.

^KT-64629 Verification Pending
2024-01-05 12:34:27 +00:00
Alexander Shabalin e959e97992 [K/N] Fix :kotlin-native:runtime:clean
The task erroneously deleted the build directory during
configuration phase.
2024-01-05 12:17:08 +00:00
Leonid Startsev 7700921646 Add K2 configurations for specific kotlinx.serialization tests
#KT-64447 Fixed
2024-01-05 11:38:35 +00:00
Dmitriy Novozhilov c2cbbecfe9 [K2 Serialization] Store serializable properties in metadata extension
This solution is temporary (see KT-64694 for details)

^KT-64312 Fixed
2024-01-05 11:30:57 +00:00
Dmitriy Novozhilov fb3963dead [FIR] Add extension point to metadata serialization
This is a temporary solution for KT-64312
Introduced extension point should be removed (KT-64695)
2024-01-05 11:30:57 +00:00
Dmitriy Novozhilov 717d1c774b [FIR] Save information about SerializationPluginMetadataExtensions in the property attribute
K1 implementation of kotlinx.serialization used SerializationPluginMetadataExtensions
  for two purposes:
- to extract the source-order of properties
- to identify which properties are actually serializable

In K2, the first point is covered by the compiler itself (as it correctly orders
  properties during deserialization), and to cover the second point we
  need to save in the propery information if it was mentioned in this extension
  or not

KT-64312
2024-01-05 11:30:57 +00:00
Alexander Shabalin 5208b3c024 [K/N] Put FinalizerProcessor CFRunLoop usage under a flag ^KT-64313 2024-01-05 10:46:49 +00:00
Dmitriy Novozhilov 8ff869a08c [FIR] Unregister FirJavaElementFinder at the Project disposing
^KT-64433 Fixed
2024-01-05 10:23:04 +00:00
Pavel Kunyavskiy 32de968531 [Names] Avoid deadlock in initialization of classId constants
StandardClassIds was using Annotations subclass in its initialization.
At the same time, Annotations subclass was using StandardClassIds in its
initialization implicitly through baseId() method.

This leads to a rare deadlock on CI in case where two different threads
tried to initialize both classes at the same time.

It can't be reproduced robustly, as a single thread was able to
successfully initialize both, and will do it on an attempt to
initialize any of them.

^KT-64720 Fixed
2024-01-05 09:53:05 +00:00
Dmitriy Novozhilov 7accda6cda [FIR] Make FirProviderWithGeneratedFiles know about providers from mpp dependencies
During refactoring of FIR2IR commit 8ebb4127 introduced
  `FirProviderWithGeneratedFiles` for lookups for containing FIR for
  generated declaration

But it broke the logic of `Fir2IrIrGeneratedDeclarationsRegistrar`,
  which provides annotations for metadata from generated IR annotations
  (see `containingFile` function in it), as it started to use fir
  provider from the platfrom session instead of provider of the
  corresponding session

So to fix this issue `FirProviderWithGeneratedFiles` was changed in the
  way so it sees declarations from dependant sessions too (only with
  `dependsOn` relation), which allows to use provider for the leaf
  platform session for declarations from any module within the same
  HMPP hierarchy

^KT-64444 Fixed
2024-01-05 09:42:22 +00:00
Roman Golyshev 8feb4def4d KTIJ-28167 [AA] Add a note about type aliases to the findAvailableConstructors function 2024-01-04 20:07:41 +00:00
Roman Golyshev df8c6c694a KTIJ-28167 [AA] Support SAM constructors in KtFirReferenceShortener
Utilize `FirSamResolver` to obtain the potential SAM constructor
from the classifier

Also, accept K2_SYNTHETIC_RESOLVED in the `resolveUnqualifiedAccess`,
since this is the kind of resolve success which corresponds to the
SAM constructor call resolution

^KTIJ-28167 Fixed
2024-01-04 20:07:41 +00:00
Roman Golyshev e561de8a22 KTIJ-28167 [AA] Refactor FirShorteningContext.findFunctionsInScopes
It will make it easier processing SAM constructor there later
2024-01-04 20:07:41 +00:00
Roman Golyshev 31291fc8fa KTIJ-28385 [AA] Support SAM constructors in computeImportableName
This allows to properly report them as used in `KtFirImportOptimizer`

This change will also be important for properly fixing KTIJ-28167,
since `computeImportableName` is also used in reference shortener

^KTIJ-28385 Fixed
2024-01-04 20:07:41 +00:00
Brian Norman 9ec469e3c3 [Parcel] Expand types from TypeParceler annotation to support aliases
Class properties are being expanded before checking for custom
parcelers, which makes custom parcelers of type alias unable to be
found. To maintain K1 behavior, the custom parceler type must also be
expanded, so even the aliased type is supported when used in its raw
form as a class property.

^KT-64707 Fixed
2024-01-04 19:59:56 +00:00
Vladimir Sukharev 55bff799a8 [K/N][tests] Split tests for Any.collectReferenceFieldValues
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev d972fec13c [K/N][tests] Move tests into better places
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev e68bd1f04f [K/N][tests] Adjust moved tests to new testing infra
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev 0a0da76a56 [K/N][tests] Move some more native tests to new testing infra
^KT-61259
2024-01-04 18:24:37 +00:00
Pavel Kunyavskiy 4080776fe3 [Fir2IR] Set correct module descriptors for builtins
^KT-64420
2024-01-04 17:29:58 +00:00
Alexander Shabalin d665eb3575 [K/N] Fix calls checker allow list for signposts ^KT-62689 2024-01-04 16:58:20 +00:00
Dmitrii Gridin 44388ea15f [SLC] generate correct name for property assessors in case of JvmRecord
^KT-62357 Fixed
2024-01-04 16:32:10 +00:00
Dmitrii Gridin 5c71015b09 [LC] implement isRecord for classes
Java world should better understand our classes with JvmRecord annotation

^KT-62357
2024-01-04 16:32:10 +00:00
Dmitrii Gridin b463f1fdfa [SLC] unmute tests on JvmRecord
^KT-62357
2024-01-04 16:32:10 +00:00
Ivan Kochurkin 69b9bfc3e0 [FIR] Initialize public visibility for class-like declarations at FIR building phase if no modifier is presented
Java resolving subsystem requires calculated visibility for correct disambiguation of supertypes.
But visibility remains `Unknown` for Kotlin class-like declarations during supertypes resolving because `STATUS` resolve phase is performed after `SUPER_TYPES` phase.
To fix the problem, the visibility should be initialized to public at the FIR building phase if no modifier is presented.

^KT-64127 Fixed
2024-01-04 16:17:32 +00:00
Alexander Udalov ee8d42532b Fir2Ir, JVM IR: support flexible Array types loaded from Java
We don't have true flexible types in the IR, but we approximate it with
internal type annotations, such as FlexibleNullability,
FlexibleMutability, RawType. These annotations are then handled
specially in JvmIrTypeSystemContext, which can construct a fake flexible
type so that type checker on IR types would behave exactly as on
frontend types.

As shown in KT-63441, one instance of flexible types where flexibility
was lost during conversion to IR is Java array/vararg types. It's
necessary to support it so that IR fake overrides could be constructed
correctly, because IR fake override checker requires parameter types to
be equal. So this change introduces another internal type annotation,
FlexibleArrayElementVariance, which is only applicable to types with
classifier kotlin/Array, and which signifies that the annotated type
`Array<X>` should rather be seen as `Array<X>..Array<out X>`.

 #KT-63441 Fixed
 #KT-63446 Fixed
2024-01-04 15:54:27 +00:00
Alexander Udalov e98902ce74 Fir2Ir, JVM IR: minor, deduplicate constants for ClassId of special annotations 2024-01-04 15:54:26 +00:00
Dmitrii Gridin 3fcf5c47c2 [resolution] KotlinJavaPsiFacade: replace explicit EMPTY_SCOPE check with more general
Someone can request search for `LocalSearchScope.EMPTY` and we can
catch this case

^KT-62892
2024-01-04 15:20:38 +00:00
Dmitrii Gridin 37ccf5d4f3 [resolution] KotlinJavaPsiFacade: do not return classes with wrong ClassId
We shouldn't return from `findClass`/`findClasses` Java classes with
`ClassId` different from the requested one

^KT-62892
2024-01-04 15:20:38 +00:00
Dmitrii Gridin c6004874c1 [SLC] generate light classes for functions with JvmName and value class as parameter
Such functions/accessors have not-mangled names, so they can be called
from Java

^KT-63087 Fixed
2024-01-04 15:16:20 +00:00
Dmitrii Gridin e0f524b6b3 [LC] add tests on declarations with JvmName and value classes
^KT-63087
2024-01-04 15:16:20 +00:00
Brian Norman aae8cd2a7c [FIR] Local variable assignment must be propagated before loops
When performing lookahead for local variable assignments, make sure
assignments taking place within loops are being propagated before loops.
This makes sure smartcasts within non-inline declarations before the
loop are disallowed.

^KT-63867 Fixed
2024-01-04 14:20:21 +00:00
Kirill Rakhman 10d6d95ee8 [Tests] Add regression test for #KT-64702 2024-01-04 14:12:42 +00:00