Commit Graph

205 Commits

Author SHA1 Message Date
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
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Alexander Udalov 584137121b Do not write version requirements in metadata for lambdas
#KT-29790 Fixed
2019-03-12 18:53:08 +01:00
Alexander Udalov e942bff4a2 Reformat module 'serialization', fix inspections 2019-03-12 18:53:08 +01:00
Alexander Udalov 3f1533c35b Restore support for local class literals in annotation arguments
This was broken in c1ab08c8ce where we started to represent KClassValue
as a ClassId of the referenced class + number of times it's been wrapped
into kotlin.Array. Local classes do not have a sane ClassId, so in this
change we restore the old behavior by representing KClassValue with a
sealed class value instead

 #KT-29891 Fixed
2019-02-25 19:22:09 +01:00
Dmitriy Novozhilov 44ae7a19e6 Reformat ContractSerializer.kt according to code style 2019-01-31 17:25:13 +03:00
Mikhael Bogdanov a122cba862 Switch Kotlin project to jvm-target 1.8
#KT-29405
2019-01-31 07:43:05 +01:00
Sergey Rostov f35185b261 Build: remove explicit dependencies to org.jetbrains.annotations 2019-01-28 13:43:08 +03:00
Sergey Rostov 883970fadb Add explicit dependencies to nullable annotations 2018-12-26 09:07:06 +03:00
Marcin Moskala 686cfa6fd2 Fix common misspellings 2018-12-21 16:13:42 +03:00
Alexey Tsvetkov d54ce2da6f Exclude nested classes of private classes from ABI classes 2018-12-11 22:48:53 +03:00
Alexey Tsvetkov 3a29b337a0 Exclude private typealiases from ABI classes 2018-12-11 22:48:53 +03:00
Alexey Tsvetkov 903f6bc79b Exclude private members from ABI classes 2018-12-11 22:48:53 +03:00
Pavel Punegov fe0a2bc75e Provide SerializerExtension methods with child DescriptorSerializer instance
to make Native be able to serialize backing properties and inline bodies.
Change visibility for functions and properties of DescriptorSerializer.
2018-11-26 18:15:30 +03:00
Alexander Udalov c1ab08c8ce Refactor KClassValue to store ClassLiteralValue internally
Only invariant array projections and non-null element types will be
supported soon (see KT-26568), so it makes no sense to store the
complete type in KClassValue. What we need is only the ClassId of the
class, and the number of times it's wrapped into kotlin/Array, which is
exactly what ClassLiteralValue represents.

This change helps in decoupling annotation values from
descriptors/types. The only constant value that depends on descriptors
is now AnnotationValue.

 #KT-26582 Fixed
2018-10-25 16:27:23 +02:00
Alexander Udalov 19c79b906f Minor, add utility to get class name from StringTable via ClassId 2018-10-25 16:27:22 +02:00
Alexander Udalov 1ee1d15b91 Support annotations on property accessors in JS/common metadata
#KT-14529 Fixed
2018-10-24 18:17:12 +02:00
Mikhail Zarechenskiy 908be10bf4 Write version requirement on inline classes and relevant declarations
#KT-26720 Fixed
2018-09-11 17:13:44 +03:00