Commit Graph

315 Commits

Author SHA1 Message Date
Nikita Bobko fa89b8b0f1 [FE 1.0] 2/2 Don't report a warning when new members are added to open expect actualization
^KT-62655 Fixed
2023-10-20 14:37:10 +00:00
Nikita Bobko 1d4ab50047 [FE 1.0] 1/2 Don't report a warning when new supertypes are added to open expect actualization
^KT-62655 Fixed
2023-10-20 14:37:10 +00:00
Nikita Bobko 12f932a63a [FE 1.0] Report a more precise diagnostic when parameter modifiers (vararg) are changed in actualization
^KT-62747 Fixed
2023-10-20 14:37:10 +00:00
Nikita Bobko 0f82baf841 [FE 1.0] 2/2 Drop AllowDifferentMembersInActual from compiler and testData
The annotation was dropped in the previous commit
2023-10-20 14:37:09 +00:00
Nikolay Lunyak a0e9cc3206 [FIR] Fix new test data after merging a68a2409 2023-10-19 14:29:24 +00:00
Roman Efremov 601c517887 [FIR] Don't print function's default value parameters
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov 0f0540cda0 [Test] Add test for reporting of function default value parameters
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov 7893624589 [FIR] Remove debug labels in annotation arguments rendering
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov 37a0dd9487 [FIR] Use idRenderer to print referenced class and callable ids
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.
Unlike in previous commit, this can't be fixed right in
`FirSymbolRenderer`, because `ConeIdRendererForDebugging` renders
differently and a lot of lazy resolve tests rely on that.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov 7f7801a7bc [FIR] Use idRenderer to render ClassId in qualifiers
It shouldn't break existing usages, because
1) default `ConeIdRendererForDebugging` renders ClassId in
same way as before the change;
2) I didn't find any usages, which use non-default idRenderer,
but rely on full ClassId be rendered for qualifiers.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov cb6ec46de1 [FIR] Fix type annotation arguments rendering inside symbols
...in ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic.

^KT-62585
2023-10-18 20:01:47 +00:00
Roman Efremov b3467353b2 [Test] Add test for ugly K2 reporting of annotation arguments
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62585
2023-10-18 20:01:47 +00:00
Dmitriy Novozhilov 3b6ad36af1 [Test] Update/unmute tests after previous fixes
It's hard to tell which exact commit fixed each test
2023-10-17 12:46:28 +00:00
Mikhail Glukhikh fd057ac68a FE: Add two more tests around KT-59561 2023-10-17 06:49:38 +00:00
Mikhail Glukhikh 9f6abfc166 K2/MPP: treat Array<Some> & Array<out Some> as similar types in annotations
#KT-59561 Fixed
Related to KT-61100
2023-10-17 06:49:38 +00:00
Mikhail Glukhikh f085d0f660 K2: add reproduction of KT-61100 and KT-59561 2023-10-17 06:49:37 +00:00
Roman Efremov 0fd700de21 [FIR] Fix case with lazy resolve in expect-actual annotation checker
Unresolved annotation arguments were treated as absent arguments,
which lead to false-positive reports.
Add assert and test for that and fix.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov 423f4ca5f0 [FE, IR] Check compatibility of annotations set on type usages in expect and actual declarations
This includes checking of annotatins set on:

- value parameter types
- type parameter bound types
- extension functions receiver types
- function return types
- class super types

Fix in `defaultParams_inheritanceByDelegation_positive.kt`
is needed because of problem in resolution of implicit return types
(KT-62064), which leads to crash in annotation checker, because it
expects resolved return type.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov cb8529d65b [Test] Add tests for annotations set on type usages in expect and
...actual declarations.

 MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Mikhail Glukhikh 0fb4c9b4fe FIR2IR: generate specific sources for property accessors
Related to KT-60111
2023-10-13 15:42:58 +00:00
Roman Efremov d09c3783fd [K2] Fix mistake in language feature name for
...`DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE`
diagnostic.

^KT-62036
2023-10-13 12:30:41 +00:00
Roman Efremov a05b37c652 [K2] Support reporting of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS
...on regular classes and enum entries.

