Commit Graph

393 Commits

Author SHA1 Message Date
Nikita Bobko c31a72a4af [FIR] Switch FirExpectActualDeclarationChecker to Platform checker
^KT-66028 Fixed
2024-02-25 18:18:55 +00:00
Nikita Bobko 7924573d20 [FIR] Report redeclaration across KMP source sets
^KT-57585 Fixed

Related tests:
- MultiPlatformIntegrationTestGenerated.testSimpleNoImplKeywordOnTopLevelFunction
- MultiPlatformIntegrationTestGenerated.testWeakIncompatibilityWithoutActualModifier
- FirPsiJsKlibDiagnosticsTestGenerated.testSignatureClash_MPP
- LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated$ResolveWithStdlib$MultiModule.testFakeOverrides
- DiagnosticCompilerTestFE10TestdataTestGenerated$Tests$Multiplatform:
- LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated$Tests$Multiplatform
- FirOldFrontendMPPDiagnosticsWithPsiTestGenerated
- FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated
- FirLibraryModuleDeclarationResolveTestGenerated.testDataClass
- org.jetbrains.kotlin.idea.k2.highlighting.K2HighlightingMetaInfoTestGenerated$Diagnostics.testDataClassFromLibrary
- org.jetbrains.fir.uast.test.FirLightClassBehaviorTest.testContainingFile
- org.jetbrains.fir.uast.test.FirLightClassBehaviorTest.testAnnotationParameterReference
- org.jetbrains.uast.test.kotlin.org.jetbrains.uast.test.kotlin.comparison.FE1LightClassBehaviorTest.testContainingFile
2024-02-22 16:06:36 +00:00
Nikolay Lunyak 76ed5453b3 [FIR] Report all Visibilities.Unknown in FirOverrideChecker
Check all members for `Visibility.Unknown`,
otherwise we miss them when they come
from supertypes. This is the reason why
the FP intellij build failed with a
cryptic stacktrace instead of a
human-readable diagnostic.

Also, do report the diagnostic at all
cases of `Visibilities.Unknown`. Turns
out, there are no "simple to reason
about" situations here :(

Also, an interesting detail:
`retrieveDirectOverriddenOf` returns an
empty list for intersection overrides.
But this doesn't seem to break anything...

Replacing `CANNOT_INFER_VISIBILITY`'s
type `KtDeclaration` with
`PsiNameIdentifierOwner` and the related
changes in `PositioningStrategies`
were needed to prevent an exception saying that
`PsiClassImpl` is not a subtype of
`KtDeclaration`.
2024-02-21 20:24:13 +00:00
Pavel Kirpichenkov 3dede06d51 [Tests] Add diagnostic tests for sealed class inheritors
- Fix unrelated resolution errors in an existing test
- Add separate test for sealed classes and interfaces in HMPP projects,
located in different source sets

KT-64919
2024-02-12 10:17:20 +00:00
Nikita Bobko 21fff5634e [FIR] Fir modality of FirPropertyAccessor
^KT-61798 Fixed
Review: https://jetbrains.team/p/kt/reviews/14230/timeline

Q: How resolved modality of an accessor affects expect/actual matching
   algorithm of properties?
A: It's not expect/actual matching of properties, but expect/actual
   matching of properties setter. Declarations (setters in our case) in
   actual are allowed to have wider visibility but only if the
   appropriate expect is `final`. Before this commit, all property
   accessors were always `final` by mistake. After this commit, they
   have the modality derived from their containingProperty.

Related problem: PositionStrategy for ACTUAL_WITHOUT_EXPECT can be
improved KT-65720

The fix in `resolveModality` is similar to how `resolveVisibility` works

Related tests:
- ConfigurationCacheForAndroidIT.testKotlinAndroidProject
- FirIdeNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testDelegateInterfaceLibrary
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirIdeNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated.testEnumEntryOverride
- FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated.testEnumValueMember
- FirStandaloneNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleCombinedDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- FirStandaloneNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumClassWithAbstractMembers
- FirStandaloneNormalAnalysisSourceModuleMemberScopeTestGenerated.testEnumEntryInitializerWithOverriddenMember
- DiagnosticCompilerTestFE10TestdataTestGenerated*testChangeSetterVisibilityInOverride
2024-02-09 19:49:35 +00:00
Evgeniy.Zhelenskiy 7eab4b672d [K1, K2, CLI] Mark whole position range of compiler diagnostics in CLI
#KT-64989
2024-02-08 12:59:31 +00:00
Mikhail Glukhikh ed246d372b K2: introduce platform-dependent filtering for non-JVM platforms
This commit fixes a false negative in testData/cli/metadata/getOrDefault
Related to KT-57268
2024-01-30 19:44:00 +00:00
Mikhail Glukhikh 672b5ba0d7 K2/Java: implement platform-dependent function filtering in JvmMappedScope
We drop Kotlin function 'remove' or 'getOrDefault' from JvmMappedScope,
if it has platform-dependent annotation, and the bound Java class scope
does not contain a function with the same signature.

