Commit Graph

3486 Commits

Author SHA1 Message Date
Yahor Berdnikau eb4e96a113 Add kotlin-build-tools-enum-compat workaround
It acts as a workaround for the case when build tools or dependencies
are compiled with latest 'kotlin-stdlib' version, but at a runtime older
 'kotlin-stdlib' is provided, which does not know about new
 `EnumEntries`.

 ^KT-57317 Fixed
2023-04-21 14:57:17 +00:00
Nikolay Krasko 9e00bb8a21 [213] More dependencies aalto + stax2
KTI-1114
2023-04-21 13:19:05 +00:00
Roman Golyshev 83f9e0f87e [213] Add more missing runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev ac388010b1 [213] Add missing test runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Sergey.Shanshin d8d643b7d7 [KxSerialization] Fix "IllegalAccessError: Update to static final field"
Fixes #KT-57647

For value classes, if you add code to companion anonymous init block in IR, it will be executed in the instance constructor. This causes an error when initializing static fields, because writing to them can only occur from the <clinit> method.

The solution is to transfer the static field initialization code from an anonymous init block to the IR initializer of this field

Merge-request: KT-MR-9633
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-04-21 12:37:32 +00:00
Pavel Mikhailovskii 58143a2006 KT-57598 Run Kapt with K1 even when the compiler is run with K2 2023-04-20 09:30:38 +00:00
Alexander Udalov bc7aea1426 Kapt+JVM_IR: generate delegated members correctly
Generate a declaration for each delegated member without body. If we
don't generate delegated declarations, subclasses will have incorrect IR
with unbound symbols in fake overrides.

 #KT-58027 Fixed
2023-04-19 23:04:45 +00:00
Leonid Startsev f29e505bd3 Use correct check in FirSerializationPluginClassChecker to determine if the given type is a enum class.
Otherwise, findTypeSerializerOrContextUnchecked works incorrectly when analyzing code
compiled with Kotlin 1.7.20 and serialization 1.4.1.

#KT-57704 Fixed
2023-04-19 16:13:28 +00:00
Leonid Startsev ef9074e24d Correctly support nullability in type arguments for serializer<T>() intrinsic.
Nullability info should be added to TYPE_OF operation marker.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2265
2023-04-19 12:31:19 +00:00
Leonid Startsev fa8f38c2c8 Don't fail if there is no serializer for type parameters of contextual serializer
Return null instead.
Such behaviour is needed to support cachedChildSerializers logic.
Since this field creator doesn't provide genericGetter (because it's
static),
type param serializer can't be retrieved, and the whole contextual
serializer shouldn't be cached.

#KT-58067 Fixed
2023-04-19 10:09:06 +00:00
Leonid Startsev d9e16fb76e Do not create cacheableChildSerializers unless it is necessary
Creation of this property in the SerializerIrGenerator.<init> can lead to
a 'Serializer not found' internal error when generator is applied to a fully-customized external serializer.
In that case, generator is still created, but none of the generateSave/Load functions are called,
so cacheableChildSerializers(Property) is not necessary.

