Commit Graph

108347 Commits

Author SHA1 Message Date
Brian Norman bb6f466162 [FIR] Do not smartcast class delegation implemented properties
When a property is implemented via class delegation, it should be
considered unstable for smart-casting. This is because it is unknown
what kind of stability the underlying class delegate property has. It
could be a stable property, or it could be implemented via a custom
getter and unstable.

^KT-57417 Fixed
2024-01-29 14:20:11 +00:00
Alexander Shabalin ce291b45b9 [K/N][tests] Cache executors based on testTarget 2024-01-29 14:12:14 +00:00
Alexander Shabalin 65abb5de46 [K/N][tests] Remove now unused LocalTestRunner 2024-01-29 14:12:14 +00:00
Alexander Shabalin f2ba4a3e6e [K/N][tests] Use HostExecutor in new test infra 2024-01-29 14:12:14 +00:00
Roman Efremov 8c000b8319 [LightTree] Stop reporting LOCAL_VARIABLE_WITH_TYPE_PARAMETERS on
...destructuring declarations to make it similar to PSI.

^KT-62704
2024-01-29 14:09:59 +00:00
Roman Efremov d22cc01638 [LightTree] Stop reporting NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER on
...local properties to make it similar to PSI.

See this logic in `org.jetbrains.kotlin.fir.builder.PsiRawFirBuilder.Visitor.toFirProperty`

^KT-62704
2024-01-29 14:09:59 +00:00
Roman Efremov 3c8855c152 [LightTree] Fix positioning of VAR_TYPE_MISMATCH_ON_OVERRIDE in LT
The problem is that `override var b: String` in constructor has token
type `VALUE_PARAMETER`, thus was not considered as declaration.

^KT-62704
2024-01-29 14:09:59 +00:00
Roman Efremov 8edb1842a5 [Tests] Add spec tests in FIR + LightTree configuration
In some tests PSI and LT differ. Test data was fixed accordingly.

In the following tests I consider that difference is acceptable:
- compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/3.1.kt
- compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/4.1.kt

This is because:
- It only happens when recovering from syntax errors happened above in
code. I was unable to reproduce it in valid code.
- It doesn't break parsing further, the rest of the errors in file are
reported identically.

The rest of the tests will be fixed in subsequent commits.

^KT-62704 Fixed
2024-01-29 14:09:59 +00:00
Roman Efremov 18b9cf3bc6 [Tests] Update spec tests autogenerated files
Just run `./gradlew generateSpecTests`.

^KT-62704
2024-01-29 14:09:59 +00:00
Nataliya.Valtman fc8c6dadc9 Don't run testProjectWithBuildSrcForGradleVersion7 on windows
#KT-65227
2024-01-29 14:04:51 +00:00
Alexander Udalov 7ca2df3ff9 Kapt: minor, remove unneeded check
Most likely it has been made obsolete by KT-27936 where we started to
generate all inner class names correctly.

 #KT-61080 Fixed
2024-01-29 12:58:06 +00:00
Artem Kobzar 1fe77705b0 [K/Wasm] Convert non-capturing lambdas into singletons ^KT-64803 Fixed 2024-01-29 12:52:18 +00:00
Dmitrii Gridin e03f8b503f [LL FIR] implement lock resolution algorithm for jumping phases
This commit extends `LLFirLockProvider` API functionality to provide
`withJumpingLock`, which can be safely used in multithreaded scenarios.
Comparing to regular `withWriteLock`/`withReadLock`, the new API has a
bit more overhead as we have to maintain `jumpingResolutionStatesStack`
and `FirInProcessOfResolvingToJumpingPhaseState` even without contention.
See KDoc of `LLFirLockProvider#withJumpingLockImpl` for implementation
details.

The implicit type phase has been migrated to the new approach, so
now it is safe to drop the last global phase lock.
Potentially, we can have some benefits from migration of other
jumping phases to this API.

^KT-56551 Fixed
^KT-55750 Fixed
2024-01-29 12:39:09 +00:00
Dmitrii Gridin 58ed52ee1f [LL FIR] LLFirTargetResolver: drop withPossiblyJumpingLock function
We should have explicit separation for jumping and non-jumping

^KT-56551
2024-01-29 12:39:09 +00:00
Dmitrii Gridin 0a55cfebd5 [LL FIR] LLFirLockProvider: cleanup code
^KT-56551
2024-01-29 12:39:09 +00:00
Dmitrii Gridin 92fc3ec824 [LL FIR] LLFirLockProvider: add registry key to disable global phase lock
It is enabled by default

^KT-56551
2024-01-29 12:39:09 +00:00
Dmitrii Gridin 53c4a10817 [FIR] FirImplicitBodyResolve: extract recursive error into a function
to be able to reuse it from Low Level FIR later

^KT-56551
2024-01-29 12:39:09 +00:00
Artem Olkov de6a27aeeb KT-65123: move Swift Export Compiler Plugin into swift-export-standalone module
Merge-request: KT-MR-14031
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2024-01-29 10:32:09 +00:00
aleksandrina-streltsova d935db9e3a [Analysis API] render enhanced types
^KTIJ-28555 Fixed
2024-01-29 09:37:59 +00:00
Anna Kozlova 69fe60f494 [psi] avoid usages of KtFile in kotlin psi
^KT-65223 fixed
2024-01-29 08:16:59 +00:00
Anastasia.Nekrasova ee143e9370 [K2]: compiler crash on unresolved delegated extention receiver
A report of UNRESOLVED_REFERENCE should not be made for elements like
FirImplicitThisReference that don't have a source, as they are implicit.

#KT-65044 Fixed
2024-01-29 07:59:13 +00:00
Anastasia.Nekrasova 1d817e2ace [K2]: Missing error and miscompilation in destructuring declaration delegation
In convertDestructingDeclaration, property delegates are mistakenly
treated as valid expressions for destructuring, but they should be
ignored.

#KT-65021 Fixed
2024-01-29 07:56:43 +00:00
Evgeniy.Zhelenskiy b0367d9399 [Reflection] Support callBy for inline class interface functions with default parameters
#KT-57972
2024-01-29 04:04:59 +00:00
vladislav.grechko 1e7cc00dcb [FIR] Serialize type annotations of vararg parameters in metadata
^KT-63899: Fixed
2024-01-28 22:10:05 +00:00
Yan Zhulanow 36d5ffd4eb Revert "AA FIR: have KtFirReceiverParameterSymbol implement KtFirSymbol"
The commit is reverted due to failing tests:
    - FirGotoTypeDeclarationTestGenerated
    - FirGotoDeclarationTestGenerated

This reverts commit eb23984182.
2024-01-27 15:56:27 +09:00
Alexander Shabalin c821c8fe6e [K/N] Add runProcess convenience function to executors 2024-01-26 22:18:05 +00:00
vladislav.grechko f318b5969d Erase non-reified type parameters by-default when inlining.
Substitution of type arguments to non-reified type parameters may lead
to accidental reification, which should not be done (see ^KT-60174 for
examples). So, we should erase them, except the few cases.

^KT-60174: Fixed
^KT-60175: Fixed
2024-01-26 18:31:20 +00:00
vladislav.grechko 29ecc4d987 Minor: refactor ApiVersionIsAtLeastEvaluationLowering 2024-01-26 18:31:19 +00:00
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