Commit Graph

4918 Commits

Author SHA1 Message Date
Ivan Kochurkin 2d4f4b9bb5 [FIR] Disallow operators not on functions
Introduce `NOT_FUNCTION_AS_OPERATOR` and use it instead of `PROPERTY_AS_OPERATOR`

^KT-65881 Fixed

Merge-request: KT-MR-14547
2024-03-08 10:07:23 +00:00
Nikolay Lunyak 7f12af9452 [FIR] Ensure KT-66161 is not reproducible in the compiler
^KT-66161


Merge-request: KT-MR-14730
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-03-07 15:10:18 +00:00
Dmitrii Gridin 8cc2208c00 [LL FIR] support lazy resolution tests for scripts with custom definition
^KT-66276
^KT-66232
2024-03-07 12:50:59 +00:00
Dmitrii Gridin d5cfea330b [LL FIR] support parameters resolution
Script parameters now can be resolved independently of the script.
But, as parameters are part of the script, their resolve will be called
before the script.

^KT-66276 Fixed
2024-03-07 12:50:59 +00:00
Dmitrii Gridin 150af66b55 [LL FIR] implement diagnostic tests on custom script definitions
it is impossible to declare test data with another output yet
as `myScriptFile.test.ll.kts` won't be treated as custom definition as
it requires `test.kts` extension.

^KT-66232 Fixed
^KT-66276
2024-03-07 12:50:59 +00:00
Dmitrii Gridin 204465132f [LL FIR] AbstractLLFirBlackBoxCodegenBasedTestBase: unify logic
^KT-66232
2024-03-07 12:50:59 +00:00
Dmitrii Gridin dd0d2168fc [LL FIR] rename AbstractCompilerBasedTestForFir to AbstractLowLevelCompilerBasedTest
^KT-66232
2024-03-07 12:50:59 +00:00
Dmitrii Gridin d6b3f6f352 [LL FIR] AbstractCompilerBasedTestForFir: convert receiver to parameter
to allow using super call from implementations

^KT-66232
2024-03-07 12:50:59 +00:00
Dmitriy Novozhilov 4b5eac7816 [Test] Add regression tests for issues which are fixed in K2
Related issues:
KT-10879, KT-18055, KT-20617, KT-23873
KT-25668, KT-31191, KT-33108, KT-41013
KT-51827, KT-53886, KT-56624, KT-58447
KT-58458, KT-58751, KT-58814, KT-60597
KT-62806, KT-63258, KT-63444, KT-65101
KT-65408, KT-65844, KT-66186

^KT-65926 Fixed
2024-03-07 12:49:47 +00:00
Dmitriy Novozhilov b875ae774e [FIR] Unwrap captured types in target type of SAM conversion
^KT-66256 Fixed
2024-03-07 12:41:05 +00:00
Yan Zhulanow 690f39b91c [Analysis API] Minor, refactor 'createDumbVirtualFile()'
Pass the file name explicitly, and refine the dumb 'VirtualFile'
implementation.
2024-03-07 12:14:19 +00:00
Jinseong Jeon de4cce8dc8 AA: add support VirtualFile inputs to source module
^KT-65571 fixed
2024-03-07 12:14:19 +00:00
Jinseong Jeon 520ae725d1 Add test about dependsOn dependency and stdlib-common 2024-03-07 12:14:19 +00:00
Jinseong Jeon 6c062b0cea Add test about resolution to klib from non/common platforms 2024-03-07 12:14:19 +00:00
Jinseong Jeon 7f33097634 Fix typo in test input file name 2024-03-07 12:14:19 +00:00
Vladimir Sukharev a9af52c288 [Tests] Add test for KT-44199
^KT-44199 Fixed
2024-03-07 11:36:49 +00:00
Mikhail Glukhikh c04a8fc3b8 K1/K2: add test cases for KT-53792 and KT-66369 2024-03-07 10:25:11 +00:00
Jinseong Jeon f3ed9476a3 SLC: remove unused/redundant utils
KtTypeInfoProvider has many other variants like that,
e.g., KtType.(isUnit | isInt | isLong | ...)
2024-03-07 10:17:01 +00:00
Jinseong Jeon afd20b0c2d SLC: honor wildcard suppression on declarations
^KT-61734 fixed
2024-03-07 10:17:00 +00:00
Jinseong Jeon 9c16c52564 AA: pass wildcard suppression hints on declarations
^KT-61734
2024-03-07 10:17:00 +00:00
Jinseong Jeon d089db5a45 AA: honor wildcard suppression on type during type conversion
^KT-61734
2024-03-07 10:16:59 +00:00
Jinseong Jeon d4d2bae630 AA: add tests about wildcard suppress
^KT-61734
2024-03-07 10:16:58 +00:00
Anastasia.Nekrasova 1bb6f869a2 [K2]: Compiler crashes when array literal is used in delegate expression
FirCallResolver tries to find a
candidate for the delegate's getValue and cannot parse an arrayLiteral
with a nullable coneType.Running
FirCallCompletionResultsWriterTransformer.transformArrayLiteral is
required to find the result type. Therefore, completeCall should not be
invoked with the ResolutionMode from the 'data' param, but rather in
ResolutionMode.ContextIndependent.

