Commit Graph

950 Commits

Author SHA1 Message Date
Stanislav Ruban ec995fc847 [tests] Regenerate configurations for box-tests 2023-11-23 09:34:15 +00:00
Kirill Rakhman 865b8a4175 [FIR] Create special hidden override for Java signature clash due to rename
This fixes CharBuffer.get resolving to CharBuffer.charAt

#KT-61282 Fixed
2023-11-22 08:46:17 +00:00
Alexander Udalov 471f25abfc IR: support buildSimpleType for IrCapturedType
To make it possible to change nullability of IrCapturedType and change
its annotations, which is happening when determining overridability of
functions via IR.

 #KT-63437 Fixed
2023-11-21 20:02:13 +00:00
Ivan Kylchik 8715bd6189 [IR] Don't evaluate expressions in inner class of an annotation 2023-11-21 09:48:58 +00:00
Ivan Kylchik 3fa82c7bb1 [K2] Properly evaluate complex boolean constants
Some boolean expressions could be transformed into `IrWhen`
node. To understand that this node is actually
a boolean expression, we need to analyze its origin.

#KT-62683
2023-11-21 09:48:57 +00:00
Dmitrii Gridin b3b184f00d [FIR] add more tests diagnostic tests on data and delegated classes
^KT-63522
^KT-63512
^KT-63042
2023-11-21 08:11:20 +00:00
Mikhail Glukhikh a139965231 K2: reproduce KT-63164 2023-11-17 20:29:58 +00:00
Artem Kobzar e64068cf82 [K/JS, K/Wasm, K/Native] Process anonymous initializers inside classes as a part of their primary constructors ^KT-61929 Fixed 2023-11-17 13:04:34 +00:00
Stanislav Ruban 6edc742934 [tests] builder inference test-set: regenerate diagnostic & codegen tests 2023-11-17 07:02:15 +00:00
Vladimir Sukharev c38a0e10af [K/N] Implement a concept of conditional ignore of K/N blackbox tests
^KT-59288 Fixed
2023-11-15 19:03:07 +00:00
Mikhail Glukhikh 4d49bdb8ca K2: add a black box test to confirm KT-53718 now works properly (JVM IR only)
Related to: KT-57584, KT-58110
2023-11-15 09:33:05 +00:00
Mikhail Glukhikh 4b1368409d K2: add a black box test to confirm KT-55705 now works properly 2023-11-15 09:33:05 +00:00
Mikhail Glukhikh f2ef41dbbd K2: add a black box test for KT-58874 to confirm work also in runtime 2023-11-15 09:33:03 +00:00
Mikhail Glukhikh cf9bd44cf7 K2: add test to confirm KT-54139 now works properly 2023-11-14 13:33:18 +00:00
Alexander Udalov 54705e5afc IR: copy context receiver parameters count in FakeOverrideCopier
#KT-63430 Fixed
2023-11-13 21:36:22 +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
Kirill Rakhman 7da271bab8 [FIR] Serialize context receivers using the correct local serializer
This leads to type ref referring to generic type variables being
serialized correctly.
When the type variable is declared on the member itself, it's written to
typeParameterName,
otherwise it's written to typeParameter. This is required for
deserialization to work correctly.

#KT-63227 Fixed
2023-11-08 10:26:34 +00:00
Dmitriy Novozhilov d08567c2c7 [FIR2IR] Approximate extension receiver type after type argument substitution
Frontend may leak captured types into type arguments, so they should be
  approximated before using them in fir2ir cast inserter to determine
 a specific type from smartcast

^KT-62863 Fixed
2023-11-07 12:37:19 +00:00
Alexander Udalov d2ebaf4e6c Minor, add regression test for K2 delegation issue
#KT-62120
2023-11-07 12:30:45 +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
Vladimir Sukharev e43b634122 [K/N] Migrate most simple filecheck tests to new infra
^KT-62157


Merge-request: KT-MR-12376
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-23 10:07:28 +00:00
Ivan Kylchik a45bb8d92b [FIR] Find the correct FIR file in Java finder for file with JvmName
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 8c7c44f9f5 [FIR] Fix evaluation of Java properties for Char and String types
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 7935b2bdb1 [FIR] Allow to evaluate top level const properties in Java world
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 886ef1a4b4 [FIR] Support the simple case of java field interpretation
#KT-57802
2023-10-20 16:33:20 +00:00
Ilya Chernikov 268d058bbb Implement missing invoke resolution branch with context receivers
#KT-61937 fixed
Note: the current implementation only resolves for a single receiver
in each group. See KT-62712 and KT-62709 for the followup.
2023-10-19 19:39:31 +00:00
Evgeniy.Zhelenskiy b89d8a65a1 [Reflection] Fix parsing JVM function descriptors
#KT-60708
2023-10-19 19:09:31 +00:00
Dmitriy Novozhilov 940567978d [FIR2IR] Treat delegated functions as fake-overrides
Delegated callables in FIR are session-dependant (as fake-overrides),
  so it's incorrect to use their FIR as a key for declaration storage.
  Pair of original function and owner lookup tag should be used instead

