Commit Graph

109248 Commits

Author SHA1 Message Date
Marco Pennekamp 78ef58bef4 [AA] Tests: Remove decompiled files from LibraryBinary and add LibraryBinaryDecompiled
- `LibraryBinary` should not contain any decompiled files, as we want
  FIR symbols in tests to be provided from indexed stubs or class files,
  but definitely not from decompiled PSI. This brings `LibraryBinary`
  much closer to the behavior of binary libraries in the IDE.
- Some tests may still require access to a decompiled file, for example
  when trying to test `getOrBuildFir` for some `KtElement` coming from a
  library. This commit introduces `LibraryBinaryDecompiled`, which
  does contain decompiled files.
- We don't really need `LibraryBinary` as a main test module kind
  anymore, since tests generally want to access some main `KtFile`.
  Hence, test configurators for `LibraryBinary` have been turned into
  configurators for `LibraryBinaryDecompiled`.
- An alternative would be decompiling files on demand, but this is not
  currently feasible because the Standalone API doesn't reconcile stubs
  with decompiled PSI, like the IDE does automatically. (For the same
  declaration, the stub and the PSI will have a different identity.) As
  long as there is no support for this, we'll have to rely on a separate
  test module kind.

^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp 7baaa38b8a [AA] Add KtTestModule.moduleKind
- `TestModule.explicitTestModuleKind` requires a directive to be present
  to get the `TestModuleKind`. But we still want to find out the test
  module kind for test modules without a directive. Hence, we have to
  add this property to `KtTestModule` during its construction.

^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp dc0f498b15 [AA] Simplify prepareFilesInModule with KtTestModule
^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp 6cc414bdfd [AA] Simplify createProjectStructureByTestStructure with KtTestModule
^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp 2060709c03 [AA] Turn KtModuleWithFiles into KtTestModule (AA test framework)
- `KtModuleWithFiles` isn't actually used in a production Standalone API
  context, but it was exposed via `analysis-api-standalone-base`. In
  current production usages, the project structure is built with the
  module builder DSL.
- Hence, `KtModuleWithFiles` is only relevant for tests. This commit
  moves `KtModuleWithFiles` to the Analysis API test framework and
  renames it to `KtTestModule`. This removes any risk that an outside
  user could start using `KtModuleWithFiles` and completely uncouples
  the test project structure from production APIs.
- In addition, we can add the `TestModule` to `KtTestModule`, allowing
  tests to quickly access the original test module, for example to check
  the test module kind.
- The commit also removes the data class status of `KtTestModule` and
  `KtTestModuleProjectStructure` to avoid issues with destructuring when
  properties are added or removed.

^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp 878eba7d52 [AA] Introduce AnalysisApiIndexingConfiguration test service
- The configuration allows the test infrastructure to decide whether to
  index binary libraries to stubs (when stub-based deserialized symbol
  providers are used) or to skip indexing (when class file-based
  deserialization is used).
- The information is needed in `AnalysisApiBaseTestServiceRegistrar`,
  where the `KotlinStaticDeclarationProviderFactory` is created. This
  service registrar shouldn't access `LLFirLibrarySymbolProviderFactory`
  and so checking the library symbol provider factory wasn't an option.
- Another alternative was adding a property to
  `AnalysisApiTestConfigurator`. However, this then requires passing the
  property to `AnalysisApiBaseTestServiceRegistrar`, because it doesn't
  have access to the configurator out of the box. This however goes
  against the design of our service registrars, which generally only
  access test services. So adding a test service seemed like the best
  solution.

^KT-65960
2024-02-26 21:57:23 +00:00
Alexander Udalov d4278250e6 IR: never check static members for overridability
#KT-66077 Fixed
2024-02-26 20:38:02 +00:00
Yahor Berdnikau bdb96dc0db [Gradle] Rename to HasConfigurableKotlinCompilerOptions
Added "Kotlin" to better indicate to what this interface belongs to.

^KT-65196
2024-02-26 19:32:26 +00:00
Alexander Shabalin edf05b69ac [K/N][performance] Fix build 2024-02-26 18:06:44 +00:00
Jaebaek Seo 2f64a878e4 K2: Support dependency symbol providers for binary libraries
When a symbol X from a binary library A uses another symbol Y from
another binary library B, `LLFirDependenciesSymbolProvider` cannot
resolve Y for X. This is because the existing
LLFirAbstractSessionFactory passes symbol providers for only builtin
libraries to `LLFirDependenciesSymbolProvider` even when the session has
dependencies. As a result, when `LLFirDependenciesSymbolProvider`
searches a symbol, it can find only symbols from the builtin libraries,
but it cannot find a symbol from libraries other than builtin libraries.
This happens only for the binary libraries.

