Commit Graph

55 Commits

Author SHA1 Message Date
Alexander Udalov f3a7312ee6 K2: use ClassKind.CLASS for object literals
K1 uses CLASS, and libraries like kotlinx-metadata-jvm and
kotlin-reflect already rely on it.

 #KT-57641 Fixed
2023-06-26 20:58:55 +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 1f3b8142a8 [K2] Enable tests for hasConstant field on properties in metadata. 2023-04-21 23:40:40 +02:00
Mads Ager f7171f01ae [K2] Enable tests for metadata for nested types. 2023-04-21 23:40:40 +02:00
Mads Ager 46db4b4e6d [K2] Ignore failing metadata tests while working on them. 2023-03-17 07:15:14 +00:00
Mads Ager 683220a32c [K1] Remove compiler version requirements for context receivers in metadata. 2023-03-17 07:15:13 +00:00
Mads Ager ed84fbd8a6 Sort kotlinp output in tests to reduce diff between K1 and K2. 2023-03-17 07:15:13 +00:00
Mads Ager 04a088039c [K2] Add support for running Kotlinp tests with K2.
The tests fail spectacularly at this point in time.
2023-03-17 07:15:12 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +00:00
Roman Efremov 2dc3871954 Add "hasEnumEntries" class flag to kotlinx-metadata
^KT-53929 Fixed
2023-01-23 12:53:06 +01:00
Alexander Udalov 7a9c59aeb5 JVM IR: do not serialize metadata for actualized optional expectations
Optional-expectation annotations which have an actual counterpart should
have never been serialized to the kotlin_module's proto. See for example
the original (correct) implementation in the old JVM backend in
`PackageCodegenImpl.addDescriptorToOptionalAnnotationsIfNeeded`.

 #KT-55611 Fixed
2023-01-02 15:30:27 +00:00
Leonid Startsev c4d409608c Rewrite KotlinP so it does not use visitors from kotlinx-metadata anymore;
fix bug with missing moduleName.
2022-11-10 13:30:10 +00:00
Alexander Udalov abaffeddab Remove LocalClassProtoTestGenerated, replace with kotlinp tests
This test uses a hacky mode of the compiler which is not worth it to
support further (especially in K2), `USE_SINGLE_MODULE`, where
everything is compiled in one module. The purpose of the test is just to
check that metadata for local/anonymous classes is written correctly.
So we can replace it with the tests on kotlinp, which uses
kotlinx-metadata-jvm and dumps all loaded metadata to text.

This replacement is not perfect, in particular because it won't check
that the reflection machinery is able to load this metadata, and because
it won't check that annotations are loaded correctly from the bytecode.
But IMHO it's good enough, there are box tests on reflection on local
classes (e.g. `reflection/annotations/localClassLiteral.kt`), so this
way is better than having to support the weird compiler mode for just
one test.
2022-08-31 20:54:50 +02:00
Alexander Udalov 61652c04e1 kotlinx-metadata: support experimental context receivers 2022-06-15 21:59:45 +02:00
Alexander Udalov 6abf14087c kotlinx-metadata: add Flag.Type.IS_DEFINITELY_NON_NULL 2022-06-15 21:59:45 +02:00
Pavel Mikhailovskii 65b2cee913 KT-23397 Optimize out field for property delegate when it's safe (JVM) 2022-06-07 10:46:01 +00: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
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
Mikhael Bogdanov ea58c858d1 JvmDefault. Support @JvmDefaultWithCompatibility annotation
#KT-48217 Fixed
2021-12-06 14:20:24 +01:00
Steven Schäfer 4b4ee78e5d kotlinx-metadata: Fix parsing of inlineClassUnderlyingType 2021-11-20 12:39:15 +01:00
Alexander Udalov f5dd0abb76 Render JVM default flags in kotlinp 2021-11-09 15:09:29 +01:00
Mikhail Glukhikh fc6403679a Rename !USE_EXPERIMENTAL test directive to !OPT_IN 2021-09-10 16:29:16 +03:00
pyos 2fe7cf27ad kotlinp: use JVM_IR backend for compiling tests
Also, test optimized delegated properties.
2021-07-12 22:38:45 +02:00
Alexander Udalov c4b2b7e0da Add underlying property name & type for inline class to kotlinx-metadata
#KT-45635 Fixed
2021-04-01 22:34:53 +02:00
Alexander Udalov 1a82158472 Fix array of KClass annotation arguments in kotlinx-metadata-jvm
#KT-45594 Fixed
2021-04-01 22:34:53 +02:00
Alexander Udalov ee11202db5 Add Flag.IS_VALUE for value classes to kotlinx-metadata-jvm
#KT-44783 Fixed
2021-03-08 21:22:40 +01:00
Dmitriy Novozhilov f3a8fcaea6 [FE] Make constructors of sealed classes protected instead of internal 2021-02-12 13:36:38 +03:00
Dmitriy Novozhilov ee1aff1012 [Test] Update different testdata according to changes in sealed classes 2021-01-28 13:19:29 +03:00
Ilmir Usmanov c22071566e IC mangling: Use old mangling scheme when LV is 1.3
Add integration test to check, that nothing is broken with LV 1.3.
2020-11-19 17:39:34 +01:00
Dmitriy Dolovov c25742c91a kotlinx-metadata: Fix tests for Flag.Constructor.IS_SECONDARY flag
^KT-42429
2020-10-07 09:43:23 +03:00
Mikhail Zarechenskiy 0ab9b3639b Approximate types for lambda literals before serialization 2020-05-31 17:38:18 +03:00
Dmitry Petrov 5db6a0b563 New mangling rules require language version 1.4 (not compiler version)
Follow-up to a270ee094c
2020-05-29 15:15:54 +03:00
Dmitry Petrov 94509bdb4e KT-39228 Fix inliner when latest 1.4 compiler used with 1.3 stdlib
Since 1.4.0-dev-8774, we mangle functions returning inline class values,
including functions with return type 'kotlin.Result'. This causes
incompatibility when 1.4 compiler is used with 1.3 (or just some
pre-1.4.0-dev-8774) standard library.

