Commit Graph

167 Commits

Author SHA1 Message Date
Nikita Bobko 0fc7ea6004 [IR] Workaround expectActualOverloads test failure
Under the hood this test was broken before my KT-62590 changes. KT-62926
demonstrates it
2023-11-06 14:41:27 +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
Nikita Bobko 0f82baf841 [FE 1.0] 2/2 Drop AllowDifferentMembersInActual from compiler and testData
The annotation was dropped in the previous commit
2023-10-20 14:37:09 +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 3f89f03b54 [IR Actualizer] Set overridden symbols for property accessors 2023-10-17 12:46:28 +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
Dmitriy Novozhilov 34d0f3dbc2 [FIR2IR] Correctly calculate ir origin for f/o callables in declarations generator
This change uncovers one problem, which causes some MPP tests to fail
This problem will be fixed in further commits

Uncovers KT-62535
2023-10-17 12:46:27 +00:00
Roman Efremov a05b37c652 [K2] Support reporting of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS
...on regular classes and enum entries.

^KT-59979 Fixed
2023-10-12 13:01:40 +00:00
Brian Norman 365ce2a6a5 [FIR] Implement checker for missing dependency supertypes
#KT-60778 Fixed
2023-10-04 21:57:43 +00:00
Dmitriy Dolovov 249106b23f [KLIB] Drop obsolete tests on serialization of expect IR declarations
These tests are muted for all KLIB-oriented platforms for a long time
and are no more relevant since the removal of ExpectActualTable.

^KT-61136
2023-09-20 07:54:36 +00:00
Ilmir Usmanov f7a2da8f82 Minor. Add regression test for KT-41997
#KT-41997 Fixed
2023-09-19 20:11:57 +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
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 ac102dedac [IR Actualizer] Fix fake-override generation in actual A -> common B -> actual C hierarchy
...  where C defines a member x and A overrides the member x

#KT-61166 Fixed
2023-08-31 07:52:02 +00:00
Ivan Kochurkin c8c25d8b98 [FIR] Fix resolving of overload function with expect and common candidates
^KT-58896 Fixed
2023-08-30 15:58:59 +00:00
Roman Efremov 8aa3ccd342 [FIR] Store matched actual class members inside FIR attribute
Currently, there is only attribute `ExpectForActualAttributeKey`
where mapping is stored only for source declarations with `actual`
modifier. But we need mapping of all class members, including classes
which were actualized via `actual typealias` or fake override members.
This data will be needed for the annotation checker in subsequent
commits.

^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Nikita Bobko 25c082f02b K1: Implement a checker that disallows to have different member scopes for expect open and its actual
^KT-22841 Fixed
Review: https://jetbrains.team/p/kt/reviews/11603/timeline

The commit also introduces `@AllowDifferentMembersInActual` annotation in
stdlib which allows to suppress the diagnostic
2023-08-21 19:51:08 +00:00
Ivan Kochurkin 553114e245 [K2, MPP] Actualize annotation calls
^KT-57963 Fixed
2023-08-17 14:04:59 +00:00
Kirill Rakhman 6fba6a2e3c [FIR2IR] Don't add synthetic propertiy fake overrides to parent class
This fixes a KMP issue where IrActualizer would add duplicate
fake overrides because the parent class would have both the getter
and the synthetic property in its list of declarations.
Now, the synthetic property fake overrides are still generated and
cached in the Fir2IrDeclarationStorage, but not added to the class.

#KT-60854 Fixed
2023-08-17 07:34:04 +00:00
Ivan Kochurkin 8e8de513ee [FIR] Introduce OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE diagnostic
^KT-60892
2023-08-10 17:46:08 +00:00
Nikita Bobko d39755b578 [FE] Convert specific diagnostic for actual function with default arguments into a common incompatibility
^KT-59665 Fixed
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

It's better to have this logic in common place
(AbstractExpectActualCompatibilityChecker) to avoid missing compilation
errors in the future

This commit fixes:
1. Missing compilation error for actual function with default arguments
   for 'actual typealias' KT-59665
2. Missing compilation error for actual function with default arguments
   for actual fake-override KT-59665

Alternative solution for KT-59665 is to create a special checker.

"incompatibility" vs "special checker":

Arguments for common incompatibility:
- What if we had a rule that expect and actual default params must
  match? If so then it certainly would be an incompatibility.
- Technically, we do the matching of expect and actual params (because
  we allow default params in common ancestors of expect and actual
  declarations).
- It's hard to check that the actual definition doesn't use default
  params because `ExpectedActualResolver.findActualForExpected` filters
  out fake-overrides and doesn't return them. It's not clear logic for
  me, that I'm afraid to touch.
  implicitActualFakeOverride_AbstractMap.kt test breaks if you drop this
  weird logic
- WEAK incompatibilities can be considered as "checkers". So it doesn't
  matter how it's implemented, as a "incompatibility" or a "checker"

Arguments against common incompatibility:
- Although we match expect and actual declarations to allow default
  params in common ancestors of expect and actual declarations, it's
  still can be considered that we check that the actual declaration
  doesn't have default params. And it doesn't feel right that we check
  correctness of the actual declaration in expect-actual matcher.
- ~~It may change the rules of expect actual matching~~ (It's not true,
  because ActualFunctionWithDefaultParameters is declared as WEAK
  incompatibility)
2023-08-10 15:46:46 +00:00
Dmitriy Novozhilov 4e3dbcada3 [FIR2IR] Always look for already generated fake overrides before creating them
This change covers the case where some f/o was generated in common module
  and it is referenced in platform code. But signature of this f/o may be
  different in different modules because of e.g. actualization of value
  parameters with actual typealias

