Commit Graph

108054 Commits

Author SHA1 Message Date
Pavel Punegov 6b409d87f5 [K/N][test] Support library for running Kotlin/Native tests with XCTest
This change adds a library with cinterop that has XCTest wrapper around
Kotlin/Native tests (that are @kotlin.test.Test marked methods).
This library can be compiled with either test code using the option
`-produce test_bundle` to make a loadable test bundle or used inside
the existing ObjC/Swift tests if compiled to a framework.

The basic idea is to make XCTest be able to resolve separate test cases
and correctly show them in test reports. This was achieved by wrapping
test cases with dynamically created invocation methods. Test listeners
are integrated with XCTest Observation to make it possible to have 
the same ability to report with GTest or TeamCity logging.

Gradle build files use MPP Gradle plugin and use a bootstrap version
of K/N. Property `kotlin.native.home` was moved to the kotlin-native
subproject to not override this project's K/N distribution, that is
being used by the KGP with the same property.

This is a part of ^KT-58928


Merge-request: KT-MR-13268
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2024-01-18 15:04:37 +00:00
Ivan Kochurkin e3ddc843bc [FIR] Fix and simplify FirUnsupportedArrayLiteralChecker 2024-01-18 14:39:54 +00:00
Ivan Kochurkin 2be9a341ca [FIR] Report ARGUMENT_TYPE_MISMATCH for nested array literals
^KT-61843 Fixed
2024-01-18 14:39:54 +00:00
Ivan Kylchik aecf05c4ac [FIR] Use ConeKotlinType to represent vararg's element type
We are using `ConeKotlinType` instead of `FirTypeRef` to represent
that element type of vararg doesn't have any source. It has a type
that was inferred. If we try to specify a source, then we could
end up with the incorrect place for diagnostic.

#KT-59682 Fixed
2024-01-18 13:33:48 +00:00
Aleksei.Cherepanov a4a433fd65 Follow-up commit for 1e7e42ba with refactoring
^KT-65043 Fixed
2024-01-18 12:32:35 +00:00
Ivan Kylchik 86e6912447 [FIR2IR] Don't generate excess IR block from FirSingleExpressionBlock
This is needed to unify K1 and K2 behavior.

#KT-65064
#KT-63781 Fixed
2024-01-18 10:59:01 +00:00
Ivan Kylchik a56bebe44e [FIR2IR] Set correct endOffset for the IrBranch
We want to use end offset of branch's result as the end for the whole
branch, not just the end of its condition.

#KT-63779 Fixed
2024-01-18 10:59:01 +00:00
Kirill Rakhman 582dd1d3c0 [FIR] Only don't approximate nested captured arguments if they have recursive supertypes
This fixes a compiler crash
IllegalStateException: Captured type for incorporation shouldn't escape
from incorporation

The crash occurs when a captured type with status FOR_INCORPORATION
is two layers deep inside a captured type with status FROM_EXPRESSION.
We first check if approximation is required for the most outer captured
type in AbstractTypeApproximator.approximateCapturedType.
Then we encounter the second captured type with status FROM_EXPRESSION
in AbstractTypeApproximator.approximateParametrizedType.
At this point, we stop checking and miss the third captured type with
status FOR_INCORPORATION.

Unfortunately, we can't check recursively if nested captured types
need to be approximated because of types with recursive super types
(the original reason why the extra check was introduced).
That's why we restrict the second check to types with recursive
super types, effectively restoring the previous behavior for all other
types.

#KT-65050 Fixed
2024-01-18 09:22:15 +00:00
anzhela.sukhanova 7587f73846 [Test] KT-61937: add tests with context functions and naming clash
Update tests for ^KT-61937


