Commit Graph

338 Commits

Author SHA1 Message Date
Roman Efremov 37b839f2c2 [Tests] Refactor: move one more annotation arguments lazy resolve test
for `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` checker near to
other tests of this diagnostic. It is fine to move it out of
`multiplatformCompositeAnalysis` dir, because, actually, it tests
the case with comparison of FirAnnotationCall and FirAnnotationImpl,
which doesn't require composite analysis mode.

^KT-62559
2023-11-10 19:36:10 +00:00
Roman Efremov 99bf96e747 [Tests] Refactor: move annotation arguments lazy resolve test for
...`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` checker near to
other tests of this diagnostic. This is because now such tests
are run in lazy resolve test suite, so no need to store them
separately.

^KT-62559
2023-11-10 19:36:10 +00:00
Roman Efremov c20a5fc650 [Tests] Fix .ll.kt KMP tests data added in previous commit
It is expected, that in some complex cases
`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` reports in .ll.kt disappeared
at all. This is because FIR checker doesn't catch comlex cases,
which are handled by IR checker.

Also add comments about bugs KT-62886 and KT-63382 found by tests.

^KT-62559
2023-11-10 19:36:09 +00:00
Roman Efremov 29980c6b85 [Tests] Run KMP tests in Analysis API LL FIR test suites
New tests are red in current commit!
All `.ll.kt` files are just copies of `.fir.kt` or `.kt`. This will be
fixed in the next commit to clearly show difference between LL and FIR.

