Commit Graph

7503 Commits

Author SHA1 Message Date
Ivan Kochurkin 1f0fb5a1a8 [FIR] Check for ConeErrorType in doUnify to prevent endless recursion
^KT-64625 Fixed
2024-01-05 19:21:10 +00:00
Mikhail Glukhikh ae358fe194 K1/K2: add more tests regarding SequencedCollection.add/remove calls
Related to KT-64640
2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 0ef41d75b5 K1/K2: consider List.(add/remove)(First/Last) as mutable list methods
#KT-64640 Fixed
2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 8a560d2629 FE tests: don't render text of disabled diagnostics 2024-01-05 17:20:32 +00:00
Mikhail Glukhikh e1b7b0e768 K1/K2: reproduce KT-64640 2024-01-05 17:20:32 +00:00
Mikhail Glukhikh 3d560cd92c K2: use correct scope for overrides calculation in ObjCName checker
To call retrieveDirectOverriddenOf,
one must use directly the owner scope of a callable symbol we consider,
and not a scope of some derived class.

#KT-64276 Fixed
2024-01-05 14:39:05 +00:00
Nikolay Lunyak aea2e8052a [FIR] Ensure KT-64089 works
Make sure SENSELESS_COMPARISON
is absent in this case.

^KT-64089 Obsolete


Merge-request: KT-MR-13754
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 14:15:06 +00:00
Nikolay Lunyak 8cd87059c8 [FIR] Fix the failing test after merging 533ed5c6
It started failing because of other
changes having been merged right before it

^KT-64644 Fixed

Merge-request: KT-MR-13755
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-01-05 13:34:43 +00:00
Ivan Kochurkin 69b9bfc3e0 [FIR] Initialize public visibility for class-like declarations at FIR building phase if no modifier is presented
Java resolving subsystem requires calculated visibility for correct disambiguation of supertypes.
But visibility remains `Unknown` for Kotlin class-like declarations during supertypes resolving because `STATUS` resolve phase is performed after `SUPER_TYPES` phase.
To fix the problem, the visibility should be initialized to public at the FIR building phase if no modifier is presented.

^KT-64127 Fixed
2024-01-04 16:17:32 +00:00
Brian Norman aae8cd2a7c [FIR] Local variable assignment must be propagated before loops
When performing lookahead for local variable assignments, make sure
assignments taking place within loops are being propagated before loops.
This makes sure smartcasts within non-inline declarations before the
loop are disallowed.

^KT-63867 Fixed
2024-01-04 14:20:21 +00:00
Kirill Rakhman 10d6d95ee8 [Tests] Add regression test for #KT-64702 2024-01-04 14:12:42 +00:00
Nikolay Lunyak 7c3042772e [FIR] Reproduce KT-64644
Ensure the given code crashes the
compiler.

^KT-64644
2024-01-04 14:08:43 +00:00
Kirill Rakhman 7fb5cbd1f8 [FIR] Implement UNNECESSARY_NOT_NULL_ASSERTION checker for java warning level types 2024-01-04 09:59:50 +00:00
Kirill Rakhman d6bd31b313 [FIR] Implement UNNECESSARY_SAFE_CALL checker for java warning level types
#KT-63528 Fixed
2024-01-04 09:59:50 +00:00
Nikolay Lunyak 9c0ac27307 [FIR] Don't miss annotations on properties from primary constructors
^KT-64609 Fixed
2024-01-04 09:45:27 +00:00
Nikolay Lunyak 1f46aed3e0 [FIR] Reproduce KT-64609
^KT-64609
2024-01-04 09:45:27 +00:00
Kirill Rakhman 1018ff280e [FIR] Fully expand the bounds of type parameters for canBeNull check
This is required because a not-null bound `Foo` can resolve to a
`typealias Foo = Bar?` in which case we must return true.

