Commit Graph

11061 Commits

Author SHA1 Message Date
Mikhail Glukhikh c6e0268893 Revert "Temporary: make PRE_RELEASE_CLASS a warning in both K1/K2 (KT-66551)"
This reverts commit a0cb713d19.
#KT-66551 Fixed
2024-03-15 11:33:10 +00:00
Mikhail Glukhikh a0cb713d19 Temporary: make PRE_RELEASE_CLASS a warning in both K1/K2 (KT-66551) 2024-03-13 20:38:44 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Dmitriy Novozhilov 6740a596c7 [Frontend] Provide ProjectExtensionDescriptor for DiagnosticSuppressor
`DiagnosticSuppressor` didn't contain `ProjectExtensionDescriptor`, which
  prevented usages of this extension point with API provided by
  `CompilerPluginRegistrar`

See discussion in KT-60952
2024-03-07 15:33:07 +00:00
Mikhail Glukhikh 678816f9e8 K1: introduce BUILDER_INFERENCE_STUB_PARAMETER_TYPE to prevent compiler crashes
This diagnostic is reported in rare situations when
StubTypeForBuilderInference is kept as a parameter type
of for loop or lambda. Before this commit, we had in K1
"Could not load module <error module>" from IrLinker instead.

Related to: KT-52757, KT-53109, KT-63841, KT-64066
#KT-53478 Fixed
2024-02-27 10:25:13 +00:00
Pavel Kirpichenkov ae664d37ae [Tests] Support KLIB metadata for stdlib in test compile utility
Create dependency provider able to resolve code from .knm metadata
files to simplify migration from the legacy kotlin-stdlib-common
artifact.

KTIJ-28668
KTI-1457
2024-02-26 10:18:38 +00:00
Dmitrii Gridin 072d191306 [compiler] replace Enum values() with entries
To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
2024-02-20 17:56:46 +00:00
Pavel Kunyavskiy 6e8a7d4662 [ObjCInterop] Implement @ObjCSignatureOverride
This annotation leads to conflicting overloads error supression,
in case where several function with the same argument types,
but different argument names are inherited from ObjC class.

We need to implement it in both K1 and K2 to make the IDE experience
better.
But the annotation itself wouldn't be available in K1.

    ^KT-61323
2024-02-14 11:44:01 +00:00
Nikita Bobko 58e1c4c6ac [FIR] Kmp: Deprecate header/impl keywords
Review: https://jetbrains.team/p/kt/reviews/14224/timeline

Timeline:
**(1)** Kotlin 1.1.60 https://github.com/JetBrains/kotlin/commit/59efedf610a25b004edf3d19897ce4dfca28ddb2 `header` keyword is introduced (committed on Dec 13, 2016)
**(2)** Kotlin `header`/`impl` has been deprecated (warning) at least since 1.1.60 https://github.com/JetBrains/kotlin/commit/5d251062677e09d607f295189b7978d5833e448f (committed on Sep 15, 2017)
**(3)** 1.1.60 release https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler/1.1.60/ Nov 13, 2017

It sounds stupid but it looks like `header` was introduced and
deprecated right in the same release. Though it may be possible that we
had a release between **(1)** and **(2)** that I couldn't find

Anyway the keywords have been deprecated since basically forever

The fix is not perfect

"The perfect fix" would be:
1. Introduce a separate `DEPRECATED_MODIFIER_ERROR` diagnostic
2. Introduce LanguageVersionSettings for the `DEPRECATED_MODIFIER_ERROR`
   diagnostic

But "the perfect fix" requires:
1. Adopting `ReplaceModifierFix` in the IDE to make it work with the new
   diagnostic. `ReplaceModifierFix` is only implemented in K1 IDE. So
   there are two ways:
   1. Create a KTIJ ticket to port the diagnostic to K2 IDE (it needs to
      be ported anyway), and **mention** in the ticket that
      `DEPRECATED_MODIFIER_ERROR` also needs to be supported in K2 IDE.
      It's the ticket that nobody will probably find and fix
   2. Go and port `ReplaceModifierFix` to K2 IDE myself. It's fairly
      simple task, but I've not worked in intellij for quite a while,
      and it will take me too much time to index and compile

Considering that DEPRECATED_MODIFIER diagnostic is used only to report
`header`/`impl`, and there are literally 0 known cases when people use
it. It's just easier to convert the diagnostic to error in K2

