Commit Graph

307 Commits

Author SHA1 Message Date
Tomas Husak ec167d4d42 K2: implement FirForLoopStatementAssignmentChecker
#KT-60006 Fixed
2024-02-20 17:34:49 +00:00
Ivan Kochurkin 55159694df [FIR] Use Operator origin for ITERATOR and HAS_NEXT function calls instead of Regular
It automatically fixes KT-62356 since iterators now are operators

^KT-62356 Fixed
2024-02-20 13:30:47 +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
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
Kirill Rakhman 8aa32d9f45 [FIR] Rename DUPLICATE_LABEL_IN_WHEN to DUPLICATE_BRANCH_CONDITION_IN_WHEN
... and fix the message

#KT-35289 Fixed
2024-01-02 15:17:02 +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
Egor Kulikov 43fc4ccf40 [FIR] Source for implicit iterator calls in for should not be null
^KT-62111 fixed


Merge-request: KT-MR-13029
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-22 17:15:24 +00:00
Kirill Rakhman d54068b8ab [FIR] Report NONE_APPLICABLE on callable references with multiple failed candidates 2023-11-08 15:45:48 +00:00
Kirill Rakhman d91000e39c [FIR] Report INAPPLICABLE_CANDIDATE or more specific diagnostic for callable references
... instead of just UNRESOLVED_REFERENCE when something went wrong
during resolution.

#KT-59401 related
2023-11-08 15:45:48 +00:00
Ivan Kochurkin d50c6f1b6d [FIR] Fix missing USELESS_CAST
`FirUselessTypeOperationCallChecker` always checks exact types matching for `as` operator

Simplify code of cast checker and utils

^KT-56629 Fixed
^KT-56615 Fixed
^KT-59820 Fixed
2023-10-24 20:59:56 +00:00
Evgeniy.Zhelenskiy f4d18da6a0 [FIR] Introduce OPERATOR_CALL_ON_CONSTRUCTOR diagnostic
#KT-59943
2023-10-24 12:24:52 +00:00
Nikolay Lunyak a68a2409d3 [FIR] Remove the applicability filtering when reporting diagnostics
In case we don't want to introduce any new
abstractions like "user relevance for
applicability", we can just remove the
filtering.

^KT-62541 Fixed
2023-10-19 09:27:45 +00:00
Vladimir Sukharev 56eedfebee [FIR] K2: Fix disappeared diagnostic UNDERSCORE_USAGE_WITHOUT_BACKTICKS on types
^KT-59985 Fixed

Merge-request: KT-MR-12282
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-22 11:18:19 +00:00
Kirill Rakhman fa77e3952d [FIR] Bring equivalent call behavior closer to K1
#KT-61159 Fixed
2023-08-21 12:11:58 +00:00
Kirill Rakhman 724d527fd8 [FIR] Fixes for call conflict resolution
Let ConeCompositeConflictResolver pass the results of the previous
resolver to the next one.
Otherwise, we get false positive conflicts when a set of candidates
can't be fully reduced by one resolver but could be resolved by the
subsequent application of multiple ones.
This change makes ConeCompositeConflictResolver order-dependent and
thus, ConeOverloadConflictResolver must be invoked last, because it
must work on a pre-filtered list.

Also, let ConeEquivalentCallConflictResolver use
FirStandardOverrideChecker instead of compareCallsByUsedArguments
because it's stricter.

This all fixes a false positive overload resolution ambiguity in common
metadata compilation that is caused by stdlib using the new KMP
format.
Now stdlib metadata is in the classpath, and so declarations from the
stdlib are returned from both MetadataSymbolProvider and
KlibBasedSymbolProvider.
This isn't a problem per se because duplicate candidates are filtered
out by ConeEquivalentCallConflictResolver (K1 works analogously), but
in the case of top-level functions with generic receivers like
Collection<T>.toTypedArray, the check failed because of the direct
comparison of receiver types.

