Commit Graph

10982 Commits

Author SHA1 Message Date
Roman Efremov 234f453173 [FE, IR] Don't check SOURCE annotations if actual declaration has no source
^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 2980179bd7 [IR] Implement IR checker for expect actual annotations matching
^KT-58551
2023-07-24 09:48:48 +00:00
Roman Efremov 1a4ab9bb4b [FE] Implement FE logic of expect actual annotations matching
This implementation only checks annotations set on expect/actual
declarations and requires further refinement (e.g. checking of other
annotation targets, class scopes within typealiases).

^KT-58551
2023-07-24 09:48:48 +00:00
Nikita Bobko 4f3ecedbca [FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes
^KT-59739 Fixed
Review: https://jetbrains.team/p/kt/reviews/11038/timeline
2023-07-24 09:15:11 +00:00
Marco Pennekamp 4ead02271b [FIR] Move TrackableModuleInfo to the common frontend
- FIR-specific parts of the Kotlin IntelliJ plugin depend on
  `TrackableModuleInfo`, so it should be part of the common frontend.
2023-07-19 13:03:51 +00:00
Roman Efremov a79282cec1 [FE] Prohibit actual typealias to certain compiler annotations
^KT-58554
2023-07-13 16:12:59 +00:00
Roman Efremov 4a598afc36 [FE] Prohibit expect or actual opt-in annotations
^KT-58554
2023-07-13 08:15:42 +00:00
Timofey Solonin e12e78d96b Add an explicit diagnostic for when expect/actual modifiers are used in
an unsupported compilation

^KT-31281
2023-07-12 08:29:28 +00:00
Ilya Kirillov 5b4916a808 Introduce StandardNames.IMPLICIT_LAMBDA_PARAMETER_NAME
and use it instead of hardcoded constant
2023-06-30 13:43:31 +00:00
Mikhail Zarechenskiy 060f3fa7c4 Extract diagnostics about class literals with empty LHS
^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy 1153238fd7 Extract diagnostics about references to variables to a separate one
Note that I've left in FIR everything as is to avoid non-trivial
refactoring that is required right now to report more specific diagnostics

 ^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy 9cf40f8c2f Extract diagnostics about 'suspend test' to a separate one
^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy 2dfdd8dcf6 Extract diagnostics about 'sealed fun interface' to a separate one
^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy d772126f2c Extract diagnostics about 'sealed when' to a separate one
^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy c613b312f9 Refactoring: inline single-used method, move checker closer to the usage 2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy ab7ae75f66 Remove unused method
Note that `yield` was allowed since 1.7.0: KT-27750
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy 1df4893a43 Extract diagnostics about an unsupported case of inheritance from Java
^KT-59152
2023-06-19 15:21:32 +00:00
Svyatoslav Kuzmich 1dc0b054ed Deprecate PlatformDiagnosticSuppressors::shouldReportUnusedParameter with one parameter 2023-06-13 15:37:54 +00:00
Svyatoslav Kuzmich dc4aa8c15e [Wasm] Restore binary compatibility of PlatformDiagnosticSuppressor
Keep the original shouldReportUnusedParameter method without
 BindingContext parameter

^KT-58188 Fixed
2023-06-13 15:37:53 +00:00
Ivan Kochurkin 1e09e8663c [FIR] Add compatibleOnly parameter to getSingleCompatibleExpectForActualOrNull
Rename `getSingleCompatibleExpectForActualOrNull` to `getSingleExpectForActualOrNull`
2023-06-13 10:12:44 +00:00
Roman Efremov d2eb4a0abf [FE] Prohibit default arguments in expect declarations actualized via typealias
Cases when default argument inhertied from super class are allowed.

Some tests for default arguments already exist and can be found in
`testData/diagnostics/tests/multiplatform/defaultArguments`, for example
`annotationsViaActualTypeAlias.kt`.

^KT-57614 Fixed

Merge-request: KT-MR-10356
Merged-by: Roman Efremov <Roman.Efremov@jetbrains.com>
2023-05-31 13:14:37 +00:00
Roman Efremov 439cc88525 [FE] Prohibit expect external and expect tailrec
^KT-58536 Fixed
2023-05-23 12:43:51 +00:00
Toshiaki Kameyama 833edfb209 [IDE] EXPOSED_RECEIVER_TYPE: add quickfix to decrease visibility on the use side
^KTIJ-23267 Fixed
2023-05-23 12:33:31 +00:00
Nikita Bobko 771f82bcf6 [FE] Fix "Not reachable case" exception
Review: https://jetbrains.team/p/kt/reviews/9967

This commit fixes:

    Cause 2: java.lang.IllegalStateException: Not reachable case. We can always suggest making `open val` property `final`
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.reportMustBeInitialized(DeclarationsChecker.kt:845)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkPropertyInitializer(DeclarationsChecker.kt:778)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkProperty(DeclarationsChecker.kt:614)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.process(DeclarationsChecker.kt:106)
            at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:258)