#KT-64645 Fixed
2024-01-03 17:15:50 +00:00
Brian Norman 3346cc4b19 [FIR] Lambdas without contracts should be considered repeatable
^KT-63777 Fixed
2024-01-03 14:08:04 +00:00
Kirill Rakhman fd12f24725 [FIR] Only let supertypes of ILTs include Number when it's not unsigned
#KT-64607 Fixed
2024-01-03 12:05:18 +00:00
Dmitriy Novozhilov 56221467ff [FIR] Rename PLUGIN_ANNOTATION_AMBIGUITY to COMPILER_REQUIRED_ANNOTATION_AMBIGUITY
This diagnostic may be reported even without any compiler plugins (e.g.
  for annotation named `Target` or `Deprecated`), so the old name
  and message were quite confusing

^KT-64654
2024-01-03 08:50:20 +00:00
Alexander Korepanov d5aaa29a7f [JS FIR] Implement FirJsReflectionAPICallChecker diagnostic
^KT-60899 Fixed
2024-01-02 16:45:12 +00:00
Kirill Rakhman 5d3738c804 [FIR] Improve annotation use-site target rendring for diagnostics
#KT-62816 Fixed
2024-01-02 15:17:02 +00:00
Kirill Rakhman 8f3f72d9c9 [FIR] Use correct type renderer in symbol rendering for diagnostics
#KT-62815 Fixed
2024-01-02 15:17:02 +00:00
Kirill Rakhman 6b049df87c [FIR] Render deprecation message if it's not a named argument. 2024-01-02 15:17:02 +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
Alexander Korepanov 4609b11102 [JS FIR] Add JsName clash test
^KT-64364
2024-01-02 10:15:02 +00:00
Alexander Korepanov 89e2af2047 [JS FIR] Fix the JsExport diagnostic for nullable primitive types
- Correctly handle nullable primitive types.
- Unsigned primitive arrays are not exportable.

^KT-64366 Fixed
2024-01-02 10:14:46 +00:00
Ivan Kochurkin 88f7b085e6 [FIR] Try to infer result type of incomplete when expression
^KT-62069 Fixed
2023-12-22 16:57:07 +00:00
Anastasia.Nekrasova 867be40c8e K1/K2: add tests for KT-55811 2023-12-21 16:37:10 +00:00
Anastasia.Nekrasova 19fe605a3e K1/K2: add tests for KT-58767 2023-12-21 13:39:41 +00:00
Anastasia.Nekrasova 6268cfedab K1/K2: add tests for KT-58766 2023-12-21 13:36:54 +00:00
Kirill Rakhman ad2689ecbf [FIR] Prefer the non-smartcasted receiver in resolution if it's visible
Previously, we would ignore the candidate with the non-smartcasted
receiver if they have the same symbol.
Now we prefer them when they're visible or when the smart cast changes
the nullability.
2023-12-21 13:29:01 +00:00
Kirill Rakhman 5186ba80e2 [FIR] Check for setter visibility in resolution stage
This is required for the following commit where candidates from the
original scope in presence of smart cast will not be ignored if they're
the same symbol.
2023-12-21 13:29:00 +00:00
Mikhail Glukhikh 5409a51ce9 K2: remove a workaround for suspend functions implementation status
This commit breaks two diagnostic tests:
- testSuspendJavaImplementationFromDifferentClass
- testSuspendJavaOverrides

Related to KT-59818
#KT-63233 Fixed
2023-12-21 13:10:17 +00:00
Mikhail Glukhikh 7f7bc1f36c K2: add test to reproduce KT-63233 2023-12-21 13:10:17 +00:00
Mikhail Glukhikh 79e041a310 FE: drop a redundant diagnostic test (exact duplicate of suspendJavaOverrides.kt) 2023-12-21 13:10:16 +00:00
Mikhail Glukhikh a02cf76d6c K2: build SAM-based function type for a given captured type properly
Before this commit, we assumed (erroneously) that a captured type
cannot have an associated SAM-based function type.
In this commit we changed this assumption, replacing a captured type
with its lower type for this purpose