#KT-60943 Fixed
2023-08-11 10:54:24 +00:00
Kirill Rakhman 2f3293f99e [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument
A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
2023-07-20 07:29:18 +00:00
Kirill Rakhman 028921ade1 [FIR] Implement checker for value parameter default value type mismatch
#KT-58901 Fixed
2023-07-03 10:11:36 +00:00
Denis.Zharkov 3279313f2c K2: Fix priority for implicit receiver + extensionInvoke
See K1 counterpart at org.jetbrains.kotlin.resolve.calls.tower.TowerResolver.Task.processImplicitReceiver

^KT-58943 Fixed
^KT-59541 Fixed
2023-07-01 16:29:06 +00:00
Egor Kulikov b147b7e929 [FIR] Store fir for invalid when branches
^KTIJ-25646 fixed

Merge-request: KT-MR-10646
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-20 16:11:31 +00:00
Nikolay Lunyak 7541732752 [FIR] Fix TEST SPEC tests
Ensure the test data contents for both the frontends
are identical. This is needed for proper analysis of
K2-differences.
2023-06-19 07:40:15 +00:00
Kirill Rakhman b2fa104081 [FIR] Keep all failed resolution candidates and fully resolve them
Previously, when a candidate was found with an applicability that is
better than the current best applicability, all previous candidates were
thrown away. Now we keep them, unless the new applicability is
successful. If no successful candidates are found, we fully resolve all
the unsuccessful ones and select the ones with the least bad
applicability. This improves diagnostics for unresolved calls.

#KT-57844 Fixed
2023-05-10 11:48:58 +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
Kirill Rakhman 1f0d56e157 [FIR] Make type parameters inaccessible for non-inner nested types
#KT-57209
2023-03-28 13:20:53 +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
Kirill Rakhman 3b9724d20e [FIR] Desugar increment/decrement in body resolve phase
The expression needs to be resolved first to determine if there is a
receiver that needs to be extracted to a temporary variable. Also, the
special case for prefix increment/decrement on local variable without
delegates requires resolution to check if the variable is local.

^KT-56771 Fixed
^KT-56659 Fixed
2023-03-02 10:19:57 +00:00
Denis.Zharkov a38040680c K2: Do not use KFunctionN as representation type for adapted references
Beside some corner cases, it's already prohibited in K1 because
adaptation have a bit strange nature
(they don't represent any existing real function exactly)

^KT-55137 Fixed
2023-02-15 08:13:45 +00:00
Denis.Zharkov dcdc48a233 K2: Support callable references adaptation on top-level
^KT-45989 In progress
^KT-54709 Related
^KT-55217 Fixed
2023-02-15 08:13:44 +00:00
Denis.Zharkov d7399ed1cf K2: Avoid losing diagnostics for synthetic calls
Some of the changed tests may duplicate other existing diagnostics,
but that should not be reason not to report them at all.

There might be another job to be done to avoid diagnostic duplications
2023-02-15 08:13:41 +00:00
Kirill Rakhman 1eb18f13bd FIR: Fix test data after making LHS of assignment an expression
KT-54648
2023-01-31 08:39:43 +00:00
Marco Pennekamp b0db0f59b4 [LL FIR] KT-50732 Remove FIR_IDE_IGNORE from K1 spec tests
- `FIR_IDE_IGNORE` was already removed from the `.fir.kt` counterparts,
  but removing the directive from the `.kt` files had been forgotten.
2023-01-16 15:20:50 +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
Dmitriy Novozhilov 1b16d651ae [FIR] Disambiguate names of files with helpers in spec tests
Test framework assumes that there won't be any files with same names
  in one test. But there were cases when test declared test file
  with same name as one of files with helpers (e.g. `functions.kt`)
2022-12-21 16:30:58 +00:00
Dmitriy Novozhilov 02e327277e [FIR] Report VAL_REASSIGNMENT on assign to non-local vals
In this commit reporting on member properties in init section of class
  is not supported (see KT-55528)

^KT-55493 Fixed
2022-12-20 08:12:09 +00:00
Dmitriy Novozhilov b174bb8844 [FIR] Update testdata after introducing FirResolvedErrorReference 2022-12-15 12:12:19 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
pyos f485413cfd FIR DFA: x !is T? => x != null
^KT-22996 tag fixed-in-k2
2022-12-08 10:19:27 +00:00
Dmitriy Novozhilov 1b42298025 [FIR] Implement IMPLICIT_NOTHING_*_TYPE diagnostics 2022-11-22 15:46:19 +00:00
Dmitriy Novozhilov 0e84bf2053 [FIR] Don't report ARGUMENT_TYPE_MISMATCH on error types 2022-11-22 15:46:19 +00:00
pyos 6a2d74e211 FIR DFA: generate type implications on all null comparisons 2022-11-22 15:44:28 +00:00
Nikolay Lunyak c5469d5fb5 [FIR] KT-53988: Report ILLEGAL_SELECTOR for constants as selectors
Merge-request: KT-MR-7756
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>

^KT-53988 Fixed
2022-11-22 10:54:09 +00:00
pyos e7b4927b6c FIR: don't emit SENSELESS_NULL_IN_WHEN when value is always null
This case (value is always null) contradicts the error message which says
"Expression under 'when' is never equal to null".
2022-11-10 13:10:58 +00:00
Mikhail Glukhikh 2598ecf23f Revert "K2: fix internal visibility checks for overrides #KT-53197 Fixed"
This reverts commit 166965e559.
2022-08-05 18:26:59 +02:00
Mikhail Glukhikh 166965e559 K2: fix internal visibility checks for overrides #KT-53197 Fixed 2022-08-03 07:52:14 +00:00
Victor Petukhov 42e71f8c53 Remove explicit enabling the new type inference from test data 2022-07-22 16:03:52 +00:00
Victor Petukhov 224beb24eb Remove explicit disabling the new type inference from test data 2022-07-22 16:03:51 +00:00
Ilya Chernikov bb996c1b27 Switch kotlin version to 1.8
with appropriate fixes in testdata, tests and other
places.
2022-06-29 10:20:30 +02:00
Ilya Gorbunov 383e814d82 Update FIR spec test data
NONE_APPLICABLE instead of UNRESOLVED_REFERENCE_WRONG_RECEIVER
presumably because of the introduction of another `contains` extension overload
2022-06-28 00:08:08 +00:00
Ilya Kirillov 3b55585782 [tests] Fix file path in testdata 2022-04-13 12:53:03 +02:00
Ilya Kirillov 339a51fbc6 [low level api fir] unmute now passing tests 2022-04-13 12:53:02 +02:00