Commit Graph

43 Commits

Author SHA1 Message Date
Evgeniy.Zhelenskiy 5096fd266e [FIR] Forbid generic type checks inside contracts in K2 as it is done in K1.
#KT-59922
2023-11-21 18:00:10 +00:00
Kirill Rakhman d0cc86f52c [Tests] Update test data after changes to FIR diagnostic messages 2023-08-21 16:28:48 +00:00
Nikolay Lunyak 884cd6c754 [FIR] Move FirReturnsImpliesAnalyzer to the extended checkers 2023-07-10 09:28:54 +00:00
Dmitrii Gridin 72def186a3 [LL FIR] rework transformers, so transformers resolve only a specific set of declarations
The change is needed for the parallel resolution (^KT-55750), so we can resolve the declaration
under a lock that is specific to this declaration.
Previously, if LL FIR was resolving some FirClass, LL FIR  resolved all its children too, and it had no control over what parts of the FIR tree were modified.
The same applied to the designation path, sometimes the classes on the designation path
might be unexpectedly (and without lock) modified.

This commit introduces LLFirResolveTarget, which specifies which exact declarations should be resolved during the lazy resolution of the declaration.
All elements outside the declarations specified for resolve in LLFirResolveTarget, should not be modified.

The logic of lazy transformers is the following:
- Go to target declaration collecting all scopes from the file and containing classes
- Resolve only declarations that are specified by the LLFirResolveTarget, performing the resolve under a separate lock for each declaration

^KT-56543
^KT-57619 Fixed
2023-04-19 20:12:38 +00:00
Dmitriy Novozhilov f8dc8057f0 [FIR] Prohibit referencing type parameters in contracts ...
...if they are not reified or not belong to owner declaration of the contract

KT-57911
2023-04-18 13:31:28 +00:00
Dmitriy Novozhilov 5a92eb2c67 [FIR] Properly track problems in contract description during effect extraction 2023-04-18 13:31:28 +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
Nikolay Lunyak c156dfe855 [FIR] KT-56877: Allow checking types of containing classes in contracts 2023-03-09 09:43:03 +00:00
Nikolay Lunyak c7a71fec17 [FIR] KT-56877: Allow referencing implicit receivers in class contracts 2023-03-09 09:43:02 +00:00
Kirill Rakhman f946ddeb40 [FIR] Implement checks for contract not allowed
^KT-55423 Fixed
2023-03-09 08:32:02 +00:00
Dmitriy Novozhilov 9b7b517f43 [FIR] Properly resolve declarations inside contract calls on CONTRACT phase 2022-11-22 15:46:21 +00:00
Mikhail Glukhikh fc6403679a Rename !USE_EXPERIMENTAL test directive to !OPT_IN 2021-09-10 16:29:16 +03:00
Tianyu Geng bcf6202863 FIR checker: fix position strategy for UNRESOLVED_LABEL 2021-08-10 19:36:04 +03:00
Tianyu Geng c7272f6986 FIR checker: SENSELESS_(COMPARISON|NULL_IN_WHEN)
Currently DFA does not set "definitely equal to null" for access to variables that got assigned `null`. For example, FIR should mark the following line as SENSELESS_COMPARISON due to `s = null` above.
 https://github.com/JetBrains/kotlin/blob/d1531f9cdd5852352c0133198706125dc63b6007/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.fir.kt#L6

The problem is at https://github.com/JetBrains/kotlin/blob/7e9f27436a77de1c76e3705da7aa1fbe8938336b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt#L1104

For null assignment, ideally the type should be `Nothing?`. This is
addressed in a followup commit instead.
2021-08-06 22:57:16 +03:00
Dmitriy Novozhilov 0ab4770f02 [FIR] Add correctly reported diagnostics to testdata 2021-07-02 15:55:05 +03:00
Dmitriy Novozhilov 32c3f85679 [FIR] Add inline checker for bodies of inline functions
This checker doesn't support `@PublishedAPI` yet, so some BB tests for it
 were muted. #KT-46270
