Commit Graph

117 Commits

Author SHA1 Message Date
Mikhail Glukhikh cf9bd44cf7 K2: add test to confirm KT-54139 now works properly 2023-11-14 13:33:18 +00:00
Mikhail Glukhikh 290adda8fc Calculate empty array literal types in FIR2IR instead of deserializer
This commit handles situations when some annotation in deserialized code
has an empty array literal argument [] or even non-empty [something].
Before this commit, we tried to guess a type of this array by "resolving"
the relevant annotation class and looking into the corresponding
parameter. Sometimes it can work, but also it can provoke recursive
resolve e.g. when the annotation class is a nested class in the same scope.
In this commit we changed the behavior in the following way:
- first, for non-empty array literals in deserialized code we just
take the array type from the corresponding array literal element
- second, for empty array literals we no more try to "guess" anything.
Instead we approximate array type as Array<Any>, and later at FIR2IR
stage we use the corresponding parameter type instead. At FIR2IR stage,
everything is already resolved and problems with recursions are no more
possible.

#KT-62598 Fixed
2023-10-31 12:30:29 +00:00
Mikhail Glukhikh 19a95f2fb4 K2: swap heuristics in AnnotationLoader (related to KT-62598)
Before this commit, we first tried to guess a type of array literal
in deserialized annotation (it's a strange heuristics which can
lead to SOE and maybe not needed at all, see KT-62598, KT-62929),
and then, if unsuccessful, took the type from the first literal element,
if any. Since the second heuristic is much more clear, safe, and
understandable, in this commit they were swapped.

This commit does not fix KT-62598 in general case,
but decreases a set of cases when it can occur to
empty array literals only.
See the commented line at the end of the added test.
2023-10-31 12:30:29 +00:00
Dmitrii Gridin 2eb761adae [LL FIR] generate resolution tests over codegen/box testData
Such testData can contain contract violations and other resolution
problems, so we should check them as well

^KT-62776
^KT-62832
^KT-62834
^KT-62836
2023-10-24 10:30:55 +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
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 3b6ad36af1 [Test] Update/unmute tests after previous fixes
It's hard to tell which exact commit fixed each test
2023-10-17 12:46:28 +00:00
Dmitriy Novozhilov 84f41b7d68 [FIR] Use lower bound of supertype in findClassRepresentation for intersection types 2023-10-17 12:46:28 +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 5857e6cc5d [Test] Mute some tests because of KT-62393 and KT-62394 2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 8bf4d3cbf7 [Test] Mute some tests because of KT-62334 2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 50425e82c5 [FIR2IR] Simplify Fir2IrDeclarationStorage.getIrPropertySymbol
For reasoning refer to the message of the previous commit
It is the same as for `getIrFunctionSymbol`

There is one failing test here, caused by KT-61941
The issue was here before this commit, but it was hidden
2023-10-17 12:46:27 +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
Kirill Rakhman 2e4d486131 [FIR] Use enhanced scope to guess array type in annotation loading
Otherwise, we return null for any java annotation because the
unenhanced scope doesn't contain any properties.

#KT-61856 Fixed
2023-09-20 08:02:37 +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
Alexander Udalov fda47c45ec IR: do not change overrides for lazy IR in FakeOverrideRebuilder
`FakeOverrideBuilder.provideFakeOverrides` recursively changes overrides
for all superclasses in the hierarchy, including lazy IR, which is a lot
of extra work.

Also it leads to some tests failing in the IR fake override builder mode
because it changes correct fake overrides of Java classes to incorrect
ones. Those tests are unmuted but it doesn't mean they are fixed -- most
likely we'll generate fake overrides via IR for lazy IR too, at which
point they'll start to fail again.
2023-09-15 12:55:33 +00:00
Alexander Udalov 21d56d04d6 Tests: reclassify some failures in fake override rebuilder tests
See issues for more information: KT-61751, KT-61804, KT-61805, KT-61370.
2023-09-13 15:01:52 +02:00
Kirill Rakhman 9a2307ad44 [FIR] Fix expression types in java annotations
#KT-61518 Fixed
2023-09-08 07:40:30 +00:00
Pavel Kunyavskiy 91e96e9f31 [Fir2Ir] Introduce testing with IrFakeOverrideBuilder
^KT-61514
2023-08-31 13:12:15 +00:00
Mikhail Glukhikh 289dafa331 FIR2IR: don't apply SAM conversion for type parameter based types
#KT-58893 Fixed
#KT-58884 Fixed
2023-08-22 15:13:17 +00:00
Mikhail Glukhikh 2ff075c961 FIR2IR: use ELVIS origin only on wrapping blocks #KT-60250 Fixed 2023-08-22 11:20:19 +00:00
Mikhail Glukhikh b06188180e FIR2IR: don't generate 'none' type arguments for Java field references
#KT-60254 Fixed
2023-08-22 11:20:19 +00:00
Kirill Rakhman 79fe48ab5b [FIR2IR] Support error qualifier in case of error suppression
#KT-60536 Fixed
2023-08-18 14:28:56 +00:00
Vladimir Sukharev 5b825282a4 [IR] Render type abbreviations by default, and not render in irText tests
^KT-60248