The original purpose of this change was to test
`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic, for which FIR checker
will be run only in IDE (to be changed in next MR), so its reports
a lost from usual KMP tests.
But this looks like a useful change for all KMP tests, not only this
diagnostic.

^KT-62559
2023-11-10 19:36:09 +00:00
Roman Efremov 026ad1cebc [Tests] Refactor: move unrelated tests out of annotationMatching dir
It will be used only for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
diagnostic tests.

^KT-62559
2023-11-10 19:36:09 +00:00
Dmitriy Novozhilov fe66f3a384 [FIR2IR] Manage constructor symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
  for references of corresponding declarations (KT-62856)

There was an exception from FIR2IR that was fixed with this change,
 so fir2ir test SuperClass started to pass along with IrActualizer,
 which reported some new errors
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 3c0f153de4 [FIR2IR] Manage function symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
  for references of corresponding declarations (KT-62856)

There was an exception from FIR2IR that was fixed with this change,
  so fir2ir test expectDeclarationWithWeakIncompatibilities started to
  pass along with IrActualizer, which reported some new errors
2023-11-09 10:43:31 +00:00
Kirill Rakhman eba1fdec1d [Tests] Check for duplicate file names in FIR diagnostic tests with IR
The relative path of a test file is just its name, even if it's in a
module.
Diagnostics in IR are mapped to the file path and so it's reported on
all files with the same path, i.e. name.
This doesn't happen in production code because no two files can have
the same path.

The proper fix would be to prefix the test files' paths with the module
name.
Unfortunately, this breaks a bunch of test runners that rely on the
current behavior.
Especially, some JS runners turned out to be hard to fix.
The linked YouTrack issue contains a WIP, incomplete patch of fixing
some runners.

#KT-61592 Fixed
#KT-63252
2023-11-08 08:25:19 +00:00
Nikita Bobko 45c5fd7a2d [FE] Introduce a language feature entry for expect actual classes
^KT-62885 Fixed
2023-11-07 20:05:59 +00:00
Nikita Bobko 7b8445f914 [FIR] 2/2 Support more wider actual member visibility, if the expect member is effectively final
^KT-61955 Fixed

Introduce LV vs don't introduce LV:

introduce LV:
- K1 IDE and K2 project: IDE accurately shows compiler errors
- K2 IDE and K1 project: There are cases when IDE shows red but in reality it's green

don't introduce LV:
- K1 IDE and K2 project: There are cases when IDE shows red but in reality it's green
- K2 IDE and K1 project: There are cases when IDE shows green but in reality it's red
2023-11-07 15:53:54 +00:00
Nikita Bobko d6acba1c33 Add regression tests for final expect classes overrides that change modality
KT-61840
Specifically see the comment:
https://youtrack.jetbrains.com/issue/KT-61840/K2-support-changes-in-overrides-of-fake-overrides-of-expect-declarations#focus=Comments-27-8077580.0-0

Review: https://jetbrains.team/p/kt/reviews/12147/timeline
2023-11-07 10:24:35 +00:00
Nikita Bobko 75a0442b61 [FIR] 2/2 Cleanup: drop no longer necessary FirActualCallableDeclarationChecker
It became possible to drop it after KT-62590. Now, on a frontend, the
return type check is part of a common AbstractExpectActualChecker logic

Change in nestedAnnotationClassViaActualTypealias.fir.kt aligns the
behaviour with K1. KT-61964

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:23 +00:00
Nikita Bobko a9583e4f9a [FIR, IR] 1/2 Align FirExpectActualMatchingContextImpl.areCompatibleExpectActualTypes with ExpectActualUtilsKt.areCompatibleExpectActualTypes
Those two functions are copy-paste of each other. They diverged since
the time they were copy-pasted. This commit makes
FirExpectActualMatchingContextImpl.areCompatibleExpectActualTypes
up-to-date.

I didn't update ExpectActualUtilsKt.areCompatibleExpectActualTypes
because I will drop it in the next commit.

Change in `dynamicTypesEqualToAnything` doesn't change any logic (yet.
This change in logic will take effect in the next commit), because:
1. `dynamicTypesEqualToAnything` is only changed in
AbstractExpectActualChecker.getCallablesCheckingIncompatibility. But
AbstractExpectActualChecker.getCallablesCheckingIncompatibility doesn't
check return types on frontend (it only check return types on backend).
2. `dynamicTypesEqualToAnything` is ignored on IR backend

I have no idea what is the difference between `createTypeCheckerState()`
and `actualSession.typeContext`, but it aligns these copy-pasted
versions and makes the tests behave like in K1 (at least
'typeUsageWithUnresolvedReference' and 'kt57320' are affected)

This commit is mainly a preparation for the next commit.

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:23 +00:00
Nikita Bobko ddc1ae9ac6 [IR] Split INCOMPATIBLE_MATCHING to EXPECT_ACTUAL_MISMATCH & EXPECT_ACTUAL_INCOMPATIBILITY
KT-62590

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:22 +00:00
Nikita Bobko 60e5a9c298 [IR] Update testData INCOMPATIBLE_MATCHING
^KT-62916 Fixed
(well, actually it got fixed in one of my previous commits, but it's
hard to track)

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:21 +00:00
Nikita Bobko 76ffbcc67c [IR] Update testData ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
After previous commits, IrExpectActualAnnotationMatchingChecker reports
errors even if the declaration is incompatible but matched

We had a duplicated diagnostic in other cases before my commits, anyway.
it will be fixed in
https://youtrack.jetbrains.com/issue/KT-62559/KMP-K2-prevent-reporting-ACTUALANNOTATIONSNOTMATCHEXPECT-twice-in-CLI#focus=Comments-27-8293687.0-0

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:20 +00:00
Nikita Bobko 8722e142f6 [IR] 2/2 Propogate expect-actual checker incompatibilities to IR backend
Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:20 +00:00
Nikita Bobko 664b9cc3ba [FIR, IR] ClassScopes incompatibility: split unfulfilled incompatibilities into "mismatchedMembers" and "incompatibleMembers"
KT-62590 is in progress

Unfortunatelly, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT is now reported
twice in 'classScopeViaTypealiasIncompatible' test.

We had a duplicated diagnostic in other cases before my commits, anyway.
it will be fixed in
https://youtrack.jetbrains.com/issue/KT-62559/KMP-K2-prevent-reporting-ACTUALANNOTATIONSNOTMATCHEXPECT-twice-in-CLI#focus=Comments-27-8293687.0-0

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:19 +00:00
Nikita Bobko bc5180656d [FIR] ReturnType expect-actual incompatibility: convert from strong to weak
It should have been WeakIncompatible from the beginning because it's not
possible to overload by return type in Kotlin

This commit is a step forward to fix KT-62591

Unfortunately, the test cannot demonstrate the problem because of
another bug in K2 KT-59887

^KT-62752 Fixed
Review: https://jetbrains.team/p/kt/reviews/12750/timeline

Motivation:

It makes expect-actual matching-checking model more consistent.

expect-actual "matching" is run before FirResolvePhase.BODY_RESOLVE. You
can't know return types, until you run BODY_RESOLVE. That's why the
return type can't be checked during expect-actual matching. But it's
cursed: you have something that have to match by, but, at the same time,
you can't do it.

expect-actual "checking" is run after FirResolvePhase.BODY_RESOLVE.
That's why if we convert ReturnType incompatibility to WeakIncompatible
(which should have been called CheckingIncompatible), then expect-actual
matching model becomes consistent.

We will also be able to get rid of unnecessary
FirActualCallableDeclarationChecker. Because it won't be necessary.
Return types will be checked by common logic of expect-actual "checker"
2023-11-06 14:41:16 +00:00
Nikolay Lunyak b8e2a17de1 [Test] Fix diagnostics arguments rendering when quotes are present
Non-capturing `(?:)` was now needed to avoid
getting an additional group that only
contains the last symbol before the closing `"`.

^KT-62711 Fixed
2023-11-03 08:14:28 +00:00
Nikita Bobko 173651eb5c Fix misconfigured widerVisibilityInActualClassifier test
^KT-59977 Fixed
Review: https://jetbrains.team/p/kt/reviews/12807/timeline
2023-11-01 19:14:20 +00:00
Mikhail Glukhikh 3cb9396b20 K2: prefer derived class sources for callable copies (e.g. fake overrides) 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh a9894b1842 K2: use derived class sources for callable copies if base callables have no sources
Related to KT-60155
2023-10-24 17:08:40 +00:00
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