#KT-57730 Fixed
Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2260
2023-04-18 11:04:56 +00:00
Sebastian Sellmair 5d0bf2de24 [CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2

Reverts:
- 9dcd40d7b7
- fb66764c4d

KTIJ-25227
2023-04-18 09:18:10 +00:00
Mads Ager 699ad87be2 [KAPT+IR] Use ErrorType for unresolved delegate class.
^KT-57946
2023-04-17 16:49:11 +02:00
Yahor Berdnikau 1eb27f2aac Update publishing and usage of kotlin-annotation-processing plugin
- removed 'kotlin-annotation-processing-gradle' publication as it
duplicated 'kotlin-annotation-processing-embeddable'
- removed 'kotlin-annotation-processing-maven' as it is embedded into
  'kotlin-maven-plugin'. Instead 'kotlin-maven-plugin' now depends on
  'kotlin-annotation-processing' directly.

^KT-52811 In Progress
2023-04-17 14:40:51 +00:00
Yahor Berdnikau a58d6fd13a Publish 'kotlinx-serialization-compiler-plugin' separately
- Also publish 'kotlinx-serialization-compiler-plugin-embeddable' to be
used with 'kotlin-compiler-embeddable'.
- Now Serialization Maven and Gradle plugins do not embed plugin into
itself, but declare on published one normal dependency.
- 'kotlin-serialization-unshaded' publication is deprecated.

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 78c94b65b9 Change sam-with-receiver plugin to use published compiler plugin
- also publish 'kotlin-sam-with-receiver-compiler-plugin-embeddable' to
  be used with 'kotlin-compiler-embeddable'
- 'kotlin-maven-sam-with-receiver' now just adds
  'kotlin-sam-with-receiver-compiler-plugin' as normal dependency
  instead of embedding it into itself

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau a58266050f Publish noarg compiler plugin separately
- also publish 'kotlin-noarg-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-embeddable'
- 'kotlin-noarg-maven' plugin now just adds
  'kotlin-noarg-compiler-plugin' as normal dependency instead embedding
  it into itself

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 1a4d203d1c Publish lombok compiler plugin separately
- also add 'kotlin-lombok-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-emebeddable'
- 'kotlin-maven-lombok' does not try to embed plugin into itself and
  just depends on compiler plugin as normal dependency

^KT-52811 In Progress
2023-04-17 14:40:50 +00:00
Yahor Berdnikau 5e41cbda75 Change kotlin-assignment plugin to use published compiler plugin
^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Yahor Berdnikau 1ccd7afde7 Publish allopen compiler plugin separately
- added also 'kotlin-allopen-compiler-plugin-embeddable' to be used with
  'kotlin-compiler-embeddable'
- 'kotlin-maven-allopen' now just depends on
  'kotlin-allopen-compiler-plugin' instead of "embeding" it into itself

^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Yahor Berdnikau 64f8b87b66 Publish atomicfu compiler plugin separately
- rename plugin into 'kotlin-atomicfu-compiler-plugin'
- add 'kotlin-atomicfu-compiler-plugin-embeddable' to be used with
  'kotlin-comiler-embeddable'

^KT-52811 In Progress
2023-04-17 14:40:49 +00:00
Alexander Udalov 287e0909cc Kapt+JVM_IR: do not generate super constructor call
#KT-57699 Fixed
 #KT-57939 Fixed
2023-04-17 10:40:15 +00:00
Nikolay Lunyak 20786bb35a [FIR] Refactor the default messages presence checking
Forbid calling `checkMissingMessages` accidentally
outside tests.

Checking Parcelize default messages inside a test.
2023-04-14 13:07:03 +00:00
Artem Kobzar f0aa6c6d32 [K/JS Gradle] Remove forceLegacyBackendUsage from KotlinGradlePlugin previously added with the compiler flags refactoring, also fix bootstrap compilation of atomicfu plugin 2023-04-12 14:04:34 +00:00
Dmitriy Novozhilov 94f77add49 [FIR] Try to load properties in order according to kotlinx.serialization metadata extension
Move metadata extension with property order from kotlinx.serialization to core

After fix of KT-54792 properties will be deserialized in declaration order
  if corresponding class was compiled with modern compiler. But this order
  is needed for kotlinx.serialization for binaries compiled with any
  kotlin compiler >= 1.4. Since we don't plan to add any extension points
  into (de)serialization into FIR, we need to take into account existing
  metadata extension from kotlinx.serialization in compiler itself

^KT-57769 Fixed
2023-04-11 13:43:39 +00:00
Dmitriy Novozhilov 839026b6fe [FIR2IR] Generate IR declarations in classes in strict order
Order is following:
- declared declarations in declaration (in source) order
- generated declarations in sorted order
2023-04-11 13:43:38 +00:00
Sebastian Sellmair 9dcd40d7b7 [CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE

KTIJ-24976
2023-04-06 16:03:03 +00:00
Igor Yakovlev 8102744e00 [Serialization] Fix serialization test data 2023-04-04 11:04:18 +00:00
Igor Yakovlev 81ceb856bb [Serialization] Fix invalid int array creation 2023-04-04 11:04:18 +00:00
Igor Yakovlev 8cb1fca299 [Serialization] Add wasm target platform to serialization plugin 2023-04-04 11:04:17 +00:00
Igor Yakovlev e990c8efd2 [Serialization] Fix invalid ir type for serialize generator 2023-04-04 11:04:17 +00:00
Igor Yakovlev b4d6482581 [Serialization] Fix invalid ir type for deserialize generator 2023-04-04 11:04:17 +00:00
Roman Golyshev 4e0b68b516 [Assign plugin] Use FqName to match annotations in FirAssignAnnotationMatchingService
All other compiler plugins accept "pkg1.pkg2.Class1" classes notation
and correctly match against it

But Assignment plugin used `ClassId` on such qualified names and got
`ClassId("/pkg1.pkg2.Class1")` instead of `ClassId("pkg1/pkg2/Class1")`,
and that lead to unexpected problems

This commit fixes that by using `FqName` instead of `ClassId`

^KT-57406 Fixed
2023-03-31 10:55:05 +00:00
Dmitriy Novozhilov c957a0b43b [IR] Properly serialize IrDeclarationOrigin.GeneratedByPlugin to klibs
^KT-56911 Fixed
2023-03-30 07:52:56 +00:00
Dmitriy Novozhilov 5ccf1eddab [K2 Serialization] Remove obsolete formatting suppression 2023-03-29 15:18:37 +00:00
Dmitriy Novozhilov fb97f4db87 [FIR] Don't create generated nested classifier scope for non-source classes
^KT-57626 Fixed
2023-03-29 15:18:37 +00:00
Pavel Mikhailovskii 85b5a4521e KT-56843 [SLC] Support unsafe property initializers 2023-03-28 08:17:37 +00:00
Dmitriy Novozhilov 62ad784b73 [FIR] Fix matching annotated predicate for java and binary declarations
^KT-57400 Fixed
2023-03-27 10:54:27 +00:00
Dmitriy Novozhilov 336b6ba9f0 [FIR] Extract extension functional type from an annotated functional type during deserialization
^KT-57140 Fixed
2023-03-27 10:44:51 +00:00
Dmitriy Novozhilov 8ca7b32577 [FIR] Register type related extensions in libraries sessions
^KT-57140
2023-03-27 10:44:50 +00:00
Dmitriy Novozhilov 01fc84ee3a [FIR] Add tests for plugins compatibility
^KT-57140
2023-03-27 10:44:50 +00:00
Alexander Udalov 562b27db4e JVM IR: initialize enum entries without invokedynamic
#KT-57316 Fixed
2023-03-24 13:38:32 +00:00
Dmitrii Gridin 706ff6b61f [FIR] pre-resolve some scope callables before creating a scope
In a lot of cases, when we want to process the
declaration in scope, it should be resolved to at least TYPES phase.

To avoid doing it manually in all our variety of scopes, we do it when the scope it created.
It was implicitly working manually before as lazy resolve did a lot of extra work
on resolving a declaration it was not supposed to resolve.
Now it's not the case, and we have to explicitly resolve all the declarations we need.

^KT-56543

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2023-03-24 09:57:46 +00:00
Dmitriy Dolovov 2a4d880037 [PL] Deep rework of the partial linkage
1. Leaving no unbound symbols in the IR tree, KT-54491:
   - All unbound symbols are bound to synthetic stub declarations
   - Improved detection of the root cause for every partially linked classifier
   - Improved error messages

2. Visibility valiation, KT-54469

3. Always check deserialized symbols:
   If the deserialized symbol mismatches the symbol kind at the call site in the deserializer then generate and reference another symbol with the same signature. In case PL is off, just throw IrSymbolTypeMismatchException.

4. Handle class inheritance violation:
   - Detect illegal inheritance (ex: inheriting from a final class)
   - Detect invalid constructor delegation (ex: delegating to another class than the direct superclass)
   - Simplification: Reduce the number of PartialLinkageCase subclasses
   - Reworked error message generation to have shorter and clearer messages

5. Handle class transformations and all known side-effects, examples:
   - nested <-> inner
   - class <-> enum/object
   - adding/removing subclasses of sealed class
   - adding/removing enum entries

6. Check direct instantiation of abstract class.
   Such instantiation could be possible if a class was non-abstract in the previous version of a library.

7. Handle unlinked annotations on declarations.
   Such annotations are removed from the IR. The appropriate compiler error message is produced for every individual case.

8. Handle value argument count mismatch at call sites

9. Handle calling suspend function from non-suspend context.
   This could happen if a suspen function was non-suspend in the previous version of a library.

10. Handle overriding inline callables.
    Only the leaf final callable can be marked with `inline`.

11. Detect illegal non-local returns from noinline/crossinline lambdas.
2023-03-23 10:24:27 +00:00
Alexander Udalov 17e4ed8ffc Kapt+JVM_IR: add stub converter test for KT-57388 2023-03-21 22:12:58 +01:00
Ivan Kylchik 2b387e7a10 [FIR LT] Get correct startOffset value for declarations with comments
#KT-56913 Fixed
#KT-56926 Fixed
2023-03-21 16:33:00 +00:00
Leonid Startsev 6ee20574e1 Correctly handle @Repeatable @SerialInfo annotations on classes
that were affected by deduplication of inherited serial info annotations.

Prohibit combination of @InheritableSerialInfo and @Repeatable.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2099
2023-03-20 18:15:09 +00:00
Artem Kobzar 7a79de6d16 [K/JS] Move JS IR box tests setup into separated function 2023-03-19 22:53:05 +00:00
Dmitriy Novozhilov 507ef3e951 [FIR] Properly handle declarations from other source sessions in FirPredicateBasedProvider
^KT-57083 Fixed
2023-03-16 15:13:19 +00:00