Commit Graph

106541 Commits

Author SHA1 Message Date
Sergey Bogolepov cc14f11e2a [Swift Export] initial infrastructure for Swift IR
New modules 'sir', 'sir-passes', and 'sir-analysis-api' were added under
'native:swift' for creating and manipulating Swift IR elements.

* `sir` contains the implementation of Swift IR.
* `sir-analysis-api` contains translation from Analysis API to SIR.
* `sir-passses` contains transformation passes.

This groundwork will allow to progress with the Swift IR.
2023-11-28 18:00:43 +00:00
Svyatoslav Scherbina d15ee71b6c Native: get rid of __NSCFBoolean references in ObjCExport
ObjCExport accessed `__NSCFBoolean` using
`objc_getClass("__NSCFBoolean")`. This class is a private API.
Remove this private API usage by getting the same class from
`[[NSNumber numberWithBool:YES] class]` instead.

Also remove `__NSCFBoolean` from the related error messages.

`__NSCFBoolean` didn't cause Kotlin-compiled apps to be rejected by
Apple, but this commit reduces the risk that this might happen in the
future, and addresses related user concerns.

^KT-62091
2023-11-28 17:57:47 +00:00
Svyatoslav Scherbina 707a650de1 Native: improve tests for __NSCFBoolean RTTI conversion
- ObjCExport tests for numbers RTTI conversions didn't really check
  RTTI, because of a compiler optimization. Fix this by converting to
  Any.
- Also add more tests that specifically check that bool `NSNumber` get
  dynamically converted to `kotlin.Boolean` box. Those tests can't be
  affected by possible future compiler optimizations.
2023-11-28 17:57:47 +00:00
Sergej Jaskiewicz 7bd4de65f8 [IR generator] Deduplicate field copying logic 2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz 5f04bc8a27 [IR generator] Simplify computation of walkable children
Don't require to specify them explicitly via `isChild` in IR generator,
instead test the field type whether it is an element.
2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz ad4e97154f [FIR/IR generator] Factor out allFields to AbstractElement 2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz 38ee477ab4 [FIR/IR generator] Make AbstractField generic over itself
This will make some code more type-safe.
2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz c6eb7d6c21 [FIR/IR generator] Factor out walkableChildren and transformableChildren 2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz 13ae129505 [FIR/IR generator] Move isSealed property to AbstractElement 2023-11-28 16:24:40 +00:00
Sergej Jaskiewicz 0465c6d0ee [FIR/IR generator] Make InterfaceAndAbstractClassConfigurator open 2023-11-28 16:24:40 +00:00
Nikolay Lunyak d5fa755e63 [FIR] Disable not null checks on dynamics
It looks like K1 doesn't do them.
And it's not particularly bad because
in the ideal world we'd have dynamics
with variable upper bound so that
in `dynamic?.let { it }` `it` would
be `Nothing..Any` (smartcasting to
`Any` is not correct because `dynamic`
can be passed into anything, but `Any`
can not).

^KT-63071
2023-11-28 15:37:09 +00:00
Nikolay Lunyak 875e2b0cd6 [FIR] Prohibit calling functions with dynamic receiver over non-dynamics
^KT-63071 Fixed
2023-11-28 15:37:09 +00:00
Nikolay Lunyak c69c34ff8b [FIR] Properly set isReceiver for implicit invoke on function types 2023-11-28 15:37:09 +00:00
Alexander.Likhachev 2bd77d5cdc [IGS] Add a non-interactive way to make a consent decision for IDEA builds
When running builds from IDEA, especially tests, the interactive consent request is barely noticeable. Also, some of the tools windows are non-interactive terminals. Thus, we detect the IDEA builds and fail fast to make it noticeable.
^KTI-1443 Fixed
2023-11-28 15:32:23 +00:00
Alexander.Likhachev ab5699f106 [IGS] Ask for consent only 5 times
^KTI-1443 In Progress
2023-11-28 15:32:23 +00:00
Alexander.Likhachev b0254add6d [Gradle] Add a check for the SNAPSHOT_SIZE metric 2023-11-28 15:22:43 +00:00
Alexander.Likhachev a7e3f7b3a6 [Gradle] Apply IDEA suggestions to BuildReportsIT.kt 2023-11-28 15:22:43 +00:00
Alexander.Likhachev 71320d2439 [IC] Add a check for the CACHE_DIRECTORY_SIZE metric
^KT-63010 Fixed
2023-11-28 15:22:43 +00:00
Alexander.Likhachev 06c1bcdc5d [IC] Add filter on files for the CACHE_DIRECTORY_SIZE metric
Without the filter, we were walking both through subdirectories and their files, so some files might be counted twice. Moreover, the behaviour of `File.length` is unspecified for directories.
^KT-63010 In Progress
2023-11-28 15:22:43 +00:00
Alexander.Likhachev 4eccbd75c3 [IC] Measure IC size metrics after the caches are closed
Before this fix, the size metrics were measured after the compilation is finished, but before the caches are closed. In many cases it might lead to incorrect measurements. After flipping the default value of the `keepIncrementalCompilationCachesInMemory` flag for Gradle builds, it started to cause always incorrect results.
^KT-63010 In Progress
2023-11-28 15:22:43 +00:00
Alexander.Likhachev 9f89e7f94f [Gradle] Flip the IC backup optimizations flags in the tests
^KT-62758 Fixed
2023-11-28 15:22:43 +00:00
Alexander.Likhachev 0f245ef3c6 [Gradle] Enable the IC backup optimizations by default
^KT-62758 In Progress
2023-11-28 15:22:43 +00:00
Alexander.Likhachev f0c643a887 [Gradle] Remove warning about experimental IC backup optimizations
This commit is part of the optimizations stabilization
^KT-62758 In Progress
2023-11-28 15:22:43 +00:00
Ilya Goncharov 093f51c89a [JS] Removing usage of legacy JS compiler #1 2023-11-28 13:44:37 +00:00
Leonid Startsev 662bff7351 Make $serializer generic constructor public
If a serializable class has generic type parameters, its serializer is not an object
and has a specialized constructor. This constructor was public in K1 and should
be public in K2 so it can be called from other serializable classes
(in case class is e.g., part of sealed hierarchy).

