Commit Graph

1636 Commits

Author SHA1 Message Date
Brian Norman ed4a778aa7 [FIR2IR] Convert data class properties of type dynamic for hashCode
Properties of type dynamic within a data class cause compilation to fail
when converting FIR to IR. This is because dynamic types do not have a
proper backing class for symbol lookup. However, dynamic types can just
be considered of type Any for hashCode calculations.

^KT-63094 Fixed
2023-11-14 17:45:04 +00:00
Mikhail Glukhikh 4913c38e98 FIR2IR: insert spread for named argument against primitive vararg
#KT-60312 Fixed
2023-11-13 16:23:26 +00:00
Mikhail Glukhikh 4abce54748 K2: reproduce KT-60312 2023-11-13 16:23:26 +00:00
Sergej Jaskiewicz 69aeddcba8 [IR] In irText tests, test full mangled names only computed from IR
We plan to disable computing full mangled names of declarations in all
manglers except the IR mangler (see the subsequent commits).

From now on, in irText tests we dump only the following mangled names:

- Full mangled names computed using the IR mangler
- Signature mangled names computed using the Descriptor mangler
- Signature mangled names computed using the IR mangler
- Signature mangled names computed using the FIR mangler

Here by a full mangled name we mean the mangled name of a declaration
computed using the `MangleMode.FULL` mode. Those mangled names include
the mangled names of the declaration'a parents.

By a signature mangled name we mean the mangled name of a declaration
computed using the `MangleMode.SIGNATURE` mode.
These mangled names are used to compute an `IdSignature` for
the declaration, hence the name.
2023-11-10 12:31:40 +00:00
Dmitriy Novozhilov 8578a0bf6a [FIR2IR] Properly insert casts for smartcasts in argument position
Previously cast inserter didn't consider expected type for arguments
  of function calls

^KT-63257 Fixed
2023-11-10 07:50:01 +00:00
Dmitriy Novozhilov c70a6425f5 [FIR2IR] Don't insert not-needed upcasts for smartcasted expressions
Related to KT-63257
2023-11-10 07:50:00 +00:00
Alexander Udalov 953f6ba6b6 K2: keep FlexibleNullability on enhanced type parameter types
Types based on type parameters which have both hasEnhancedNullability
and hasFlexibleNullability were incorrectly converted to IR: only
`@EnhancedNullability` annotation was added to the IR type. This means
that the nullability of the type started to matter, which is incorrect
because the type is supposed to be flexible.

This backfired in the IR fake override builder mode, where nullability
of methods inherited from both Kotlin maps and Java maps clashed, which
resulted in the exception from FakeOverrideRebuilder.

If the type is both flexible and enhanced, we're now adding
`@FlexibleNullability` to the IR type. Note that `@EnhancedNullability`
is not needed because it only affects primitive types which need to be
handled as wrapper types on JVM, but `@FlexibleNullability` already has
that effect.

IR still slightly differs from K1 for collection subclasses, which can
be seen for example in the changed IR text tests. This is to be
investigated later.

The change in tests is needed because the `kt48495*.kt` tests are now
passing on K2 in the IR fake override builder mode, while failing on the
vanilla K2.

This is related to KT-61370 but does not entirely fix it, although
curiously it fixes all remaining tests which were muted because of it.
2023-11-09 09:13:28 +00:00
Dmitriy Novozhilov 420fbad73d [FIR2IR] Properly insert implicit casts to extension receiver in case of intersection smartcast type
^KT-62863 Fixed
2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 50106c740c K2: reproduce situation from KT-62863 2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 168b3416ea FIR2IR: avoid redundant implicit cast creation
Related to KT-62544
2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 1ef0f9e944 K2: reproduce strange "smartcast aside" behavior related to KT-62544 fix 2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 3cb9396b20 K2: prefer derived class sources for callable copies (e.g. fake overrides) 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 4b2a122f80 FIR2IR: make delegate field/accessors sources closer to PSI2IR
#KT-59864 Fixed
2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 47fec1a113 K2: use similar sources for if branches (PSI/LT)
Related to KT-59584
2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 21b4ce050c K2: add source range test to ensure #KT-59584 Fixed 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 920b0bfe63 FIR2IR: use SYNTHETIC_OFFSET for data class generated members 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh a9894b1842 K2: use derived class sources for callable copies if base callables have no sources
Related to KT-60155
2023-10-24 17:08:40 +00:00
Vladimir Sukharev 9b9ddb760a [FIR2IR] Coerce last operator in a loop to Unit
One of many fixes for https://youtrack.jetbrains.com/issue/KT-59781/K2-investigate-implicit-cast-generation-in-fir2ir-vs-psi2ir

