Commit Graph

104963 Commits

Author SHA1 Message Date
Sergej Jaskiewicz a995c522f7 [IR generator] Factor out TypeRef to common module
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz d5394db185 [FIR generator] Factor out AbstractElement to common module
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Sergej Jaskiewicz 977e316489 [FIR generator] Factor out TypeArgument to common module
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-09-22 19:46:14 +00:00
Nikolay Krasko 46cbec7260 Remove kotlinx-collections-immutable-metadata from verification (KT-61766)
For some reason resolution have changed once again after version
switch to 2.0.0
2023-09-22 19:38:37 +00:00
Yan Zhulanow bd6d492b0c [LL API] Compile code fragment together with its context file
Recently, 'KtFirCompilerFacility' started to compile files from
dependent modules separately. Until recently, the code fragment was
in the same module as its context, so they naturally went in the same
compilation round. Now a separate 'KtCodeFragmentModule' is created,
so the code fragment case has to be handled explicitly.

This fixes the following groups of tests:
- FirIdeNormalAnalysisLibrarySourceModuleCompilerFacilityTestGenerated
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated (in IntelliJ)
2023-09-22 19:26:21 +00:00
Dmitrii Krasnov 3074b50e86 Migrated GeneralNativeIT to junit 5 and gradle TestKit 2023-09-22 18:21:46 +00:00
Ilya Kirillov 1ace71a907 [Analysis API] allow completion from non-physical files
Needed for injection

^KTIJ-21127
2023-09-22 17:42:51 +00:00
Vladimir Sukharev 690d18e541 [K/N, Test] Move test code "org.jetbrains.kotlin.konan" -> "org.jetbrains.kotlin.konan.test.*" 2023-09-22 17:27:09 +00:00
Roman Golyshev f5c33ad380 KT-62139 [AA] Remove withValidityAssertion from FE10 implementation of createContextDependentCopy
FIR implementation already does not have this check in
`createContextDependentCopy`, because it's called not
inside `analyze` call, but before it (see
`analyzeInDependedAnalysisSession`)

^KT-62139 Fixed
2023-09-22 14:19:04 +00:00
Kirill Rakhman fbf68a5bcc [FIR] Narrow down range of NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
This uses the same approach as
INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION where we use a visitor
to find a call to a symbol that contains the type variable in question.

#KT-56140 Fixed
2023-09-22 13:49:59 +00:00
Yan Zhulanow 4690a430f4 [LL API] Fix smart-cast collection for special 'FirElement's
'DFANode' is not created for certain elements, such as types or
references. Before the change, only the target element itself was
queried for DFA, making the 'ContextCollector' return an empty map of
smart casts.

^KTIJ-26973 Fixed
2023-09-22 13:40:09 +00:00
Dmitriy Dolovov 6c1711c52a Bump Kotlin/Native version in KGP to 2.0.0-dev-3904 2023-09-22 12:51:02 +00:00
Mikhail Glukhikh ae19cd91bf K2: fix "private to this" determination logic in accordance with K1
#KT-61844 Fixed
2023-09-22 12:23:46 +00:00
Mikhail Glukhikh b9302869d5 K2: reproduce KT-61844 2023-09-22 12:23:46 +00:00
Yan Zhulanow 36df749697 [LL API] Invalidate code fragment sessions on PSI modifications
Code fragments depend not only on their context module, but also on
body of the context declaration.
2023-09-22 12:20:05 +00:00
Yan Zhulanow 1293eb0fab [LL API] Rename 'KtModuleKind' to 'KtModuleResolutionStrategy'
The word "kind" is ambiguous – users might assume the kind is somehow
related to 'KtSourceModule'/'KtScriptModule'.
2023-09-22 12:20:05 +00:00
Yan Zhulanow 0f33f82ffc [LL API] Fix reflective patching for field accesses
Implement the same behavior as in K1 evaluator. Also see
'IRFragmentCompilerCodegen#codegenFactory' in the IntelliJ project.

