Commit Graph

106326 Commits

Author SHA1 Message Date
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
Dmitriy Novozhilov 89b98ef784 [FIR2IR] Properly create FIR f/o for lazy IR f/o
```kotlin
interface A {
    fun foo() // (1)
}

interface B : A {
    // f/o fun foo() // (2)
}
```

In previous commits it was forgotten to create new FIR declarations for
  IR fake-overrides, which led to the situation when `IR lazy functions
  of `(1)` and `(2)` both contained fir of function (1) as their base
  declaration

It seems this change fixed some cases from KT-42020
2023-11-20 13:36:28 +00:00
Dmitriy Novozhilov 8ebb412705 [FIR2IR] Introduce special FirProvider with plugin-generated files
For declarations generated by plugins, fir2ir creates special synthetic
  FIR files, which are not registered in the regular FirProvider. This
  leads to incorrect determination of ir parent for generated declarations,
  because `irParent` utility relies on file returned from fir provider

To fix this issue, the new FirProvider for fir2ir is introduced, which
  wraps the original provider and allows to register newly created files

Note that this means that it's illegal anymore to use FirProvider from
  session anywhere in fir2ir. `firProvider` from `Fir2IrComponents`
  should be used instead
2023-11-20 13:36:28 +00:00
Dmitriy Novozhilov d85d671b26 [FIR] Update few MPP diagnostic tests
Updated tests contain errors which are incompatible with fir2ir conversion
  (like `PACKAGE_OR_CLASSIFIER_REDECLARATION` and `EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE`),
  so running fir2ir on such code may lead to exceptions
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov 3dff232710 [FIR2IR] Generate IR for unbound symbols in allowNonCachedDeclarations mode
`allowNonCachedDeclarations` mode allows referring source declaration which
  does not belong to the set of sources passed to fir2ir (e.g. for debugger
  support). So if code refers to such declaration, fir2ir creates symbol
  for it but not the IR declaration itself
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov c9ff0c41fc [FIR2IR] Generate IR for f/o of common classes generated during platform conversion
This change fixes tests which were muted in one of previous commits
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov 65797e8fba [FIR2IR] Don't create IR constructors when their symbol is referenced
KT-62856
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov 55f62834cb [FIR2IR] Replace getOrCreateIrScript with createIrScript
Fir2IrDeclarationStorage should not sometimes create IR declarations
  during lookup requests
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov 7263edf322 [FIR2IR] Split getOrCreateIrAnonymousInitializer method into two parts
Fir2IrDeclarationStorage should not sometimes create IR declarations
  during lookup requests
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov 736201da1d [FIR2IR] Don't create IR properties when their symbol is referenced
KT-62856
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov f0f8a9728e [FIR2IR] Make parent of lazy declaration non-lateinit
There is no actual sense to have parent as a lateinit var, because in
  all places it is initialized right after declaration creation
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov bb892f10f8 [Test] Mute tests with expect supertypes
The problem: someone should generate IR for f/o in common classes appeared
  after IR actualization

Those tests will be fixed in the following commits
2023-11-20 13:36:27 +00:00