Commit Graph

222 Commits

Author SHA1 Message Date
Mads Ager 73191ff9bc [K2] Add version requirement for definitely non-null types to metadata. 2023-04-21 23:40:40 +02:00
Mads Ager 683220a32c [K1] Remove compiler version requirements for context receivers in metadata. 2023-03-17 07:15:13 +00:00
Alexander Udalov 6595275ba7 Remove ClassBuilderMode.ABI
It was a special mode used only by the removed legacy implementation of
jvm-abi-gen.
2023-03-10 12:24:50 +00:00
Oleksandr Karpovich dec9704cea Add more methods to DescriptorSerializerPlugin
New methods:
afterFunction, afterConstructor, afterProperty, afterTypealias
2023-02-06 11:15:53 +00:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
Pavel Kunyavskiy 17e9a6a781 [klib] Fix serialization of missing annotations
^KT-42490
^KT-44625
2022-12-20 20:06:51 +00:00
Ilya Chernikov 0fbc099d32 FIR JS: Refactor Klib serialization for FIR support 2022-11-12 14:34:07 +01:00
Alexander Udalov ed6fe15e07 Support serialization of builtins with ExperimentalStdlibApi
This will allow to remove OptIn and ExperimentalStdlibApi from
serialized builtins after bootstrap.

 #KT-53073
2022-09-09 21:31:39 +02:00
Alexander Udalov 22329c7124 Do not sort fake overrides in DescriptorSerializer
Sorting invokes descriptor renderer, so the fewer descriptors we are
sorting, the better. This helps to save a few percent of compilation
time in a synthetic project from KT-52326.
2022-05-31 13:22:13 +02:00
Evgeniy.Zhelenskiy 28bf83ceac [IR] Unite inline class and multi-field value class representation
#KT-1179
2022-03-24 11:38:43 +00:00
Victor Petukhov b5933c70e2 [FE 1.0] Refactor error utils: split error entities and introduce error type and error scope kinds 2022-03-23 21:13:33 +00:00
Alexander Udalov b443848ea0 Fix type table serialization in DescriptorSerializer
Always serialize type table (and version requirement table) after
everything else, to prevent bugs like KT-51446 where inline class
underlying type was added to the type table after it has already been
serialized.

 #KT-51446 Fixed
2022-02-24 16:34:25 +01:00
Evgeniy.Zhelenskiy e97ca2ada4 [Psi2Ir, Fir2Ir] Generate toString, hashCode, equals methods for MF VC 2022-01-14 13:51:57 +00:00
Irene Dea 374d287d08 Reorganize TypeAttributeTranslatorExtension 2022-01-08 15:26:38 +03:00
Irene Dea d444978ebf Add support for attribute serialization. 2022-01-08 15:25:07 +03:00
Alexander Udalov 7771e5914d Revert "Do not write version requirements for suspend functions"
This reverts commit 6807ed6642.

The reason is that Kotlin compilers until and including version 1.6.10
have code that detects obsolete coroutines via these version
requirements (see `versionAndReleaseCoroutinesMismatch`). Since Kotlin
1.6.10 can read metadata of version 1.7, the earliest we can drop these
version requirements is Kotlin 1.8.0.
2021-12-21 20:06:07 +01:00
Vyacheslav Gerasimov f7a9065b75 Build: Use intellij maven repo instead of downloaded IDEA
#KTI-82
2021-12-16 21:48:23 +03:00
Alexander Udalov 6807ed6642 Do not write version requirements for suspend functions
Coroutines are a stable feature since 1.3. Version requirement on
suspend functions, or functions mentioning suspend function types in the
signature, was needed to prevent older compilers from reading metadata
that they can't properly use. It's not needed anymore because a newer
metadata version prevents older compilers from reading any metadata
altogether.