^KT-59979 Fixed
2023-10-12 13:01:40 +00:00
Roman Efremov 32a87836c2 [Test] Improve test of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS diagnostic
Add case where explicit primary constructor is present in expect,
so that SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR is not
reported.

^KT-59979
2023-10-12 13:01:40 +00:00
Anastasia.Nekrasova e3bab4a7da [K2] Prohibit smart casts for 'expect' properties
^KT-61340
2023-10-11 17:05:29 +00:00
Roman Efremov e4ea733482 [K2] Support reporting of EXPECTED_ENUM_ENTRY_WITH_BODY
Test for the case when enum entry has constructor call but doesn't have
body already exist in
`compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt`.

^KT-59978 Fixed
2023-10-11 15:04:02 +00:00
Ivan Kochurkin 89fe73f6f4 [FIR] Consider expect default function parameters in FirSuperCallWithDefaultsChecker
^KT-61572 Fixed
2023-10-06 12:29:01 +00:00
Nikita Bobko e8630fd63f ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker: error -> warning
^KT-62263 Fixed
Review: https://jetbrains.team/p/kt/reviews/12401/timeline
2023-10-05 10:36:38 +00:00
Roman Efremov faae5f9b38 [IR] Fix annotation arguments comparison when expression is expect enum
...actualized via typealias. This caused false-positive report of
`ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE`.
In such case it's incorrect to compare signatures, because classes have
different `ClassId`s. Instead, classes could be compared using
`areCompatibleExpectActualTypes` which actualizes both types, and
then enum value names compared.

^KT-62104
^KT-59940
2023-10-04 11:38:15 +00:00
Roman Efremov 705b2e87fd Revert "[K2] Temporary mute ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE"
This reverts commit b232dbf484.
2023-10-04 11:38:15 +00:00
Roman Efremov 81fd9a679d [FIR] Prohibit expect class members with default values actualized
...by fake-override.
It is error without deprecation cycle because `expect` and `actual`
classes are still in Beta and expected impact of change is negligible.

^KT-62036 Fixed
2023-10-02 15:50:37 +00:00
Roman Efremov 02680442a0 [Test] Add tests for expect class default arguments which actualized
...by fake-override.

^KT-62036
2023-10-02 15:50:37 +00:00
Roman Efremov 7ad23aeb73 [Test] Drop forgotten TODO
^KT-62036
2023-10-02 15:50:37 +00:00
Roman Efremov b232dbf484 [K2] Temporary mute ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE
...until tests fixed. Mute on TC is not enough
because user projects compilation are affected.

^KT-62104
2023-09-21 09:05:51 +00:00
Roman Efremov ad4d1a5ba8 [IR] Support ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE in K2
It's implemented as IR checker because in K2 constant expressions are
evaluated on backend. FIR diagnostic removed because isn't needed.

"annotationViaActualTypeAlias" test has no `// FIR_IDENTICAL` because
diagnostic reported on entire typealias declaration instead of its name.
This is because in IR+LightTree we have only offsets, so can't navigate
to typealias name element.

^KT-59940 Fixed
2023-09-20 15:40:37 +00:00
Nikita Bobko b15787bfa8 Fir incorrect usage of AbstractExpectActualCompatibilityChecker.getCallablesCompatibility API
^KT-62027 Fixed

`getCallablesCompatibility` requires parentSubstitutor as a parameter,
but we created a member-level substitutor

`getCallablesCompatibility` will create member-level substitutor itself,
no need to create member-level substitutor on the call site.

IndexOutOfBounds was happening in an attempt of creating member-level
substitutor

I will refactor the `createExpectActualTypeParameterSubstitutor` API in
the following commits later. It will help to avoid problems like that
2023-09-19 14:24:15 +00:00
Roman Efremov c88b4105c5 [K2] Correctly handle case when expect annotation is unresolved
Don't report if annotation has error type.

Review: KT-MR-12250

^KT-62026 Fixed
2023-09-19 10:19:08 +00:00
Roman Efremov 04c1bf749c [K1] Correctly handle case when expect annotation is unresolved
Before change NPE was thrown.

Review: KT-MR-12250