#KT-63402 Fixed
2023-11-28 13:31:08 +00:00
Leonid Startsev 51e3e9af94 Use a correct type for SERIALIZER_TYPE_INCOMPATIBLE diagnostic.
This diagnostic used an incorrect type for rendering (outer class type instead of a property type)
and didn't expand type argument of `KSerializer`.

Also add an additional test case for generic parameters.

#KT-63570 Fixed
2023-11-28 13:30:45 +00:00
Mikhail Glukhikh 1260d03561 Drop erroneous FirJavaConstructorBuilder.visibility
Related to KT-62961
2023-11-28 13:30:26 +00:00
Mikhail Glukhikh 2cea2b9098 K2/Java: add private enum constructor for MPP matching
#KT-62961 Fixed
2023-11-28 13:30:26 +00:00
Evgenii Mazhukin 563c878f20 [KGP] Fix sharing build cache between Windows and Linux
On Windows, path() uses backslash as a file separator, and Mac/Linux
are using forward slashes. If friendPathsSet differs, remote build outputs
from other platforms can't be reused.

This patch uses invariant paths to address the issue.

^KT-63460 Fixed


Merge-request: KT-MR-13261
Merged-by: Evgenii Mazhukin <evgenii.mazhukin@jetbrains.com>
2023-11-28 12:09:39 +00:00
Evgeniy.Zhelenskiy 5258e2044d [FIR] Forbid annotations on anonymous initializers and destructuring declarations
#KT-59896


Merge-request: KT-MR-13197
Merged-by: Evgeniy Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>
2023-11-28 11:59:26 +00:00
Svyatoslav Kuzmich e901629cf0 [Wasm] Support WASI target in K2
- Support WASI mode in CLI and test infrastructure
- Add external declaration checker
- Split Fir diagnostic lists into Base, JS and WASI

#KT-56849 Fixed
2023-11-28 11:51:53 +00:00
Artem Kobzar f26b0a5be6 [K/JS] Fix case with boxing/unboxing inside the BlockDecomposerLowering ^KT-63808 Fixed 2023-11-28 11:51:08 +00:00
Ilya Goncharov 8c95665e27 [Gradle, JS] Deprecate specific Node.js properties
^KT-62780 fixed
2023-11-28 10:36:36 +00:00
Igor Chevdar 1805f322f8 [K/N] Do not use LazyIr for per-file caches
#KT-63789 Fixed
2023-11-28 09:22:36 +00:00
Igor Chevdar b264cf2119 [K/N] Reformat 2023-11-28 09:22:36 +00:00
Anastasia.Nekrasova 00119c6a97 [K2] Disappeared UNSUPPORTED
Prohibit named parameters in function types in supertype position

^KT-59881
2023-11-28 07:55:15 +00:00
Roman Efremov 5147a5e805 [Test] Add test for current behavior of resolution of nested class type
...when it is actualized via typealias.

^KT-31636
2023-11-27 18:23:43 +00:00
Roman Efremov 205690b220 [IR] Fix incorrect matching of nested classes when actualized via typealias
Also, add tests for the cases when expect and actual nested classes
have no compatible matching to check new logic doesn't crash.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov d343e40ac5 [FIR] Actualize expect nested classes in type arguments in expect actual
...checker.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov cec644e9db [Test] Add test for expect nested classes unwrapping
...in type arguments, when they were actualized via
typealias.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov 4aaf290c99 [FIR] Fix incorrect matching of nested classes when actualized via typealias
There are still some places in `.fir.kt` where false-positive reports
remained. This is because of IR checker, which will be fixed in next
commit.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov a768ece70d [Tests] Add tests for other checkers having same problem with
...nested classes marching.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov bfc775faf5 [Tests] Create test for nested classes matching when actualized via typealias
^KT-31636
2023-11-27 18:23:42 +00:00
Svyatoslav Kuzmich 6b6353f3b9 [Wasm] Add external file checker to K2
#KT-56849
2023-11-27 16:55:04 +00:00
Svyatoslav Kuzmich 7687b86654 [Wasm] Add JsModule checker to K2
#KT-56849
2023-11-27 16:55:04 +00:00
Sebastian Sellmair 977d1c0e41 [K/N] Implement objc export header test: functionWithErrorType 2023-11-27 16:39:15 +00:00
Sebastian Sellmair 04df33eec1 [K/N] Implement ObjCExportNamerTest and ObjCExportMapperTest
... to provide simple and quick validation
for their corresponding entities.

Those tests can also act as convenient entry points
for debugging.
2023-11-27 16:39:15 +00:00
Stanislav Ruban 269b60b420 [tests] Add a test case for KT-61978
^KT-61978 Obsolete
2023-11-27 15:50:46 +00:00
Ilya Gorbunov 28c1049518 [stdlib] KT-55619 provide samples and extend documentation for String.format 2023-11-27 15:04:51 +00:00
Alexander Korepanov b1465fbfb8 [JS FIR] Enable warnings and infos for JS FIR tests 2023-11-27 14:31:31 +00:00