Commit Graph

1316 Commits

Author SHA1 Message Date
Leonid Startsev 648c1f4599 Support instantiation of annotations with type parameters
By ignoring type parameters. Since type parameters in annotations are a
very limited feature, their sole use is to be able to specify them as
KClass argument: annotation class Foo<T: Any>(val bar: KClass<T>).
Since we can encounter type param only as a KClass type argument (and
never as a property type), simple approach of ignoring them works fine.
In that case, since we simply copy property types to synthetic
implementation class, its properties in IR start look like this:
annotation class FooImpl(override val bar: KClass<T of Foo>). This IR
seems to be not completely correct, since FooImpl.bar type contains T of
Foo param, which is out of its scope. However, so far I didn't
encounter any problems with this during testing and after MR discussion
this approach has been considered possible.

#KT-59558 Fixed
#KT-59036 Fixed
2023-07-26 17:16:13 +00:00
Mikhail Glukhikh f20e2dec31 K2: generate Unit conversion for indexed assignment at raw FIR stage
#KT-59748 Fixed
2023-07-26 06:09:15 +00:00
Sergey Bogolepov 9daa40d2ed [K/N] Use platform_version instead of sdk_version and os_version_min 2023-07-25 14:30:06 +00:00
Pavel Kunyavskiy 9cbd55aa72 [K/N] Intrinsify enumEntries<T>
^KT-59711
2023-07-25 14:24:44 +00:00
Svyatoslav Scherbina 61dbe7fb75 [Gradle] temporarily change error to warning for linuxArm32Hfp
^KT-58864
2023-07-25 12:33:46 +00:00
Alexander Udalov 874d1c514a JVM: support enumEntries intrinsic for Kotlin enums
Implementation is very similar to the `enumValues` intrinsic.

Java enums and old (pre-1.9) Kotlin enums will be supported in a
subsequent commit.

 #KT-59710
2023-07-25 09:55:43 +00:00
vladislav.grechko e5763a692f Substitute type arguments to return type of inlined function references
Such substitution is crucial on codegen stage if the return type is
reified (e.g. for `Array`)

^KT-59507: Fixed
^KT-59281: Fixed
2023-07-24 22:11:59 +00:00
Pavel Kunyavskiy 488d24296a [K/N]: Allow invocation of volatile intrinsics on inline function constant arguments.
Invocation of atomic intrinsics is only allowed on property references that are known at compile time. This commit makes it possible to also invoke intrinsics on a constant property reference getter passed as an argument.
See KT-58359

Co-authored-by: Pavel Kunyavskiy <Pavel.Kunyavskiy@jetbrains.com>