#KT-63379 Fixed
2023-12-21 10:19:23 +00:00
Mikhail Glukhikh 8588588760 K2: add test reproducing KT-63379 2023-12-21 10:19:23 +00:00
Mikhail Glukhikh 3a106fc88e K1/K2: add some more tests around KT-63558 2023-12-21 07:43:38 +00:00
Mikhail Glukhikh d3a0a6cabe K2: discriminate candidates with adaptations in the first place in ConeOverloadConflictResolver
Before this commit, we discriminated particular candidates with callable
reference adaptations during resolution stages.
After disabling compatibility mode for new inference, it's not so,
but now we discriminate similar candidates in ConeOverloadConflictResolver;
more precisely, it's candidates with callable reference adaptation
in their postponed atoms.
This does not allow going up the tower,
but allows to select better candidate at similar tower level.

Related to KT-63558, KT-64307, KT-64308
2023-12-21 07:43:38 +00:00
Mikhail Glukhikh 087edc026d K2: discriminate particular SAMs in the first place in ConeOverloadConflictResolver
Before this commit, we discriminated particular candidates with SAM
during resolution stages. More precisely, candidates from Kotlin
which used Java SAM types, were discriminated allowing go up the tower
for better candidates. After disabling compatibility mode for new
inference, it's not so, but now we discriminate similar candidates
in ConeOverloadConflictResolver. This does not allow going up the tower,
but allows to select better candidate at similar tower level.

Related to KT-63558, KT-64306
2023-12-21 07:43:38 +00:00
Mikhail Glukhikh a7dc381b93 K2: disable compatibility mode for new inference
#KT-64306 Fixed
#KT-64307 Fixed
#KT-64308 Fixed
2023-12-20 21:39:21 +01:00
Artem Kobzar eb790732fd [K/JS] Enable identifiers escaping by default in 2.1 version ^KT-31799 Fixed 2023-12-20 16:39:19 +00:00
Ivan Kochurkin a2cd2200d6 [FIR] Infer Unit type for generic lambda function if implicit return exists
Make behavior more consistent with K1

^KT-63563 Fixed
2023-12-20 13:50:05 +00:00
Roman Efremov 30aad31ece [FIR, IR] Prohibit actualization of expect Kotlin property to Java field
The problem from KT-63624 was that during matching phase we must choose
only one candidate, but in Java we can have two successfully matched
properties: 1) from field and 2) from method, which overrides Kotlin
property.
See test `propertyAgainstJavaPrivateFieldAndPublicMethod.kt`.
As a result, we choose field candidate, throw away method candidate, and
then fail during visibility check.

Instead of inventing special rule of prioritizing field over method
it was decided to prohibit actualization to Java field at all because:

1. It doesn't seem that Java fields actualization was implemented in K1
on purpose
2. People usually don't use public Java fields, and use instead
private field + getter, especially when compatibility is important, so
it shouldn't be a breaking change

Besides that, such solution simplifies code and is consistent with
the current logic of matcher, which doesn't expect that two members
can be matched successfully. Also, it fixes KT-63624 and KT-63667.

^KT-63624 Fixed
^KT-63667 Fixed
2023-12-20 13:37:43 +00:00
Roman Efremov 3f95e99e29 [Tests] Add tests for matching of expect property against Java property
...via typealias. Java property can be either field or method, which
overrides Kotlin property.

^KT-63624
2023-12-20 13:37:43 +00:00
Mikhail Glukhikh c322644860 K2: report only warning on lambda parameters with missing dependencies
During the fix of KT-62525, we've forbidden to use lambda parameters
with inaccessible types at all. After it, some impact was noticed,
so we decided to forbid them only in case it's necessary
(the case when associated types have type arguments, see KT-62525
description), and to deprecate them in other cases.

#KT-64266 Fixed
2023-12-20 12:48:00 +00:00
Mikhail Glukhikh 44aa2d86d3 K2: add test to reproduce KT-64266 2023-12-20 12:47:59 +00:00
Vladimir Sukharev 26b626c8cf [K/N][Tests] Add test for KT-64276
^KT-64276
2023-12-20 07:15:52 +00:00
Dmitriy Novozhilov fa33c5dc79 [FIR] Implement deprecation warning for synthetic without java base getter
Also implement new resolution behavior under language feature

^KT-63076 Fixed
^KT-64358
2023-12-19 09:04:26 +00:00