Commit Graph

217 Commits

Author SHA1 Message Date
Kirill Rakhman c5da2b7433 [FIR] Rename FirElementSerializer.containingDeclaration to currentDeclaration for clarity 2023-11-08 10:26:34 +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
Ilya Chernikov 31f9e9e7a8 K2 Scripting: implement basic metadata serialization support
#KT-62305 fixed
NB: kotlin reflection do not see script class constructor after
this change, and it's ok, since the fact that the script is compiled
into a class is an implementation detail.
If needed, java reflection could be used to access the constructor.
2023-11-03 21:54:23 +00:00
Mikhail Glukhikh d42ae35624 K2: support DELEGATION member kind for properties #KT-62581 Fixed 2023-10-25 20:19:39 +00:00
Johan Bay fb1d2278a0 [klibs] header klibs should keep private interfaces
^KT-62213 Fixed
2023-10-23 11:48:05 +00:00
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Kirill Rakhman a4fff7c7c0 [FIR] Inline FirExpression.coneTypeUnsafe
#KT-61367
2023-09-14 10:03:03 +00:00
Dmitriy Novozhilov f203681ffa [FIR] Make extensionReceiver and dispatchReceiver nullable
Get rid of FirNoReceiverExpression

^KT-59650 Fixed
2023-09-06 09:25:22 +00:00
Johan Bay 0a612e4268 [klib] Add an option to write out header klibs
The header klib is supposed to only contain the public abi of the module
similar to jvm-abi-gen. It is intended to be used as a dependency for other
klib compilations instead of the full klib for compilation avoidance.

^KT-60807
2023-08-29 13:25:07 +00:00
Kirill Rakhman 7fde5af7f8 [FIR] Rename FirExpression.coneType to resolvedType 2023-08-24 07:54:57 +00:00
Kirill Rakhman 9ec814b7ad [FIR] Replace FirExpression.typeRef.coneType (and variants) with FirExpression.coneType
#KT-59855
2023-08-24 07:54:56 +00:00
Alexander Udalov e3efff7a33 K2: remove dependencies of fir-serialization on JVM modules 2023-08-02 14:50:10 +00:00
Kirill Rakhman 38a54549ff [FIR] Fix serialization of empty varargs in annotations in KLIBs
#KT-59249 Fixed
2023-08-01 15:31:18 +00:00
Alexander Udalov 9c03dcd230 Do not write version requirements for suspend functions
Previous attempt was at 6807ed6642, but it was reverted in 7771e5914d
(see that commit for the explanation). Now it should be fine to remove
these version requirements.

No issue reported because it's mostly not a user-visible change. The
main effect is that it reduces differences in metadata between K1 and
K2, namely it fixes the ValueClass.kt kotlinp test.
2023-07-31 13:05:29 +00:00
Alexander Udalov 06e370b012 K2: use Any? as last argument when serializing suspend types
K1 uses `Any?` in `transformSuspendFunctionToRuntimeFunctionType`, so
use `Any?` in K2 too.

This type is not used for anything, it's just an artifact of how suspend
types are represented in metadata. It's removed during deserialization
(see `TypeDeserializer.createSuspendFunctionType` or
`FirTypeDeserializer.createSuspendFunctionType`). So it's not a
user-visible change. The only effect is that it reduces differences in
metadata between K1 and K2, namely in the test
`libraries/tools/kotlinp/testData/ValueClass.kt`.
2023-07-31 13:05:29 +00:00
Alexander Udalov afd35accd8 Do not write version requirements for InlineClasses
Language feature InlineClasses is enabled since 1.3. The current lowest
supported language version is 1.4, so any compiler that can read
binaries produced by the current compiler also supports inline classes,
which means that the version requirement is not needed anymore.

No issue reported because it's mostly not a user-visible change. The
main effect is that it reduces differences in metadata between K1 and
K2, because K2 never supported writing this version requirement properly
due to the TODO in `hasInlineClassTypesInSignature`.
2023-07-31 13:05:29 +00:00
Dmitriy Novozhilov 69a35970eb [FIR] Introduce different synthetic origins for FIR declarations
This is needed to be able to precisely distinguish different synthetic
  declarations (like fields for delegates and functions for data classes)
  in fir2ir
2023-07-28 13:59:38 +00:00
Ivan Kylchik 7e5e2fe1e4 [FIR] Drop dependency on ir.serialization from fir-serialization 2023-07-28 09:02:44 +00:00
Ivan Kochurkin 2eba7da5eb [FIR] Rename FirArrayOfCall to FirArrayLiteral 2023-07-27 17:53:44 +00:00
Mikhail Glukhikh cdd3f10e99 K2: make synthesized functions synthesized in protobuf
Related to KT-59171
2023-07-27 11:24:09 +00:00
Kirill Rakhman 47d0f3593a [FIR] Use SpecialNames.NO_NAME_PROVIDED everywhere 2023-07-27 08:06:19 +00:00
Pavel Mikhailovskii fd07f7f43c [FIR] KT-60427 Don't generate outerType attributes for non-inner classes in FirElementSerializer 2023-07-19 15:27:03 +00:00
Mikhail Glukhikh 00b4ae6ae9 K2: expand type before isSomeType checks properly
Related to KT-60229
2023-07-14 16:38:47 +00:00
Denis.Zharkov e98890cece K2: Remove a bunch of unused declarations 2023-07-11 13:12:22 +00:00
Denis.Zharkov f7e54fa76a K2: Simplify FirToConstantValueTransformer hierarchy
FirToConstantValueTransformerSafe was unused and then
there only one FirToConstantValueTransformer left
2023-07-11 13:12:22 +00:00
Mikhail Glukhikh 71456c5514 FIR2IR: properly set constant expression type 2023-07-11 08:28:04 +00:00
Kirill Rakhman 988dbfc5c8 [FIR] Extract common helper for checking of (expect) default value 2023-07-05 08:51:01 +00:00
Kirill Rakhman 1d3a127f52 [FIR] Simplify getSingleExpectForActualOrNull
When compatibleOnly == false, the logic was equivalent to returning
singleOrNull.
The only call-site with compatibleOnly = true was FirElementSerializer,
but after the fix for KT-59613, the map will never contain multiple
entries when one of the entries is compatible.
Assuming that we only run serialization on green code, the map will
either contain one compatible entry or no entries which makes the
additional check redundant.
2023-07-05 08:51:01 +00:00
Ivan Kylchik fba0bd79ad [K2] Don't crash compiler if receiver on property wasn't evaluated
Compilation crash must be handled separately in
`convertToConstantValues` method because we still want successfully
compile common code. All constants will be evaluated later on
fir2ir phase.

