Commit Graph

192 Commits

Author SHA1 Message Date
vladislav.grechko d753a22fc6 [FIR] Handle expect declarations in JVM backend
1. Do not generate bytecode for expect declarations

2. Serialize @OptionalExpectation annotations into .kotlin_module file

^KT-62931: Fixed
2024-02-19 18:17:37 +00:00
vladislav.grechko b74501ee93 Compare module metadata in JVM ABI consistency tests 2024-02-19 18:17:37 +00:00
Pavel Kunyavskiy e6f4d6e6fa [Tests] Use stable order for ir/kotlinLike dumps
^KT-65406
2024-02-16 10:19:38 +00:00
Mikhail Glukhikh 8ee54a9045 K2: add a test to ensure #KT-63756 Fixed 2024-02-07 20:56:04 +00:00
Alexander Korepanov f5d0c22736 [K2 JS] Unmute and link to issue some JS K2 tests 2024-01-18 15:48:55 +00:00
Pavel Kunyavskiy 2bf5a58a30 [Fir2Ir] Don't use FirSyntheticProperty as the cache key
^KT-64871
2024-01-16 19:14:52 +00:00
Pavel Kunyavskiy 882dc18e0e [IrActualizer] Don't copy attributeOwnerId in actualizer
In before, actualizer was copying attributeOwnerId to new
nodes. This leads to attributeOwnerId linked to non-actualized
node. It's unclear what it leads to, so we just stop doing that.

In particular, if attributeOwnerId references another node,
this information would be lost.

^KT-64895
2024-01-15 14:10:35 +00:00
Pavel Kunyavskiy 9374cacdd6 [IrActualizer] Don't actualize expect types
This was never semantically correct, but was not important
before KT-63644, as they were immediately dropped after that anyway.

After KT-63644, they were used to compute fake overrides inside them,
which were later matched against actual class, which can
produce false-positive matching errors.

^KT-64835
2024-01-09 17:53:06 +00:00
Pavel Kunyavskiy c6e32571d6 [FakeOverrideBuilder] Workaround KT-64743
Because of KT-64743 there is unexpanded type-alias in a place we don't
expect it to occur. To workaround this, we just expand typialiases in
one more place.

^KT-64743
2024-01-08 07:46:07 +00:00
Nikita Nazarov 438b2dd164 [K2, MPP] Actualize value class representation
^KT-63638 fixed
2024-01-03 16:39:56 +00:00
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Dmitrii Gridin 6ca6221be9 [LL FIR] LLFirStatusLazyResolver: more conservative optimization for actual classes
We cannot skip resolution in the case of type actualization as we cannot
guaranty that there are no any classes in super types which can be
actualized in the current context

^KT-62832 Fixed
^KT-63547
2023-12-21 09:34:39 +00:00
Pavel Kunyavskiy c485382e80 [FIR2IR] Rework actualization pipeline
There are a lot of restrictions between different parts of the pipeline.

1. Fake overrides can't be built before classes are actualized
2. Constants can't be evaluated before callables are actualized
3. Callables can't be actulaized before fake overrides are built
4. Checkers can't run before constants are evaluated

This commit reorders things to make all these restrictions happy.

^KT-63644
2023-12-15 15:38:10 +00:00
Dmitriy Novozhilov f4e3203cd8 [FIR] Unregister java element finders from previous sessions
The problem here is that for common session we register `FirJavaElementFinder`
  which provides light classes based on expect classes. And then
  at the start of analysis of jvm module we register one another
  `FirJavaElementFinder`, which sees actual classes and uses them to
  build light classes

But, because class ids of expect and actual class pair are the same and
  element finders are ordered by creation order, when java resolve tries
  to resolve some class, it founds light class based on expect class,
  even if we are already in platform session

To fix this problem, it was decided to unregister all previous element
  finders on creation of each new session, so old finders won't interfere
  with analysis

^KT-63612 Fixed
^KT-64296
2023-12-14 09:51:15 +00:00
Dmitriy Novozhilov 56a48b1148 [Test] Add missing WITH_STDLIB directive to test
This particular test references kotlin.reflect.KProperty1 both in
  common and platform sourceset. And if there is no stdlib in dependecies
  it resolves to KProperty1 from builstins, which is expect (see KT-64061),
  which leads to broken expectations that after IR actualization there
  are no referenced expect classes
2023-12-14 08:32:58 +00:00
Pavel Kunyavskiy 8e047e6d8a [FIR2IR] Make all source sets friends for IrFakeOverrideBuilder
^KT-63644
2023-12-14 08:32:58 +00:00
Dmitriy Novozhilov 34bf32866b [Test] Remove redundant K1 ignore directives from K2 MPP box tests
Corresponding tests for K1 are no longer generated, so there is no need
  to ignore them anymore
2023-12-13 16:47:42 +00:00
Dmitriy Novozhilov 7d685522ce [IR] Fix calculation of receiver type for properies in expect/actual context
^KT-62926 Fixed
2023-12-08 13:28:27 +00:00
Dmitriy Novozhilov 58678c09e8 [FIR2IR] Include generated IR fields into Fir2IrCommonMemberStorage
In case of HMPP structure with common JVM module (e.g. shared between
  JVM and Android) one can reference the same field from java code,
  so it should be shared between fir2ir sessions

^KT-63574 Fixed
2023-12-08 11:16:03 +00:00
Nikita Bobko 8c0cf7d0bc [FIR] Fix disappeared ACTUAL_MISSING
^KT-59887 Fixed

Review: https://jetbrains.team/p/kt/reviews/13244
2023-12-04 13:08:23 +00:00
Artem Kobzar 55d41db2ce [K/JS] Include jsFirEs6Test into jsFirCompilerTest tests 2023-11-24 22:09:43 +00:00
Nikita Bobko 5aa0475aa7 [KMP] Fix incorrect transitiveSuperclassActualization_java.kt test
Review: https://jetbrains.team/p/kt/reviews/13094

I made the test to look like transitiveSuperclassActualization.kt

`actual typealias A = A_J` is incorrect because `A` isn't expect

If I kept the test "as it's", then it would become red once KT-63550 is
fixed
2023-11-24 18:02:47 +00:00
Dmitriy Novozhilov c9ff0c41fc [FIR2IR] Generate IR for f/o of common classes generated during platform conversion
This change fixes tests which were muted in one of previous commits
2023-11-20 13:36:27 +00:00
Dmitriy Novozhilov bb892f10f8 [Test] Mute tests with expect supertypes
The problem: someone should generate IR for f/o in common classes appeared
  after IR actualization

Those tests will be fixed in the following commits
2023-11-20 13:36:27 +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
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