Commit Graph

106221 Commits

Author SHA1 Message Date
Marco Pennekamp 39c38aa588 [PSI] KtQualifiedExpression: Replace AssertionError with errorWithAttachment
- There is no other usage of `AssertionError` in the
  `org.jetbrains.kotlin.psi` package. `errorWithAttachment` is more
  idiomatic, throws an `Exception` instead of an `Error`, and avoids
  leaking user code.
2023-11-16 19:50:51 +00:00
Marco Pennekamp 6668cc281d [LL] Avoid exceptions when analyzing inconsistent PSI in LLFirDeclarationModificationService
- The exceptions in KT-63130 occur because PSI tree change events may be
  published when parts of the PSI under modification are inconsistent.
  Such inconsistent elements are then analyzed by
  `LLFirDeclarationModificationService` to check if the modification
  occurs in a contract statement.
- The solution adds `*OrNull` functions to `KtQualifiedExpression` which
  return `null` instead of failing with an exception when the receiver
  or selector cannot be found.

^KT-63130 fixed
2023-11-16 19:50:51 +00:00
Marco Pennekamp 6c67835128 [LL] Add PSI resilience tests for LLFirDeclarationModificationService
- The cause of KT-63130 is that `LLFirDeclarationModificationService`
  tries to analyze inconsistent PSI. These new tests replicate the
  inconsistent PSI by deleting different children and then call the
  declaration modification service with it, making sure that the service
  doesn't throw any exceptions. Both exceptions mentioned in the issue
  are reproduced by the added tests, specifically, the receiver and
  selector resilience tests for dot-qualified expressions.
- A few of the tests need to be marked with `IGNORE_FIR` until the error
  has been fixed in the subsequent commit.

^KT-63130
2023-11-16 19:50:51 +00:00
Marco Pennekamp 12b6096b67 [LL] Add a test base for PSI-modifying low-level API tests
- To support PSI modification, the test environment requires some
  additional configuration, which is encapsulated in
  `AnalysisApiPsiModificationTestServiceRegistrar`.
- The test also has to allow write access explicitly, which is
  configured in `AnalysisApiFirModifiablePsiSourceTestConfigurator`.
2023-11-16 19:50:51 +00:00
Marco Pennekamp 03a7162f37 [AA] Enable test-specific configuration of write access permissions
- In general, Analysis API tests forbid write access because the
  Analysis API should not be used from write actions. However, in some
  cases we might want tests to e.g. modify PSI, which requires write
  access. This change allows `AnalysisApiTestConfigurator`s to enable
  write access for the specific test.
2023-11-16 19:50:51 +00:00
Marco Pennekamp 6189d68c3c [AA] Refactoring: Provide default implementations for functions of AnalysisApiTestServiceRegistrar
- Most inheritors of `AnalysisApiTestServiceRegistrar` only need to
  override one or two functions.
2023-11-16 19:50:51 +00:00
Ivan Kochurkin df43226a08 [FIR] Fix CAST_NEVER_SUCCEEDS for definitely not null types 2023-11-16 19:29:58 +00:00
Ivan Kochurkin 0efcad51e9 [FIR] Add a comment to isSubtypeOfClass that explains what this method does
And what the difference is between `isSubtypeOf` and `isSubtypeOf`
2023-11-16 19:29:58 +00:00
Ivan Kochurkin 3b9095a5ab [FIR] Use isSubtypeOfClass with platform types mapping instead of isSubtypeOf during checking CAST_NEVER_SUCCEEDS
Refactor and generalize code

^KT-62783 Fixed
2023-11-16 19:29:58 +00:00
Ivan Kochurkin 0935e2b270 [FIR] Make originalIfDefinitelyNotNullable more universal
It takes `ConeSimpleKotlinType` but not `ConeKotlinType` as input parameter
2023-11-16 19:29:58 +00:00
Artem Kobzar ff50d40b32 [K/JS] Rework kotlin tests compilation to make it works with per-file granularity ^KT-61525 Fixed 2023-11-16 19:02:04 +00:00
Brian Norman a4b3b08e59 [FIR] Do not terminate smartcast CFG nodes when result is Nothing
Terminating a CFG node because the result is Nothing should be reserved
for explicit Nothing type definitions, and not apply when smartcasting.
This allows boolean expressions to propagate implications correctly even
when the RHS is impossible or will never be executed.