Merge-request: KT-MR-12629
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-19 09:53:46 +00:00
Dmitriy Novozhilov 9366847e96 [FIR2IR] Properly approximate intersection types during fir2ir conversion
^KT-62544 Fixed
2023-10-18 13:02:11 +00:00
Mikhail Glukhikh 4ed7504d87 FIR deserializer: apply attributes on type parameter-based types
#KT-62578 Fixed
2023-10-18 10:30:31 +00:00
Dmitriy Novozhilov c3f3a4192c [FIR] Check supertypes hierarchy for java classes during creation of synhtetic properies
^KT-62394 Fixed
2023-10-17 12:46:28 +00:00
Dmitriy Novozhilov 61ec143b74 [FIR] Don't generate delegated members for java methods with default implementation
^KT-62334 Fixed
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 3d6ec0ec75 [FIR2IR] Automatically store IR declaration in its parent upon creation
Previously, creating a declaration with Fir2IrCallableDeclarationsGenerator/
  Fir2IrClassifiersGenerator didn't guarantee that this declaration will
  be actually added to the list of parent class/file declarations, which
  lead to situations when FIR2IR created some declarations in the air
  (mostly fake-overrides)
2023-10-17 12:46:27 +00:00
Ivan Kochurkin 498f2e534a [FIR] Don't enhance Int and String Java final static fields
It's effectively a breaking change (^KT-62558)

