Commit Graph

672 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
Pavel Kunyavskiy 9cbd55aa72 [K/N] Intrinsify enumEntries<T>
^KT-59711
2023-07-25 14:24:44 +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
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
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
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
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
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
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
Vladimir Sukharev f3fcaa69eb [Test] Convert IGNORE: NATIVE directives in box tests from T to W and boxInline
^KT-59057

Merge-request: KT-MR-10752
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 18:33:24 +00:00
Vladimir Sukharev 3e6175fe30 [Test] Convert IGNORE: NATIVE directives in box tests "super"
^KT-59057

Merge-request: KT-MR-10764
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 14:50:18 +00:00
Vladimir Sukharev 3d60ed8874 [Test] Convert IGNORE: NATIVE directives in box tests from A to C
^KT-59057

Merge-request: KT-MR-10747
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-22 08:39:20 +00:00
Dmitriy Dolovov 2e43fa7cd0 [PL][tests] Adapt tests for K/N to the conditions when static cache is used w/o lazy IR 2023-06-22 08:10:11 +00:00
Dmitriy Novozhilov 1b24b95cde [FIR] Check for subtyping during actualization of supertypes of expect class
^KT-59356 Fixed
2023-06-22 07:05:31 +00:00
Kirill Rakhman c867a4b52f [FIR] Don't expand typealiases when checking for DeprecatedSinceKotlin
During serialization, this can lead to a cycle resulting in a Stack
Overflow.

#KT-58356 Fixed
2023-06-21 14:35:43 +00:00
Kirill Rakhman ee91ee9403 [FIR] Set publishedApiEffectiveVisibility on deserialized declarations
#KT-58641 Fixed
2023-06-21 07:34:29 +00:00
Evgeniy.Zhelenskiy 2d920df507 [IR] Fix KT-59346, KT-55993
#KT-59346
#KT-55993
2023-06-19 12:36:08 +00:00
Dmitriy Novozhilov d972b78627 [FIR] Allow actualization of expect classes by classes with wider visibility
^KT-59355 Fixed
2023-06-19 11:09:32 +00:00
Abduqodiri Qurbonzoda d6867917c9 Enum entry hashCode() should return identity hash code #KT-59223 2023-06-16 22:18:20 +00:00
Vladimir Sukharev 05e22e56d3 [K/N] Mark rest of reflection related tests as jvm-only
^KT-59057

Merge-request: KT-MR-10570
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-16 11:50:03 +00:00
vladislav.grechko 457837a255 Fix function invocation mangling rule
Mangle invocations of functions with value classes in signature which
override (directly or indirectly) a method declared in Kotlin code.
Otherwise, NoSuchMethodError is being thrown.

^KT-55945: Fixed
2023-06-15 09:34:21 +00:00