^KT-47931 Fixed
2023-11-16 18:04:26 +00:00
Brian Norman e92fab65aa [FIR] Support including flow information when dumping CFG dot file 2023-11-16 18:04:26 +00:00
Alexander.Likhachev 6fbd26905a [Gradle] Add Gradle 8.2+ plugin variant
Fixups KT-52976 as the intention was to remove conventions registration. However until this commit, `gradle81` variant was used for all the 8.1+ versions providing an implementation that registers conventions.
^KT-63499 Fixed
2023-11-16 16:59:02 +00:00
Alexander.Likhachev 965b6b544d [Gradle] Add integration test for KT-63499 2023-11-16 16:59:02 +00:00
Stanislav Ruban 73aaa1ce28 [tests] Add code examples from exploration of KT-62239 2023-11-16 16:39:35 +00:00
Ivan Kylchik d7d42134df [JVM] Don't analyze KtCodeFragment's file twice
We could get several files from the IDE to analyze. For example, some
code fragment and a file with context information. This additional
file, in fact, can be a file where a code fragment is defined, and we
can accidentally analyze a single file twice that leads to errors.
2023-11-16 15:59:48 +00:00
Ivan Kylchik d6f0530215 [JVM] Use getContextContainingFile method in CodegenBinding 2023-11-16 15:59:48 +00:00
Ilya Chernikov 6877fa8e42 Scripting: remove obsolete script-util module
#KT-58367 fixed
2023-11-16 15:46:08 +00:00
Nataliya.Valtman c332e1beb5 Remove BuildStatsService.applyIfInitialized outside BuildFlowService
#KT-58768 In Progress
2023-11-16 15:22:01 +00:00
Svyatoslav Kuzmich 62ebb9932f [Wasm] Port external declaration checker to K2 (KT-56849)
Share common code with FirJsExternalChecker using
FirWebCommonExternalChecker
2023-11-16 14:27:49 +00:00
Svyatoslav Kuzmich 83aa014d81 [FIR] Fix default message test failing with NPE
Return early. Otherwise, if map doesn't contain the key,
`get(factory)!!` in the next statement fails with an NPE.
2023-11-16 14:27:49 +00:00
Ilya Kirillov 531e4fb86e [Analysis API Standalone] add comment about KT-63493 to StandaloneSessionBuilderAgainstStdlibTest 2023-11-16 13:31:54 +00:00
Ilya Kirillov fca04d4143 [LL FIR] run low-level-fir Kotlin/Native tests on TC
It's a part of KT-62910
2023-11-16 13:31:54 +00:00
Ilya Kirillov fee7d63975 [Analysis API Standalone] add tests for resolution against native KLib
^KT-63126
2023-11-16 13:31:53 +00:00
Ilya Kirillov 63c807f7bd [Analysis API Standalone] extract test logic for a test against the stdlib to a base classes
It will be reused in a Kotlin/Native resolution test in the following commit

^KT-63126
2023-11-16 13:31:53 +00:00
Ilya Kirillov 6aeabc83ea [kotlin] fix "IllegalStateException: Could not find stdlib"
The commit removes all the KLib resolution logic,
now Analysis API Standalone clients need to provide all the KLib
list directly.

The resolution logic was removed as too error-prone and requiring compiler configurations.

Kotlin Gradle plugin can provide a full set of required KLibs,
so if a client is a Gradle plugin, this should not be an issue.

Probably, some fancy API which will explicitly perform all KLib dependency searches
should be introduced in the future (KT-63395)

^KT-63126 fixed
2023-11-16 13:31:53 +00:00
Ilya Kirillov 1c17f4a835 [Analysis API Standalone] extract a assertIsCallOf test utility to reused in other test modules
^KT-63126
2023-11-16 13:31:53 +00:00
Artem Kobzar 890fbd6b0b [K/JS] Process JS-specific returnable blocks before the state machine building
^KT-60785 Fixed
^KT-63207 Fixed
2023-11-16 13:25:51 +00:00
Igor Chevdar 36452b5db7 [K/N] IR version of isObjCObjectType 2023-11-16 12:17:46 +00:00
Ivan Kylchik af716b2e3e [IR] Add KDoc for PhaserState, CompilerPhase and PhaseConfig classes 2023-11-16 12:03:41 +00:00
Ivan Kylchik 48a0274989 [WASM] Reuse common makeIrModulePhase to create lowerings
#KT-63074
2023-11-16 12:03:41 +00:00
Ivan Kylchik b3e485c649 [JS_IR] Try to find generated default stub fun before creating a new one
This change is required to support a new approach to lowering
execution. There will be no more guarantee that every module
will execute `JsDefaultArgumentStubGenerator` lowering before
moving on.