Merge-request: KT-MR-13678
Merged-by: Anzhela Sukhanova <anzhela.sukhanova@jetbrains.com>
2024-01-18 08:27:31 +00:00
Kirill Rakhman cf494ada0b [FIR] Flatten ConeAttributeWithConeType when transforming
This is necessary to prevent exponential growth of the attribute
structure.
Since we usually care for the most inner value of a
ConeAttributeWithConeType like EnhancedTypeForWarningAttribute, this
shouldn't alter any behavior.
2024-01-18 08:27:10 +00:00
Kirill Rakhman b8ff04004a [FIR] Make EnhancedTypeForWarningAttribute a data class
(cherry picked from commit 76898ddb0f)
2024-01-18 08:27:10 +00:00
Kirill Rakhman d74b5c59fb [kapt] Fix new compilation warnings after #KT-63208
(cherry picked from commit 9b4ebc31c1)
2024-01-18 08:27:10 +00:00
Kirill Rakhman 228ab60476 [FE 1.0] Fix new compilation warnings after #KT-63208
(cherry picked from commit dc0f4e6995)
2024-01-18 08:27:10 +00:00
Kirill Rakhman b7b1bd0a2c [FIR] Fix parameter order of NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS
(cherry picked from commit 8bfc4675c4)
2024-01-18 08:27:10 +00:00
Kirill Rakhman e91e9d8ca8 [FIR] Don't lose error level enhancements in warning-level-enhanced arguments
The error-level enhancement is kept as warning-level and a new
LanguageFeature is introduced to turn the warning into an error.

#KT-63208 Fixed
#KT-63209

(cherry picked from commit 371b1eb3d5)
2024-01-18 08:27:10 +00:00
Kirill Rakhman c39262195d [FIR] Let attributes opt-in to participating in ConeClassLikeTypeImpl structural equality
This is required for EnhancedTypeForWarningAttribute because scopes
should not be reused between cone types with different values of
this attribute.

#KT-63208

(cherry picked from commit 9189154cae)
2024-01-18 08:27:10 +00:00
Alexander Shabalin ccba52aae4 [K/N][test] Mitigate a race in WorkerTest.executeAfterOrdering
Mostly affects linux aarch64 because we run it under qemu.
2024-01-18 08:12:22 +00:00
Artem Olkov 37a8723a79 KT-64931: add convertion of kotlin top-lvl functions into swift static functions
Merge-request: KT-MR-13878
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2024-01-17 20:30:04 +00:00
Yahor Berdnikau 01824a336c [Gradle] Fix warnings in MultiplatformLayoutV2KotlinAndroidSourceSetNaming
^KT-56904 In Progress
2024-01-17 19:32:04 +00:00
Yahor Berdnikau 5ed28a6a79 [Gradle] Fix warnings in KotlinAndroidSourceSetNaming
^KT-56904 In Progress
2024-01-17 19:32:04 +00:00
Yahor Berdnikau ca996d0833 [Gradle] Fix warnings in KotlinAndroidSourceSetInfo
^KT-56904 In Progress
2024-01-17 19:32:04 +00:00
Yahor Berdnikau db62637318 [Gradle] Fix warnings in KotlinAndroidSourceSetFactory
^KT-56904 In Progress
2024-01-17 19:32:04 +00:00
Alexander Shabalin 30d6fa730e [K/N] Add separate FinalizerProcessor for main thread ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin 8a86fec38f [K/N] Add RunLoopFinalizerProcessor ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin d8fdc4d31a [K/N] Add RunLoopTimer ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin b2d957b990 [K/N] Extract RunLoopSource ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin 2dd7a9ef21 [K/N] Support CF objects in ObjectPtr ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin e5269daa74 [K/N] Constructor of ObjectPtr with retain ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin c4992f1912 [K/N] Move AutoreleasePool into objc_support ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin 815b452435 [K/N] Remove old release-on-main ^KT-63423 2024-01-17 18:26:00 +00:00
Alexander Shabalin eb0bd0112a [K/N] Add a stress test on dispose-on-main ^KT-63423 2024-01-17 18:26:00 +00:00
Dmitriy Novozhilov 0741250b12 [FIR] Use proper FirProvider in the FirKLibSerializerExtension
3aa84906 changed native metadata serialization to use proper platform
  session, but it caused a new bug: FirKLibSerializerExtension uses
  FirProvider from the passed session to get a containing file of
  serialized declaration to put some extension into the metadata. And
  platform session doesn't contain information about any declarations
  except platform ones