The commit fixes the following failing tests in the IntelliJ project:
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$CompilingEvaluator$InaccessibleMembers.testPrivateAnnotationCompanionValue
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$CompilingEvaluator$InaccessibleMembers.testSelfMembers
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$CompilingEvaluator$InaccessibleMembers.testOuterMembers
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$Uncategorized.testPrivateMember
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$Uncategorized.testProperties
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$Uncategorized.testPrivatePropertyWithExplicitDefaultGetter
- K2IdeK2CodeKotlinEvaluateExpressionTestGenerated$SingleBreakpoint$Uncategorized.testPrivateClass
2023-09-22 12:20:05 +00:00
Yan Zhulanow fa98945719 [LL API] Remove KtCodeFragment-targeted conflict resolver from libraries
Before, 'KtCodeFragment's were analyzed as a part of their context
session. Now, a separate session is created for each code fragment,
and the LLLibraryScopeAwareCallConflictResolverFactory registration
moved there.
2023-09-22 12:20:05 +00:00
Yan Zhulanow 715f7d1a35 [LL API] Analyze code fragment in a separate 'FirSession'
Before, `KtCodeFragment`/`FirCodeFragment` was analyzed as a part of
its context `KtModule`. This has the following complications:

- In non-source sessions, diagnostic reporting is globally disabled.
  For code fragments, however, checking the code before passing it to
  the backend is essential.

- Special treatment for call ambiguities in libraries
  (`LLLibraryScopeAwareCallConflictResolverFactory`) becomes complicated
  as the conflict resolver has to be applied to a library module.

- `KtCodeFragment`s usually have a shorter lifetime than their own
  context. Caching may potentially be implemented differently for them.

^KT-61783 Fixed
2023-09-22 12:20:05 +00:00
Yan Zhulanow b32c083346 [LL API] Remove leaves of 'LLFirResolvableResolveSession' 2023-09-22 12:20:05 +00:00
Yan Zhulanow f51a7515e1 [LL API] Move 'LLModuleKindProvider' instantiation out 2023-09-22 12:20:05 +00:00
Yan Zhulanow 095dd7d9c3 [LL API] Move 'LLDiagnosticProvider' instantiation out 2023-09-22 12:20:05 +00:00
Yan Zhulanow 68bb39fbcd [LL API] Pass 'LLDiagnosticProvider' to 'LLFirResolveSession' explicitly 2023-09-22 12:20:05 +00:00
Yan Zhulanow b18856dc0a [LL API] Move LLModuleProvider and LLSessionProvider instantiation out 2023-09-22 12:20:05 +00:00
Yan Zhulanow 147712975f [LL API] Remove instance checks for LLFirResolveSession implementations 2023-09-22 12:20:04 +00:00
Yan Zhulanow fee3e696ea [LL API] Move out traits of 'LLFirResolveSession' to separate classes 2023-09-22 12:20:04 +00:00
Yan Zhulanow 25c9ef12df [LL API] Minor, return 'List' from 'getAllDiagnosticsForFile()' 2023-09-22 20:53:26 +09:00
Yan Zhulanow 9ef58f2bdb [LL API] Collect syntax errors in 'KtFirCompilerFacility'
^KTIJ-27167 Fixed
2023-09-22 11:39:49 +00:00
Ilya Chernikov 141333bdcd K2: Update extension receiver after checking in CheckExtensionReceiver
fixes receiver selection when the candidate has more that one possible
extension receiver
#KT-62129 fixed
2023-09-22 11:33:46 +00:00
Vladimir Sukharev 56eedfebee [FIR] K2: Fix disappeared diagnostic UNDERSCORE_USAGE_WITHOUT_BACKTICKS on types
^KT-59985 Fixed