#KT-63073
2023-11-16 12:03:41 +00:00
Ivan Kylchik 917b9481c1 [JS_IR] Drop old comment from loweringList
This comment is not needed anymore after
64158a8a2f
2023-11-16 12:03:41 +00:00
Ivan Kylchik 1db595c676 [JS_IR] Reuse common makeIrModulePhase to create lowerings
#KT-63073
2023-11-16 12:03:41 +00:00
Ivan Kylchik 0a6f711a41 [JS_IR] Use IrModuleFragment as input to lowering instead of iterable
This way we will be able to reuse existing utils
to create a lowering.

#KT-63073
2023-11-16 12:03:41 +00:00
Mikhail Glukhikh 1eacd5efc2 K1/K2: support org.jspecify.annotations.NonNull in Java interop
#KT-62352 Fixed
2023-11-16 11:13:44 +00:00
Dmitriy Novozhilov dcbc1e6a04 [Build] Update system properties for tests in JPS mode
Property `jps.kotlin.home` in test run configuration template pointed
  to wrong kotlinc dist location
2023-11-16 09:04:06 +00:00
Aleksei.Cherepanov 6f3204da0a Stop using IJ's maps in graph implementation of JPS 2023-11-16 08:53:13 +00:00
Yahor Berdnikau 55f6614b66 [Gradle] Increase max Kotlin daemon heap size to 2g for all kapt tests
Apparently, they all require more than 1g of heap size to run kapt.
2023-11-16 08:01:33 +00:00
Dmitriy Dolovov 1183244455 [tests] Use full paths with the proper extensions to KLIBs in LibraryProvider
^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov 82b08a813b [Native] Fix scripts for computing dependencies in platform DEF files
Now, the scripts are able to compute and record full dependencies
(i.e. direct + transitive) to DEF files.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov 2fe49f2e5a [Native][tests] Don't use KLIB repositories in new test infrastructure
Don't pass KLIB repositories via '-repo' or '-r' compiler parameters.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov f4617f405c [Native] Don't use KLIB repositories in generation of platform libs
Don't pass KLIB repositories via '-repo' or '-r' compiler parameters.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov c13c917a8a [Native] Don't use KLIB repositories in K/N build infra
Don't pass KLIB repositories via '-repo' or '-r' compiler parameters.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov 4f1f06c24f [Native][tests] Use full paths to dependencies in K/N test in old infra
Affected tests:
- fake_override_0
- split_compilation_pipeline
- library_ir_provider_mismatch (reworked)
- objs tests (resolve of exported klib in framework)

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov 97f1a23f8b [Native][tests] Handle errors in individual compiler invocations 2023-11-15 19:38:25 +00:00
Dmitriy Dolovov 60c88b010d [Native] Add missing dependencies to platform lib DEF files
There are a lot of cases when a DEF file for a K/N platform library
has incomplete set of dependencies in 'depends=' property in
the manifest file. This leads to use of "KLIB resolver" - the
component inside the compiler that is responsible for finding the
missing libraries and implicitly (i.e. invisibly for the end user)
adding them to the set of dependencies of the compiler invocation.

The goal of this commit is to fix 'depends=' in manifest files so that
they should reflect the REAL set of dependencies, and as a result don't
trigger use of "KLIB resolver". This way we could be more prepared to
removed in the "KLIB resolver" in the future.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov c3da16a1d8 [Native] Use library paths instead of library names in K/N build infra
Use library paths instead of library names in K/N build infra when
passing a library through `-library` compiler argument.

^KT-61098
2023-11-15 19:38:25 +00:00
Dmitriy Dolovov e7b8f3ecde [Native] Deprecate KLIB repositories in Kotlin/Native compiler
1. Log warnings on usage of KLIB repositories.
2. Don't block using repositories for now.

^KT-61098
2023-11-15 19:38:24 +00:00