^KT-62026
2023-09-19 10:19:08 +00:00
Roman Efremov a23f2894b2 [K2] Support reporting of EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
^KT-59982 Fixed
2023-09-18 12:22:42 +00:00
Roman Efremov 5623427c6d [Test] Extract test for EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
...to separate file. Also, add 3 cases with true-negative reporting:
annotation class, value class and secondary constructor.

^KT-59982
2023-09-18 12:22:42 +00:00
Roman Efremov 489371219f [K2] Support reporting of EXPECTED_ENUM_CONSTRUCTOR
^KT-59980 Fixed
2023-09-18 12:22:42 +00:00
Roman Efremov 6112c4ab2c [K2] Rewrite condition for EXPECTED_PRIVATE_DECLARATION
...without `isTopLevelOrInsideClass` property. Behavior stays the same,
because in fact we require all `expect` member declarations to be non-private
except constructors and property setter.
Enhance already existing test.

^KT-59899
2023-09-18 12:22:41 +00:00
Roman Efremov 1fdc607898 [K2] Fix EXPECTED_DECLARATION_WITH_BODY not reporting on property accessors
We don't want any `expect` function to have body. So we're sure no
new false-positive reports are introduced because of removal of
`isTopLevelOrInsideClass` condition.

^KT-59899 Fixed
2023-09-18 12:22:41 +00:00
Roman Efremov e79851910e [FE, IR] Check annotations compatibility on expect and actual getters and setters
^KT-60671
2023-09-15 14:41:38 +00:00
Roman Efremov 8fb2935ef6 [FE, IR] Check annotations compatibility on expect and actual type parameters
^KT-60671
2023-09-15 14:41:37 +00:00
Roman Efremov 5c95f69aef [FE, IR] Check annotations compatibility on expect and actual value parameters
Comment was added to make it clear why whole declarations reported
in diagnostic instead of value parameter symbols (same will be done
with other targets in subsequent commits).

^KT-60671
2023-09-15 14:41:37 +00:00
Vladimir Sukharev bab00255dc [K/N, Tests] Add diagnostic tests for SUPER_CALL_WITH_DEFAULT_PARAMETERS
^KT-61572


Merge-request: KT-MR-11941
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-13 11:10:25 +00:00
Anastasia.Nekrasova eab6e9bb36 Added tests for all code samples from KT-60523, except 2.3.
Test for 2.3 sample must be added in the context of KT-61792.
2023-09-12 07:03:20 +00:00
Roman Efremov 2dae7ce6c1 [LT2FIR] Fix missing "expect" modifier on members of nested classes
For members of nested classes inside expect class
`classWrapper.hasExpect()` would be false, because it only reflects
modifiers of nested class itself and not aware of "expect" modifier
inherited from the parent class.
Fix is done in same way in PSI2FIR, see
`PsiRawFirBuilder.Visitor.toFirProperty`.

This fix now makes it possible to add test for functionality from
previous commit.

Review: KT-MR-12107

^KT-61784
2023-09-11 21:29:02 +00:00
Roman Efremov c6d7f15070 [FE] Fix checker of DEFAULT_ARGUMENTS_IN_EXPECT_WITH_ACTUAL_TYPEALIAS
...not reporting on companion object members as well as other
nested classes.

Annotation classes are accepted because this is how it already worked,
see other tests, for example `annotationsViaActualTypeAlias.kt`.

Test for nested annotation classes will be added in subsequent commit,
because it currently will fail in test
`TreeCompareTest.testCompareDiagnostics` because light-tree2fir
produces different tree due to a bug when converting properties
from expect primary constructor. See subsequent commit for a fix.

Review: KT-MR-12107

^KT-61784
2023-09-11 21:29:02 +00:00
Nikita Bobko 2127b2ce68 expect/actual classes: experimental -> Beta
KT-61573
^KT-61712 Fixed
Review: https://jetbrains.team/p/kt/reviews/12044/files

It's a follow up commit

According our guidelines, it must be in Beta
https://kotlinlang.org/docs/components-stability.html#stability-of-subcomponents

And the whole multiplatform was in Beta, so we can't make part of the
multiplatform to have lower stability level
2023-09-11 13:57:28 +00:00