#KT-57268 Fixed
2024-01-30 19:44:00 +00:00
Nikita Bobko 19c46662c6 [FIR] Fix missing ACTUAL_WITHOUT_EXPECT when expect is fake-override
^KT-65270 Fixed
KT review: https://jetbrains.team/p/kt/reviews/14064/timeline
IJ review: https://jetbrains.team/p/ij/reviews/124657/timeline
2024-01-29 14:56:49 +00:00
Nikita Bobko c214c5445a [FIR] Implement EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE
^KT-60367 Fixed
KT review: https://jetbrains.team/p/kt/reviews/14064/timeline
IJ review: https://jetbrains.team/p/ij/reviews/124657/timeline
2024-01-29 14:56:48 +00:00
Dmitriy Novozhilov e8f5e35a86 [FIR] Consider expect declarations in defaults arguments inheritance checker
Actual functions cannot declare default values for parameters
Corresponding expect function should be checked instead
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 2982f548d4 [Test] Update testdata of MPP diagnostic tests after previous changes
Related issues: KT-58845, KT-58881, KT-64187
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 77547c0312 [Test] Add more diagnostic tests for cases with expect class in supertypes
Related issues: KT-58845, KT-58881, KT-64187
2024-01-24 10:44:59 +02:00
Dmitriy Novozhilov ed04cca62b [Test] Move some MPP diagnostic tests into a dedicated folder
All those tests check different diagnostics on class scopes
2024-01-24 10:44:59 +02:00
Pavel Kirpichenkov ce3c05500e [LL] Sort modules from the same KMP project in symbol providers
Sort dependency modules topologically if they belong to the same KMP
project, preserving their relative positions. Sorting all modules and
changing positions of unrelated modules can be harmful: in the case of
a classpath hell, IDE results can become different from runtime
behavior. Sorting in place can help to avoid this problem, because
conflicting declarations shouldn't be allowed in different source sets
of the same multiplatform project.

KTIJ-27569
2024-01-19 10:20:52 +00:00
Roman Efremov ee1ee965a1 [FIR] Fix incorrect work of K2 expect-actual matcher when actual is Java
...field, which is fake override.
This was failing in Stdlib with `expect HashMap` + actual typealias to
`java.util.HashMap`.

^KT-63624 Fixed
2024-01-17 14:47:41 +00:00
Roman Efremov 3d2a37ee41 [Test] Write reproducer test for expect-actual matching to Java field
..., which comes from super class, which incorrectly works in K2.

^KT-63624
2024-01-17 14:47:41 +00:00
Sergej Jaskiewicz 422128f3dc [MPP] Fix a failing MPP diagnostic test
This test had the IGNORE_FIR2IR_EXCEPTIONS_IF_FIR_CONTAINS_ERRORS
directive enabled. This prevented some diagnostics from showing up
in this test, because there was this exception thrown in FIR2IR:

java.lang.IllegalStateException: IrSimpleFunctionPublicSymbolImpl for
/foo|foo(){}[0] is already bound:
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit

a0ba878b1d disabled the
`linkViaSignatures` flag in JS tests, which also fixed the exception.
Because of that, the full pipeline could be run, and the diagnostics
started to appear, which is the correct behavior.

Not that this only concerns _tests_, not production code, because
in the production pipeline `linkViaSignatures` had been disabled even
before that change.
2024-01-11 21:07:34 +00:00
Nikita Bobko 013b5e3780 [IR] Fix missing AMBIGUOUS_ACTUALS
^KT-59938 Fixed
Review: https://jetbrains.team/p/kt/reviews/13760