2021-04-27 18:39:09 +03:00
Mikhail Glukhikh 43a2ad0467 FIR: don't flatten for loop blocks in raw FIR builder 2021-04-19 15:11:12 +03:00
Mikhail Glukhikh 2e14b65644 Introduce FirForLoopChecker 2021-04-19 15:10:58 +03:00
Tianyu Geng fb14b03824 FIR checker: skip error named reference if receiver is unresolved
Currently, FIR reports errors caused by previous resolution failure. For
example with unresolved `a` and `b` in code `a.b`, both `a` and `b` are
highlighted. FE1.0 only highlights `a` since it's the root cause. This
change applies this heuristics when reporting FirDiagnostics.
2021-03-29 12:45:27 +03:00
Jinseong Jeon 20f9787c70 FIR checker: report errors in contract description 2021-02-11 17:02:18 +03:00
Jinseong Jeon bd37badf29 FIR checker: add diagnostics for backing fields 2021-02-10 12:29:34 +03:00
Nick c8f8908a01 [FIR] Add NO_THIS & INSTANCE_ACCESS_BEFORE_SUPER_CALL 2020-08-24 11:06:10 +03:00
Oleg Ivanov 21b8679799 [FIR] Add ReturnsImplies effect analyzer 2020-08-12 11:06:07 +03:00
Dmitriy Novozhilov 2e4183db7d [FIR-TEST] Update testdata of old FE contracts tests 2020-04-15 11:13:01 +03:00
simon.ogorodnik f573719cc1 [FIR] Fix missing receiver type if anonymous function without label 2020-04-08 14:56:17 +03:00
Mikhail Glukhikh 8884cbe415 Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed 2020-03-05 09:39:40 +03:00
Dmitriy Novozhilov 7d8363d6aa [FIR] Use Function<R> as super type for all FunctionNtypes 2020-01-28 14:14:20 +03:00
Dmitriy Novozhilov 76b3964e96 Update testdata according to change compiler version to 1.4 2020-01-17 10:33:50 +03:00
Mikhail Glukhikh 5c6341b4e4 [FIR] Handle fully qualified expressions separately in tower resolver 2020-01-13 13:26:13 +03:00
Dmitriy Novozhilov 5dfe100ae5 Allow use reference to reified type parameters in contracts since 1.4 2019-12-26 17:43:28 +03:00
Dmitriy Novozhilov 9c1b68f839 Prohibit using references to this from outer scope in contract declarations 2019-12-26 17:43:28 +03:00
Dmitriy Novozhilov f083edfac2 Allow contracts on final non-override members since 1.4 2019-12-26 17:43:27 +03:00
Dmitriy Novozhilov 2536fa0cd5 [FIR-TEST] Add new testdata generated after changes in previous commit 2019-12-12 16:11:46 +03:00
Dmitriy Novozhilov 77c98bef4d Fix recursion in contract declaration analysis. KT-26386 Fixed
Issue fixed only in old inference
2019-03-07 14:35:18 +03:00
Dmitriy Novozhilov 2f5843f764 Move detecting of illegal call of contract function into call checker
(#KT-26153, #KT-26191) fixed
2019-03-01 14:50:46 +03:00
Dmitriy Novozhilov 4a7420d77d Allow declaring contracts on suspend functions. KT-27468 Fixed 2019-03-01 14:50:46 +03:00
Dmitriy Novozhilov 84da8b6279 Report CONTRACT_NOT_ALLOWED diagnostic on extension property getter/setter
KT-27090
2019-03-01 14:50:46 +03:00
victor.petukhov 30762a450a Wrap diagnostic parameters to double quotes and split by comma instead of semicolon 2019-02-14 12:31:42 +03:00
Dmitry Savvinov 2179ae496e Fix testdata after improvements in contract parsing diagnostics 2018-08-30 16:20:36 +03:00
Dmitry Savvinov a6783176ea Add tests on illegal usages of Contracts DSL
(currently with undesired behavior, it will be fixed in the next
commits)
2018-08-30 16:20:04 +03:00
Dmitry Savvinov ee8702d21e Load of testdata change due to contracts publishing
See changes in e2606b72bdbec2fea567d4127197707869eb801e
2018-08-30 16:19:55 +03:00
Dmitry Savvinov b29a6e48fb Refactor language features, which control effect system
- Introduce new language feature 'ReadDeserializedContracts', which
allows to deserialize contracts from metadata.

- Introduce new language feature 'AllowContractsForCustomFunctions',
which allows reading contracts from sources.

- Use new features instead of combination 'CallsInPlaceEffect ||
ReturnsEffect'

- Rename 'CallsInPlaceEffect' -> 'UseCallsInPlaceEffect',
'ReturnsEffect' -> 'UseReturnsEffect'. As names suggest, they control
if it is allowed to use corresponding effect in analysis.

We have to introduce separate 'ReadDeserializedContracts' to enable
contracts only in some modules of the project, because libraries are
read with project-wide settings (see KT-20692).
2018-01-26 11:30:44 +03:00
Dmitry Savvinov 4434db4d69 Effects: add diagnostic tests on contracts
- Make AbstractDiagnosticsTest dump function contracts
- Add diagnostics tests on parsing contracts
- Add diagnostics tests on smartcats in presence of functions with
contracts
- Add diagnostics tests on initialization and flow in presence of
in-place called lambdas

==========
Introduction of EffectSystem: 16/18
2017-10-12 11:55:26 +03:00