Commit Graph

108314 Commits

Author SHA1 Message Date
Denis.Zharkov 09b6bbc5e3 K2: Get rid of AugmentedAssignmentCallOption resolution mode
It's been used only for regular function call nodes resolution,
so I made it more explicit.

The main idea behind this change is ResolutionMode hierarchy
simplification and the kind of statement
that "AugmentedAssignmentCallOption" is only relevant to calls.

Instead, CallResolutionMode is introduced that is only used for
`transformFunctionCallInternal` call sites.
2024-01-26 16:56:07 +00:00
Denis.Zharkov df2a1d4d02 K2: Refine handling of Delegate resolution mode
- Move it out of the ContextDependent hierarchy
- Get rid of many controversial checks that were necessary because
Delegate was a ContextDependent inheritor
- Actually fix semantics for lambda processing

Previously, lambdas as delegate expression were not being analyzed
thus leading to an exception (see KT-64635), and this change
forces analyzing them in the same mode as ContextIndependent
(thus `{}` made by default `() -> Unit` leaving to DELEGATE_SPECIAL_FUNCTION_MISSING)

Before this change, new test was failing with an exception.

I've analyzed all `is ContextDependent` and it seems that none of them
is relevant to delegates.

^KT-64635 Fixed
2024-01-26 16:56:07 +00:00
Nikolay Lunyak 47a51f6499 [FIR] Fix failing Space build
Build failure was introduced by `9b786d35`,
where I forgot that typealiases exist.

^KT-64891
^KT-65336 Fixed

Merge-request: KT-MR-14087
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-26 16:32:18 +00:00
Artem Kobzar a593936b8a [K/Wasm] Fix stepping tests flakiness with reading stdout until it is empty 2024-01-26 16:20:41 +00:00
Ilya Kirillov db7e58ef35 [Analysis API FE1.0] support calling analyze with KtModule in FE10 implementation
^KT-65307 fixed
2024-01-26 16:20:19 +00:00
Sebastian Sellmair 0db8931026 [ObjCExport] Implement 'TodoAnalysisApi' annotation and run AA based tests as part of ':native:objcexport-header-generator:check'
^KT-65281 Fixed
^KT-65108 Fixed
2024-01-26 16:19:20 +00:00
Evgeniy.Zhelenskiy 55adeba011 [FIR] Include anonymous objects in containingDeclarations in FirDeclarationsResolveTransformer.kt
K1 and K2 still differ because of KT-58203

#KT-63434
2024-01-26 16:08:45 +00:00
Sonya Valchuk eb23984182 AA FIR: have KtFirReceiverParameterSymbol implement KtFirSymbol
Aside from making the code shorter, this allows for correct equals/hashCode.
2024-01-26 16:07:57 +00:00
Ivan Kylchik 69c83698fb [Native] Add K2 version of LLDB tests 2024-01-26 15:54:41 +00:00
Ivan Kylchik 2ded62c53e [Native] Drop LLDB_TRACE test directive
This directive doesn't have a lot of meaning. It is always set this
way that we are getting text file with the same name as test file.
2024-01-26 15:54:41 +00:00
Ilya Goncharov d18660c8f1 [Gradle, JS] Add npm support but default Yarn package manager left
Co-authored-by: Alexander Likhachev <Alexander.Likhachev@jetbrains.com>


^KT-64119 fixed
2024-01-26 13:38:23 +00:00
Roman Golyshev f9348c69ba KT-62695 [AA] Refactor KDocReferenceResolver.findParentSymbol
Avoid traversing parents when there are none
2024-01-26 10:12:09 +00:00
Roman Golyshev d45662c2c3 KT-62695 [AA] Better resolve ambiguous receiver types in KDocReferenceResolver
When encountering multiple available same named types,
resolve all of them together with corresponding extensions.
This aligns well with the current resolve behavior of classes
with the same name (see `SameNameClassesFromStarImports.kt`)

Also, add extra test for resolving the ambiguous type without
the extension function. The behavior is the same - resolve to the
both classes.
2024-01-26 10:12:09 +00:00
Roman Golyshev e5c6a5bac3 [tests] Clean-up AbstractReferenceResolveTest.kt
Extract local `getRenderedReferencesForCaretPosition` function
into a member function for clarity
2024-01-26 10:12:09 +00:00
Roman Golyshev fb225f5f20 [tests] Return caret names from ExpressionMarkerProvider
Render caret names in resolve testData, so that we don't have to guess
the indices of the carets;
it makes the multi-caret testData less error-prone.