Reproducible in K1 & K2
2023-05-23 14:12:29 +03:00
Nikita Bobko de8c3826c2 [FE] Prohibit missed MUST_BE_INITIALIZED when there is no primary constructor
^KT-58472 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967
2023-05-23 14:12:29 +03:00
Nikita Bobko ac40010501 [FE] Prohibit open val deferred initialization
^KT-57553 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

Other related tests:
- testUninitializedOrReassignedVariables
- testUseOfPropertiesWithoutPrimary
- @TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
- testAugmentedAssignmentInInitializer
- testInitOpenSetter
- testInitOverrideInConstructorComplex
- testPropertyInitializationOrder
2023-05-23 14:12:28 +03:00
Nikita Bobko 38319c55a8 [FE] Replace some MUST_BE_INITIALIZED messages with MUST_BE_INITIALIZED_OR_BE_FINAL
From user point of view it's an improvement in compilation message.

From technical point of view it's an introduction of new compilation
diagnostic.

Review: https://jetbrains.team/p/kt/reviews/9967

I'm going to deprecate `open val` case in the next few commits KT-57553.
But it is always possible to suggest using `final` for `open val` case.
2023-05-23 14:12:28 +03:00
Ilmir Usmanov f3a22e0ac4 Warn about suspend extension functional types as supertypes
They will become error in 2.0

 #KT-58529 Fixed
 #KT-49175 Fixed
2023-05-19 12:41:37 +02:00
Michael Knudson 067456c052 Clarify error message for abstract property in primary constructor 2023-05-19 09:40:49 +00:00
Ilya Goncharov bcefa1cd66 [Gradle, Wasm] Add wasm platform kind
KTIJ-25583
2023-05-17 13:28:20 +00:00
Nikita Bobko 9a65dcb664 MUST_BE_INITIALIZED: take into account containingDeclaration's modality
^KT-58587 Fixed
Review: https://jetbrains.team/p/kt/reviews/10136

This commit is important in scope of KT-57553. It makes the migration
more smooth.

Other related tests:
- testUninitializedOrReassignedVariables
- testAugmentedAssignmentInInitializer
2023-05-12 13:48:49 +00:00
Vladimir Dolzhenko 451daaa7c5 Do not publish non fully initialized descriptors
Leaking of a reference (via publishing to binding trace) of not fully
initialized object could lead to unpredicted and unexpected NPEs
iff some exception (like PCE or InvalidPsiAccess) happens between
the publishing and initialization.

#KT-57514
#KT-56388
#KT-56364

Merge-request: KT-MR-10052
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-05-10 11:40:44 +00:00
Mikhail Glukhikh bbee881b5b K1: add separate TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_IN_AUGMENTED_ASSIGNMENT
This is made to have a correct error message for a problem
described in KT-48546
#KT-48546 Fixed
2023-05-02 12:57:15 +00:00
Mikhail Glukhikh 94c94d0605 K1: add a language feature to negate new errors from DiagnosticReporterByTrackingStrategy
Related to KT-55055, KT-55056, KT-55079, KT-57854
2023-05-01 11:47:01 +00:00
Mikhail Glukhikh 4188bca9b8 K1: don't report RECEIVER_TYPE_MISMATCH with -ProperTypeInferenceConstraintProcessing
Related to KT-55056
#KT-57854 Fixed
2023-05-01 11:47:01 +00:00
Vladimir Dolzhenko adc5fe6e4e rr/vd/KT-57514
Revert "Create SimpleFunctionDescriptorImpl under nonCancelableSection"

This reverts commit d959b3a289b24487dba2e36da94a34a0dbb4661e.

Revert "Create PropertyDescriptorImpl under nonCancelableSection"

This reverts commit 362e8c2151c8e18009463fd51b995cce27ac8eb5.