So it's needed to use the proper FirProvider in it, which can be
  extracted from Fir2IrComponents. This provider contains providers from
  all sessions that are being compiled plus providers for top-level
  declarations generated by compiler plugins

^KT-65024 Fixed
2024-01-17 17:38:44 +00:00
Evgeniy.Zhelenskiy 70d1a2ea8c [FIR] Report package usages as a LHS
#KT-59972
2024-01-17 17:28:46 +00:00
Mikhail Glukhikh e999e289ee K2: split EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS to property/objects
Related to KT-64982
2024-01-17 16:51:48 +00:00
Mikhail Glukhikh 4fd73b06e2 FIR: render FirErrorResolvedQualifier properly 2024-01-17 16:51:48 +00:00
Mikhail Glukhikh 581cac3d45 K2: report EXPLICIT_TYPE_ARGUMENTS_... also on resolved qualifiers
#KT-64982 Fixed
2024-01-17 16:51:48 +00:00
Mikhail Glukhikh ee515ec5c4 K2: drop TODO in buildResolvedQualifierForClass
#KT-59649 Fixed
2024-01-17 16:51:48 +00:00
Mikhail Glukhikh caa850e470 FIR: render resolved qualifier type arguments in dumps 2024-01-17 16:51:48 +00:00
Mikhail Glukhikh 0a21669fb9 K2: reproduce KT-64982 2024-01-17 16:51:48 +00:00
Brian Norman 8f9bb75e60 [FIR] Allow identity equality to be used in contract implications
^KT-63256 Fixed
2024-01-17 14:59:59 +00:00
Roman Efremov ee1ee965a1 [FIR] Fix incorrect work of K2 expect-actual matcher when actual is Java
...field, which is fake override.
This was failing in Stdlib with `expect HashMap` + actual typealias to
`java.util.HashMap`.

^KT-63624 Fixed
2024-01-17 14:47:41 +00:00
Roman Efremov 3d2a37ee41 [Test] Write reproducer test for expect-actual matching to Java field
..., which comes from super class, which incorrectly works in K2.

^KT-63624
2024-01-17 14:47:41 +00:00
Roman Golyshev bb044bb57e [docs] Improve formatting in JavaToKotlinClassMap docs
Add `-` symbols to form a proper list
2024-01-17 14:28:35 +00:00
Nikita Bobko 0dc8629312 [FIR] Don't report MUST_BE_INITIALIZED on private open properites
^KT-59074 Fixed

This solution is not ideal. Ideally, the allopen compiler plugin
shouldn't report `private` properites as `open` KT-64980, but it will
unpredictably break other things.
2024-01-17 14:18:06 +00:00
Alexander Udalov 35caae355d Tests: minor, add box test for KT-31367/KT-61805
For some reason, codegen box test was not added in 082c337faa. The main
point of it now is to check that everything works correctly in the
IrFakeOverrideBuilder mode.
2024-01-17 12:27:36 +00:00
Pavel Kunyavskiy 15094eb03a [IrFakeOverrideBuilder] Support fake overrides for java static methods
^KT-64150
2024-01-17 11:40:12 +00:00
Dmitriy Dolovov 8f046d36e0 [FIR2IR] Implement support for Fir2IrLazyTypeAlias
Fir-based lazy type alias is required in IR text tests to check that
lazily loaded IR is equivalent to deserialized IR (module bodies)
and does not cause ABI compatibility issues in KLIB-based backends.

^KT-65033
2024-01-17 11:37:48 +00:00
Nikolay Lunyak 96db6eb94f [FIR] Support tailrec safe-calls
^KT-63529 Fixed
2024-01-17 11:31:26 +00:00
Nikolay Lunyak a4b7697714 [FIR] Reproduce KT-63529
^KT-63529
2024-01-17 11:31:26 +00:00
Dmitriy Novozhilov 9d0f17da26 Advance bootstrap to 2.0.0-dev-12830 2024-01-17 11:29:29 +00:00