Related tests:
- compiler/testData/diagnostics/tests/multiplatform/deprecated/header.kt

^KT-59839 Fixed
2024-02-08 16:34:27 +00:00
Alexander Udalov 9d5e1bdc47 CLI: remove obsolete -Xallow-result-return-type 2024-02-01 23:37:23 +00:00
Yan Zhulanow c8af3381d6 [Stubs] Fix stub inconsistency on unnamed setter parameters
If an unused setter parameter was replaced with an underscore ('_'),
it had a special name in the stub ('<anonymous parameter 0>'). The text
version of the stub inserted it as is, leading to an extra
'PsiErrorElement'.

^KTIJ-28194 Fixed
2024-01-24 18:41:42 +00:00
Kirill Rakhman 228ab60476 [FE 1.0] Fix new compilation warnings after #KT-63208
(cherry picked from commit dc0f4e6995)
2024-01-18 08:27:10 +00:00
Kirill Rakhman fa6ad41395 Revert "[FE 1.0] Fix new compilation warnings after #KT-63208"
This reverts commit dc0f4e6995.
2024-01-16 09:14:19 +01:00
Kirill Rakhman dc0f4e6995 [FE 1.0] Fix new compilation warnings after #KT-63208 2024-01-15 12:23:26 +00:00
Sergej Jaskiewicz eda30ff704 [klib] Implement diagnostics for clashing KLIB signatures
Now, we detect clashing signatures during serialization to KLIB and
report a compiler error if two or more declarations have the same
`IdSignature`

For example, for the following code:
```kotlin
@Deprecated("", level = DeprecationLevel.HIDDEN)
fun foo(): String = ""

fun foo(): Int = 0
```

the compiler will produce this diagnostic:
```
e: main.kt:1:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
e: main.kt:4:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
```

Note that we report this diagnostic during serialization and not earlier
(e.g., in fir2ir) for more robustness, so ensure that we check
exactly the signatures that will be written to a KLIB.
If we later introduce some annotation for customizing a declaration's
signature (e.g., for preserving binary compatibility), this
diagnostic will continue to work as expected.

^KT-63670 Fixed
2024-01-12 15:59:28 +00:00
Alexander.Likhachev 21b438f55d Replace the trove4j collections usages with the fastutil ones
The trove4j library is licensed under LGPL, and that causes some troubles while working with it. The fastutil library provides the same functionality in the context of our needs, and is licensed under the Apache license.
^KTI-1135 In Progress
2024-01-10 11:29:25 +00:00
Anna Kozlova ce0a41fc69 [psi] move frontend independent string manipulators to psi.main module
this way IDE can drop dependency to old frontend,
when it's actually redundant
2024-01-08 09:54:48 +00:00
Nikita Nazarov 251fdb21c9 [FIR] Generate spread element for unsigned arrays
Previously when unsigned arrays were passed as vararg in a named form the necessary spread element wasn't generated, which resulted in a compilation error.

^KT-63514 fixed
2023-12-13 15:30:27 +00:00
Mikhail Glukhikh 526bc1744a K2: implement BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION
#KT-59390 Fixed
2023-12-01 10:54:29 +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
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +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 a537ab898e [FE 1.0] Refactoring: replace defensive NonPrivateCallableAdded with Unknown
Motivation: I'm going to drop NonPrivateCallableAdded (KT-62655) in the
next commits. But I don't want to change the existing logic when I drop
it. That's why I have to introduce the "Unknown" case
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
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Ilya Kirillov f11cb277cd Remove obsolete @OptIn(ExperimentalStdlibApi::class) annotations
They were added when `buildList`, `buildMap` and `buildSet` were experimental.