^KT-60850 Fixed
2023-08-09 09:40:23 +00:00
marat.akhin ae4fab8483 [KMP] Allow matching expect ctorless final classes to objects
both directly and via typealias.

This is a possible fix to KT-59747
2023-08-08 23:18:35 +00:00
Igor Yakovlev a13e16cb77 [Wasm] Unmute passing tests 2023-08-08 18:10:20 +02:00
Dmitriy Novozhilov cc2bc5e8b1 [FIR2IR] Reuse IR fake overrides for FIR fake overrides for all MPP modules
^KT-58229 Fixed
2023-08-03 10:02:57 +00:00
Artem Kobzar 08bd0d6ce1 [K/JS] Generate tests for K2 + ES-classes compilation 2023-08-01 09:16:20 +00:00
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
Mikhail Glukhikh c350280e64 K2: fix enhancement building for Java methods with type parameters
Before this commit, we copied each type parameter during method
enhancement, while not copying the symbol. This led to symbol clashes
in MPP scenarios and various other problems.

Now we create a fully-functional type parameter copy in enhancement
and perform a substitution of old type parameters with new ones
in receiver type, value parameter types, return type,
and type parameter upper bounds.

#KT-59766 Fixed
#KT-59738 Fixed
2023-07-14 16:17:49 +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
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
Svyatoslav Kuzmich a3e2d2804c [Wasm] Update testData after adding K2 and new test infra support.
- Actualize muted K2 tests
- Actualize muted K1 tests with module systems because legacy Wasm test
  infra had no respect for "// MODULE: ..." test directives
2023-06-25 10:20:40 +02: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
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
Vladimir Sukharev 217550d10e [K/N] Enable passed MPP K1/N tests
^KT-59057

Merge-request: KT-MR-10526
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-16 07:45:01 +00:00
Dmitriy Novozhilov c64310a833 [Test] Update tests according to KT-58544
There are some cases for fake-override actualization which become
  prohibited in the new expect/actual model, so few tests start to fail,
  despite the fact that they are checking entirely different things
2023-06-10 07:33:29 +00:00
Dmitriy Novozhilov ba41e8ec38 [IR] Use common expect/actual matching algorithm in IR actualizer
^KT-58578 Fixed
2023-06-10 07:33:29 +00:00
Pavel Kunyavskiy 733ca5a358 [K/N] Unmute tests already working on native
Also, add issue references for some tests
2023-06-06 14:29:21 +00:00
Ivan Kochurkin 432c781ff7 [K2, MPP] Fix actualization of fake overrides (fixes a set of bugs in coroutines / ktor)
Split MissingFakeOverridesAdder on FakeOverridesActualizer and ActualFakeOverridesAdder

^KT-57984 Fixed
^KT-58003 Fixed
^KT-58124 Fixed
^KT-57833 Fixed
^KT-58153 Fixed
2023-05-24 14:54:51 +00:00
Vladimir Sukharev fde8909e6f [K2/N] IntegerLiteralType coercion only to unsigned integer types
^KT-57484 Fixed

Merge-request: KT-MR-10270
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-05-24 07:56:14 +00:00
Vladimir Sukharev bbe1e708f9 [K2/N] Rewrite mpp tests from old native infra to new
^KT-58543

Merge-request: KT-MR-10065
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-05-16 08:41:39 +00:00
Pavel Punegov 3d65907b8c [K/N][test] Ignore test in Native K1
This test doesn't work with K1 in Native

Merge-request: KT-MR-9934
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2023-05-04 08:50:42 +00:00
Dmitriy Novozhilov e9c8be3b64 [FIR] Don't generated fake-overrides for private declarations of actualized super classes
^KT-58252 Fixed
2023-05-02 10:24:53 +00:00
Dmitriy Novozhilov 15dfe6c750 [FIR2IR] Use signature instead of FIR as a key for fake-override storage
This is needed to correctly handle the case, when we have the same java
  class in common and platform module. In this scenario we have two
  different classes on frontend (because symbol providers are not shared)
  and completely different enhanced function in scopes of those classes,
  but exactly one IrClass for those classes, which is cached during
  conversion of common module together with cache of its fake overrides.
  So using FirDeclaration as a key to FO cache leads to the problem, when
  we can not find cached value for platform module, because it has different
  fir declarations for the same real decalration

^KT-58030 Fixed
2023-04-28 13:08:19 +00:00
Ivan Kochurkin b72dcf8b37 [K2, MPP] Fix actualization of nullability-based overloads
^KT-58043 Fixed
2023-04-20 17:22:45 +00:00
Svyatoslav Scherbina 54c07f5ebb Ignore K2 expectPropertyAsDefaultArgument.kt test for K1/Native
It is not supposed to work with K1 on Native due to test infrastructure
limitations, and actually fails in one of the compilation modes in
nightly tests.
2023-04-18 10:43:51 +00:00
Ivan Kochurkin beaeb405d2 [K2, MPP] Build expect-actual map for type parameters from functions
^KT-57181 Fixed
2023-04-17 19:55:35 +00:00
Ivan Kochurkin b7bb9c317f [K2, MPP] Introduce FunctionDefaultParametersActualizerVisitor and use it in FunctionDefaultParametersActualizer
^KT-57263 Fixed
2023-04-17 19:55:34 +00:00
Ivan Kochurkin 9a09565cf6 [K2, MPP] Handle overloaded properties
^KT-57532 Fixed
2023-04-12 20:43:57 +00:00