Commit Graph

106370 Commits

Author SHA1 Message Date
Dmitrii Gridin bc1e9fd2ea [LL FIR] LLFirTargetResolver: introduce resolveDependencyTarget step
This entry point is required to be able to pre-resolve dependency
declarations.
E.g., fake override declaration shares annotation instances between
the original and the fake one, so we should resolve the original
firstly to avoid concurrent modification and correct context.
This will be done later.

This commit effectively only drops body resolution for a file annotation
container if the target element is not a file because this
is not required for correct resolution

^KT-63042
2023-11-22 11:02:09 +00:00
Dmitrii Gridin 0b07b86ec9 [FIR] make FirLazyDeclarationResolver FirElementWithResolveState-based
This is required to be able to call lazy resolve for FirFileAnnotationsContainer

^KT-63042
2023-11-22 11:02:09 +00:00
Sergej Jaskiewicz d7710b8e8d [FIR generator] Remove redundant full qualifier in generated builders 2023-11-22 10:00:06 +00:00
Ivan Kylchik 5edfd6af0f [JVM_IR] Declare type parameters of an outer declaration for code fragment
#KT-63597 Fixed
2023-11-22 09:58:20 +00:00
Alexander Korepanov 45c166abf8 [JS IR] Introduce special setMetadataFor*() for synthetic classes
^KT-63436 Fixed
2023-11-22 09:21:44 +00:00
Alexander Korepanov 9af681e234 [JS IR] Rename metadataUtils.kt -> metadataUtilsOld.kt 2023-11-22 09:21:44 +00:00
Alexander Korepanov 85b2daf41d [JS IR] Add reflection tests 2023-11-22 09:21:44 +00:00
Alexander Korepanov c13cc38758 [JS IR] Remove unused code 2023-11-22 09:21:44 +00:00
Kirill Rakhman 3fe0d3286c [Tests] Mute failing FakeOverrideRebuilder tests after #KT-61282
#KT-63489
2023-11-22 08:46:17 +00:00
Kirill Rakhman 865b8a4175 [FIR] Create special hidden override for Java signature clash due to rename
This fixes CharBuffer.get resolving to CharBuffer.charAt

#KT-61282 Fixed
2023-11-22 08:46:17 +00:00
Kirill Rakhman 528a2d3c62 [FIR] Rename CheckDeprecatedSinceKotlin resolution stage to CheckHiddenDeclaration 2023-11-22 08:46:16 +00:00
Nikolay Lunyak f12ecb3011 [FIR2IR] Avoid converting arguments of dynamic array set twice
^KT-63593 Fixed


Merge-request: KT-MR-13152
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-11-22 07:39:46 +00:00
Anastasia.Nekrasova fb0461f422 [K2] Disappeared UNSUPPORTED_FEATURE (3)
Added a check for the enabled context receivers feature flag for @ContextFunctionTypeParams.

^KT-59913
2023-11-22 06:04:13 +00:00
Anastasia.Nekrasova c04767f1f4 [K2] Disappeared UNSUPPORTED_FEATURE (2)
Added a check for the enabled context receivers feature flag for declaration.

^KT-59913
2023-11-22 06:04:13 +00:00
Anastasia.Nekrasova 685c8e4fe7 [K2] Disappeared UNSUPPORTED_FEATURE (1)
Added a check for the enabled context receivers feature flag for typeRef.

^KT-59913
2023-11-22 06:04:13 +00:00
Alexander Udalov 471f25abfc IR: support buildSimpleType for IrCapturedType
To make it possible to change nullability of IrCapturedType and change
its annotations, which is happening when determining overridability of
functions via IR.

 #KT-63437 Fixed
2023-11-21 20:02:13 +00:00
Alexander Udalov 8379e48e33 IR: remove IrSimpleTypeBuilder.variance
IrCapturedType (which is a IrSimpleType) does not have variance, so it
is confusing to have it in IrSimpleTypeBuilder, and it's clearer to
construct type projection separately anyway.
2023-11-21 20:02:12 +00:00
Alexander Udalov 898d3aeea9 IR: minor refactorings around IrType/IrCapturedType
- use identity in equals/hashCode. It was already effectively working
  like this because of `constructor === other.constructor`
- implement variance and declare it in IrSimpleType
- remove obsolete TODO
- simplify code in captureFromArguments
- use data objects
2023-11-21 20:02:12 +00:00
Alexander Udalov dec41e8c46 Improve muted K2 metadata (kotlinp) tests
Add comments referencing issues where K2 behavior is questionable, and
provide `.fir.txt` versions where behavior is different but fine.
2023-11-21 19:57:10 +00:00
Roman Golyshev f5131d0be2 KTIJ-27730 [AA] Do not shorten constructors of nested classes by default
The relevant tests are in the `intellij` repo