^KT-62510
2023-10-12 10:41:00 +00:00
Nikita Bobko 43c97077eb 2/2 Extract K1 KMP matcher in its own subsystem. Fix compilation errors 2023-10-06 11:41:22 +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
Mikhail Glukhikh 156097fe17 Restore KotlinCompilerVersion.IS_PRE_RELEASE
This commit is a slightly modified revert of 4f29c113.
IS_PRE_RELEASE allows to make LATEST_STABLE version behave as
experimental when this flag is set to true.
The general goal is to prepare fix of KT-62058; after this commit
one can do it by changing IS_PRE_RELEASE flag to true.
The fix of KT-62058 is planned to be done during bootstrapping.
This preparation and the future fix are parts of umbrella KT-61951.
2023-09-21 20:09:25 +00:00
Mikhail Glukhikh 8b8088720b Rename: DeserializedContainerAbiStability.IR_UNSTABLE -> UNSTABLE
Related to KT-62056
2023-09-21 11:14:09 +00:00
Mikhail Glukhikh a77b758efa LV 2.0: drop reporting FIR_COMPILED_CLASS and relevant stuff
#KT-62056 Fixed
Related to KT-59171, KT-61951
2023-09-21 11:14:09 +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 420dceb7d8 [FE, IR] Store PsiElement for mismatched annotation's actual target
There is IDE quick fix which suggests to copy mismatched annotation
from `expect` to `actual` (see KTIJ-26633). It needs to find
`actual` PsiElement where to add annotation. Before previous commit, it
was easy - just get source of `Incompatibility.actualSymbol`.
After previous commit, the problem might be in value parameter, while
`actualSymbol` would contain function symbol. This is solved by adding
new field `Incompatibility.actualAnnotationTargetElement`.

`SourceElementMarker` introduced, because it's needed to be used in
abstract checker. Existing `DeclarationSymbolMarker` doesn't fit
because in next PR for this issue annotations set on types will be reported,
and types are not declarations.

^KT-60671
2023-09-15 14:41:37 +00:00
Dmitriy Dolovov 98b3bdb175 [K1] Rename analysis flag expectActualLinker
Rename analysis flag `expectActualLinker` to `skipExpectedActualDeclarationChecker`
to better reflect its semantics. This flag isn't used on IDE plugin side, so no
additional changes in `intellij` repo are needed.

^KT-61136
2023-09-14 07:32:18 +00:00
Timofey Solonin 53584cdd49 Don't emit CAST_NEVER_SUCCEEDS when casting to a forward declaration type
^KT-58929
2023-09-13 17:49:12 +00:00
Sergej Jaskiewicz dff2d2ed60 [descriptors] Move some annotation-related utilities to the core module
- AnnotationDescriptor#argumentValue is not frontend-specific
- AnnotationDescriptor#getAnnotationStringValue is not Native-specific

We are going to need these functions in the IR code, so it makes
sense to factor them out to the core module.
2023-09-13 14:25:08 +00:00
Alexander Udalov d16f33cf5b JVM IR: do not collect all dependency modules in IDE
Collecting all modules takes a lot of time in Evaluate Expression in
IDE, and it's useless because we then invoke JvmIrLinker to load module
headers, but that linker is discarded in the IDE (see `val irProviders`
below).

 #IDEA-329915
2023-09-12 09:11:44 +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
Nikita Bobko 3c73331821 KMP: Put "prohibit actual typealias to special annotations" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:43 +00:00
Nikita Bobko e742d43ee0 KMP: Put "prohibit expect/actual tailrec/external" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:43 +00:00
Nikita Bobko 172c04c96a KMP: Put "prohibit expect actual OptIn annotations" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:43 +00:00
Nikita Bobko 0922833b46 KMP: Put "prohbit actual typealias to Nothing and Nullable" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Nikita Bobko 141bc9cac9 KMP: Put "prohbit actual typealias if expect has default params" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Nikita Bobko 6868c95263 KMP: Put "prohbit expect/actual different annotations" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Nikita Bobko 3a0c4d1087 KMP: Put "prohbit implicit Java actualization" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Nikita Bobko 7667b36aa0 KMP: Put "prohibit member scope mismatch for non-final expect" under the flag
^KT-61668 Fixed

Review: https://jetbrains.team/p/kt/reviews/12062/timeline
2023-09-08 10:51:42 +00:00
Denis.Zharkov a02cb16fb2 K2: Rewrite delegate inference
The main idea is getting rid of stub types and using just type variables
See more detailed description at docs/fir/delegated_property_inference.md

The problem with stub types is that they need really special treatment
in many places, and on the other hand, there are no clear contracts on
how they should work (that regularly leads to bugs like KT-59529)

^KT-61060 Fixed
^KT-61075 Fixed
^KT-61077 Fixed
^KT-59529 Fixed
^KT-61633 Related
^KT-61618 Related
^KT-61740 Related
^KT-59107 Related
^KT-61747 Related
^KT-61077 Related
^KT-61781 Related
2023-09-08 07:11:48 +00:00