Commit Graph

109329 Commits

Author SHA1 Message Date
Artem Kobzar 8d1a90c23c [K/JS] Support essential Kotlin collections (List, MutableList, Set, MutableSet, Map, MutableMap) for exporting into JS
^KT-34995 Fixed
^KT-44871 Fixed
2024-01-24 11:14:46 +00:00
Dmitriy Novozhilov b71797383f [Test] Add CLI tests for platform checkers in MPP
^KT-58881
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov e8f5e35a86 [FIR] Consider expect declarations in defaults arguments inheritance checker
Actual functions cannot declare default values for parameters
Corresponding expect function should be checked instead
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 2982f548d4 [Test] Update testdata of MPP diagnostic tests after previous changes
Related issues: KT-58845, KT-58881, KT-64187
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 1de8a1dda6 [Test] Correcly collect diagnostics in AA tests
One of the previous commits moved calculation of diagnostics from
  FirAnalyzerFacadeinto the separate test service, so it should be altered
  in AA tests too
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov cb3f41f669 [Test] Don't override manually registered services during test configuration
There are two ways of test service registration:
- manual call to `useAdditionalServices` in abstract test runner
- using of `additionalServices` property in one of test entity (e.g. in handler)

Services are registered in the same order (manual first, automatic second)

This led to the situation that if there was registered more specific
  implementation of the service in the test configuration, it will be
  overridden with regular implementation from handler, which is fixed
  by this commit
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 990da9fa1a [FIR] Part 5. Introduce paired common checkers for expect classes
There are some cases when we want to run some platform checker not from
  platform session but from common session. All such cases appear when
  we check some `expect` class

```kotlin
// MODULE: common
expect interface A
expect class B : A

class C : A

// MODULE: platform()()(common)
actual interface A {
    fun foo()
}

actual class B : A {
    override fun foo() {}
}
```

In this example we want to report "abstract foo not implemented" on
  class `C`, but we don't want to report it on `expect class B` (as
  its supertype is always `expect A`, never `actual A`)

So to cover such cases some platform checkers were split into two parts:
- `Regular`, which is platform checkers and runs for everything except
  expect declaration
- `ForExpectClass`, which is common checkers and runs only for expect
  declarations

^KT-58881 Fixed
^KT-58881 Fixed
^KT-64187 Fixed
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov f5d8113de3 [FIR] Part 4. Setup running platform checkers in Analysis API
^KT-58881
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov ed874262e3 [FIR] Part 3. Setup running platform checkers in CLI
^KT-58881
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov c4e4776c5e [FIR] Part 2. Setup running platform checkers in tests
^KT-58881
2024-01-24 10:45:00 +02:00
Dmitriy Novozhilov 727d2f46f8 [FIR] Part 1. Group checkers by the MPP kind
This commit introduces MppChecker kind, which represents the new property
  of checkers
- `MppCheckerKind.Common` means that this checker should run from the same
  session to which corresponding declaration belongs
- `MppCheckerKind.Platform` means that in case of MPP compilation this
  checker should run with session of leaf platform module for sources
  of all modules

An example of a platform checker is a checker that checks class scopes
  and reports ABSTRACT_NOT_IMPLEMENTED and similar diagnostics. If some
  regular class in the common module contains expect supertypes, the
  checker should consider the actualization of those supertypes to get
  a complete type scope

^KT-58881
2024-01-24 10:44:59 +02:00
Dmitriy Novozhilov ff063f553e [FIR] Make session part of the key of declared scope cache
In the following commits, there will be a need to retrieve the scope of
  the same class from different sessions, so we need to consider the
  session as part of the key along with class symbol
2024-01-24 10:44:59 +02:00
Dmitriy Novozhilov 77547c0312 [Test] Add more diagnostic tests for cases with expect class in supertypes
Related issues: KT-58845, KT-58881, KT-64187
2024-01-24 10:44:59 +02:00
Dmitriy Novozhilov ed04cca62b [Test] Move some MPP diagnostic tests into a dedicated folder
All those tests check different diagnostics on class scopes
2024-01-24 10:44:59 +02:00
Mikhail Glukhikh 51093a4764 K1/K2: add a group of BB test around primitives in Java
Related to KT-62554, KT-63242
2024-01-24 08:39:18 +00:00
Mikhail Glukhikh e42c1be354 K2: use intersection scope override checker also in intersection scope
In more details, we use either platform override checker (if we came
from platform) or the combined intersection scope override checker
at this place. Also this commit fixes various places around
JavaOverrideChecker, allowing to apply it in intersection override
checker properly:
- don't consider return types in this place
- apply JavaOverrideChecker if at least one candidate is from Java
- compare type primitivity closer to K1 logic