^KT-62671 Fixed
2023-10-19 13:15:48 +00:00
Pavel Kunyavskiy da488f513f [IR] Fix file modules after actualization
When files from different IrModules are merged in IrActualizer
their IrModule link was not updated. This led to assuming them
as different modules, and incorrect internal visibility handling.

^KT-62623
2023-10-19 10:16:45 +00:00
Dmitriy Novozhilov 847442d547 [Test] Add regression test for KT-60876 2023-10-19 06:58:14 +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 84f41b7d68 [FIR] Use lower bound of supertype in findClassRepresentation for intersection types 2023-10-17 12:46:28 +00:00
Alexander Udalov 2788dcb5ff K2: resolve remove(Int) clash in JavaOverrideChecker
In Kotlin subclasses of `MutableCollection<Int>`, the method
`remove(Int)` has its argument boxed, so that it wouldn't clash with the
method from `java.util.List`. So `JavaOverrideChecker` should understand
that a Java method `boolean remove(java.lang.Integer)` overrides it,
otherwise platform declaration clash was reported.

The code is adapted from `forceSingleValueParameterBoxing` in K1's
`methodSignatureMapping.kt`.

The test has been moved and adapted from diagnostic to codegen box
tests, to check correct backend execution + runtime.

 #KT-62316 Fixed
2023-10-16 11:26:58 +00:00
Ilmir Usmanov 197f0112b4 Minor. Add regression test for KT-62127
#KT-62127 Fixed
2023-10-09 12:43:27 +00:00
Evgeniy.Zhelenskiy 291d52820c [Reflection] Use reference equality to determine that a callable reference is bound
It helps to avoid problems when receiver object implements structural equals violating the equality contract

#KT-60709
2023-10-05 22:16:39 +00:00
Igor Yakovlev 758484a01f [Wasm] Fix generation optimised when expression with Nothing type
Fixed #KT-62147
2023-09-23 10:18:30 +02:00
Ilya Chernikov 141333bdcd K2: Update extension receiver after checking in CheckExtensionReceiver
fixes receiver selection when the candidate has more that one possible
extension receiver
#KT-62129 fixed
2023-09-22 11:33:46 +00:00
Ivan Kochurkin 3cd4f7c3aa [FIR] Consider @PlatformDependent annotation everywhere (including JS and Native)
^KT-57858 Fixed

Remove FirEmptyOverridesBackwardCompatibilityHelper since it's not used anymore

Remove overridesMemberWithPlatformDependent.kt test file since it becomes redundant
2023-09-20 17:12:52 +00:00
Kirill Rakhman 5b4409e34c [FIR] Store abbreviated type in deserialized declarations as attribute
#KT-58542 Fixed
2023-09-20 09:31:29 +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
Ilmir Usmanov f7a2da8f82 Minor. Add regression test for KT-41997
#KT-41997 Fixed
2023-09-19 20:11:57 +00:00
Alexander Udalov 5cae87b263 K2: add package FQ name to ClassId of anonymous objects
This is needed because in order to figure out which declarations are
visible from anonymous objects in terms of overridability (see
`FirVisibilityChecker.isVisibleForOverriding`), we need to get the
package name of that anonymous object, because there's package-private
visibility on JVM.

 #KT-62017 Fixed
2023-09-19 09:32:55 +00:00
Dmitriy Novozhilov 97cf240450 [FIR] Reuse enhancement storage during creation of synthetic properies
^KT-61972 Fixed
2023-09-18 15:09:07 +00:00
Dmitriy Novozhilov 9a6c6a40a9 [FIR2IR] Allow symbolTable cache lookups for generated Any methods
^KT-61972 Fixed
2023-09-18 09:16:15 +00:00
Dmitriy Novozhilov 85c2226335 [FIR2IR] Allow symbolTable cache lookups for mapped JVM declarations 2023-09-15 11:51:58 +00:00
Igor Chevdar 1df93e1611 [box-tests] Added a reproducer for #KT-61924 2023-09-15 09:26:54 +00:00
Anastasia.Nekrasova eab6e9bb36 Added tests for all code samples from KT-60523, except 2.3.
Test for 2.3 sample must be added in the context of KT-61792.
2023-09-12 07:03:20 +00:00
Kirill Rakhman 9a2307ad44 [FIR] Fix expression types in java annotations
#KT-61518 Fixed
2023-09-08 07:40:30 +00:00