Commit Graph

107206 Commits

Author SHA1 Message Date
Nikita Bobko 8bbbbfa3ce [FIR] Fix MT intellij tests
MT stands for "modularized tests"

^KT-64166 Fixed
Review: https://jetbrains.team/p/kt/reviews/13517/timeline

This commit fixes:

    java.lang.IllegalArgumentException: Local <local>/<anonymous> should never be used to find its corresponding classifier
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl.getFirClassifierByFqName(FirProviderImpl.kt:252)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl$SymbolProvider.getClassLikeSymbolByClassId(FirProviderImpl.kt:60)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.computeClass(FirCachingCompositeSymbolProvider.kt:131)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.access$computeClass(FirCachingCompositeSymbolProvider.kt:27)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider$special$$inlined$createCache$1.invoke(FirCachesFactory.kt:75)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider$special$$inlined$createCache$1.invoke(FirCachesFactory.kt:69)
            at org.jetbrains.kotlin.fir.caches.FirThreadUnsafeCache.getValue(FirThreadUnsafeCachesFactory.kt:40)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.getClassLikeSymbolByClassId(FirCachingCompositeSymbolProvider.kt:158)
            at org.jetbrains.kotlin.fir.resolve.transformers.mpp.FirExpectActualResolver.findExpectForActual(FirExpectActualResolver.kt:41)
2023-12-13 18:42:14 +00:00
Dmitriy Dolovov e9b4b8919d [KLIB Resolver] Add a heuristic to look up for KLIB file given only unique name
This fix adds a workaround to allow Kotlin/Native compiler to resolve
KLIB library if only library name was passed via `-l` CLI argument.

^KT-63931
2023-12-13 18:06:07 +00:00
Dmitriy Dolovov 2b1fc51f89 [KLIB Resolver] Deprecate UnresolvedLibrary.substitutePath()
This method in unused in Kotlin compiler and IDEA plugin.
2023-12-13 18:06:07 +00:00
strangepleasures 1015ae858e [KAPT] KT-64301 Report invalid enum value names
Merge-request: KT-MR-13520
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2023-12-13 17:53:52 +00:00
Mikhail Glukhikh 676e350b6f K1/K2: add test to confirm behavior of KT-63243 2023-12-13 17:43:45 +00:00
strangepleasures b84aa190d7 [KAPT] KT-64297 Mark deprecated members with @java.lang.Deprecated
Merge-request: KT-MR-13521
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2023-12-13 17:18:54 +00:00
Dmitriy Novozhilov 34bf32866b [Test] Remove redundant K1 ignore directives from K2 MPP box tests
Corresponding tests for K1 are no longer generated, so there is no need
  to ignore them anymore
2023-12-13 16:47:42 +00:00
Dmitriy Novozhilov b4947e6cfe [Test] Exclude K2 MPP codegen box tests from K1 generated suites
Those tests always were muted for K1 because of incompatible module
  structure in testdata, so there is no actual sense to even generate
  them for K1
2023-12-13 16:47:42 +00:00
Kirill Rakhman b7bdbd270f [FIR] Add comment for keeping the two places where class scopes are build in sync. 2023-12-13 16:46:24 +00:00
Kirill Rakhman d574d859cb [FIR] Clean up unused dummy code 2023-12-13 16:46:24 +00:00
Kirill Rakhman 44b3c66ad7 [FIR] Add companion scope before static scope
Static scope is checked first during resolution
(scopes are in reverse order).
This fixes a difference between how K1 and K2 resolve annotations.

#KT-63249 Fixed
2023-12-13 16:46:24 +00:00
Kirill Rakhman 2c74a2356a [FIR] Fix IOOBE in ConeTypeRenderer for bad extension function types 2023-12-13 16:46:24 +00:00
Ilya Gorbunov 5ce2a2cbee Use strongly typed task GenerateProjectStructureMetadata to tweak kpsm.json 2023-12-13 15:40:25 +00:00
Ilya Gorbunov e0bc0b81c6 [kotlin-test] Drop subprojects unneeded anymore KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 35aa17e1d0 Pack K/N stdlib sources into single zip
With the directory structure similar to one of a multiplatform library,
where each source set sources are placed into the directory
named after this source set.

Do not use legacy projects for building relative paths
2023-12-13 15:40:25 +00:00
Ilya Gorbunov fb74c18235 Fix maven plugin IT install and kotlin-bom dependencies after KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov b0bee09948 Change Gradle test expectations after KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 653fc03cbc Replace kotlin-test project dependencies in dist
KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov c40de28775 Replace kotlin-test-js project dependencies in the project
KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov 4b2e1240eb Replace kotlin-test-wasm project dependencies in the project
KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov d2aae67e03 Replace kotlin-test project dependencies in the project
Use dependency helper function that chooses whether to take them
from the bootstrap repository or from a configuration of kotlin-test

KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov f07bf70aa7 Switch stdlib tests to KMP kotlin-test KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 7a4335b087 [kotlin-test] Enable explicit API mode KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 6c46d11d0a [kotlin-test] Post-process capabilities in leaf framework artifacts' .module files KT-61969
Gradle copies capabilities from the variants of the root artifacts
to the variants of leaf artifacts which leads to capability conflict
when both root and leaf artifacts are present in a configuration during
variant-based dependency resolution
2023-12-13 15:40:25 +00:00
Ilya Gorbunov b91e4e24c4 [kotlin-test] Custom publishing layout KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov ffe54d3fc4 [kotlin-test] Alignment constraints for legacy artifacts KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 446cd1eec9 [kotlin-test] kpsm.json patching KT-61969
Adds source set relationships for additional variants
and also slightly stretches common source sets included into jvm variant
2023-12-13 15:40:25 +00:00
Ilya Gorbunov 5c4f0a70e0 [kotlin-test] Unit tests for additional compilations KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 2db2b18910 [kotlin-test] Additional framework jars and outgoing configurations KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 008a961913 [kotlin-test] Add module-info compilations KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 977da5c9b1 Support multiple java9 compilations in a project
Required for KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov 1d1645fd2d [kotlin-test] Setup KMP project for kotlin-test, targets and source sets KT-61969 2023-12-13 15:40:25 +00:00
Ilya Gorbunov f3240757ed Extract custom publishing dsl to buildsrc-compat
It will be used also in kotlin-test KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov 38ed3216fd [kotlin-test] Exclude kotlin-test project from GE test splitting
Not supported for kotlin-multiplatform tests

KT-61969
2023-12-13 15:40:25 +00:00
Ilya Gorbunov 6d62119659 Introduce expects in common wasm sources actualized in wasmJs and wasmWasi 2023-12-13 15:40:25 +00:00
Ilya Gorbunov 943c11d239 [Gradle] Support multiple variants of a module resolved when determining visible common source sets
With capabilities in variants it is possible to depend on multiple variants of
an artifact in the same target compilation. These variants can implement
different common source sets which all should be visible from that target.

Instead of intersecting single variant source sets visible from different
targets, first union source sets from all target variant dependencies
and only then intersect these union results from different targets.
2023-12-13 15:40:25 +00:00
Nikita Nazarov 251fdb21c9 [FIR] Generate spread element for unsigned arrays
Previously when unsigned arrays were passed as vararg in a named form the necessary spread element wasn't generated, which resulted in a compilation error.

^KT-63514 fixed
2023-12-13 15:30:27 +00:00
Mikhail Glukhikh dbca7358af K2: add explicit cast to Any for Any function calls on stub types
This commit solves a stub type inconsistency problem.
As a part of KT-59369 fix we decided (see commit 299d2799),
that ConeStubTypeForChainInference has a scope of Any,
so we can safely resolve only to equals/hashCode/toString.
However, later we can replace a stub type with some inferred type,
which can have its own equals/hashCode/toString implementation,
while the call still refers Any member.
In this situation FIR2IR decides that we are calling a fake override,
which is not true, in fact we are calling an overriding method.
This leads to a crash in Native backend.

To solve this situation, we provide an explicit cast of a dispatch
receiver with a stub type (ConeStubTypeForChainInference) to Any,
thus confirming directly we are calling Any method and nothing else.

#KT-63932 Fixed
2023-12-13 14:56:58 +00:00
Mikhail Glukhikh a0deaea8fe Add FIR_DUMP for KT-36220 / KT-63932 situations
In the second lambda, we should either have it of type Any,
or resolve toString() call to Int.toString()
2023-12-13 14:56:58 +00:00
Bogdan Mukvich 3616adbe1b Replace single artifacts-test with test factory
* Add the ability to fix all tests locally in one run

^KTI-1515
2023-12-13 14:50:57 +00:00
Marco Pennekamp c92396069a [LL] Implement LLFirResolveExtensionToolDeclarationProvider.computePackageNames
^KT-62553
2023-12-13 14:40:10 +00:00
Marco Pennekamp 04f4d39877 [LL] StubBasedBuiltInsSymbolProvider: Support synthetic function types in symbol names provider
- The symbol provider may additionally provide function types, so we
  have to compose its symbol names provider with the synthetic function
  type symbol names provider.
2023-12-13 14:40:10 +00:00
Marco Pennekamp ab805321e4 [FIR] FirNullSymbolNamesProvider: Fix mayHaveSyntheticFunctionType
- The null symbol names provider knows nothing about the names provided
  by its symbol provider, so it also has to assume that the symbol
  provider can provide a synthetic function type.