Also, write "message from the future" on functions returning inline
class values indicating that they can be used since compiler version 1.4
(otherwise 1.3 compiler using 1.4 stdlib would fail to find some
@InlineOnly functions such as 'Result.success' and 'Result.failure').
2020-05-29 00:53:00 +03:00
Alexander Udalov 4520e02bae Support fun interfaces in kotlinx-metadata
#KT-37421 Fixed
2020-05-27 23:29:12 +02:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
Alexander Udalov 795d6ab407 Migrate UseExperimental->OptIn in project sources 2020-03-10 12:07:14 +01:00
Alexander Udalov 55e29363dc Update test data for kotlinp
Inline functions require Kotlin compiler at least 1.3.50 if they were
generated by the compiler with API version >= 1.4. This is because since
API version 1.4, we've changed the generation scheme of parameter
nullability assertions and they now refer to methods from the standard
library which did not exist until 1.4. See
JvmSerializerExtension.writeInlineParameterNullCheckRequirement.
2020-01-17 20:40:35 +01:00
Dmitriy Novozhilov 76b3964e96 Update testdata according to change compiler version to 1.4 2020-01-17 10:33:50 +03:00
Alexander Udalov 01ddac58e1 Add language feature for changed name of property annotations method
#KT-31352 Fixed
2019-08-12 16:48:26 +02:00
Alexander Udalov ea0142da60 Use JVM name of getter in synthetic method for property annotations
#KT-31352 In Progress
2019-08-12 16:48:25 +02:00
Alexander Udalov fd00999771 Render contracts in kotlinp, fix minor bug in kotlinx-metadata-jvm 2019-05-24 14:42:25 +02:00
Alexander Udalov 9e2733915b Add module name JVM extensions to class/package in kotlinx-metadata-jvm
#KT-31308 Fixed
2019-05-24 14:42:25 +02:00
Mikhail Zarechenskiy ed2b9172da Support unsigned integers in kotlinx-metadata-jvm
#KT-25371 Fixed
2018-11-13 01:29:39 +03:00
Alexander Udalov 5fb1bbe3f3 Add bytecode listing test on private default setter
Also fix test data of the kotlinp test and remove the newly added test
case in the obsolete PropertyGenTest

 #KT-20344 Fixed
2018-10-18 12:13:22 +02:00
Alexander Udalov 47bde73ed5 Minor, fix testdata to use release coroutines 2018-08-30 17:34:32 +02:00
Alexander Udalov b55fc818d1 Support JvmName on annotation constructor parameters
#KT-25372 Fixed
2018-08-30 14:56:42 +03:00
Alexander Udalov 3345dc81fd Do not return field signature if there's none in the metadata
Otherwise this code behaves incorrectly on getter-only properties: it
returns a meaningless field signature whereas the property has no field.
It's hard to come up with an example of when this could matter in
compiler code, but it's very noticeable in kotlinx-metadata-jvm

 #KT-26188 Fixed
2018-08-16 15:05:19 +02:00
Alexander Udalov 3f32e1cce9 Do not serialize empty property signature to JVM metadata
This should have no effect on the correct code currently because all
properties have at least a getter, but may help in debugging problems
with serialized metadata for properties
2018-08-16 14:11:09 +02:00