Also, computing isSuspendOrHasSuspendTypesInSignature took ~0.5% of
backend time on compilation of intellij (related to KT-48233).
2021-12-15 22:27:51 +01:00
Anastasiya Shadrina d47cf315e7 [Metadata] Add context receivers to metadata.proto
[Tests] Add JvmVersionRequirementTest
2021-12-02 20:24:20 +03:00
Vyacheslav Gerasimov ab146bd6d4 Build: Fix deprecated Gradle configurations usages
for migration to Gradle 7+ #KTI-559
2021-09-26 18:28:44 +03:00
Denis.Zharkov d91155558b Rename LF: DefinitelyNotNullTypeParameters -> DefinitelyNonNullableTypes 2021-08-31 15:41:17 +03:00
Ilmir Usmanov 1f8dd45c2b Remove experimental coroutines support. Part 2 2021-08-30 14:21:57 +03:00
Ilmir Usmanov 486c6b3c15 Remove obsolete experimental coroutines support
in compiler.
2021-08-13 22:31:30 +02:00
Alexander Udalov e790fa8ac9 Remove dependency of serialization on frontend
Move ApplicationExtensionDescriptor and ProjectExtensionDescriptor to
:compiler:util.
2021-06-01 20:28:22 +02:00
Pavel Kirpichenkov f5a53c82c5 Don't write type arguments of types replaced with Any to metadata
Anonymous types are not approximated by frontend for private declarations.
Class IDs for such types are replaced by StringTable before being written
to metadata. JVM string table mangles such types and keeps them generic
for reflection. For other purposes the types are replaced with `Any`.
Type arguments of the replaced type should be ignored in the latter case.
Otherwise decompiled text builder crashes on an attempt to restore `Any`
type with non-zero number of type arguments.

The code pretending to replace a type with its first supertype was dropped
from ApproximatingStringTable for two reasons:
- the first type from `getAllSuperClassifiers` is the original type itself
which doens't provide a ClassId for anonymous type, so it was a noop
- tracking potential type arguments of the first anonymous type's supertype
would be a complication with almost no practical value (types in decompiled
text would be slightly closer to the real type of a private declaration).

^KT-46393 Fixed
2021-05-28 14:42:47 +00:00
Alexander Udalov 4c7f207309 Use new getInlineClassRepresentation in some utilities 2021-05-13 13:54:02 +02:00
Denis.Zharkov 37813d9d82 Add version requirements for declarations with !! types
^KT-26245 Related
2021-04-09 13:06:40 +03:00
Denis.Zharkov 30eb9ad32f Add serialization/deserialization of definitely-not-null types
^KT-26245 In Progress
2021-04-09 13:06:31 +03:00
Ilya Gorbunov e450a6494a Migrate deprecations in core, compiler, idea, tests
Replacing deprecated Char.toInt() with Char.code and
Number.toChar() with Number.toInt().toChar(), where Number is not Int.

KT-23451
2021-04-07 18:30:20 +03:00
Alexander Udalov ea01c97a8e Write underlying property name & type for inline class to metadata
This will be used in the compiler starting from 1.5.20 instead of the
currently used approach of looking for the single value parameter of the
primary constructor. The problem with the current approach is that
primary constructor can be private (since 1.4.30) and the property could
always be private. Relying on private declarations from metadata is
dangerous; for example lazy IR doesn't usually create stubs for private
declarations, and it didn't create stubs for private inline class
constructors before b5f9b1df, which led to the problem reported in
KT-44723.
2021-03-23 11:45:22 +01:00
Pavel Kirpichenkov 5c28762c02 Fix check for local classes in approximating string table
Take local/anonymous classes and their inner classes into account.
Simplify approximation: use first available super classifier instead
of first super class. This approximation should only happen for
private declarations that were not previously approximated by frontend.
So basically the only requirement for the approximated types is to be
denotable. Note that this only works if the types are not used later.
JVM uses a different string table implementatin as it needs exact
types of private members for reflection.

^KT-20996 Fixed
2021-01-20 11:05:53 +03:00
Pavel Kirpichenkov 2f3f75b512 Fix local anonymous class name error in K2MetadataCompiler
Extract the logic of approximating to denotable class supertype
from JS/KLIB and use it in metadata compiler.