- This inconsistency has not caused an issue so far because
  `mayHaveTopLevelClassifier` is also overridden, and
  `mayHaveSyntheticFunctionType` is not used outside that context.
2023-12-13 14:40:10 +00:00
Marco Pennekamp 07c5f6fd22 [FIR] FirSymbolNamesProvider: Add missing get to mayHaveSyntheticFunctionTypes 2023-12-13 14:40:10 +00:00
Marco Pennekamp 6474ff88fa [FIR] FirSymbolNamesProvider: Implement classifier package name sets
- Previously, only callable package name sets were implemented, because
  the compiler cannot economically compute classifier package sets for
  libraries. This has not changed. However, the K2 IntelliJ plugin and
  standalone Analysis API can very easily compute classifier package
  sets. Hence, this commit adds support to `FirSymbolNamesProvider` for
  such sets.
- Similar to callable package sets, classifier package sets (1) improve
  the memory usage of symbol names providers and (2) improve the
  performance of `mayHaveTopLevelClassifier`, which is a significant
  bottleneck in the IDE.
- In many cases, the package sets for callables and classifiers are the
  same. For example, the IDE Kotlin declaration provider computes the
  set of packages that contain any classifier and/or callable, for the
  following reasons: (1) indexing package names without filtering for
  declarations is much faster, (2) computing separate sets is not free
  both in time and memory, and (3) the performance impact of having a
  more narrow set for callables is expected to be negligible. For this
  reason, `FirSymbolNamesProvider.getPackageNames` exists to provide a
  shared package set.
- The `hasSpecific*PackageNamesComputation` properties are required to
  avoid caching the same package set in cached symbol names providers
  twice. Because these properties are constant, they can be checked very
  quickly, and no time has to be wasted trying a specific package set
  computation to find out whether it's supported.

### IDE Performance Results

Package set construction performance improved in the IDE in multiple
benchmarks. This improves the performance of symbol providers overall,
which has a direct impact on completion, code analysis, and Find Usages.

In a local manual run of the `intellij_commit/setUp` Find Usages
performance test, the total time spent in `getClassLikeSymbolByClassId`
improved from ~18.7s to ~11.2s. Due to parallel resolve, this does not
translate to a wall clock improvement of 7 seconds, but rather of a few
seconds.

Some performance tests improved markedly in warmup, with for example
`toolbox_enterprise/genUuid` Find Usages having an improvement in
`StubBasedFirDeserializedSymbolProvider.getClassLikeSymbolByClassId`
from 2.4s to 0.2s. This has a direct impact on the first-run performance
of the tested Find Usages command.

So far, classifier package sets in the IDE are only implemented for
libraries, and library sessions are cached after the first warmup.
Because the biggest impact of classifier package sets is avoiding
computation of "class names in package" sets, the impact of this
optimization is not accurately reflected in the timings reported by our
performance tests. `toolbox_enterprise/genUuid` above is a good example,
as the warmup timings are great, but after warmup,
`StubBasedFirDeserializedSymbolProvider.getClassLikeSymbolByClassId`
improved only from 150ms to 70ms.

`toolbox_enterprise/genUuid` is another example, as we can confidently
say that the first-run Find Usages performance has improved (which makes
a difference for the user), but it is unclear by how much, as warmup is
not measured in performance tests.

The same optimization for source sessions will be easier to measure, as
source sessions are invalidated after each performance test run. This
commit lays the groundwork for that as well, because source session
support only requires the requisite package set computation in the
IDE declaration provider to be implemented.

^KT-62553 fixed
2023-12-13 14:40:10 +00:00
Kirill Rakhman 6d1ca3d379 [FIR] Fix CCE in deserialization of suspend function type with star projection continuation
#KT-64148 Fixed
2023-12-13 14:36:01 +00:00
Sergey Bogolepov 01976990e8 [Swift Export] Use ExportedBridge instead of ExportForCppRuntime
ExportedBridge annotation actually does what we need in Swift Export.
Unlike ExportForCppRuntime, it prevents symbol from DCE.
2023-12-13 14:09:58 +00:00
Ilya Chernikov d83027720d minor: K2 IC tests: rename incremental FirIC tests for consistency 2023-12-13 13:40:44 +00:00
Ilya Chernikov a295a34d77 K2 IC tests: reenable incremental tests with PSI
#KT-64228 fixed
2023-12-13 13:40:44 +00:00
Ilya Chernikov ed820d6b57 K2 IC: fix lookup recording for a "red" companion object
#KT-63665 fixed
2023-12-13 13:40:44 +00:00