After this patch:

    > The /compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.kt test:

    Fixed

    > The /compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.kt test:

    Declarations are in the same module. `PACKAGE_OR_CLASSIFIER_REDECLARATION` is reported anyway

    > The /compiler/testData/diagnostics/tests/multiplatform/java/varPropertyAgainstJavaGetterAndNonFinalField.kt test:

    Expect-actual matcher doesn't match fields in K2 https://youtrack.jetbrains.com/issue/KT-63667 => green code

    > The /compiler/testData/diagnostics/tests/multiplatform/java/propertyAgainstJavaPrivateFieldAndPublicMethod.kt test:

    Expect-actual matcher doesn't match fields in K2 https://youtrack.jetbrains.com/issue/KT-63667 => green code

    > The /compiler/testData/diagnostics/tests/multiplatform/java/implicitJavaActualization_multipleActuals.kt test:

    K2 doesn't have implicit Java actualization. And PACKAGE_OR_CLASSIFIER_REDECLARATION is reported anyway

    > The /compiler/testData/diagnostics/tests/multiplatform/java/propertyAgainstJavaPublicFieldAndPublicGetter.kt test:

    Expect-actual matcher doesn't match fields in K2 https://youtrack.jetbrains.com/issue/KT-63667 => green code

    > The /compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectContextReceiverOverload.kt test:

    Context receivers are not supported in expect-actual matcher. https://youtrack.jetbrains.com/issue/KT-61447
    And K2 reports another error right now anyway
2024-01-10 08:08:42 +00:00
Mikhail Glukhikh c2d031254c K2/MPP: add test confirming proper work of KT-62024
#KT-62024 Obsolete
2024-01-08 17:16:22 +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
Nikita Bobko 599998039e [IR] Use resolveFakeOverrideMaybeAbstract instead of resolveFakeOverride in hasStableParameterNames
Well, the resolved fake-override can be ABSTRACT

^KT-64045 Fixed
2023-12-14 11:23:51 +00:00
Anastasia.Nekrasova e58b5e7d22 K2: change resolution for deprecated actual declaration
This commit addresses a scenario where an 'actual' declaration is marked
with a Deprecated annotation at the 'Hidden' level, while the
corresponding 'expect' declaration is not. When resolving,
'CheckHiddenDeclaration' marks the 'actual' declaration as unsuccessful,
leading to the selection of the 'expect' declaration as the successful
candidate.

'FirDeprecationChecker' handles a case where an 'actual' class is
annotated with Deprecated, but the 'expect' class is not. During the
checking of the 'actual' class constructor, 'CheckHiddenDeclaration'
skips it due to the absence of a direct Deprecated annotation.
'FirDeprecationChecker' then identifies this constructor and reports a
DEPRECATION_ERROR.

'FirDeprecationChecker' will now be applied to solving problems related
to 'actual' declarations with corresponding Deprecated annotations. The
process remains the same: 'CheckHiddenDeclaration' will skip the
'actual' declaration, and then 'FirDeprecationChecker' will identify it
and report the error.

^KT-61792 Fixed
2023-12-14 09:21:43 +00:00
Nikita Bobko 8bbbbfa3ce [FIR] Fix MT intellij tests
MT stands for "modularized tests"

^KT-64166 Fixed
Review: https://jetbrains.team/p/kt/reviews/13517/timeline

This commit fixes:

    java.lang.IllegalArgumentException: Local <local>/<anonymous> should never be used to find its corresponding classifier
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl.getFirClassifierByFqName(FirProviderImpl.kt:252)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl$SymbolProvider.getClassLikeSymbolByClassId(FirProviderImpl.kt:60)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.computeClass(FirCachingCompositeSymbolProvider.kt:131)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.access$computeClass(FirCachingCompositeSymbolProvider.kt:27)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider$special$$inlined$createCache$1.invoke(FirCachesFactory.kt:75)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider$special$$inlined$createCache$1.invoke(FirCachesFactory.kt:69)
            at org.jetbrains.kotlin.fir.caches.FirThreadUnsafeCache.getValue(FirThreadUnsafeCachesFactory.kt:40)
            at org.jetbrains.kotlin.fir.resolve.providers.impl.FirCachingCompositeSymbolProvider.getClassLikeSymbolByClassId(FirCachingCompositeSymbolProvider.kt:158)
            at org.jetbrains.kotlin.fir.resolve.transformers.mpp.FirExpectActualResolver.findExpectForActual(FirExpectActualResolver.kt:41)