Relevant for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 2befd2bffb KT-62695 [AA] Implement resolution of extension functions in KDoc
The solution is not complete, since resolution of KDocs is not
fully specified and is rather tricky.
Many more corner cases are to be expected.
This solution should at least give some groundwork for the future
improvements/fixes of the resolver.

^KT-62695 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev 42753c461f KT-62695 [AA] Add ResolveResult data class to KDocReferenceResolver
It's a part of implementation; it will be required to properly navigate
from resolved extension function to its receiver type, since receiver
type cannot be properly inferred from the function symbol itself
2024-01-26 10:12:09 +00:00
Roman Golyshev f9d4a35d80 KT-62695 [AA] Preliminary set of tests for extensions resolve 2024-01-26 10:12:09 +00:00
Roman Golyshev c0d54f9bbf KT-65152 [AA] Add extra test for package resolution
Make sure that, when ambiguous, both the package
and the callable/class/property are resolved from
KDoc reference.

Do a slight refactoring of `KDocReferenceResolver`

This behavior is also true for K1
2024-01-26 10:12:09 +00:00
Roman Golyshev f402daba98 KT-65152 [AA] Fix resolve of partial package qualifiers in KDocs
^KT-65152 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev 38e0b154c3 KT-65152 [AA] Add resolve testData for a package with multiple qualifiers resolve 2024-01-26 10:12:09 +00:00
Roman Golyshev ec97659462 [tests] Refactor AbstractReferenceResolveTest. Part 4
Allow multiple carets to be used in reference resolve tests.
Adjust the testdata for the only test case which has actually
had multiple carets in it.

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 17c1352d82 [tests] Refactor AbstractReferenceResolveTest. Part 3
Add possibility to `ExpressionMarkerProvider` to get all the carets
from the file.
Use it in `AbstractReferenceResolveTest`, but not check all the carets
yet.

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 0c70119637 [tests] Refactor AbstractReferenceResolveTest. Part 2
Extract processing a single caret into a function, so it would be
easier to process multiple carets in the future

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 304112cd8a [tests] Refactor AbstractReferenceResolveTest. Part 1
Instead of relying on UNRESOLVED_REFERENCE directive for the whole file,
just render the unresolved reference right in the .txt testdata

This will allow to introduce multi-caret resolve testdata more naturally

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Sebastian Sellmair c958aef679 [ObjCExport] Initial implementation of function type translation
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 3766a5f2ad [ObjCExport][Minor] Move 'isBinaryRepresentationNullable' utility to bottom of translateToObjCType.kt
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 9f0aa7d30c [ObjCExport] Use K1 convention and do not mark KtErrorType as nullable
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 2bf7bbb6c1 [ObjCExport] Support mapping of ObjCObject types to id
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 3cd20bd7b0 [ObjCExport] Support generic type parameters for ObjC translation
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 3111678f8b [ObjCExport] Support nullable type arguments in translating known Collection types
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 858af02a24 [ObjCExport] Initial support for inline classes in type mapping
^KT-65167
2024-01-26 10:11:48 +00:00
Sebastian Sellmair 262bfb18cc [ObjCExport] Initial support for ObjCClassType type arguments
^KT-65167
2024-01-26 08:19:05 +01:00
Sebastian Sellmair a6a27466fc [ObjCExport] Fix emission of 'ValueTypeBridge' for 'non primitive' types
^KT-65167
2024-01-26 08:19:05 +01:00
Sebastian Sellmair 8fbf0f21c8 [ObjCExport] Implement ObjCExportHeaderGeneratorTesttest - topLevelFunctionWithNumberReturn
^KT-65167
2024-01-26 08:19:05 +01:00
Sebastian Sellmair 1912ffded6 [ObjCExport] Implement ObjCExportTypeTranslationTest
^KT-65167
2024-01-26 08:19:05 +01:00
Sebastian Sellmair de4380cd4e [CODEOWNERS] 'objcexport-header-generator' Share ownership between K/N and KiF teams 2024-01-26 07:01:58 +00:00
Simon Ogorodnik 3f4d2e93c6 K2. Minor. Rename CFG ConstExpressionNode to LiteralExpressionNode
^KT-64314
2024-01-25 23:05:15 +00:00
Simon Ogorodnik 53e89a9722 K2. Minor. Rename FirConstExpression to FirLiteralExpression
FirConstExpression is usually confused with "constant" calculations,
while in fact, it just denotes a simple literal expression
and `1 + 1` isn't represented by a FirConstExpression.

