Commit Graph

1562 Commits

Author SHA1 Message Date
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
Kirill Rakhman e35a28d36d [FIR2IR] Correctly map arguments of type alias constructor call
Previously, we applied type arguments as is when converting type alias
constructor calls to IR.
Now, we map them using the expansion of the type alias.

#KT-59743 Fixed
2023-07-21 07:45:52 +00:00
Kirill Rakhman 63374e870d [Tests] Specify ticket number in test mute reason
#KT-60136
2023-07-19 13:34:58 +00:00
Kirill Rakhman 97024d9ccb [FIR] Resolve array literal argument for non-primitive-array parameter as arrayOf call in annotation calls
This allows us to properly complete array literals arguments of
annotation calls fixing several false-negative type mismatch errors
as well as enabling the inference of generic type arguments.

#KT-59581 Fixed
#KT-58883 Fixed
2023-07-19 13:34:58 +00:00
Dmitrii Gridin 4366164b65 [FIR] ConeAttributes: fix plus method
The 'plus' method was actually creating a new 'ConeAttributes' with
only one new attribute due to a typo inside 'buildList'

^KT-60451
^KT-60504
2023-07-19 10:40:03 +00:00
Kirill Rakhman c605cb9855 [FIR2IR] Align object receiver generation with K1
#KT-59548 Fixed
2023-07-19 10:39:41 +00:00
Vladimir Sukharev f7269eb384 [FIR2IR] Rework reordering condition to better handle synthetic class delegation fields
^KT-60243

Merge-request: KT-MR-11125
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-07-19 09:59: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 79fa2b6db0 Fir2Ir: generate coercion to Unit for when branches if needed
Before this change, it could happen that `when` of type Unit has a
branch whose type is not Unit. This can lead to problems in IR
lowerings, for example PolymorphicSignatureLowering which is very
reliant on the correct types of expressions and placement of coercions
to Unit (KT-59218).
2023-07-18 11:37:41 +00:00
Vladimir Sukharev f9df4e1487 [K/N] Reorder hashCode, toString, equals in data classes to match K1 order
^KT-60247 Fixed

Merge-request: KT-MR-11080
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-07-18 00:06:48 +00:00
Sergej Jaskiewicz 5e63f7627f [klib] Test signature descriptions in irText tests
KT-59486
2023-07-14 20:26:45 +00:00
Brian Norman 10ed26991d [FIR] Extract LHS receiver of assignment operator statements
#KT-53490 Fixed
2023-07-12 11:41:33 +00:00
Mikhail Glukhikh 39406710b2 FIR2IR: fix origin calculation for explicit inc/dec calls 2023-07-11 08:28:04 +00:00
Mikhail Glukhikh f8ca440e96 K2: resolve Java enum entries from the beginning (related to KT-59464) 2023-07-11 08:28:04 +00:00
Dmitriy Novozhilov 6bb7fc05df [IR] Split implementation of DataClassMembersGenerator to IR based and descriptor based 2023-07-05 14:57:55 +00:00
Sergej Jaskiewicz addb048ce9 [FIR] Generate signatures for synthesized class delegation fields
This is to align the behavior with K1.

^KT-57754 Fixed

Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
2023-06-26 12:39:37 +00:00
Alexander Udalov 13baf43ae3 K2: fix NSME on toChar for subclasses of Number
Code in `ReplaceNumberToCharCallSitesLowering` relies on `Number.toChar`
being declared in IR as non-abstract. Otherwise the
`resolveFakeOverride` call there doesn't work, and the lowering can't
rewrite the call to `toInt().toChar()`, and we end up with a call to the
missing method `Number.toChar` in the bytecode.

 #KT-57217 Fixed
2023-06-21 14:58:02 +00:00
Mikhail Glukhikh d8a20f1975 K2: don't generate Java overridden synthetics for Kotlin get/sets
#KT-59038 Fixed
2023-06-20 07:07:10 +00:00
Sergej Jaskiewicz fd094835a4 [test] Add the NATIVE backend to non-JVM check blocks in signature tests
(see KT-59204)
2023-06-16 10:01:54 +00:00
Ivan Kylchik dd264cff50 [IR] Split const folding into necessary one and for optimizations only
In this commit we have a lot of change in test data. This was caused
by the way where we evaluate constants. We split constant evaluation
into two distinct parts: only necessary evaluations for `fir2ir`
(like const val and annotations) and optimizations for lowering.
Now we don't do all constant evaluation on `fir2ir`, but IR
dump is executed after this phase, so test data changed.