K2 assigns flexible type to all static fields (from Java) and, for example,
`String? becomes String unlike K1. It affects IR signature generating.
That's why signature dump is disabled for some tests.

^KT-57811 Fixed
^KT-61786 Fixed
2023-10-16 17:16:56 +00:00
Mikhail Glukhikh f501c3870d FIR2IR: make source range for implicit invoke call similar to PSI2IR 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh fe979cc822 K2: add source range test with extension lambda call
This test is equivalent to IDE debugger test
testNoParameterExtensionLambdaArgumentCallInInline3,
which changes behavior due to previous commit
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh b7b7dd1000 FIR2IR: make sources of qualified accesses & calls closer to PSI2IR
#KT-60111 Fixed
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 7c66a3dc65 Add source range test around multi-line calls 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 0fb4c9b4fe FIR2IR: generate specific sources for property accessors
Related to KT-60111
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh f38b8fd8cb K2: reproduce KT-60111 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh c4ec576a99 FIR2IR: make *Assign call origins closer to PSI2IR
#KT-60261 In Progress
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 13ae4abe52 FIR2IR: use elvis temporary variable name closer to PSI2IR
Related to KT-61983
2023-10-13 15:42:57 +00:00
Vladimir Sukharev bae8b283c7 [IR] Normalize temp var names in Kotlin-like dump
^KT-61983 Fixed
2023-10-11 07:49:35 +00:00
Mikhail Glukhikh a5a8f6736b Raw FIR: set source for setter parameter <set-?> access in delegated properties
Related to KT-59864
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh d321fa3fd9 K2: add partial reproduction of KT-59864 2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 162ba59d7f Raw FIR: set source for delegate field references
Related to KT-59864
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 9d3bf69212 Raw FIR/LT: use similar sources for delegated constructor calls
After this commit all IR source range tests behave in the same way
for FIR/PSI and FIR/LT, test data is now consistent
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 4ed6ece78b Test: IR source ranges: make line/column -1 for negative offsets
Before this commit, test data for 'synthesizedDataClassMembers' test
was different between PSI and LT, because we had SYNTHETIC_OFFSET = -2
for synthetic functions and NaiveSourceBasedFileEntryImpl calculated
line/column as 0 for LT. In this commit the dumper was edited to
count -1 as line -1 / column -1 independent of a file entry used.
2023-10-10 13:38:51 +00:00
Mikhail Glukhikh 1d631500f5 Test: add K2 version of IR source ranges test
After this commit there are three different versions of
IR source range tests: classic (K1), FIR/PSI (K2), FIR/LT (K2).
Since 5 tests behave differently for FIR/PSI and FIR/LT,
in this commit their test data was set to FIR/LT state,
so relevant 5 tests are failing for FIR/PSI right now.
They will be fixed in two subsequent commits

Related to KT-59864, KT-60111, KT-59584
2023-10-10 13:38:51 +00:00
Mikhail Glukhikh 072757cdde Test: convert IR source ranges test to the new infrastructure
Related to KT-59864, KT-60111, KT-59584
2023-10-10 13:38:51 +00:00
Vladimir Sukharev cd4c241fa3 [K/N] Run irText tests for K2/Native
^KT-58240
2023-10-04 18:20:05 +00:00
Mikhail Glukhikh 8bd792792f K2: consider backing fields of vars as smartcast unstable
#KT-61974 Fixed
2023-10-04 10:12:57 +00:00
Mikhail Glukhikh 8e577e101e K2: reproduce KT-61974 2023-10-04 10:12:57 +00:00
Pavel Kunyavskiy cd409abfd8 [Fir2IR] Fix dispatch receiver of fake override lazy function
After the fix, it's at least consistent with what generated
for other fake overrides.

^KT-61386
2023-09-21 13:09:32 +00:00
Vladimir Sukharev e9d4de658d [FIR2IR] Don't emit empty body of while/do_while loop
Merge-request: KT-MR-12283
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-20 10:06:00 +00:00
Vladimir Sukharev 9a2eff6487 [FIR2IR] Don't replace while loop and when branch body blocks with single expression. Skip some empty blocks.
https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression

Merge-request: KT-MR-12035
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-18 15:27:19 +00:00
Mikhail Glukhikh 53e4e2f6b1 K2: update return type properly for delegated members #KT-61443 Fixed 2023-09-15 15:21:10 +00:00
Mikhail Glukhikh 1b9197dd17 K2: reproduce KT-61443 2023-09-15 15:21:10 +00:00
Alexander Udalov 23ceb5d08a K2: do not build fake overrides for substituted package-private members
For example, `java.util.ArrayList.elementData` is a generic
package-private method. Not unwrapping intersection/substitution fake
overrides resulted in incorrect FQ names being compared in the package
visibility check, which led to the fake override always being created in
any subclass of ArrayList.

This change will help in testing IR fake overrides (KT-61360) because in
the current (temporary) mode, IrFakeOverrideRebuilder throws an
exception if initial fake overrides constructed by fir2ir differ from
the ones rebuilt by the IR -- and here they'll be different after fixing
KT-61366.
2023-09-15 14:09:29 +02:00
Dmitriy Novozhilov 36cb869ac2 [FIR2IR] Create fake one-time use properties for callable reference to synthetic properies
Previously fir2ir created real IR properties some getter and setter for
  such references, which lead to the situation that there might be a
  unbound fake override for synthetic property which wasn't stored in
  declaration storage (and code in FakeOverrideGenerator was a hack
  to cover this case)
In the same time K1 creates fake property for such cases, which is stored
  in IrPropertyReference along with original get... and set... functions
  as getter and setter of reference. And in this commit K2 does the same thing

^KT-61637
2023-09-15 11:51:57 +00:00