Commit Graph

7781 Commits

Author SHA1 Message Date
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
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
Mikhail Glukhikh c04a8fc3b8 K1/K2: add test cases for KT-53792 and KT-66369 2024-03-07 10:25:11 +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
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 ae9c9b051f [FIR] do not use MUTE_LL_FIR for multiplatform tests 2024-03-06 16:13:09 +00:00
Dmitrii Gridin c090ae96ab [LL FIR] update attached issue
^KT-66352
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 124453016d [LL FIR] Replace IGNORE_REVERSED_RESOLVE + IGNORE_NON_REVERSED_RESOLVE with MUTE_LL_FIR 2024-03-06 16:13:09 +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
Dmitriy Novozhilov e989e6d397 [FIR] Don't compute getter return type if synthetic property is inapplicable
Return type computation of getter for synthetic property, which is
  incompatible anyway (e.g. because there is no java in the hierarchy)
  may cause excess dependency between return types of declarations, which
  may lead to recursive problems in resolution

^KT-66313 Fixed
2024-03-06 11:56:01 +00:00
Dmitriy Novozhilov fece081265 [Test] Reproduce KT-66313 2024-03-06 11:56:01 +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
Mikhail Glukhikh e8ba534904 K1/K2: add tests confirming behavior of remaining KT-63242 cases 2024-03-05 20:19:02 +00:00
Kirill Rakhman b4413776ab [Raw FIR] Build if - else if - else as two nested whens
This is necessary for inference to work like in K1 because we only
add equality constraints from expected types on top-level `when`, not
on nested ones.

#KT-65882
2024-03-05 17:38:59 +00:00
Kirill Rakhman 888c1defa0 [FIR] Improve source selection for NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER 2024-03-05 17:38:59 +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
Dmitriy Novozhilov a08df1821f [FIR] Provide suppression from primary value parameter to property
`@Suppress` annotation has `VALUE_PARAMETER` target, so when a property
  in the primary constructor is annotated with `@Suppress` it sticks
  to the parameter. But the suppression should work for all diagnostics
  reported on the parameter **and** the property

^KT-66258 Fixed
2024-03-05 07:59:26 +00:00
Dmitriy Novozhilov 5e742884de [Test] Reproduce KT-66258 2024-03-05 07:59:26 +00:00
Kirill Rakhman 172df04c9b [FIR] Fix raw type nullability computation
Consider the nullability of the type arguments, not of the type.
This fixes a false positive ARGUMENT_TYPE_MISMATCH.

#KT-66294 Fixed
2024-03-05 07:45:01 +00:00
Pavel Kunyavskiy 8d725753f8 [Fir2IR] Don't build overrides for expect classes.
We don't need them except for checking.
And checking doesn't work in any reasonable way anyway.

^KT-65249 Fixed
2024-03-04 14:12:48 +00:00
Brian Norman 8320668485 [FIR] Adding a test case to show resolution of KT-29559 in K2 2024-03-04 13:34:04 +00:00
Stanislav Ruban 2de0e4b8d2 [FIR][checkers] Respect ClassKind.INTERFACE in FirRegularClass.canHaveAbstractDeclaration
A Kotlin interface can have abstract members regardless of its modality. However, this invariant was previously ignored by FIR checkers. As a result, false-positive `ABSTRACT_<MEMBER>_IN_NON_ABSTRACT_CLASS` errors were being reported in explicitly non-abstract interfaces.

This commit makes a relevant FIR utility used by relevant FIR checkers aware of the aforementioned invariant.

#KT-66260 Fixed
2024-03-04 12:00:18 +00:00
Stanislav Ruban e0b83def00 [tests] Add test data for KT-66260 2024-03-04 12:00:18 +00:00
Mikhail Glukhikh 75ecba5a4a Tests/PCLA: extend the test for KT-55168
#KT-55168 As Designed
2024-03-01 17:02:49 +00:00
Kirill Rakhman bb6091cc90 [Tests] Add regression test for #KT-66158 2024-03-01 14:08:39 +00:00
Brian Norman 75c6d06077 [FIR] Collect local properties for CFG analysis with a FIR visitor
When collecting local properties for property initialization analysis,
the nodes of the CFG were navigated. However, there are problems when
trying to determine what local properties are defined within do-while
loops. This is because the node order of a CFG does not always follow
the FIR structure order.