^KT-65240 Fixed
2024-02-26 18:02:08 +00:00
Yan Zhulanow 42c2e7d503 [Analysis API] Minor, prettify 'createModules()' 2024-02-26 18:02:08 +00:00
Yan Zhulanow b925462852 [Analysis API] Minor, tune the 'createModule()' signature
Move the 'dependencyPaths' parameter closer to other traits of
a created module.
2024-02-26 18:02:08 +00:00
Dmitriy Novozhilov 6a94a3331f [FIR] Don't create synthetic property if getter and property came from the same class
Usually we create synthetic property in java class if there is a property
  from the base kotlin class and getter/setter with a corresponding name
  in the declared scope or one of supertype scopes. But there is a case,
  where the same supertype contains both property and getter:
```
// FILE: Base.kt
open class Base {
    open val b = "O"

    @JvmName("getBJava")
    fun getB() : String = "K"
}

// FILE: Derived.java
public class Derived extends Base {}
```

In this case we shouldn't create synthetic property, because `getB()`
  function is invisible for `Derived` class

^KT-66020 Fixed
2024-02-26 17:44:30 +00:00
Alexander Shabalin 513f86f8fc [K/N][tests] Remove atomicfu tests from :nativeCompilerTest ^KT-65977
These tests fail in native testing infrastructure on different
platforms. Removing them until it's fixed.
2024-02-26 16:42:04 +00:00
Marco Pennekamp ea2bb32bc0 [PSI] Don't calculate ClassIds for local classes in call elements
- The fix uses relevant logic from  `getNonLocalContainingDeclaration`.
- The annotation entry case is covered by `KtCallElement` because
  `KtAnnotationEntry` is a subtype of it.
- KT-66038 is fixed by this because the static declaration provider only
  indexes non-local classes.

^KT-66038 fixed
2024-02-26 16:36:00 +00:00
Marco Pennekamp d52860b835 [LL] Add tests for ClassId calculation of local class inside annotation argument
- The class IDs are erroneously calculated and will be fixed in the next
  commit.

^KT-66038
2024-02-26 16:36:00 +00:00
Dmitriy Dolovov 4b4c5c4e6b [FIR] Serialization to KLIB: Clean-up in firKlibSerialization.kt 2024-02-26 16:07:10 +00:00
Dmitriy Dolovov 5a8330ebad [FIR] Serialization to KLIB: Don't sort classes
^KT-62135
2024-02-26 16:07:10 +00:00
Dmitriy Dolovov 4b0ac63c38 [FIR] Serialization to KLIB: Drop obsolete TODO comments 2024-02-26 16:07:10 +00:00
Alexander Shabalin b1f59e5f0d [K/N] Make NativeDependenciesDownloader compatible with CC ^KTI-1553 2024-02-26 14:53:23 +00:00
Artem Olkov e4acb396ba Add SIR builder and printer for classes #KT-65905 fixed
Merge-request: KT-MR-14478
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2024-02-26 14:30:07 +00:00
Vladimir Sukharev febac0dd5f [Tests] Migrate backend-independent tests from native to compiler/testData.
^KT-65979
2024-02-26 13:38:49 +00:00
Artem Olkov dd9332d9e1 Add kotlin runtime modulemap for swift export as part of kotlin-native dist #KT-65673 fixed
Co-authored-by: Alexander Shabalin <alexander.shabalin@ashabalin.me>

Merge-request: KT-MR-14493
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2024-02-26 12:51:57 +00:00
Andrey Yastrebov 28a305a826 KT-65928 Worker API for Swift Export 2024-02-26 12:44:22 +00:00
Yan Zhulanow 1c1da6bced [Analysis API] Cause OOB when imports change in code fragments
In K1, code fragment analysis was completely invalidated on any PSI
change. Because imports are not a part of the PSI tree of
'KtCodeFragment's, a colon tremble happened on 'addImportsFromString()'.