Merge-request: KT-MR-12282
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-22 11:18:19 +00:00
Ilya Kirillov 80f86a3527 [FIR] Render flexible types as A..B instead of cryptic ft<A, B>` in diagnostic messages
^KT-62032 fixed
2023-09-22 10:48:31 +00:00
Ilya Kirillov 252c59a8a3 [FIR] Render k2-specific flexible types in a more compact way in diagnostic messages
^KT-62031 fixed
2023-09-22 10:48:31 +00:00
Ilya Kirillov e2252f5e6b [FIR] add testcase for KT-62031 2023-09-22 10:48:31 +00:00
Ilya Kirillov d98da87278 [FIR] Render dot-separated FQNs instead of slash-separated ones in diagnostics
^KT-62030 fixed
2023-09-22 10:48:31 +00:00
Gavriil Maksyutenko b119b4de02 [Wasm] Return SpiderMonkey in box tests
^KT-61958 fixed
2023-09-22 10:16:31 +00:00
Gavriil Maksyutenko c9ba080383 [Gradle, Wasm] Update jsshell 2023-09-22 10:16:30 +00:00
Vladimir Sukharev 42af684ab7 [FIR] Fix disappeared ILLEGAL_ESCAPE
^KT-59950 Fixed
2023-09-22 08:38:50 +00:00
Nataliya.Valtman e4fc375900 Fix unstable TryK2IT.smokeTestForNativeTasks test
fix test fails with unexpected task execution order


Merge-request: KT-MR-12327
Merged-by: Nataliya Valtman <Nataliya.Valtman@jetbrains.com>
2023-09-22 08:09:32 +00:00
Vladimir Sukharev 70ea0de2db [FIR] Fix some disappeared AMBIGUOUS_ANONYMOUS_TYPE_INFERRED
^KT-59932

Merge-request: KT-MR-12312
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-22 07:47:12 +00:00
Dmitriy Dolovov fa34021a04 [Native][tests] Fix KLIB contents tests 2023-09-22 05:56:22 +00:00
Brian Norman e6669b51d4 [FIR] Check standalone companion object qualifiers are visible 2023-09-21 22:33:50 +00:00
Mikhail Glukhikh 2603077db9 Move independent pre-release tests to K2 group to avoid duplication
Without this commit these tests are run twice without any reason for it.
Related to KT-62058
2023-09-21 20:09:25 +00:00
Mikhail Glukhikh 156097fe17 Restore KotlinCompilerVersion.IS_PRE_RELEASE
This commit is a slightly modified revert of 4f29c113.
IS_PRE_RELEASE allows to make LATEST_STABLE version behave as
experimental when this flag is set to true.
The general goal is to prepare fix of KT-62058; after this commit
one can do it by changing IS_PRE_RELEASE flag to true.
The fix of KT-62058 is planned to be done during bootstrapping.
This preparation and the future fix are parts of umbrella KT-61951.
2023-09-21 20:09:25 +00:00
Dmitrii Gridin 850201a65c [LL FIR] LLFirContractsLazyResolver: avoid transformation for primary constructors
Primary constructors can't have any contracts.
This change also should improve memory consumption because we will
less frequently calculate bodies.

^KT-55750
2023-09-21 20:08:32 +00:00
Dmitrii Gridin d5047bfa90 [LL FIR] LLFirContractsLazyResolver: process synthetic properties correctly
FirContractResolveTransformer under the hood calls
```
if (property is FirSyntheticProperty) {
  transformSimpleFunction(property.getter.delegate, data)
}
```,
so this leads to unsafe transformation of the original function

^KT-55750
2023-09-21 20:08:32 +00:00
Dmitrii Gridin 2962482d75 [LL FIR] LLFirContractsLazyResolver: avoid transformation for delegated properties
Delegated properties can't have any contracts.
This change also should improve memory consumption because we will
less frequently calculate bodies.

^KT-55750
2023-09-21 20:08:31 +00:00
Dmitrii Gridin 3e9e66493f [LL FIR] LLFirContractsLazyResolver: avoid transformation for functions with implicit type
Legacy (current) contracts can exist only on functions with bodies.
This change also should improve memory consumption because we will
less frequently calculate bodies.

^KT-55750
2023-09-21 20:08:31 +00:00
Dmitrii Gridin 3c865bdddd [LL FIR] add lazy resolve tests on function with raw contract and implicit type
^KT-56551
2023-09-21 20:08:31 +00:00
Dmitrii Gridin c0b147e31c [LL FIR] LLFirContractsLazyResolver: drop redundant branch for property accessor
FirPropertyAccessor is not supposed to be processed separately from property

^KT-55750
2023-09-21 20:08:31 +00:00
Dmitrii Gridin a128cbc97a [LL FIR] skip implicit type resolution for declarations without implicit type
This also fixes non-resolved contract calls in the case
of wrong contract description.
And we can avoid body calculation.

^KT-56551
2023-09-21 20:08:31 +00:00