^KTIJ-27730 Fixed
2023-11-21 18:52:57 +00:00
Pavel Kirpichenkov 5729fab8c4 Fix deprecation warning
KTIJ-27752
2023-11-21 18:43:06 +00:00
Pavel Kirpichenkov 645e4af8b1 [IDE] Move KotlinJavaScriptMetaFileDecompiler to kotlin.git
KTIJ-27752
2023-11-21 18:43:06 +00:00
Pavel Kirpichenkov b41c4bc4c1 [IDE] create KotlinLabelProviderService on request
getServiceIfCreated doesn't create a service instance if id wasn't
created before. There are no other service requests for
KotlinLabelProviderService, so it was not used for file types.

KTIJ-27755
2023-11-21 18:43:06 +00:00
Ilya Gorbunov 4d8cf4903c [stdlib] Explicit visibility and return types: DOM API 2023-11-21 18:14:09 +00:00
Ilya Gorbunov ce427b96b3 [stdlib] Suppress explicit api errors in DOM declarations generated by dukat
Suppressions should be removed once dukat supports generating
explicit public visibility and return types
2023-11-21 18:14:09 +00:00
Ilya Gorbunov cfa8a1dc0f [stdlib] Explicit visibility and return types: Wasm 2023-11-21 18:14:09 +00:00
Ilya Gorbunov 381a8fd55f [stdlib] Explicit visibility and return types: JS
Stepping test line number changes are due to changes in coroutineInternalJS.kt
2023-11-21 18:14:09 +00:00
Mikhail Glukhikh 0c61ce61c3 K2: for Java source override, don't compare return types in override checker
#KT-57044 Fixed
2023-11-21 18:11:58 +00:00
Roman Golyshev 7d7256536c KT-63627 [AA] Properly handle object declarations when traversing scopes in KtFirReferenceShortener
`KtClass` denotes only classes, interfaces and enums.
To handle object declarations, we now use
`KtClassOrObject` PSI type

^KT-63627 Fixed
2023-11-21 18:08:43 +00:00
Evgeniy.Zhelenskiy 5096fd266e [FIR] Forbid generic type checks inside contracts in K2 as it is done in K1.
#KT-59922
2023-11-21 18:00:10 +00:00
strangepleasures a35191706f [KAPT] Minor. Fix the signature of printField method
Merge-request: KT-MR-13154
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2023-11-21 17:55:51 +00:00
Nataliya.Valtman fff089eba8 Fix ClassCastException in JPS statistics ad update log messages
#KT-63594 Fixed
2023-11-21 15:28:27 +00:00
Yahor Berdnikau ffa6bfc95e [Gradle] Partially restore top-level compiler options DSL in MPP
To support configuring free compiler arguments for all shared source
sets (KT-61573), we restore 'compilerOptions { }' DSL in the
multiplatform extension.

To avoid user confusion on accidentally using 'compilerOptions {}'
inside Kotlin targets and Kotlin compilations DSL, similar methods with
ERROR deprecation level were added into `KotlinTarget` and
`KotlinCompilation` interfaces. Invoking these interfaces will throw
UnsupportedOperationException. Such an approach works both for Kotlin
and Groove Gradle scripts.

^KT-63491 Fixed
2023-11-21 14:06:17 +00:00
strangepleasures f32fd314f8 [KAPT] Adhere to the call conventions when instantiating and using KtAnalysisSession
Merge-request: KT-MR-13098
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2023-11-21 13:21:19 +00:00
strangepleasures 7c6375c85a KT-63552 [SLC] Support empty arrays in property initializers and default parameter values 2023-11-21 13:20:26 +00:00
Evgeniy.Zhelenskiy 67b1bb448a [FIR] Report repeating parameters in dynamic functions in Kotlin/JS
^KT-59988
2023-11-21 13:12:46 +00:00
Marco Pennekamp 166964bfcc [LL] Declaration modification service: Discover contract removal in "element removed" events
- PSI tree change events from the IDE aren't necessarily paired. For
  example, when we delete a contract statement via `PsiElement.delete`,
  only "after removal" PSI tree change events will be published.
- Previously, the declaration modification service would not see such
  contract removal as an out-of-block modification because it didn't see
  the already removed contract in the associated function. As there is
  no "before removal" event, the service had no chance to discover the
  contract removal.