Merge-request: KT-MR-9772
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-04-29 06:39:59 +00:00
Andrei Klunnyi 1e0115aef8 KT-57468 Kotlin assignment plugin: operation name cannot be found
The problem results in broken import quick fix and import optimizer on
the IDE side [1].

`AssignResolutionAltererExtension` introduced a possibility to override
 resolution of assignment statements. The inconsistency though is
 that `KtSimpleNameReference.getResolvesByNames` doesn't return a name
 for the overridden `=`. Kotlin as a language doesn't support this [2].

This commit eliminates the drawback above:
1. It fixes the name `assign` the `=` can be resolved to [3].
   This eliminates the need to search for the name, bypassing the
   plugins.
2. `KtSimpleNameReference.getResolvesByNames` returns `assign` among
   other names in case it deals with binary `=` and assignment is
   resolved.
3. `KtCompilerPluginsProvider` was extended to check plugins' presence.
   K1 implementation added.

----------------------------------------------------------------
[1]: https://youtrack.jetbrains.com/issue/KTIJ-24390
[2]: OperatorConventions.getNameForOperationSymbol
     https://kotlinlang.org/docs/operator-overloading.html#augmented-assignments
[3]: OperatorConventions#ASSIGN_METHOD + AssignmentPluginNames
2023-04-27 14:05:02 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Alexander Udalov bc7aea1426 Kapt+JVM_IR: generate delegated members correctly
Generate a declaration for each delegated member without body. If we
don't generate delegated declarations, subclasses will have incorrect IR
with unbound symbols in fake overrides.

 #KT-58027 Fixed
2023-04-19 23:04:45 +00:00
Mikhail Glukhikh b6fdc2dbfc DiagnosticReporterByTrackingStrategy: replace TODO() with assertions/errors
#KT-55079 Fixed
2023-04-19 07:24:05 +00:00
Vladimir Dolzhenko e10e821cd4 Fix onTheFlyDiagnosticsCallback
KtNamedFunction, KtClass etc are KtAnnotated.
Annotation recursion could happen within onTheFlyDiagnosticsCallback if
KtAnnotated has some annotations.

#KTIJ-25219

Merge-request: KT-MR-9652
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-04-18 19:44:00 +00:00
Mikhail Glukhikh 0dbf698653 K1: count anonymous function as function expression in checkers
Related to KT-57991
2023-04-17 18:05:44 +00:00
Mikhail Zarechenskiy fc37885d6d K1: report a warning for invisible setter accessed from a derived class
The issue is that during binding fake overrides, the compiler doesn't
 differ setters from its properties, so the compiler uses the same
 visibility for setter and entire property.

 Changing logic at the binding stage can cause some unpredictable consequences so
 the fix is to do this differentiation right at the reporting stage

 ^KT-56662 Fixed

Merge-request: KT-MR-9565
Merged-by: Michail Zarečenskij <Mikhail.Zarechenskiy@jetbrains.com>
2023-04-17 11:08:16 +00:00
Roman Efremov c718c77c43 [FE] Check visibilities of expected and actual property setters are compatible
^KT-30905 Fixed
2023-04-06 13:10:30 +00:00
Roman Efremov 9044dfe394 [FE] Revert prohibition of protected members inside actual final classes
^KT-28850 Fixed
2023-04-06 13:10:12 +00:00
Roman Efremov b368b78faa [FE] Prohibit protected members in final expected or actual classes
^KT-28850 Fixed
2023-04-05 15:25:46 +00:00
Roman Efremov 456d3e0f42 [FE] Prohibit expect fun interface to have non-fun actual counterpart
In K1 .isFun is always false for Java classes, so extra check
is added for that. This is not needed for K2, because .isFun is
true for all Java classes. Here it is not necessary to check
that interface has only one method, because such check will be
done in the place where interface implementation is created.

^KT-39362 Fixed
2023-04-05 07:31:58 +00:00
Roman Efremov bcf4528763 [MPP] Forbid actual member in expect class
Such member descriptor will be actual and expect at the same time,
so we should run both checks.

^KT-40903 Fixed
2023-04-04 12:28:00 +00:00
Anna Kozlova 3496f69f33 [cfg] don't traverse annotation arguments for decompiled code
^ KT-57768
decompiled code have no annotation arguments expressions,
but search for them causes decompiling of code
which is slow and unneeded
2023-04-04 10:55:22 +00:00
Kirill Rakhman 91adb88eff [K1] Make Volatile diagnostics applicable to kotlin.concurrent.Volatile
#KT-55628
2023-04-04 10:36:39 +00:00