^KT-20996 In Progress
2021-01-20 11:05:53 +03:00
Ilmir Usmanov 129de76288 Value classes: Generate @JvmInline annotation for inline classes
but not for value classes.
Since inline classes and value classes share the same flag, we use
presence of the annotation to distinguish them.
2020-12-01 23:45:47 +01:00
Ilmir Usmanov 92f1681de0 Value classes: treat @JvmInline value classes as inline classes
Report error on value classes without @JvmInline annotation.
Do not check for @JvmInline annotation in value classes since
it breaks reflection.
2020-11-27 23:52:06 +01:00
Ilmir Usmanov 7a18ab9094 IC mangling: Generate version requirements to properties as well
Generate the requirements at JVM only.
2020-11-19 17:39:32 +01:00
Ilmir Usmanov 2cd9016016 IC mangling: Replace compiler hack with configuration flag 2020-11-19 17:39:30 +01:00
Ilmir Usmanov 20e7a77b78 IC mangling: Write version 1.4.30 requirement to functions with new mangling 2020-11-19 17:39:28 +01:00
Leonid Startsev 4ec90b18bc Rework DescriptorSerializerPlugin to be a part of Project's extensions
instead of statically registering it.

Static registering can cause subtle errors when plugin implementation
(e.g. SerializationDescriptorPluginForKotlinxSerialization) is registered
from multiple classloaders: in multi-module with daemon compilation scenario

 #KT-41857 Fixed
2020-10-22 17:04:35 +03:00
Dmitriy Novozhilov 8d2e89a9ea Move ProtoEnumFlags to :core:metadata 2020-09-11 10:08:34 +03:00
Dmitriy Dolovov 3d9093583f Metadata: 'non-stable parameter names' flag for callables
^KT-34602
2020-07-27 23:11:30 +07:00
Alexander Udalov 8c71d8f126 Undeprecate VariableDescriptorWithAccessors.isDelegated
Apparently there's quite a few valid usages of this method outside of
the compiler frontend, where manual suppression is annoying.
2020-07-07 18:09:40 +02:00
Alexander Udalov 05e8546bdb Skip unresolved JvmStatic/JvmField annotations in builtins
This is needed to implement KT-30084 and KT-30083 after bootstrap.
2020-06-23 13:55:08 +02:00
Dmitriy Novozhilov d01817ce14 Rename InvocationKind to EventOccurrencesRange 2020-06-19 15:53:11 +03:00
Dmitriy Novozhilov 25621d699b Add methods for combine InvocationKind's
There is two methods added -- `or` and `and`

`or` is used by CFA for combining two kinds that came from different
edges of control flow graph

`and` is analog of `+` operator for invocation kinds
2020-06-19 15:53:08 +03:00
Leonid Startsev 7c8c5b057f Extensible mechanism for plugin metadata during descriptor serialization
A mechanism that allows kotlinx.serialization plugin to preserve the
correct (program) order of properties after serializing/deserializing
descriptors to kotlin metadata, which is needed for correct and stable
json serialization of class hierarchies in incremental/multi-module scenario.
It uses protobuf extensions.
2020-06-01 17:48:16 +03:00
Alexander Udalov 92534eadaa Remove dependency of 'resolution' on 'deserialization'
Replace it with a dependency on 'descriptors'.

Move the existing marker interface ContractProvider to 'descriptors',
and create a new marker interface DeserializedDescriptor.
2020-03-28 21:30:07 +01:00
Alexander Udalov d70271b6aa Move RequireKotlinNames to 'descriptors'
Also move version string regex there and rename the class to
RequireKotlinConstants. This allows to get rid of dependency of
'serialization' on 'frontend'.
2020-03-28 21:30:07 +01:00
Mikhail Zarechenskiy f7ce1c669b FIC: Introduce isFun property for descriptors and proto 2020-01-17 19:35:06 +03:00
Alexander Udalov b970a57adb Generate version requirement on inline functions since API version 1.4
The old compiler will crash if it tries to inline a function that's
passing a lambda parameter into the new parameter null check method
`Intrinsics.checkNotNullParameter` because that usage is not considered as
inlinable by the old compiler (it only knows about
`Intrinsics.checkParameterIsNotNull`). Therefore we require that these
functions can only be read by compilers of version 1.3.50 or greater.

 #KT-22275 Fixed
2019-08-12 16:09:23 +02:00
Dmitry Petrov f590d4da9e IR: IrTypeAlias: serialize/deserialize new IR objects
Add uniqId for typealias declarations.
Implement WrappedTypeAliasDescriptor.
2019-08-06 12:42:43 +03:00