Commit Graph

199 Commits

Author SHA1 Message Date
Ivan Kochurkin c4e0cafe9c [FIR] Check DELEGATE_USES_EXTENSION_PROPERTY_TYPE_PARAMETER for anonymous objects
^KT-64102 Fixed
2024-02-07 21:15:59 +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
Denis.Zharkov 6052e24626 K2: Adjust test data after PCLA implementation [red-to-red]
^KT-59791 In Progress
2024-01-10 14:56:30 +00:00
Dmitriy Novozhilov 93563d7c80 [FIR] Report PROPERTY_AS_OPERATOR for all operator conventions
^KT-62347 Fixed
^KT-59715 Fixed
2023-12-13 09:27:14 +00:00
Denis.Zharkov bb548e3df4 K2: Fix exception for PropertyDelegateProvider + lazy case
^KT-63646 Fixed
2023-11-29 15:10:36 +00:00
Dmitrii Gridin 3941b05909 [FIR] do not transform annotations on delegated property accessors during implicit type phase
^KT-62874 Fixed
2023-10-25 08:59:15 +00:00
Dmitrii Gridin 1b636bf450 [FIR] add tests on annotations for delegated getter during implicit type phase
^KT-62874
2023-10-25 08:59:15 +00:00
Kirill Rakhman fbf68a5bcc [FIR] Narrow down range of NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
This uses the same approach as
INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION where we use a visitor
to find a call to a symbol that contains the type variable in question.

#KT-56140 Fixed
2023-09-22 13:49:59 +00:00
Brian Norman 4b6c767704 [FIR] Report UNINITIALIZED_VARIABLE for top-level properties
When checking top-level properties, check with initialization enabled.
This makes sure the same errors are reported for member and top-level
properties.
2023-09-19 13:42:54 +00:00
Denis.Zharkov 033ff38fef K2: Adjust diagnostic test data after delegate inference is rewritten
In all tests, some red-code diagnostics have changed insignificantly
to some other combination or red-code diagnostics

^KT-61060 Related
2023-09-08 07:11:48 +00:00
Denis.Zharkov a02cb16fb2 K2: Rewrite delegate inference
The main idea is getting rid of stub types and using just type variables
See more detailed description at docs/fir/delegated_property_inference.md

The problem with stub types is that they need really special treatment
in many places, and on the other hand, there are no clear contracts on
how they should work (that regularly leads to bugs like KT-59529)

^KT-61060 Fixed
^KT-61075 Fixed
^KT-61077 Fixed
^KT-59529 Fixed
^KT-61633 Related
^KT-61618 Related
^KT-61740 Related
^KT-59107 Related
^KT-61747 Related
^KT-61077 Related
^KT-61781 Related
2023-09-08 07:11:48 +00:00
Denis.Zharkov 41933facbb K2: Fix ISE from inference on delegate vars with implicit types
See the test data.
ISE happened because at some point after incomplete `getValue` resolution
of `a` property, we updated in the `transformAccessors` the property type
to the `Variable(Y)` type and then used it as a 3rd argument for
`setValue` call which is incorrect because the variable belongs
to a different constraint system (from `getValue`).

Mostly, the fix is just a repeating K1 behavior, namely postponing
`setValue` resolution until delegate inference is completed.

^KT-59066 Fixed
2023-06-12 11:30:35 +00:00
Mikhail Glukhikh 6e58ba8f33 FE: don't approximate type variable based types for public/local declarations
#KT-58618 Fixed
2023-05-26 11:13:39 +00:00
Mikhail Glukhikh 2cfa3d7e0d K2: reproduce KT-58618 2023-05-26 11:13:39 +00:00
Mikhail Glukhikh 3964ee38be K2: fix handling of synthetic calls in delegate inference
This commit is intended to avoid the second resolve of delegate when
we need to consider provideDelegate() possibility in inference.
Also here we provide correct completion of synthetic calls during
delegate inference.

#KT-58013 Fixed
2023-05-04 11:48:37 +00:00
Mikhail Glukhikh bbee881b5b K1: add separate TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_IN_AUGMENTED_ASSIGNMENT
This is made to have a correct error message for a problem
described in KT-48546
#KT-48546 Fixed
2023-05-02 12:57:15 +00:00
Mikhail Glukhikh c5fe4b53cf FE: add more augmented assignment tests around KT-48546 2023-05-02 12:57:15 +00:00
Denis.Zharkov 555d8eeb25 K2: Fix false-positive DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
For explanation, see nestedPartiallyResolvedCallsSimple.k

The problem was caused by "select" variable is being leaked to the
inference session of delegate while it should not happen because
it doesn't belong to the common system of `KotlinVal { ..` call,
as we complete it with fixing `E` variable during completion
for `A(select(null, fun(): Int { return 1 }))`.

The root of the problem is that we were adding all the partial
nested calls to the session, while in fact we only need there
the top-level one.

^KT-57543 Fixed
2023-04-28 16:20:06 +02:00
Dmitrii Gridin 6170d83301 [FIR] update reversed testData
^KT-56543
2023-04-19 20:12:41 +00:00
Dmitrii Gridin 1c5aa6c45b [FIR] add reversed testData to update it in the next commit
^KT-56543
2023-04-19 20:12:41 +00:00
Denis.Zharkov 39639e08f9 K2: Fix incorrect inference of delegated property type
It was working incorrectly, because we've been trying to fix
P1 variable to intersectTypes(String?, StubForP2) that should result
to String? because we've got stubEqualsToAnything enabled there,
but nullability was being chosen incorrectly because
`StubForP2.isNullableType()` returned false