#KT-62554 Fixed
Partially fixes KT-63242
2024-01-24 08:39:18 +00:00
Mikhail Glukhikh 54d978ba86 K2: add various tests describing current KT-62554 / KT-63242 behavior 2024-01-24 08:39:18 +00:00
Brian Norman 17a1871b83 [FIR] Make sure the primary constructor is first in class CFG
The primary constructor of a class needs to be the first subgraph of the
class control-flow graph. Based on the Kotlin specification, class
initialization order goes first primary constructor, in-place
declarations (properties and init blocks), and then secondary
constructors. If the class doesn't have a primary constructor, then it
is just skipped in the order.

Unfortunately, the class control-flow graph had in-place declarations
first and then all constructors. Instead, we should treat the primary
constructor as the first in-place declaration, and then continue with
the existing processing as secondary constructors. This will guarantee
that super constructor calls have the correct property initialization
information.

^KT-65093 Fixed
2024-01-23 23:16:00 +00:00
Brian Norman c628172235 [FIR] Disallow qualified access to uninitialized fields in delegate
When using a field as the delegate for a super-interface of an object,
make sure uninitialized fields are not allowed. Specifically, disallow
access to these fields when referenced via object qualifier.

^KT-56489 Fixed
2024-01-23 23:16:00 +00:00
Anton Lakotka e2f9af1592 [Gradle] Revert CompilerArgumentAware including DependencyClasspath
This is not necessary and incorrect as it dependencies should not leak
to IDE import through this way. So reverting it back to original state.

But for KotlinNativeCompileArgumentsTest update context in the same way
as in Kotlin2JsCompileArgumentsTest and KotlinCompileArgumentsTest

just because KotlinNative Compilation classpath contain stdlib.

^KT-61430 Verification Pending
^KT-61559 Verification Pending
2024-01-23 22:14:33 +00:00
Anton Lakotka e4b760370f [Gradle] Put stdlib in K/Native classpath in first position
And stop doing so on Compiler Side.

^KT-61430 Verification Pending
^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 71a03a7c7d [K/N] Exclude stdlib from icedLibraries cache when passed explicitly
As part of KT-61559 stdlib is intended to be passed explicitly from
Gradle. However, CacheBuilder was not aware of such configuration
and was failing during cache building.

Author of this commit is Igor Chevdar

^KT-61430 Verification Pending
^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 9acb9ff2b7 [Gradle] Pass stdlib explicitly as K/native dependency. Keep original...
... platform dependencies while filter out them from actual compiler
invocation. So kotlin native compiler will provide them implicitly
from kotlin native bundle. Since K/Native compiler is not yet
optimised to consume platform dependencies explicitly and simply slow.
More details in related issue: KT-61559

