Commit Graph

108319 Commits

Author SHA1 Message Date
vladislav.grechko cb43f3c805 Fix Symbols::isTypeOfIntrinsic implementation
Function did not work as expected for JVM backend
2024-01-26 18:31:19 +00:00
vladislav.grechko 286196e8b2 Do not use receiver type as GET_OBJECT type when interpreting constants
It is incompatible with type erasure of non-reified type
parameters on inlining (which will be done in future).

See NaNPropagationTest.kt for example.
2024-01-26 18:31:19 +00:00
vladislav.grechko 44caa3cdd5 Do not use dispatch receiver type when calculating method owner
Motivation of using dispatch receiver type when calculating method owner
was discussed here: https://github.com/JetBrains/kotlin/pull/3054

However, this is incompatible with type erasure of non-reified type
parameters on inlining (which will be done in future). Consider the
code:

```
inline fun <T> f(arr:  Array<T>, p: (T) -> Int): Int = p(arr[0])
fun box() = f(arrayOf("abacaba"), String::length)
```

After inlining and erasure, the type of `arr[0]` is `Any`. Thus, when
calculating owner of `String::length` we would have `Any` instead of
`String` if we used dispatch receiver type.

Note, that this change affects bytecode instruction that invokes
method, but does not change which method is being invoked.
2024-01-26 18:31:19 +00:00
Denis.Zharkov ca80ddb8ca K2: Run completion-writer related PCLA tasks for irregular call kinds
- For synthetic calls
- For delegated constructor calls

Also, I checked that for each toResolvedReference() (beside annotations)
that converts candidate to the resolved reference,
we run `runPCLARelatedTasksForCandidate()` in the same context.

^KT-65103 Fixed
2024-01-26 18:13:27 +00:00
Denis.Zharkov 438c55756f K2: Minor. Add kdoc for CalculatorForNestedCall.computeCompletionMode 2024-01-26 16:56:07 +00:00
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