Merge-request: KT-MR-10413
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-24 17:45:16 +00:00
Nikita Bobko 4f3ecedbca [FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes
^KT-59739 Fixed
Review: https://jetbrains.team/p/kt/reviews/11038/timeline
2023-07-24 09:15:11 +00:00
Pavel Kunyavskiy fd564d4af9 [K/N] Disable custom import for forward declarations
If forward declaration exists in a library, it was
possible to import it both by forward declaration name
and normal library name. This is strange unique behavior.
And it would also make KT-59643 changes binary incompatible.
So from now it's only possible to import forward declaration by
forward declaration name only.

^KT-59642
2023-07-24 08:24:20 +00:00
Zalim Bashorov b1a4d354f1 Regenerate tests 2023-07-21 17:27:17 +00:00
Svyatoslav Scherbina bcc4a891be Native: add tests for ExperimentalForeignApi on cinterop declarations
Add tests checking that all (top-level) declarations generated by
cinterop now have ExperimentalForeignApi annotation.

^KT-58362
2023-07-21 11:54:14 +00:00
Svyatoslav Scherbina 3280d3ef80 Native: prepare existing tests for cinterop adding ExperimentalForeignApi
cinterop tool should add ExperimentalForeignApi to all generated
declarations by default. This commit prepares existing tests for this.

^KT-58362
2023-07-21 11:54:14 +00:00
Sergey Bogolepov becbca2284 [K/N] Fix DeclarationDescriptor.findObjCExportMetaAnnotations
`require` is failing in the presence of error types,
so use nullability instead.
2023-07-21 09:57:22 +00:00
Ivan Kylchik 30c00f7983 [IR] Specify explicitly that classes from Java can be interpreted
In early prototypes of interpreter, it was easier to assume that
all classes from Java can be interpreted and fix something if not.
Check for Java declaration was done by checking that the package name is
starting with "java". But this is actually wrong and can lead to errors
when some code is declared in "java" something package, but is not from
Java stdlib.

#KT-60467 Fixed
2023-07-20 09:40:42 +00:00
Ivan Kylchik 2ecbb21a9f [IR] Add new tests on inline to check issues with type parameters
#KT-58241
2023-07-20 09:01:42 +00:00
Mikhail Glukhikh 08222c83cf K1/K2: set language version explicitly in Native tests pipeline 2023-07-19 06:46:53 +00:00
Alexander Udalov 69059362b8 Fir2Ir: generate 'finally' block always with Unit type
This is important for IR lowerings like PolymorphicSignatureLowering
which are very sensitive about the correct types of expressions and
placement of coercions to Unit (KT-59218).

A boolean parameter to `insertImplicitCasts` is not the best solution to
ensure that coercion to Unit is added. The best solution would be to fix
the TODO and generate coercion to the block's type for the last
statement. But that will affect many other places and will need to be
done separately => KT-59781.

Code in IrInterpreter is uncommented to fix the FIR test
`compiler/testData/ir/interpreter/exceptions/tryFinally.kt`; otherwise
evaluation of the function `returnTryFinally` there crashes with
"NoSuchElementException: ArrayDeque is empty". No idea why this test
didn't fail for K1 though, since the created IR is exactly the same.

For some unknown reason this breaks WASM backend with K2, but not with
K1 => KT-59800.
2023-07-18 11:37:41 +00:00
Alexander Udalov 5513740659 Minor, remove extraneous box tests
These tests are already present in
`compiler/testData/codegen/box/classes/kt496.kt`.
2023-07-18 11:37:41 +00:00
Dmitriy Dolovov ce815968cf [Native][tests] Use convention fun generatedTestDir() in build.gradle.kts 2023-07-17 21:09:40 +00:00
Dmitriy Dolovov 938146749d [PL][tests] K/JS: Avoid any unexpected warnings to appear in tests 2023-07-17 21:09:40 +00:00
Dmitriy Dolovov 19c6208cc0 [PL][tests] K/N: Avoid any unexpected warnings to appear in tests 2023-07-17 21:09:40 +00:00
Alexander Shabalin bdb534c3de [K/N] Fix perf build 2023-07-17 16:56:34 +00:00
Kirill Rakhman feed740415 [FIR2IR] Don't copy default value to annotation call with vararg parameter
This aligns the behavior with K1 and fixes an issue when the default
value was deserialized as FirExpressionStub leading to an exception
in FIR2IR when trying to convert it to an IR expression.

#KT-60120 Fixed
#KT-59610 Fixed
2023-07-17 11:42:39 +00:00
Pavel Kunyavskiy 6da3ecceab [K/N] Implement frontend checkers for usages forward declaration type
Forward declaration type doesn't exist in runtime. This restricts
its possible usages.

^KT-59764
2023-07-17 09:24:33 +00:00
mvicsokolova d9fa9c1b3b [K/N] Introduce intrinsics that atomically update array elements
Supported atomic update of elements for IntArray, LongArray and Array<T>
See KT-58360

Merge-request: KT-MR-11020
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-12 14:32:36 +00:00
Dmitrii Krasnov f2816a5531 Added property for overriding konan distribution location
#KT-50463 Fixed

Merge-request: KT-MR-10310
Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
2023-07-12 12:36:51 +00:00
Brian Norman 10ed26991d [FIR] Extract LHS receiver of assignment operator statements
#KT-53490 Fixed
2023-07-12 11:41:33 +00:00
Ivan Kylchik ad6332112e [IR] Support const optimizations for Native backend 2023-07-10 13:19:51 +00:00
Pavel Kunyavskiy ef9413108b [K/N] Consolidate forward declarations handling
This is refactoring in preparation for KT-59764.
Names and layout of forward declarations related classes
was copy-pasted many times over compiler code.

Implementing KT-59764 would require copy-pasting it two more times.
So instead of doing this it was put in single place.

No behaviour changes intended in this commit.
2023-07-10 08:59:16 +00:00
Vladimir Sukharev 32a390ea18 [K/N] K1/MPP: Enable splitting 1-stage to two CLI invocations
^KT-59245 Fixed
2023-07-07 17:51:46 +00:00
Vladimir Sukharev a87b662bc5 [K/N] Split 1-stage K1 compilations to two stages
^KT-59245 Fixed
2023-07-07 17:51:46 +00:00
Dmitriy Dolovov 8aacdb471b [K/N] Fix: Ignore bridge functions in FunctionReferenceLowering
^KT-59858
2023-07-06 12:39:46 +00:00
Kirill Rakhman b68962018c [FIR] Remove incompatible from expect actual matching if compatible exists
This fixes an issue with checking for default values in call resolution
(see FirDefaultParametersResolver) where it is expected that the map
only contains a single compatible entry.

#KT-59613 Fixed
2023-07-05 08:51:01 +00:00
Ilya Goncharov 148d8c9246 [Gradle, JS] Migrate JS cli tests to ir backend 2023-07-05 07:10:06 +00:00
Denis.Zharkov 3279313f2c K2: Fix priority for implicit receiver + extensionInvoke
See K1 counterpart at org.jetbrains.kotlin.resolve.calls.tower.TowerResolver.Task.processImplicitReceiver

^KT-58943 Fixed
^KT-59541 Fixed
2023-07-01 16:29:06 +00:00
Alexander Udalov 5dc882abf5 Reflection: create synthetic classes instead of throwing UOE
... for Kotlin-generated classes which do not correspond to a "class"
from the Kotlin language's point of view. For example, Kotlin lambdas,
file facade classes, multifile class facade/part classes, WhenMappings,
DefaultImpls. They can be distinguished from normal classes by the value
of `KotlinClassHeader.Kind` (which is the same as `Metadata.kind`).

Another theoretical option would be to throw exception at the point
where the `::class` expression is used, if the expression's type on the
left-hand side is a synthetic class. But we can't really do that since
it'll affect performance of most `<expression>::class` expressions.

So, construct a fake synthetic class instead, without any members except
equals/hashCode/toString, and without any non-trivial modifiers. It kind
of contradicts the general idea that kotlin-reflect presents anything
exactly the same as the compiler sees it, but arguably it's worth it to
avoid unexpected exceptions like in KT-41373.

In the newly added test, Java lambda check is muted but it should work
exactly the same as for Kotlin lambdas and other synthetic classes. It's
fixed in a subsequent commit.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Alexander Udalov 1e031d9fb8 Reflection: add test on introspection of local classes
kotlin-reflect works correctly already for Kotlin-generated local
classes and anonymous objects, but not for Java ones. This is fixed in a
subsequent commit.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Sergey Bogolepov 0ceadc5933 [K/N] Fix KT-59167 2023-06-30 09:01:37 +00:00
Leonid Startsev b15da7c63a Deprecate old kotlinx-metadata flags API:
Flag, Flag constants, Flags typealias, flagsOf() function, and
Flag accessors in nodes (such as KmClass.flags, KmClass.jvmFlags, KmProperty.setterFlags, etc)

#KT-59440
2023-06-27 15:12:46 +00:00
Leonid Startsev 1a1cbcb321 Rework flags in kotlinx.metadata:
Introduce extensions for KmNodes to work with various modifiers instead of old Flags.SOMETHING.invoke(flags).
Provide Visibility, Modality, and Kind enums.
Introduce KmPropertyAccessorAttributes to replace KmProperty.getterFlags and KmProperty.setterFlags.
Deprecate nodes constructors which take flags but not flags itself (yet).
Adapt KotlinP to changes.

#KT-59440 Fixed
2023-06-27 15:12:46 +00:00
Pavel Kunyavskiy b28b0e70b6 [commonizer] Support commonizing includedForwardDeclarations in manifest
It is a new manifest property which is used only in K2, and it is
required for correct K2 processing of forward declarations.

^KT-59132
2023-06-27 08:05:52 +00:00
Vladimir Sukharev 09a0905ffc [Test] Convert IGNORE: NATIVE directives in rest of tests
^KT-59057 Fixed

Merge-request: KT-MR-10794
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-26 07:44:12 +00:00
Vladimir Sukharev 4d9f93e4eb [K2/N/MPP] Disable one-stage MPP compilation
^KT-56855

Merge-request: KT-MR-10735
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 15:51:59 +00:00
Vladimir Sukharev 7930885131 [Test] Convert IGNORE: NATIVE directives in box tests from M to R
^KT-59057

Merge-request: KT-MR-10757
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 14:15:48 +00:00
Vladimir Sukharev 5c7d321e45 [Test] Convert IGNORE: NATIVE directives in box tests "sealed"
^KT-59057

Merge-request: KT-MR-10763
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 13:53:29 +00:00
Vladimir Sukharev a036e41809 [Test] Convert IGNORE: NATIVE directives in box tests from D to I
^KT-59057

Merge-request: KT-MR-10748
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 09:11:17 +00:00
Vladimir Sukharev 503cd6196c [Test] Convert IGNORE: NATIVE directives in box tests specialBuiltins
^KT-59057

Merge-request: KT-MR-10760
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 08:07:13 +00:00
Vladimir Sukharev ab03cb2357 [Test] Convert IGNORE: NATIVE directives in box tests sam/* and sameFile*/*
^KT-59057

Merge-request: KT-MR-10758
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-23 06:23:53 +00:00
Vladimir Sukharev 1bf3bde4f8 [Test] Convert IGNORE: NATIVE directives in box tests from J to J
^KT-59057

Merge-request: KT-MR-10749
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 18:39:59 +00:00