#KT-58923
2023-06-14 19:02:39 +00:00
Ivan Kylchik ec4cf40f6f [IR] Allow to fold IrGetField expressions
#KT-58923
2023-06-14 19:02:38 +00:00
Mikhail Glukhikh c898b264ba FIR2IR: fix receiver of value classes method references
This commit fixes the receiver of these method in FIR2IR code
by removing a particular hack.
However, as the consequence of it 2 black box tests become broken in K2.
The reason is KT-54952 which is not yet fixed

Related to KT-54887
2023-06-14 07:09:15 +00:00
Kirill Rakhman 4b85776405 [FIR] Fix completion of FirDelegatedConstructorCall
Before this fix, changes that were made to the arguments list by calling
argumentList.transformArguments() were overriden by replaceArgumentList.
This fixes reverses the order in which these calls are made.
This also aligns the logic between the completion of qualified accesses
and delegated constructor calls.

#KT-59102 Fixed
2023-06-13 09:47:58 +00:00
Kirill Rakhman 86836e69e9 [FIR2IR] Unwrap call-site substitution overrides
Generating IR declarations for use-site substitution overrides leads
to IR that is different from K1 as well as problems in signature
generation which relies on mangling. Use-site substitutions can contain
references to type parameters from the call-site which aren't handled
in mangling.

#KT-57022 Fixed
2023-06-09 08:22:21 +00:00
Kirill Rakhman 67fc46a190 [FIR] Fix handling of type parameters in FIR mangling
#KT-57429 Fixed
2023-06-09 08:22:21 +00:00
Sergej Jaskiewicz f2031ae642 [IR] Don't print multifile/synthetic facade class names in irText tests
This only applies to JVM and fq-names in declaration references
in IR dumps.

This enables us to run more irText tests on platforms other than JVM
(see KT-58605).
2023-06-05 10:40:17 +00:00
Sergej Jaskiewicz 5f59de23c5 [FIR] Fix computing mangled names for top-level functions and properties
^KT-57433 Fixed
2023-06-02 10:05:34 +00:00
Sergej Jaskiewicz fd76a34277 [IR] Don't print flags in declaration references in irText tests
This doesn't reduce the quality of tests, because the flags are still
printed for declarations themselves. We only omit them in references.

However, this makes the tests more compatible with non-JVM backends
(see KT-58605), because flags of referenced stdlib declarations may
differ among target platforms.
2023-05-30 17:26:30 +00:00
Denis.Zharkov 2e5b783cc6 K2: Refine how JDK members are mapped to built-in classes
Previously, the semantic was more-or-less correct for most of the cases
but some corner one, like `sort` in MutableList didn't work properly.

Namely, `sort` should be marked there in a way to forbid to call it
everywhere beside super-calls.
Also, overriding it should be allowed.

Mostly, the logic was re-written to K2 model from K1-related
JvmBuiltInsCustomizer.

^KT-57694 In progress
^KT-57269 Fixed
2023-05-30 10:44:41 +00:00
Kirill Rakhman 9ca9fc9c68 [FIR2IR] Set type arguments on annotation calls
#KT-58553 Fixed
2023-05-30 07:58:03 +00:00
Sergej Jaskiewicz 28ead4118c [test] Unmute a couple of irText tests that no longer fail on K2 2023-05-29 09:24:43 +00:00
Sergej Jaskiewicz 02180e8685 Factor out duplicated mangling logic for functions into the base class
^KT-57777 Fixed
^KT-57818 Fixed
2023-05-26 10:55:24 +00:00
Sergej Jaskiewicz 7abc6af124 [FIR, IR] Fix name mangling for dynamic types
^KT-57566 Fixed
2023-05-25 10:23:33 +00:00
Kirill Rakhman 4dd1f9f4d6 [FIR] Set type arguments for callable reference in property delegation
#KT-58555 Fixed
2023-05-25 09:27:47 +00:00
Dmitriy Novozhilov fdc236296d [FIR2IR] Generate @FlexibleMutability annotation on IR types if needed 2023-05-24 14:07:32 +00:00
Sergej Jaskiewicz 5d3fe7547a [IR] Fix mangling generic properties from IR-based descriptors
For type parameters of generic properties,
`DeclarationDescriptor#getContainingDeclaration` must return
the property descriptor instead of the accessor function descriptor.