#KT-59362 Fixed
2023-06-27 08:51:39 +00:00
Dmitriy Novozhilov 5717b59f52 [FIR/IR] Introduce an ability to propagate generated IR annotation to metadata
^KT-58638 Fixed
2023-06-21 06:56:59 +00:00
Mikhail Glukhikh 668684ca13 K2: correct FirJavaField usages taking imported variant into account
Related to KT-59140
2023-06-20 14:13:21 +00:00
Kirill Rakhman 8ff67218f5 [FIR] Fix serialization of annotation vararg arguments
#KT-58937 Fixed
2023-06-14 08:41:27 +00:00
Ivan Kochurkin 1e09e8663c [FIR] Add compatibleOnly parameter to getSingleCompatibleExpectForActualOrNull
Rename `getSingleCompatibleExpectForActualOrNull` to `getSingleExpectForActualOrNull`
2023-06-13 10:12:44 +00:00
Ivan Kochurkin 2251214d24 [FIR] Don't crash on complex expression as annotation argument if metadata compilation is used
^KT-58139 Fixed
2023-05-31 14:38:38 +00:00
Vladimir Sukharev 6a8981372b [K2/N] Read KDoc strings from LightTree nodes
^KT-56090

Merge-request: KT-MR-9613
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-05-17 08:12:39 +00:00
Mads Ager 089928ba2b [K2] Support legacy serialization for custom function type extensions.
For Compose libraries, it is important that libraries built with
K2 in version 2.0 can be read and used by a version 1.9 K1
compiler. That is not possible if custom function types are
in the metadata.

^KT-58456 Fixed
2023-05-12 10:49:43 +00:00
Ivan Kylchik d83f6a40fb [K2] Revert commit Pass FirFile to metadata serialization
We will ignore this for now. It is quite painful to bring `FirFile`
in all necessary places.

#KT-57812
2023-05-11 08:22:14 +00:00
Ivan Kylchik 951e30b683 [K2] Pass FirFile to metadata serialization
This is needed to extract correct const value from `ConstValueProvider`.

#KT-57812
2023-05-11 08:22:13 +00:00
Ivan Kylchik 846ad95c9e [K2] Return from toConstantValue only if expected type match
There was a bug with early return from `toConstantValue`
method when we found any const value in `ConstValueProvider`.
Actually we should return only if expected type match. This error can
occur if annotation and constant inside it are fakes and
have the same offset.

#KT-57812
2023-05-11 08:22:13 +00:00
Mikhail Glukhikh 0906258d03 K2: handle suspend anonymous functions properly in various compiler parts
#KT-58332 Fixed
2023-05-09 09:19:38 +00:00
Dmitriy Novozhilov af60681705 [FIR] Save declarations in metadata in source order
^KT-54792 Fixed
^KT-54801
^KT-54800
2023-05-09 07:36:32 +00:00
Dmitriy Novozhilov b359a5538c [FIR] Get rid of FirSerializerExtension.customClassMembersProducer
This service was needed in FE 1.0 because of different scope structure
  for Java classes, but seems like it has no sense for FIR
2023-05-09 07:36:32 +00:00
Ilya Chernikov a045a0a81c FIR: use default getter in serializer if fir contains none
since we generate the default getter in this case in
Fir2IrDeclarationStorage.createIrProperty, so the serialized metadata
should follow the same behavior.
#KT-57373 fixed
2023-04-27 09:14:20 +00:00
Mikhail Glukhikh f6bf7560a6 K2: fix field annotation handling around serialization
#KT-57135 Fixed
2023-04-25 12:18:27 +00:00
Anna Kozlova 4fe239375f [cls] write contracts information to cls stubs
^ KTIJ-24665
this information would be used to create resolved FirElements from stubs,
so no ProtoBuf would be kept in memory
2023-04-25 08:34:18 +00:00
Mads Ager a6520a294b [K2] Local property accessors are always default. 2023-04-21 23:40:41 +02:00
Mads Ager 3795fc1106 [K2] Fix stable parameter name metadata. 2023-04-21 23:40:41 +02:00
Mads Ager 3a8f1ca690 [K2] Type parameter metadata handling. 2023-04-21 23:40:41 +02:00
Mads Ager 73191ff9bc [K2] Add version requirement for definitely non-null types to metadata. 2023-04-21 23:40:40 +02:00
Mads Ager 1f3b8142a8 [K2] Enable tests for hasConstant field on properties in metadata. 2023-04-21 23:40:40 +02:00