By converting the collector to a FIR visitor, we can maintain the
structural order needed for finding properties defined within do-while
loops. This does require some additional logic though to make sure we
do not navigate into elements which are not part of the original graph
navigation.

^KT-65911 Fixed
2024-03-01 07:12:56 +00:00
Artem Kobzar 2e4d02e9f4 [PSI2IR, K/Wasm] Sync start and end offsets on PSI and FIR for primary constructors 2024-02-29 14:42:33 +00:00
Alexander Udalov dfd9aabf8e JVM: update test data after enabling IR fake override builder
#KT-61514 Fixed
2024-02-29 10:14:31 +00:00
Mikhail Glukhikh 09db7dbd22 K2: add tests to confirm current behavior of KT-65679 examples 2024-02-29 10:02:06 +00:00
Artem Kobzar 4f4c98ec73 [K/JS] Allow parameter properties inside external declarations ^KT-65965 Fixed 2024-02-29 09:46:59 +00:00
Kirill Rakhman 5e83350576 [Infrastructure] Assert dumps don't exist without directive
#KT-58697 Fixed
2024-02-29 08:36:16 +00:00
Nikita Bobko 052baf1b04 Revert "[FIR] Enable ForbidInferringTypeVariablesIntoEmptyIntersection in 2.0"
^KT-66196 Fixed
Keep it a warning in 2.0

This reverts commit be232d3e6f.
2024-02-28 18:08:11 +00:00
Dmitriy Novozhilov 6cfe81de50 [FIR] Properly reports about conflicts in MPP setup
Checker for conflicting declarations will now check for the following
  scenarios too
- two expect declarations in different modules
- actual and non-expect declarations in different modules

^KT-63826 Fixed
2024-02-28 13:45:29 +00:00
Dmitriy Novozhilov 5b01396a11 [FIR] Carefully process constructors of inner and nested classes in the tower
If there is an expression receiver, we should process constructors only
  of inner classes. Constructors of nested classes can be called only
  on classifier

^KT-65333 Fixed
2024-02-28 08:08:32 +00:00
Dmitriy Novozhilov 67557ce731 [Test] Reproduce KT-65333 2024-02-28 08:08:31 +00:00
Abduqodiri Qurbonzoda 557ea32f87 Introduce kotlin.AutoCloseable typealias in K/JVM stdlib #KT-55777 2024-02-27 20:52:49 +00:00
Artem Kobzar 3429cbd321 [K/JS] Support companion objects in external and exported declarations 2024-02-27 16:30:13 +00:00
Andrei Tyrin 4e10dcd808 [tests] Klib based signature clash improve coverage for KT-63670 2024-02-27 14:01:44 +00:00
Roman Efremov 23ae617ea0 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
Add separate diagnostic for the case when it is reported on qualifiers.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 02b5fed389 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
It can be reported not only from within the enum, but also from
top-level functions. Add separate diagnostic for such cases.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 34d87465ac [Test] Add test for Enum.entries shadowing when property is imported
This is similar to KT-64488 but without context receivers.
Warning message "access ... from within the enum" is also incorrect
here.

^KT-64488
2024-02-27 11:22:35 +00:00
Mikhail Glukhikh 678816f9e8 K1: introduce BUILDER_INFERENCE_STUB_PARAMETER_TYPE to prevent compiler crashes
This diagnostic is reported in rare situations when
StubTypeForBuilderInference is kept as a parameter type
of for loop or lambda. Before this commit, we had in K1
"Could not load module <error module>" from IrLinker instead.

Related to: KT-52757, KT-53109, KT-63841, KT-64066
#KT-53478 Fixed
2024-02-27 10:25:13 +00:00
Dmitriy Novozhilov 6f6e37f552 [FIR] Report about recursion in implicit types for receivers of invoke
^KT-65576 Fixed
2024-02-27 09:34:02 +00:00
Dmitriy Novozhilov 234cc5be2b [Test] Reproduce KT-65576 2024-02-27 09:34:02 +00:00
Mikhail Glukhikh 91e9fbd9bf K1: change depr. level of List.getFirst to HIDDEN but don't force it on overrides
#KT-65441 Fixed
2024-02-27 08:40:53 +00:00
Mikhail Glukhikh d870d9dcc6 K1/K2: add tests for KT-65441 current behavior 2024-02-27 08:40:52 +00:00
Nikolay Lunyak f1c7f929d2 [FIR] Don't miss diagnostics on resovled reified type parameters
^KT-66005 Fixed
2024-02-26 09:53:13 +00:00