- This fix adds the removed element as a property of `ModificationType`.
  While the element will already be removed and its parent will be a
  dummy holder, we can still analyze its PSI to determine whether it is
  a contract.

^KT-63538 fixed
2023-11-21 13:12:29 +00:00
Yahor Berdnikau 294b36e16f [Gradle] Repurpose 'kotlin.experimental.tryK2'
Now it sets +1 to default one language version. Property name was
updated to 'kotlin.experimental.tryNext'.

^KT-61975 Fixed
2023-11-21 11:58:45 +00:00
Marco Pennekamp 4efe7a00f1 [AA] KtFirSymbolContainingDeclarationProvider: Support EnumGeneratedDeclaration in getContainingPsi
- The root cause of the exception in KT-62982 is that symbol light
  classes are accessed in dumb mode (see KT-63490). Nonetheless, we can
  patch the exception by supporting `EnumGeneratedDeclaration` in
  `getContainingPsi`.
- To create a symbol from the containing PSI,
  `KtFirSymbolContainingDeclarationProvider` will still try and fail to
  find the enum class symbol via symbol providers, but it'll fall back
  to a designators search in the same `FirFile`, which will find the
  symbol without index access (see `findSourceNonLocalFirDeclaration` in
  LL API's `declarationUtils.kt`).

^KT-62982 fixed
2023-11-21 11:38:40 +00:00
Marco Pennekamp dd23415793 [AA] Improve coding conventions of KtAnalysisSession
- This commit rewords the coding conventions around `KtAnalysisSession`
  and forbids usage of class context receivers. As explained in the
  KDoc, classes opaquely capture their context receivers as properties,
  which is a high-risk source of leakage.
2023-11-21 11:37:55 +00:00
Ivan Kylchik cec9260b45 [Test] Add a new handler to check that const declarations have constants
#KT-62683 Fixed
2023-11-21 09:48:58 +00:00
Ivan Kylchik fd4a3a0b88 [FIR] Forbid to use equality and unsigned comparison in const expression
#KT-62683
2023-11-21 09:48:58 +00:00
Ivan Kylchik 8715bd6189 [IR] Don't evaluate expressions in inner class of an annotation 2023-11-21 09:48:58 +00:00
Ivan Kylchik 9742b5af73 [IR] Refactor IrConstOnlyNecessaryTransformer
This way it is just easier to understand what is going on.
2023-11-21 09:48:57 +00:00
Ivan Kylchik 3fa82c7bb1 [K2] Properly evaluate complex boolean constants
Some boolean expressions could be transformed into `IrWhen`
node. To understand that this node is actually
a boolean expression, we need to analyze its origin.

#KT-62683
2023-11-21 09:48:57 +00:00
Dmitriy Dolovov ede77ea29c [KLIB tool] Warn on unknown CLI options 2023-11-21 09:36:07 +00:00
Dmitriy Dolovov b1c9791404 [Native] Warn on any usage of -repo CLI option
^KT-61098
2023-11-21 09:36:07 +00:00
Dmitrii Gridin 0b253dc815 [FIR] resolve delegate field return type in correct scope
We should resolve it in the same way as delegate constructor call
to avoid access to nested class scopes

^KT-63522 Fixed
^KT-63042
2023-11-21 08:11:21 +00:00
Dmitrii Gridin ab6b3a6047 [LL FIR] fix scope for constructor resolution
We should grab static scope before in the same way as scopesBefore
to not get already updated static scope with nested scopes.
Also, we should restore such "before" snapshots to avoid their modification
(this can be reproduced with in the next commit)

^KT-63042
2023-11-21 08:11:21 +00:00
Dmitrii Gridin a9aa0e020a [LL FIR] add tests for constructors
We are resolving delegated constructor call in the wrong context
```
TYPES:
FILE: [ResolvedTo(IMPORTS)] superTypeCallNameClash.kt
    public? open [ResolvedTo(SUPER_TYPES)] class Base : R|kotlin/Any|
    public? final? [ResolvedTo(TYPES)] class MyClass : R|second/Base| {
        public? [ResolvedTo(TYPES)] [ContainingClassKey=MyClass] constructor(): R|second/MyClass| {
            LAZY_super<R|second/MyClass.Base|> // should be R|second/Base|
        }

        public? open [ResolvedTo(RAW_FIR)] class Base : R|kotlin/Any|
    }
```

^KT-63042
2023-11-21 08:11:21 +00:00