In K2, changes inside code fragments are always considered in-body
modifications. So, even with the colon trembling, the 'FirFile',
together with its 'FirImport's was not recreated.

^KT-65600 Fixed
2024-02-26 11:28:56 +00:00
Yan Zhulanow 45c0fa8d23 [PSI] Refactor import handling in code fragments
Now there is a single place that performs import modification, as well
as reports events related to that modification.
2024-02-26 11:28:55 +00:00
Yan Zhulanow fa511fdc52 [Analysis API] Pass PCE exceptions from KtCompilerFacility 2024-02-26 10:56:24 +00:00
Abduqodiri Qurbonzoda 7978f63d37 Set AV to 2.0 in K/N StdlibTest 2024-02-26 10:48:29 +00:00
Abduqodiri Qurbonzoda 31aa71dd6a Promote Common String.toCharArray(destination) to stable #KT-65532 2024-02-26 10:48:29 +00:00
Pavel Kirpichenkov 2bd48b7e49 [Tests] Regenerate AdditionalStubInfoKnmTestGenerated
KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 00faa6fa01 [Tests] Support language features from test data in .knm meta compiler
Mute test failure revealed by unblocked context receivers (KTIJ-28885)

KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov d17044515f [Tests] Update stub consistency test data
Common metadata compiler now reports compilation errors. Disable tests
that are not yet supported or should be skipped as JVM-specific.

KTIJ-28668
2024-02-26 10:18:38 +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
Pavel Kirpichenkov bfb1ef14f5 [Stubs] Fix contract deserialization for non-JVM stubs
Types serialized via type table weren't deserialized, which led to
missing contract information in stubs.

KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 9373437cad [Tests] Add kotlin-stdlib dependency in KLIB metadata compile utility
It's necessary, for instance, to compile custom contracts in common

KTIJ-28668
KTIJ-26788
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 3e5065fbba [Tests] Report compilation errors from test KLIB compiler
KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 5548e854a0 [Tests] Extract shared .knm test utilities
KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 1c1bdae973 [Tests] Add tests for additional stub info in .knm files
KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov 604dec7a87 [Tests] Move stub info extraction for test into a separate utility
KTIJ-28668
2024-02-26 10:18:38 +00:00
Pavel Kirpichenkov f6a35ef0e5 [Tests] Extract AbstractDecompiledKnmFileTest from the stub test
KTIJ-28668
2024-02-26 10:18:38 +00:00
Svyatoslav Scherbina 23e558d172 Bump Kotlin/Native version in KGP to 2.0.0-dev-16829 2024-02-26 10:16:19 +00:00
Nikolay Lunyak 3b2bc598b5 [FIR] Reuse getNonSubsumedNonPhantomOverriddenSymbols
Just a small refactoring to avoid
duplicating comments.
2024-02-26 10:06:26 +00:00
Nikolay Lunyak 22fc90e5a1 [FIR] Treat properties from ObjC-classes as abstract
In short, the problem is some
platform libraries contain invalid
Kotlin code. Specifically,
some classes may inherit multiple
members with default
implementations, but do not define
an explicit override, like `UIView.bounds`.

Since we can't refactor platrofm
libraries just now, we want to
treat such properties as abstract.

^KT-65866 Fixed
^KT-65855
2024-02-26 10:06:26 +00:00
Andrey Yastrebov 2ae8d28b33 KT-65582 Swift export XCTest integration tests 2024-02-26 09:57:12 +00:00
Andrey Yastrebov 6146a59636 KT-65582 Swift export build integration tests 2024-02-26 09:57:12 +00:00
Andrey Yastrebov 444dc790db KT-65582 Extract xcode simulator test helpers 2024-02-26 09:57:12 +00:00
Andrey Yastrebov 6ed6e7ce28 KT-65582 Add Swift export test tags 2024-02-26 09:57:12 +00:00
Nikolay Lunyak f1c7f929d2 [FIR] Don't miss diagnostics on resovled reified type parameters
^KT-66005 Fixed
2024-02-26 09:53:13 +00:00
Nikolay Lunyak b0e6db7807 [FIR] Reproduce KT-66005
^KT-66005
2024-02-26 09:53:13 +00:00
Dmitriy Novozhilov eb85caedad [FIR] Search for typealias in dependencies, if expect class was found first
^KT-65840 Fixed
2024-02-26 09:25:57 +00:00