^KT-61430 Verification Pending
^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 90a47e0488 [Gradle] Refactor getVisibleSourceSetsFromAssociateCompilations
To highlight the fact that there is an intersection of
visible source sets of compilations where given source set participates
2024-01-23 22:14:32 +00:00
Anton Lakotka f4681fb93a [Gradle] Add SetupKotlinNativePlatformDependenciesForLegacyImport
The code is extracted from SetupKotlinNativePlatformDependenciesAndStdlib
as the latter is applied only to native compilations and
shared native metadata compilations.
For test shared native source sets, such as `nativeTest
no native metadata compilation is created, but for legacy import
intransitive metadata dependencies should contain native platform
dependencies listed. And
SetupKotlinNativePlatformDependenciesForLegacyImport fixes that.

^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 721aafc94c [Gradle] Disable stdlib for Kotlin Native Compile and Link tasks
^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 4a0bfcd842 [Gradle] Add AddKotlinPlatformIntegersSupportLibrary
Move code from KotlinNativePlatformDependencies.kt

^KT-61559
2024-01-23 22:14:32 +00:00
Anton Lakotka 1604ab1e0b [Gradle] Add SetupKotlinNativePlatformDependenciesAndStdlib
This extension point adds NativePlatformDependencies And Stdlib to
compileFiles of Native Compilations.

^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 32de4a6b2c [Gradle] test that native compilation has platform dependencies
^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 599a6c7d6d [Gradle] Fix Native Linker integration test after adding platform libs
in compiler classpath. Now K/Native compiler doesn't "compress" platform
libraries when printing linker error.

^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Anton Lakotka 639e048438 [Gradle] Include native platform dependencies explicitly
They are now also exposed via KotlinCompilation.compileDependencyFiles
Which is useful for tools like dokka that relies on exhaustive
list of dependencies for given source set/compilation.

^KT-61559 Verification Pending
2024-01-23 22:14:32 +00:00
Jinseong Jeon 43acc6516b SLC: mangle internal accessors
...by honoring accessors' visibility

We need a special handling for backing field visibility,
e.g., lateinit, const, or JvmField, but that's not the case
for accessors' visibility.

^KT-64937 fixed
2024-01-23 21:55:09 +00:00
Marco Pennekamp dcf7b84082 [Test] Reset ApplicationManager.application when shared application environments are disposed
- Shared application environments can be disposed in the middle of test
  plan execution when the project count reaches zero. So resetting
  `ApplicationManager` only on "test plan execution finished" is
  incorrect, because it does not account for that scenario. Instead, we
  should reset `ApplicationManager` every time the application
  environment is disposed.
- We should also keep the manual reset in `testPlanExecutionFinished`
  because `disposeApplicationEnvironment` may not need to dispose
  anything if there isn't a shared application environment, but we
  should still reset `ApplicationManager` if an unshared application
  environment was created.
- This fixes "Some test disposed, but forgot to clear MockApplication"
  exceptions which appeared after KT-64099 because it opened up proper
  disposal of the shared application environment (instead of it being in
  a state of leakage because not all project disposables were properly
  disposed).

^KT-63650
^KT-64099
2024-01-23 21:52:31 +00:00
strangepleasures 85c9c57da4 [KAPT] KT-65006 fix issues when using Kapt+Serialization
This MR fixes two independent issues causing build failures when using Kapt in combination with the Kotlin serialization plugin (and, very likely, with other plugins as well):
Kapt applied compiler plugins twice, causing errors similar to the one described in KT-65006
Kapt failed to generate @Metadata annotations for plugin-generated companion objects because the corresponding SLC missed containingFile needed for generation of method and class signatures

Merge-request: KT-MR-13970
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-01-23 20:35:32 +00:00
Svyatoslav Scherbina 8e4dc1fc31 Bump Kotlin/Native version in KGP to 2.0.0-dev-13302 2024-01-23 19:29:02 +00:00
Ilya Gorbunov 72528056fb [kotlin-test] Migrate integration tests project from deprecated K/JS plugin 2024-01-23 17:57:48 +00:00
Ilya Gorbunov 000db0bb44 [kotlin-test] Move kotlin-test integration tests project 2024-01-23 17:57:48 +00:00
Alexander Korepanov 0d06efb488 [JS FIR] Fix REIFIED_TYPE_FORBIDDEN_SUBSTITUTION for dynamic types
^KT-59987 Fixed
2024-01-23 17:52:03 +00:00
Andrey Yastrebov 6db22b4975 KT-62493 Add cocoapods custom executable path test 2024-01-23 17:40:33 +00:00
Andrey Yastrebov 7958f77d09 KT-62493 explicit pod executable path in local.properties 2024-01-23 17:40:33 +00:00
Alexander Shabalin ebef991477 [K/N] Workaround hanging during stream draining ^KT-65113 2024-01-23 16:05:34 +00:00
Marco Pennekamp 641cae009e [AA] Remove obsolete KtFirAnalysisSession.mode
- On-air analysis was recently removed.
2024-01-23 16:00:43 +00:00
cristiangarcia daba449390 Update ktor to 2.3.7 2024-01-23 12:12:44 +00:00
Alexander Shabalin d04b3050c0 [K/N] Remove old workaround for osVersionMin on arm macOS 2024-01-23 11:14:38 +00:00
Pavel Punegov cdb6a06e49 [K/N][test] Move ZipTest to compiler/util-io tests
This is the last test in the Klib and was run separately.
Instead, it should be located with 'kotlin-util-io' project which it tests


Merge-request: KT-MR-13978
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2024-01-23 11:01:58 +00:00
Alexander Korepanov 3dd4a0d868 [JS FIR] Add JS_NAME_CLASH tests for constructors
^KT-64867 Related
2024-01-23 10:30:10 +00:00
Alexander Korepanov 5da4d31d37 [JS FIR] Rework JS_NAME_CLASH diagnostic for constructors
- Fix a false positive JS_NAME_CLASH report on constructors
   from different classes but with the same JsName.
 - Allow the same JsName for class constructors and other top-level
   declarations. This behavior differs from K1, but it is correct
   since there is no real name clash in the generated JS code.

^KT-64867 Fixed
2024-01-23 10:30:10 +00:00
Sebastian Sellmair 2708c74d9c [ObjCExport] Fix KT-64952 HasErrorTypesTest 2024-01-23 10:03:15 +00:00
Alexander Korepanov fc584b7c33 [JS FIR] Add non-ASCII JsName tests
^KT-64463 Related
2024-01-23 10:00:18 +00:00
Alexander Korepanov 871f04e08c [JS FIR] Do not verify typealias JS name
Since typealiases are not present in the generated JS code,
there is no need to verify their JS names.

^KT-64463 Fixed
2024-01-23 10:00:18 +00:00