#KT-65022 Fixed
2024-03-07 08:57:24 +00:00
Vladimir Sukharev b4bc576d37 [Tests] Add test for kt33411
^KT-33411 Fixed


Merge-request: KT-MR-14782
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2024-03-07 08:46:05 +00:00
Dmitrii Gridin 928fb94052 [FIR] fix internal error on suspend conversion with not-computed return type
^KT-62836 Fixed
2024-03-07 07:49:44 +00:00
Dmitrii Gridin f4096ae8e9 [FIR] add test case on more suspend conversion with more specific implicit type
^KT-62836
2024-03-07 07:49:44 +00:00
Dmitrii Gridin edd9f0348e [LL FIR] LLFirReturnTypeCalculatorWithJump: add checkCanceled
`tryCalculateReturnTypeOrNull` is the entry point for foreign symbols
resolution. We already have `checkCanceled` inside `lazyResolveToPhase`
and `checkIsResolved`, but in this case we will cover cases where
everything around is already resolved

^KTIJ-27504
2024-03-07 07:43:40 +00:00
Jinseong Jeon b47a33cf9d Back to getOrDefault test
The main purpose was to test getOrDefault w/ non/null value does not
bother the resolution. To be aligned with test file
mapGetOrDefault_nullable.kt, this one should test getOrDefault too.
All we needed was // WITH_STDLIB
2024-03-06 19:26:52 +00:00
Denis.Zharkov b7129f78a3 K2: Fix IAE at Candidate.updateSourcesOfReceivers inside PCLA lambda
Previously, it was failing at line
(resolvedReceiver?.toReference(session) as? FirNamedReferenceWithCandidate)?.candidate?.updateSourcesOfReceivers()

But this line was mostly incorrect because in case of `a.b()` call,
which is resolved to `a.b.invoke()`, `resolvedReceiver` is pointing to
`a` instead of obviously expected `a.b`.

The fix with using `candidate.callInfo.explicitReceiver` doesn't help
either because the candidate of that receiver is always completed at
that stage (so no Candidate there).

The only case when the candidate was still there is PCLA because
 in that case we explicitly don't fully complete even receiver
expressions.
(see docs/fir/pcla.md)

The idea of the fix is moving the call of `updateSourcesOfReceivers`
for invoke property receiver to the place just before the candidate
is being converted to the resolved reference
(i.e., the candidate is being lost)