Merge-request: KT-MR-11510
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-08-14 15:08:45 +00:00
Nikolay Lunyak 9850987415 [FIR] Fix mutant extension function types
Consider the following example from
`extensionLambdasAndArrow.kt`:

```
val x4: String.() -> String = if (true) {
    { str: String -> "this" }
} else {
    { str: String -> "this" }
}
```

Because of
`coerceFirstParameterToExtensionReceiver`
the given lambdas must be of the type
`String.() -> String`, but because of a bug
they are `String.(String) -> String`. At the
same time, during inference their expected
types are, indeed, calculated correctly as
`String.() -> String`.

^KT-59394 Declined
(no more compiler crashes, #potential-feature)
2023-08-04 11:20:39 +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
Sergej Jaskiewicz 5e63f7627f [klib] Test signature descriptions in irText tests
KT-59486
2023-07-14 20:26:45 +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
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
Mikhail Glukhikh 0d8f3a6026 K2: generate Java synthetics for Kotlin get/sets w/out type parameters
This commit is a follow-up to d8a20f19 and
provides additional K1 compatibility.
#KT-59550 Fixed
2023-06-23 16:44:50 +02:00
Mikhail Glukhikh fcfee9384a K2: reproduce KT-59550 2023-06-23 16:44:49 +02:00
Alexander Udalov 1588b07472 Tests: unmute light analysis tests passing with JVM_IR 2023-06-22 17:10:51 +02:00
Alexander Udalov cab53361f3 Use JVM IR backend in light analysis mode tests
Add some more filters on private/synthetic stuff (which doesn't matter
in practice) to make full and light analysis mode dumps as similar as
possible, so that all existing tests will pass for JVM IR. Unmute some
tests which were failing with the old JVM backend.

Tests on repeatable annotations are muted because in full analysis,
annotations are wrapped into the container (e.g. `@A(1) @A(2)` ->
`@A$Container(A(1), A(2))`), but they are no in the light analysis mode.
So there's always going to be a difference for these tests between full
and light analysis, unless we're going to change behavior of kapt, which
would be a kind of a breaking change.

 #KT-58497 Fixed
2023-06-22 17:10:51 +02: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
Dmitriy Novozhilov 2581139b82 [FIR2IR] Expand typealiases before inserting implicit casts
^KT-59461 Fixed
^KT-59464
2023-06-21 07:34:09 +00:00
Mikhail Glukhikh 8983e3a218 K2: correctly set importedFromObjectOrStaticData for fields
#KT-59140 Fixed
#KT-58980 Fixed
2023-06-20 14:13:21 +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
Mikhail Glukhikh 668157eb41 FirClassAnySynthesizedMemberScope.kt: make it a declared member scope
Related to KT-54844, KT-58926
2023-06-14 07:09:16 +00:00
Denis.Zharkov c474c54903 FIR2IR: Fix IAE for case of local override of a method with defaults
It was happening because for MyClass.foo we didn't set overriddenSymbols
properly because in ClassMemberGenerator.convertFunctionContent we
used incorrect containingFirClass that was pointing to anonymous class
instead of MyClass.

^KT-58902 Fixed
2023-06-08 08:04:03 +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 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
Kirill Rakhman cf2ef443f4 [FIR] Introduce a feature flag for context-sensitive enum resolution
The feature was previously enabled unconditionally in K2 which
triggered a bug when an enum has an entry with the same name as itself.

#KT-58897 Fixed
#KT-52774
2023-05-30 11:59:56 +00:00
Vladimir Sukharev a534708900 [K2/N] Use FqName to mangle invisible class-like symbol in fake override
^KT-57484

Merge-request: KT-MR-10263
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-05-24 07:34:11 +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
Mikhail Glukhikh 08c22c388c K2: change logic of result type search in ILT case
Related to KT-57487, KT-57703
2023-04-27 12:19:38 +00:00
Mikhail Glukhikh 27c4a7b7ef FE: add new tests around unresolved integer literals
Related to KT-57487, KT-57703
2023-04-27 12:19:38 +00:00
Mikhail Glukhikh 1c56a71b14 FirClassSubstitutionScope: don't recreate constructor type parameters w/out need
#KT-58008 Fixed
2023-04-25 16:42:59 +00:00
Mikhail Glukhikh 5daafd5ed5 FirNestedClassifierScope: don't give empty map substitutor to a processor
Optimization related to KT-58008 (hides the issue in some cases)
2023-04-25 16:42:59 +00:00
Mikhail Glukhikh 4172ce1018 K2: reproduce KT-58008 2023-04-25 16:42:59 +00:00