Commit Graph

106337 Commits

Author SHA1 Message Date
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
Dmitrii Gridin b3b184f00d [FIR] add more tests diagnostic tests on data and delegated classes
^KT-63522
^KT-63512
^KT-63042
2023-11-21 08:11:20 +00:00
Sergej Jaskiewicz fab63e38aa [FIR/IR generator] Reduce duplication when printing curly-braced blocks 2023-11-21 01:15:10 +00:00
Sergej Jaskiewicz 18ed85c26e [IR generator] Auto-generate IrElementTransformerVoid 2023-11-21 01:15:10 +00:00
Sergej Jaskiewicz 6798ff4a73 [IR generator] Prepare IrElementTransformerVoid for auto-generation
This commit does two things:
- Reorders methods so that after we enable auto-generation the git diff
  is clearer
- Adds explicit return types to all `IrElementTransformerVoid` methods
  for the same purpose

No semantic changes in this commit.
2023-11-21 01:15:10 +00:00
Pavel Punegov 7623d5e3eb [K/N][test] Disable array allocation test on Linux
The test allocates a lot of memory and can cause OOM-killer on Linux
with 16 Gb RAM or less kill Gradle daemon.


Merge-request: KT-MR-13131
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2023-11-20 22:22:48 +00:00
Pavel Punegov 1384377fec [K/N][perf] Fixup target toolchain path for swift compilation
Fix swiftc path in the performance infrastructure. It has a separate
plugin to regular native-build-tools.

This fixes failures caused by the 3aeca1956e.
See also MR-KT-12948


Merge-request: KT-MR-13130
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2023-11-20 22:22:08 +00:00
Yahor Berdnikau a20f21f76f [Gradle] Introduce 'kotlin.internal.compiler.arguments.log.level' property
This property allows changing log level for message printing the final
set of compiler arguments used to run compilation.

Possible levels are 'error', 'warning', 'info', 'debug'. Default level
is 'debug'.

^KT-60733 Fixed
2023-11-20 21:03:38 +00:00
strangepleasures 03ed1d1d31 KT-62560 [SLC] Fix handling of empty varargs in annotations 2023-11-20 20:57:21 +00:00
Roman Golyshev 4f5926a88f KT-62675 [AA] Handle labeled this expressions in reference shortener
At the moment, there is no good way to meaningfully filter `this`
expressions. The filters for the reference shortener can work only with
symbols, and it does not make a lot of sense to check any particular
symbol when deciding whether to shorten a labeled `this` expression.

We would probably need a better API for the shortener to be able
to filter more precisely (see KT-63555)

^KT-62675 Fixed
2023-11-20 20:18:18 +00:00
Roman Golyshev d47557067c KT-62675 [AA] Get rid of second override of ElementsToShortenCollector.addElementToShorten
Those two overrides were odd - one of them was deconstructing
`ElementToShorten` into its fields, and the other one was
re-constructing it back
2023-11-20 20:18:17 +00:00
Roman Golyshev 12fbc3384e KT-62675 [AA] Refactor ElementsToShortenCollector.createElementToShorten
Use it more instead of the constructor calls
2023-11-20 20:18:17 +00:00
Roman Golyshev 132467ae1e KT-62675 [AA] Simplify ElementToShorten hierarchy
Clearly separate `ShortenKDocQualifier` from it,
it does not belong there for now
2023-11-20 20:18:16 +00:00
Roman Golyshev 6b48ec7780 KT-62675 [AA] Refactor KtFirReferenceShortener.kt
Separate FIR visitor from collector
2023-11-20 20:18:16 +00:00
Evgeniy.Zhelenskiy 9383d0bfa4 [FIR] Check type arguments in inner/outer local classes as in K1
^KT-59922 ^KT-59951
2023-11-20 20:04:45 +00:00
Brian Norman cfa48b5cc0 [FIR] Add null implications to both sides of equality when appropriate
When both sides of an equality expression are null or Nothing?, only the
right side is receiving implications within the data-flow. Make sure the
left side has implications add as well. This is important for boolean
conditions when implications from both sides need to be combined.