2023-12-13 18:42:14 +00:00
Nikita Bobko 0d67ae7b23 [TEST] Add regression test for KT-59805 ACTUAL_MISSING for constructor 2023-12-06 18:35:39 +00:00
Nikita Bobko 2a7403a979 [FIR, IR] Run DefaultArgumentsInExpectActualizedByFakeOverride not only in FIR but in IR as well
Review: https://jetbrains.team/p/kt/reviews/13334/timeline

Thanks to the previous commit, it's now possible to run
DefaultArgumentsInExpectActualizedByFakeOverride on both: frontend (FIR)
and backend (IR).

We aim to perform a thorough examination of checks involving
fake-overrides on both FIR and IR, given their distinct implementations
for handling fake-overrides.

The commit decreases scope of influence of hacky
`shouldCheckDefaultParams` flag.
2023-12-05 13:30:14 +00:00
Nikita Bobko 1aeefe6c33 [FIR] Don't traverse expect hierarchy to check DefaultArgumentsInExpectActualizedByFakeOverride
^KT-63860 Fixed
Review: https://jetbrains.team/p/kt/reviews/13334/timeline

The previous code was nonsense (I wrote it). It doesn't make sense to
subtract actualOverriddenDeclarations from expectOverriddenDeclarations.
Default parameters are mentioned on the expect side. So default params
in expect/actual supertypes won't be subtracted from
expectOverriddenDeclarations (but should be)
2023-12-05 13:30:14 +00:00
Nikita Bobko 8c0cf7d0bc [FIR] Fix disappeared ACTUAL_MISSING
^KT-59887 Fixed

Review: https://jetbrains.team/p/kt/reviews/13244
2023-12-04 13:08:23 +00:00
Nikita Bobko e44e84d1b0 [FIR] Reuse expect/actual matching data of outer declarations during matching of inner declarations
Review: https://jetbrains.team/p/kt/reviews/13244

Motivation:
    ```
    // Module :lib
    class Foo {
        val member: Int = 2
    }

    // Module :app
    // dependencies { implementation(project(":lib")) }
    class Foo {
        val member: Int = 2
    }
    ```

    Before the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual = lib_foo.member
    After the commit:
        app_Foo.expectForActual is `null`
        app_Foo.member.expectForActual is `null`

    If I don't fix this problem then
    `CommonizerHierarchicalIT.testCommonizeHierarchicallyMultiModule`
    becomes red after I fix KT-59887 in the following commits

    `app_Foo.member.expectForActual = lib_foo.member` happens because we
    also need to match fake-overrides (KT-63550)

I didn't measure it, but theoretically, this commit should be a
performance improvement, becuase we reuse `expectForActual` cache

Additionally, The commit breaks some other tests (e.g.
compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.fir.kt).
The tests will become green again, once I fix KT-59887
2023-12-04 13:08:23 +00:00
Roman Efremov 5cf33c3556 [IR] Render different quotes depending on IR constant type
This is needed for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic
message, but also seems to be good improvement for IR dumps in tests.

^KT-62559
2023-11-28 23:17:23 +00:00
Roman Efremov 8f6b6e17be [IR] Print annotation arguments in report of ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
Now IR checker is not duplicated by FIR checker reporting, so it's
useful to have more verbose report of annotations in diagnostic message.

^KT-62559
2023-11-28 23:17:23 +00:00
Roman Efremov ec7a2c20d1 [FIR] Beautify ::class expression rendering in annotation arguments
...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62559
2023-11-28 23:17:23 +00:00
Roman Efremov fa897e4148 [Tests] Cover rendering of KClass annotation args in
...`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT`.

^KT-62559
2023-11-28 23:17:23 +00:00
Roman Efremov 29c82c668f [IR] Prevent duplicated reports of ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
...on property accessors and enum entries.

^KT-62559
2023-11-28 23:17:23 +00:00
Roman Efremov 2b120f6cdc [Tests] Cover rendering of diagnostic text by IR checker in
...`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT`.

^KT-62559
2023-11-28 23:17:23 +00:00
Mikhail Glukhikh 2cea2b9098 K2/Java: add private enum constructor for MPP matching
#KT-62961 Fixed
2023-11-28 13:30:26 +00:00
Roman Efremov 5147a5e805 [Test] Add test for current behavior of resolution of nested class type
...when it is actualized via typealias.