^KT-66148 Fixed
2024-03-06 17:01:57 +00:00
Dmitrii Gridin 9ea9950d28 [LL FIR] Replace IGNORE_DIAGNOSTIC_API with IGNORE_NON_REVERSED_RESOLVE 2024-03-06 16:13:09 +00:00
Dmitrii Gridin 28c80a1581 [LL FIR] StubBasedFirMemberDeserializer: add missed deprecation provider
^KT-60996 Fixed
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 805b7bc8f4 [Analysis API] add diagnostic tests on deprecated declarations
^KT-60996
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 9cc2c22116 [Analysis API] drop obsolete tests
They were renamed during 2ce324f1fc,
but old wasn't dropped
2024-03-06 16:09:43 +00:00
Dmitrii Gridin 1ba81fca57 [Analysis API] add tests on incomplete function type parameter symbol
^KT-65858 Obsolete
2024-03-06 16:09:43 +00:00
Dmitrii Gridin ca740b70f3 [LL FIR] LLFirLazyResolver: inline updatePhaseForDeclarationInternals
This is the responsibility of `LLFirTargetResolver` to call it
2024-03-06 16:06:21 +00:00
Dmitrii Gridin 141b187e37 [LL FIR] encapsulate checkIsResolved for LLFirResolveTarget
In this way, only `LLFirLazyResolver` will be responsible for running
and checking the resolution result.
Also, this commit replaces redundant `checkIsResolved` for
`LLFirResolveTarget` with cheaper `checkIsResolved` for declarations.
2024-03-06 16:06:21 +00:00
Dmitrii Gridin c4bb5c6d8f [LL FIR] mark LLFirTargetResolver and LLFirLazyResolver as sealed as we know hierarchy 2024-03-06 16:06:21 +00:00
Dmitrii Gridin 4db10a1d94 [LL FIR] drop ability to enable global phase lock
Also, this commit adds the missing global lock for `IMPORTS` phase.

This commit doesn't change any logic for the case with disabled lock
(the default case), only updates the case with enabled lock.

^KT-66306 Fixed
2024-03-06 16:06:21 +00:00
Dmitrii Gridin 2229c82dc4 [LL FIR] additional checkCanceled after resolution
We have explicit cancellation checks between phases and inside locks,
so it is worth adding the check after `checkIsResolved`
2024-03-06 16:06:21 +00:00
Dmitrii Gridin 8c320f0602 [LL FIR] LLFirTargetResolver: add more debug info for containingClass
^KT-66132
2024-03-06 14:44:07 +00:00
Dmitriy Novozhilov fece081265 [Test] Reproduce KT-66313 2024-03-06 11:56:01 +00:00
Ivan Kylchik 5fe3fa878e [Test] Fix LL FIR test data after introducing new CONSTANT_EVALUATION phase
#KT-64151
2024-03-06 11:35:41 +00:00
Ivan Kylchik ada47eb110 [K2] Add new resolve phase CONSTANT_EVALUATION
During this phase, the compiler will evaluate initializers of
const properties and defaults of annotation's constructor.
Evaluation results will be stored in corresponding attributes.

#KT-64151
2024-03-06 11:35:41 +00:00
Mikhail Glukhikh 5ea6f20192 K1/K2: add reproducers for KT-66229, KT-66243 and KT-66272
As all these issues aren't reproducible in K2, we may count them as fixed.
Related to KT-53478
#KT-66229 Fixed
#KT-66243 Fixed
#KT-66272 Fixed
2024-03-06 09:01:38 +00:00
Kirill Rakhman 4c93e9cff6 [FIR] Fix captured type arguments of local class as callable reference LHS
#KT-66267
2024-03-06 08:22:42 +00:00
Dmitriy Novozhilov 624bea3ecf [FIR] Never create ConeSubstitutorByMap with empty substitution
Relates to KT-66323
2024-03-06 06:40:28 +00:00
Mikhail Glukhikh e8ba534904 K1/K2: add tests confirming behavior of remaining KT-63242 cases 2024-03-05 20:19:02 +00:00
Kirill Rakhman 69a7bf7f68 [FIR] Add equality constraint from expected type for some synthetic function calls
This fixes some cases where we infer some type variable inside one
of the branches to Nothing instead of the expected type because Nothing
appeared in some other branch.

Specifically, we add an equality instead of a subtype constraint during
completion of calls to synthetic functions for if/when, try and !!.
We don't do it when the call contains a (possibly nested) elvis or is
inside the RHS of an assignment.
Otherwise, we would prevent some smart-casts.

#KT-65882 Fixed
2024-03-05 17:38:59 +00:00
Mikhail Glukhikh a77a1cf3db K1/K2: add test confirming correct work of KT-63487 case 2024-03-05 14:51:15 +00:00
Vladimir Sukharev 848cca03c0 [Tests] Add tests for KT-40180
^KT-40180 Fixed
2024-03-05 13:37:26 +00:00