NB: The code inside `is ConeTypeVariable` case wasn't working properly
because it always `lookupTag.toSymbol(session)` always returned null,
thus there was effectively five dead lines of code there.

^KT-57814 Fixed
^KT-57921 Related
2023-04-12 11:31:43 +00:00
Dmitrii Gridin 9a4a3d1f49 [LL FIR] introduce test with reversed resolve order
^KT-56543

Merge-request: KT-MR-9299
Merged-by: Dmitrii Gridin <dmitry.gridin@jetbrains.com>
2023-03-22 17:34:07 +00:00
Dmitriy Novozhilov 86af01439c [FIR] Allow to access uninitialized member properties in non-inPlace lambdas in class initialization
^KT-56696 Fixed
^KT-56408
2023-02-17 11:26:18 +00:00
Dmitriy Novozhilov c87e489dc9 [FIR] Run CFA for member properties even if they have initializer
^KT-56678 Fixed
^KT-56682 Fixed
2023-02-17 11:26:17 +00:00
Denis.Zharkov 9fa0f51a61 K2: Fix false-negative RETURN_TYPE_MISMATCH
^KT-53987 Fixed
^KT-55932 Fixed
2023-02-15 08:13:42 +00:00
Denis.Zharkov fe5adab652 K2: Avoid inference diagnostics when arguments are already error typed
For example, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER

It became especially relevant after 0e84bf2053
that together with later commits bring a lot of unnecessary
NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER diagnostic
2023-02-15 08:13:41 +00:00
Dmitriy Novozhilov a1a9a55e1a [Test] Add test for KT-41952
^KT-41952 Obsolete
2023-01-31 07:53:09 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +00:00
Ilya Kirillov 1bbcae5ed2 [FIR] fix resolve contract violation from scopes
We cannot call lazy resolve to STATUS phase from scopes as scopes may be accessed on a STATUS phase or earlier

^KT-54890
^KTIJ-23587 fixed
2023-01-13 21:32:51 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Dmitriy Novozhilov 06e88b559a [FIR] Consider ConeConstraintSystemHasContradiction as a good reason for DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE error 2022-11-22 15:46:21 +00:00
Dmitriy Novozhilov 0e84bf2053 [FIR] Don't report ARGUMENT_TYPE_MISMATCH on error types 2022-11-22 15:46:19 +00:00
Mikhail Glukhikh 5fcb18ac2b Revert "[FE 1.0] Resolve this and super calls through the new type inference infra"
This reverts commit bab8047bb3.
2022-09-13 09:09:01 +00:00
Mikhail Glukhikh f35cebbc25 Revert "[FE 1.0] Resolve special construct calls through the new type inference infra"
This reverts commit e66cc9a639.
2022-09-13 09:09:01 +00:00
Ivan Kochurkin 80450042c7 [FIR] Ignore KtFakeSourceElementKind in FirRecursiveProblemChecker 2022-07-25 23:30:10 +02:00
Victor Petukhov 42e71f8c53 Remove explicit enabling the new type inference from test data 2022-07-22 16:03:52 +00:00
Victor Petukhov e66cc9a639 [FE 1.0] Resolve special construct calls through the new type inference infra
^KT-48961 In progress
2022-07-22 16:03:48 +00:00
Victor Petukhov bab8047bb3 [FE 1.0] Resolve this and super calls through the new type inference infra
^KT-48961 In progress
2022-07-22 16:03:48 +00:00
Mikhail Glukhikh 4aed9511f6 FIR/FE10: fix false positives described in KT-24643 2022-07-03 19:10:02 +00:00
Mikhail Glukhikh 3223d3c3e9 Add test with false/true positives for KT-24643 2022-07-03 19:10:01 +00:00
Ivan Kochurkin 9f69ea1786 [FIR] Add TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM diagnostics, ^KT-52327 Fixed 2022-06-17 23:26:16 +00:00
Ivan Kochurkin c6f52893fb [FIR] Fix inconsistent RETURN_TYPE_MISMATCH and TYPE_MISMATCH reporting on functions and properties
^KT-51203 Fixed
2022-04-05 15:50:43 +00:00
Victor Petukhov 57a134c543 [FE 1.0] Report recursive type checker problem as a warning till 1.9
^KT-48546
2022-03-23 21:13:34 +00:00
Victor Petukhov 2307122089 [FE 1.0] Report errors for recursive types from completion as well
Such diagnostics could be missed at least for plus assignment's right side because it wasn't report for the second time of analysis

^KT-48546 Fixed
2022-03-23 21:13:34 +00:00
Victor Petukhov 27fa632630 [FE 1.0] Update test data with new error type representation 2022-03-23 21:13:33 +00:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Vladimir Dolzhenko 918a91dbdf Escape special names with backticks in test data
#KT-51248
2022-02-10 21:20:47 +00:00
Victor Petukhov 72a78eb423 Replace errors with warnings for type checker recursion on delegates
^KT-49477 Fixed
2022-01-17 21:27:14 +03:00
Ivan Kylchik 6fc56477bf Drop all tests that disable features for language version less than 3 2021-12-28 20:08:56 +03:00
Simon Ogorodnik 26b158bded FIR: Update test-data (Delegate inference) 2021-12-15 22:23:12 +03:00