^KT-31636
2023-11-27 18:23:43 +00:00
Roman Efremov 205690b220 [IR] Fix incorrect matching of nested classes when actualized via typealias
Also, add tests for the cases when expect and actual nested classes
have no compatible matching to check new logic doesn't crash.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov d343e40ac5 [FIR] Actualize expect nested classes in type arguments in expect actual
...checker.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov cec644e9db [Test] Add test for expect nested classes unwrapping
...in type arguments, when they were actualized via
typealias.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov 4aaf290c99 [FIR] Fix incorrect matching of nested classes when actualized via typealias
There are still some places in `.fir.kt` where false-positive reports
remained. This is because of IR checker, which will be fixed in next
commit.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov a768ece70d [Tests] Add tests for other checkers having same problem with
...nested classes marching.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov bfc775faf5 [Tests] Create test for nested classes matching when actualized via typealias
^KT-31636
2023-11-27 18:23:42 +00:00
Dmitriy Novozhilov 039baf95fc [Test] Add empty platform module for MPP diagnostic test with only one module
After previous commits IrActualizer runs only there are at least two modules
  in backend input. So to check diagnostics from Actualizer all tests
  should contain at least two modules

Diagnostics in test `extendExpectedClassWithAbstractMember.kt` were
  changed because there is an exception from IrActualizer caused by
  errors from frontend (`ABSTRACT_METHOD_NOT_IMPLEMENTED`), which is
  swallowed by this kind of tests
2023-11-27 10:17:54 +00:00
Nikita Bobko 7166adb179 [FIR, IR] Convert FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker into ExpectActualCheckingCompatibility
FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker is an adhoc
checker which can be converted to ExpectActualCheckingCompatibility to
reuse common expect-actual checking infrastructure.

^KT-62913 Fixed
Review: https://jetbrains.team/p/kt/reviews/13094/timeline

Tests that were broken by one of my previous commits are now fixed:
- actualFakeOverride_paramsAreCompatibleViaSharedMethodWithDefaultParams.kt
- inheritedJavaMembers.kt

DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE diagnostic
disappeared in delegation.fir.kt because only one
AbstractExpectActualChecker incompatibility can be reported at a time
(DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is now reported
not by adhoc checker but by common AbstractExpectActualChecker). It
would be nice to report both of them, but it's a separate issue KT-62631

delegation2 test makes sure that
DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is reported when
NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS is fixed
2023-11-24 18:02:49 +00:00
Nikita Bobko 5b72c127bd [FIR, IR] Commonize isFakeOverride check for AbstractExpectActualAnnotationMatchChecker
This commit fixes fakeOverrides.fir.kt test that got broken in the
previous commit

Previously isFakeOverride was only checked on IR backend. Now this check
is moved to AbstractExpectActualAnnotationMatchChecker which is used by
both: frontend and backend. That's why frontend no longer reports false
positive ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:48 +00:00
Nikita Bobko e6bfcc7c65 [FIR] 2/2 update testData
This tests started failing after the previous commit. I extract this
change into a separate commit to make it obvious that appeared
diagnostics is not an expected behavior. I will fix these tests in the
following commits

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:47 +00:00
Nikita Bobko a1ce8ac175 [FIR] 1/2 match and check expect fake-overrides vs actuals
^KT-63550 Fixed
Review: https://jetbrains.team/p/kt/reviews/13094/timeline

Now it's required to create a new ScopeSession when searching for expect
members for actuals. If you keep reusing actualScopeSession then members
declared in platform may "slip into" the search results, resulting an
incorrect expect for actual (e.g. it happens in
supertypeIsExpectActual_covariantOverrideOfInjectedFromSuper_transitiveSubstitutionFakeOverride.fir.kt)

I suppose that it always has been a bug that we reused
actualScopeSession because we were mixing actualScopeSession and
expect FirSession (which is a bad idea), but we simply didn't have cases
where this bug could be observed. Now after we started matching
fake-overrides, we have such cases.

But creating a new ScopeSession every time is a suboptimal solution. We
need to design a scope caching KT-63773
2023-11-24 18:02:47 +00:00
Nikita Bobko 216006c504 [FIR] NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS: report both mismatches and incompatibilites
This commit is a preparation step for KT-59887. For now,
expectActualInlineClass.fir.kt became slightly more verbose. Once is
KT-59887 fixed, the verbosity will go away. Because we won't report
incompatibilites mismatches for ACTUAL_MISSING declarations

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:46 +00:00