^KT-63535 Fixed
2023-11-20 20:03:52 +00:00
Svyatoslav Kuzmich 43345bbc34 [Wasm] Port js(code) calls checker to K2 (KT-56849)
^KT-62725 Fixed
^KT-62726 Fixed
^KT-62727 Fixed
2023-11-20 18:10:55 +00:00
Svyatoslav Kuzmich 260db2fa65 [Web] Refactor: Move FirWebCommonExternalChecker to appropriate place
Move it from gen/ to src/ and fix the package name
2023-11-20 18:10:54 +00:00
Svyatoslav Kuzmich 90948adca0 [Wasm] Minor refactor: remove unused imports in K2 checkers 2023-11-20 18:10:54 +00:00
Svyatoslav Kuzmich 7092541e34 [Wasm] K2 js(code) constant checker (KT-56849)
Reuse K/JS FirJsCodeConstantArgumentChecker by moving it to web.common
2023-11-20 18:10:54 +00:00
Evgenii Mazhukin 5973951f71 [IC] Smoke tests for KMP IC, part 1
Assert reasonable compile avoidance when basic changes are made in a
multiplatform project

^Relates to KT-56963

Merge-request: KT-MR-13032
Merged-by: Evgenii Mazhukin <evgenii.mazhukin@jetbrains.com>
2023-11-20 17:17:27 +00:00
Mikhail Glukhikh 3ff16f7798 K2: split JavaTypeParameterStack to mutable/immutable
#KT-62314 Fixed
2023-11-20 17:00:03 +00:00
Marco Pennekamp b43ceab880 [AA] Avoid running modifiable PSI tests on the EDT
- `runWriteCommandAction`, which is required for PSI modification
  functions like `PsiElement.delete`, must be invoked on the EDT.
  However, instead of `runWriteCommandAction` we can use
  `runUndoTransparentAction`, which does not need to be run on the EDT
  and fulfills the same requirement.

^KT-63560
2023-11-20 16:29:26 +00:00
Marco Pennekamp 1870189e47 [AA] Fix write access configuration in unit test application environments
- We cannot configure the application's write action accessibility on a
  per-test basis because (1) the application may be shared across
  concurrent tests and (2) the application is usually cached, so the
  configuration will be missed entirely.
- There is actually a much easier solution to allow write access
  selectively: We can enable it in `runWriteAction` blocks, and keep it
  in a thread local to support concurrent test runs. As Analysis API
  tests never call `runWriteAction`, there will be no "analyze cannot be
  called from a write action" error, and if `analyze` is somehow called
  from a write action, it will now be caught.

^KT-63560 fixed
2023-11-20 16:29:26 +00:00
Mikhail Glukhikh 3b7f43a9c2 K2: don't throw an exception for type parameter case in isJavaTypeOnThePath
#KT-63569 Fixed
2023-11-20 15:35:58 +00:00
Mikhail Glukhikh 8924e46458 K2: change API around collect/lookupSupertypes
In this commit we now require a class-like symbol
(and not a more general classifier symbol) whenever possible.
Exceptional situation with a type parameter is now handled
in Synthetics.kt

Related to KT-63569
2023-11-20 15:35:57 +00:00
Kirill Rakhman 49e786f088 [FIR] Copy java enum entry during enhancement instead of mutating it
#KT-57949 Fixed
2023-11-20 15:21:49 +00:00
Evgeniy.Zhelenskiy f5168527ae [FIR] Report type-parameterized implicit invoke call over type-parameterized property access
^KT-59988
2023-11-20 14:59:06 +00:00
Evgeniy.Zhelenskiy 86c09a1c78 [FIR] Report recursive typealias when loop is in type annotations
^KT-59908
2023-11-20 14:39:47 +00:00
Svyatoslav Kuzmich 31560217f8 [Wasm] Port @JsFun checker to K2 (KT-56849)
^KT-62724 Fixed
2023-11-20 14:39:24 +00:00
Vyacheslav Gerasimov fbc35975ab Build: Fix kotlinx-serialization-compiler-plugin compat artifacts
To avoid adding unexpected files we should add single file into
artifacts instead of directory.
 #KTI-1394
2023-11-20 14:37:54 +00:00
Dmitrii Gridin ea8a645513 [LL FIR] FirLazyBodiesCalculator: do not touch declarations during file annotation calculation
It leads to many problems in concurrent case.
E.g., we can transform the status of a declaration without the lock

^KT-62947 Fixed
2023-11-20 13:41:30 +00:00
Dmitriy Dolovov 6de0b3a645 [Gradle][MPP] Minor: Don't use @GradleTestVersions in the test
^KT-62515
2023-11-20 13:40:54 +00:00
Dmitriy Novozhilov 48141fbc2c [FIR2IR] Minor: remove unused function 2023-11-20 13:36:28 +00:00