Commit Graph

107224 Commits

Author SHA1 Message Date
Dmitriy Novozhilov f4e3203cd8 [FIR] Unregister java element finders from previous sessions
The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
2023-12-14 09:51:15 +00:00
Anastasia.Nekrasova e58b5e7d22 K2: change resolution for deprecated actual declaration
This commit addresses a scenario where an 'actual' declaration is marked
with a Deprecated annotation at the 'Hidden' level, while the
corresponding 'expect' declaration is not. When resolving,
'CheckHiddenDeclaration' marks the 'actual' declaration as unsuccessful,
leading to the selection of the 'expect' declaration as the successful
candidate.

'FirDeprecationChecker' handles a case where an 'actual' class is
annotated with Deprecated, but the 'expect' class is not. During the
checking of the 'actual' class constructor, 'CheckHiddenDeclaration'
skips it due to the absence of a direct Deprecated annotation.
'FirDeprecationChecker' then identifies this constructor and reports a
DEPRECATION_ERROR.

'FirDeprecationChecker' will now be applied to solving problems related
to 'actual' declarations with corresponding Deprecated annotations. The
process remains the same: 'CheckHiddenDeclaration' will skip the
'actual' declaration, and then 'FirDeprecationChecker' will identify it
and report the error.

^KT-61792 Fixed
2023-12-14 09:21:43 +00:00
Svyatoslav Scherbina 2cdf8cd7b1 Native: support Objective-C instancetype in more cases in cinterop
Objective-C has a special type, "instancetype". Generally, it is a type
that matches the method receiver type. So, if `Foo.foo` method returns
`instancetype`, then `Foo.foo()` would be of type `Foo`, while
`Bar.foo()` would be of type `Bar` (where `Bar` is a subclass of `Foo`).

Surprisingly, `instancetype` can be used not only as a return type, but
also somewhere inside a return type. cinterop wasn't ready for this.

This commit expands implementation of `instancetype` in cinterop to
cover more cases.

^KT-59597 Fixed
2023-12-14 08:57:29 +00:00
Dmitriy Novozhilov 149e1e02f6 [FIR2IR] Simplify building of declarations list for Fir2IrLazyClass 2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 533d824eb3 [FIR2IR] Minor: simplify function in FakeOverrideGenerator 2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 39063e59f6 [FIR2IR] Treat assignment on smartcasted this in classes using FIR instead of IR
KT-57105
2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 56a48b1148 [Test] Add missing WITH_STDLIB directive to test
This particular test references kotlin.reflect.KProperty1 both in
  common and platform sourceset. And if there is no stdlib in dependecies
  it resolves to KProperty1 from builstins, which is expect (see KT-64061),
  which leads to broken expectations that after IR actualization there
  are no referenced expect classes
2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov f5028bfc27 [Test] Reformat test for KT-57105 and add an additional case to it 2023-12-14 08:32:58 +00:00
Pavel Kunyavskiy 8e047e6d8a [FIR2IR] Make all source sets friends for IrFakeOverrideBuilder
^KT-63644
2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 60d77fbb90 [FIR2IR] Fix left usages of symbol.owner in DelegatedMemberGenerator 2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov da531bc261 [FIR2IR] Don't access symbol.owner in DataClassMembersGenerator 2023-12-14 08:32:58 +00:00
Vladimir Sukharev 50f1ea79c5 [Tests] Detect frontend type within FirIrDumpIdenticalChecker
^KT-64256 Fixed
2023-12-13 22:39:46 +00:00
Vladimir Sukharev 82c5b745e2 [Tests] Adjust FirIdenticalCheckerHelper behavior in case .ir.txt file is absent
.ir.txt file may be absent for the following test kinds with // DUMP_IR
- codegen tests with // IGNORE_BACKEND_K1: ANY
- FirScriptCodegenTestGenerated, since it does not have K1 counterpart
- Fir*PluginBlackBoxCodegenTestGenerated, since it does not have K1 counterpart

^KT-64256 Fixed
2023-12-13 22:39:46 +00:00
Vladimir Sukharev ec3dd43edc [Tests] Enforce FIR_IDENTICAL for Fir tests with IrTextDumpHandler
^KT-64256 Fixed
2023-12-13 22:39:45 +00:00
Dmitriy Dolovov cbf21acede IR text tests: Don't dump signature mangled names for IR-based descriptors
^KT-57788
2023-12-13 21:33:26 +00:00
Yan Zhulanow 07aad38c69 [Analysis API] Do not hold a reference to 'KtCodeFragment' from modules
'KtModule' references may be cached for indefinite time. If so,
unused fake documents will wait long before being cleaned up.

^KT-62562 Fixed
2023-12-13 20:29:39 +00:00
Vladimir Sukharev a59742258e [K/N] Speedup test CInterop/executable/bitfields/ 2023-12-13 19:06:57 +00:00
Artem Kobzar 1473b4bb41 [K/Wasm] Introduce JsBigInt type 2023-12-13 18:44:57 +00:00
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