^KT-57436 Fixed
2023-05-24 09:58:39 +00:00
Nikita Bobko d9d4dee582 [FIR] fix false negative MUST_BE_INITIALIZED for deferred init + custom setter case
^KT-58346 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

BTW this commit accidentaly and partially fixes KT-57553 for K2, because
of a cleaner K2 architecture. I will unify MUST_BE_INITIALIZED behaviour
in K1 and K2 in the next commits
2023-05-23 14:12:28 +03:00
Sergej Jaskiewicz 1a29b9efff [FIR, IR] Fix name mangling for functions with context receivers
- Mangled names of property accessors now include context receiver
  types of the corresponding property when computed from FIR.
- Context receivers are now supported when computing mangled names
  from IR
- IrBasedDescriptors now account for context receivers

^KT-57435 Fixed
2023-05-23 08:55:50 +00:00
Alexander Udalov 83865782ff FIR: do not generate annotations on properties from delegation
#KT-57228 Fixed
2023-05-22 20:12:29 +00:00
Sergej Jaskiewicz 56f977f70c [IR] Don't render facade classes in JVM fq-names in irText tests
This makes the tests more compatible with non-JVM backends
(see KT-58605)
2023-05-17 12:43:35 +00:00
Sergej Jaskiewicz 973adb6a38 [test] Remove TARGET_BACKEND: JVM_IR for non JVM-specific irText tests
If they fail on other backends, use the IGNORE_BACKEND directive instead
2023-05-16 18:28:23 +00:00
Sergej Jaskiewicz 6e8283a6fe [IR] Dump IdSignatures and mangled names in irText tests
The reason #1 for this feature is that we want to test IdSignatures
generated for declarations. Currently, there is no (easy) way to ensure
that a change in the signature building logic doesn't cause any breaking
changes wrt klibs.

Now, most IdSignatures include hashed mangled names in them, so even if
we catch a regression where the included hash changes, there would be no
way of knowing immediately what caused it, unless we'd also have mangled
names in the expectations.

The reason #2 is to test the manglers themselves. Currently, there are
no tests for them. They heavily duplicate each other, this is already
causing issues (see KT-57427) that would be very hard to catch without
these tests.

^KT-58238 Fixed
2023-05-15 18:20:45 +00:00
Sergej Jaskiewicz 1a8d5056bf [test] Mute an irText test on JS_IR instead of making it JVM-only
The test is not in any way JVM-specific, but it fails on the JS BE
because of different fq-names of stdlib symbols on JVM and JS.

The fix is in progress. Mute the test until the fix is ready.
2023-05-15 15:40:25 +00:00
Denis.Zharkov c3ac2e44a0 Adjust test data for enabling ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
^KT-55388 Fixed
2023-05-15 10:43:19 +00:00
Mikhail Glukhikh 1ba900be44 FIR2IR: change origin & operator flag in data classes making them closer to K1
Related to KT-54887
2023-05-15 08:16:24 +00:00
Mikhail Glukhikh 5d35bfd88d Add IR text test for KT-54887 2023-05-15 08:16:24 +00:00
Mikhail Glukhikh a86279b766 IR text: add a test with data object 2023-05-15 08:16:24 +00:00
Ivan Kochurkin d06d3ff467 [FIR2IR] Consider isExpect value of super members during fake-overrides generating
It's important for FIR2IR and IrActualizer

Because `isExpect` is a part of signature, and it's considered during actualization
2023-05-12 14:03:15 +00:00
Mikhail Glukhikh 9011af1008 K2: perform IOT approximation in completion properly #KT-58520 Fixed 2023-05-11 09:12:26 +00:00
Mikhail Glukhikh 8bc72cb2e5 K2: reproduce KT-58520 in FIR2IR (K2 fails with exception) 2023-05-11 09:12:26 +00:00