^KT-64314 Fixed
2024-01-25 23:05:15 +00:00
Kirill Rakhman 213967e25c [Tests] Fix incorrect code in tests 2024-01-25 15:55:19 +00:00
Kirill Rakhman b509d8efc2 [FIR] Replace Enum.values() with entries call 2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov 3fba3b703e [FIR] Update call-sites which are interested in annotation arguments
After the previous commit, enum entry access to the annotation may be
  presented by two different nodes

^KT-64975
2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov a4e8be8687 [FIR] Deserialize enum entries access in annotations into FirEnumEntryDeserializedAccessExpression
^KT-64975 Fixed
^KT-62900
2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov 150ff1172e [FIR] Add session parameter to all "element --> reference" utilities
`FirDeserializedEnumAccessExpression` requires session to build proper
  reference, so it's important to have it in all utilities, which may
  pass this element as input

^KT-64975
2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov bd9cb2b7e0 [FIR] Refactor val FirElement.calleeReference utility
1. Convert it to `toReference()` function to make it consistent with other
   similar utilities
2. Provide the proper implementation

^KT-64975
2024-01-25 15:55:19 +00:00
Dmitriy Novozhilov 36958d585f [FIR] Move reference-related utils from :fir:tree to :fir:semantics
This is needed to gain access to providers functionality in those
  utilities, which is important for support of FirDeserializedEnumAccessExpression
  node (see later commits)

^KT-64975
2024-01-25 15:55:19 +00:00
Svyatoslav Scherbina 2e5a9b1416 [K/N] Make cinterop include unused Objective-C forward declarations
Previously, when an Objective-C library had an unused Objective-C
forward declaration (`@class` or `@protocol`), cinterop tool didn't
include it into the resulting klib at all.

This led to a subtle bug (KT-64105). One Obj-C library has unused
Obj-C forward declaration, and another one depends on the first and
uses this forward declaration, e.g. as a function result type.
When building the first cinterop klib, this forward declaration is not
added to `includedForwardDeclarations` in the klib manifest (the
compiler uses this property to decide whether to synthesize the
corresponding class).
When building the second cinterop klib, the forward declaration is not
added to its manifest either, because it is located in the dependency
(and therefore should've been included there).
As a result, the forward declaration is included nowhere, and any
attempt to use it in Kotlin fails, including calling the function from
the second lib.

This commit fixes this bug by including even unused Objective-C forward
declarations, which is consistent with any other kind of declarations
and seems more natural.

^KT-64105 Fixed
2024-01-25 14:06:10 +00:00
Svyatoslav Scherbina 59142b3051 [K/N][tests] Fix using objcnames package in grouped tests
Native test infra groups individual tests into compilations, so it
renames packages, patching package and import directives, to avoid
clashes.
This doesn't include "standard" packages. They are distinguished by a
predicate defined in the test infra. This predicate didn't include
`objcnames.*` -- synthetic package provided by the compiler.
As a result, tests importing from `objcnames.*` got those import
directives patched, which was unexpected and could make tests fail.

This commit fixes the problem, making `objnames.*` recognized as
a "standard" package.
2024-01-25 14:06:10 +00:00
Svyatoslav Scherbina ffb0b063a8 [K/N][tests] Support dependencies for cinterop modules
When building cinterop klibs, cinterop tool can accept dependencies,
which affects the way it processes the native library.
The test infrastructure allowed to specify cinterop module dependencies,
but didn't actually pass them to the tool.
This commit fixes that.
2024-01-25 14:06:10 +00:00
Anastasiia Spaseeva 945f602b91 Revert "[Wasm] Support lazy associated object initialisation"
This reverts commit 552ee1ee38.
2024-01-25 14:11:56 +01:00