Commit Graph

189 Commits

Author SHA1 Message Date
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Nikolay Lunyak 7056ad5325 [FIR] Set status.isOverride for fake overrides
Even though SO may not be correct
overrides sometimes, it feels more
natural to treat fake overrides as...
well, "overrides". And without it
we'd need to make the code in
`FirOverrideChecker` less intuitive.
2024-02-15 16:10:13 +00:00
Nikolay Lunyak afd8895e51 [FIR] Introduce the PluginGenerated source kind
Make parcelize work consistently with
`FirOverrideChecker`.

Actually, there is a philosophical question about
what to do when a plugin generates a class
in a new package, and this class is red code
(for instance, doesn't implement an abstract
member from a supertype). There's no source
to report such an error, but we probably do
want to run checkers to avoid trying to
compile red code to binaries (because it may
crash in backend, or it may silently work).
2024-02-15 16:10:13 +00:00
Sergey.Shanshin 9a8ebd5c21 [KxSerialization] Cover all combinations of language and serialization features with tests for enums
Resolves https://github.com/Kotlin/kotlinx.serialization/issues/2324


Merge-request: KT-MR-13775
Merged-by: Sergei Shanshin <Sergey.Shanshin@jetbrains.com>
2024-02-14 13:15:01 +00:00
Sergey.Shanshin 2ae2f09fee [FIR] Fixed phase for FirCompanionGenerationProcessor to COMPANION_GENERATION
Phase COMPILER_REQUIRED_ANNOTATIONS causes errors in the kotlinx serialization tests:

org.jetbrains.kotlin.fir.symbols.FirLazyResolveContractViolationException: `lazyResolveToPhase(COMPILER_REQUIRED_ANNOTATIONS)` cannot be called from a transformer with a phase COMPILER_REQUIRED_ANNOTATIONS.
`lazyResolveToPhase` can be called only from a transformer with a phase which is strictly greater than a requested phase;
 i.e., `lazyResolveToPhase(A)` may be only called from a lazy transformer with a phase B, where A < B. This is a contract of lazy resolve
2024-02-12 15:54:11 +00:00
Sergey.Shanshin 84ad12be57 [KxSerialization] Added inspections on custom serializer parameters
Added inspections to check:
- custom serializer on class has as many parameters in primary constructor as the serializable class of type arguments
- all parameters in custom serializer has `KSerializer` type
- property in serializable class not parametrized by type parameter
- custom serializer on property of serializable class have no parameters in primary constructor
2024-02-12 15:54:11 +00:00
Alexander Udalov 3f034e8b67 Enable lightweight lambdas (aka invokedynamic) since 2.0
#KT-45375 Fixed
 #KT-58173 Open
2024-02-08 19:46:18 +00:00
Simon Ogorodnik 53e89a9722 K2. Minor. Rename FirConstExpression to FirLiteralExpression
FirConstExpression is usually confused with "constant" calculations,
while in fact, it just denotes a simple literal expression
and `1 + 1` isn't represented by a FirConstExpression.

^KT-64314 Fixed
2024-01-25 23:05:15 +00:00
Dmitriy Novozhilov 727d2f46f8 [FIR] Part 1. Group checkers by the MPP kind
This commit introduces MppChecker kind, which represents the new property
  of checkers
- `MppCheckerKind.Common` means that this checker should run from the same
  session to which corresponding declaration belongs
- `MppCheckerKind.Platform` means that in case of MPP compilation this
  checker should run with session of leaf platform module for sources
  of all modules

An example of a platform checker is a checker that checks class scopes
  and reports ABSTRACT_NOT_IMPLEMENTED and similar diagnostics. If some
  regular class in the common module contains expect supertypes, the
  checker should consider the actualization of those supertypes to get
  a complete type scope

^KT-58881
2024-01-24 10:44:59 +02:00
Sergey.Shanshin 96d7dc4fa6 [KxSerialization] Fixed access private custom serializer on property
When a custom serializer is specified on a type and this type is used in a property of another serializable class, then on the JVM this leads to an error accessing the custom serializer class - because it is private and located in another package.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2495


Merge-request: KT-MR-12877
Merged-by: Sergei Shanshin <Sergey.Shanshin@jetbrains.com>
2024-01-16 20:04:17 +00:00
Vladimir Sukharev 07938205bc [FIR][K/N] Get rid of SymbolInternals in FirObjCInterop 2024-01-16 09:39:16 +00:00
Nikolay Lunyak f7f5ac080f [FIR JS] Create an LT Box runner 2024-01-12 13:42:23 +00:00
Leonid Startsev fba2f5ea4e Expand most kotlinx.serialization tests on JS backend
to enhance and increase test coverage of the plugin.
2024-01-10 12:17:34 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Leonid Startsev 7700921646 Add K2 configurations for specific kotlinx.serialization tests
#KT-64447 Fixed
2024-01-05 11:38:35 +00:00
Dmitriy Novozhilov c2cbbecfe9 [K2 Serialization] Store serializable properties in metadata extension
This solution is temporary (see KT-64694 for details)

^KT-64312 Fixed
2024-01-05 11:30:57 +00:00
Mads Ager e41a1247e2 JVM_IR: Generate more line numbers for intrinsic comparisons.
Otherwise, if complex expressions such as when expressions are
used in combination with the intrinsics we get incorrect stepping
behavior.

^KT-64341 Fixed
2023-12-20 15:39:03 +00:00
Leonid Startsev 6c6f2ccacd Handle non-reified type parameters of function inside serializer<T>() intrinsic
to match an error message thrown from KType-based serializer<T>().

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2528
2023-12-20 13:50:39 +00:00
Sergej Jaskiewicz 1b557c1657 [IR] Mark IrExpressionBodyImpl with an opt-in annotation
KT-59318
2023-12-19 16:20:02 +00:00
Sergej Jaskiewicz f844a86057 [utils] Introduce the bind function and use it throughout 2023-12-13 10:04:45 +00:00
Leonid Startsev a03fd2e29a Make visibilities of writeSelf and deserialization constructor in FIR
same as they were in K1 (see KSerializerDescriptorResolver): internal for
final classes and public for non-final.

Unfortunately, there are no Klib API dumps tests in the compiler, so I tested manually.

#KT-64124 Fixed
2023-12-12 09:02:14 +00:00
Alexander.Likhachev a19bd2ed2e [Build] Migrate most of the build logic from Project.buildDir usage
It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
2023-12-07 18:31:06 +00:00
Dmitrii Gridin c5cba4c053 [FIR] builder: provide containingDeclarationSymbol
We cannot use only non-local declarations as anchors due to the same
resolution logic between member declarations of local classes, so we
have to support such cases as well

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitriy Novozhilov 139e1223ea [Serialization] Workaround registering static writeSelf method in metadata
`IrGeneratedDeclarationsRegistrar` assumes that all generated functions
  are correct from a Kotlin point of view. But `writeSelf` method on JVM
  is a static method outside any object/companion object

So to properly calculate containing class for this method we should
  generate a dispatch receiver parameter, register the method in metadata,
  and then remove the parameter (to make function static)
2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov 51dcd7c076 [Serialization] Introduce utility for generation of IR annotation calls 2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov c70c8f927e [FIR] Remove FirDeclarationsForMetadataProviderExtension extension
`IrGeneratedDeclarationsRegistrar` should be now used instead to register
  IR declarations in resulting metadata
2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov d94ce4dcb8 [Serialization] Migrate to IrGeneratedDeclarationsRegistrar API
^KT-63591 Fixed
2023-12-05 10:21:39 +02:00
Dmitriy Novozhilov 1cdc8361d6 [IR] Rename IrAnnotationsFromPluginRegistrar to IrGeneratedDeclarationsRegistrar
In further commits, this service will be used not only for registering
  annotations, but newly generated IR declarations too
2023-12-05 10:21:27 +02:00
Leonid Startsev 662bff7351 Make $serializer generic constructor public
If a serializable class has generic type parameters, its serializer is not an object
and has a specialized constructor. This constructor was public in K1 and should
be public in K2 so it can be called from other serializable classes
(in case class is e.g., part of sealed hierarchy).

#KT-63402 Fixed
2023-11-28 13:31:08 +00:00
Leonid Startsev 51e3e9af94 Use a correct type for SERIALIZER_TYPE_INCOMPATIBLE diagnostic.
This diagnostic used an incorrect type for rendering (outer class type instead of a property type)
and didn't expand type argument of `KSerializer`.

Also add an additional test case for generic parameters.

#KT-63570 Fixed
2023-11-28 13:30:45 +00:00
Leonid Startsev f7d87f6d70 Use type parameters' source information for kotlinx.serialization diagnostics
To be more consistent with K1, certain diagnostics should be reported
not on the whole properties' types, but on type arguments inside them.

Note that there is still a difference with K2 because K2 reports on a type argument
including its annotations, while K1 used KtTypeReference.typeElement.

IMO, K2 conveys the same or better meaning here, so I am willing to leave this
difference instead of providing PositioningStrategy.

#KT-53861 Fixed
2023-11-27 13:32:44 +00:00
Vyacheslav Gerasimov fbc35975ab Build: Fix kotlinx-serialization-compiler-plugin compat artifacts
To avoid adding unexpected files we should add single file into
artifacts instead of directory.
 #KTI-1394
2023-11-20 14:37:54 +00:00
Ivan Kochurkin 7ce0284e81 [FIR] Introduce isRealOwnerOf utility function 2023-11-15 17:56:03 +00:00
Iaroslav Postovalov a3b55cf758 [IR] Drastically simplify the hierarchy of IR origins
IrStatementOriginImpl and IrDeclarationOriginImpl were made final
classes to simplify the creation of them (a delegate provider was
added) and to optimize performance when comparing the origins by type
and name
2023-11-13 17:56:09 +00:00
Leonid Startsev 4fa121071a Update kotlinx-serialization dependency for serialization compiler plugin tests.
Properly set up dom-api-compat dependency for JS IR tests. Since this dependency is added
automatically for every Kotlin/JS library, it should be present during tests just as stdlib.

As a result, tests for serializable enums were changed since 1.6.0 runtime does not require enums to be explicitly serializable.
2023-11-10 14:14:04 +00:00
Dmitriy Novozhilov fb8bf19091 [IR] Rename IrSymbolInternals to UnsafeDuringIrConstructionAPI
The new name more precisely describes the meaning of this opt-int
2023-10-25 11:32:46 +00:00
Mikhail Glukhikh cebb6747e3 K2: drop unnecessary attributes when inferring declaration types
Related to KT-62578
2023-10-20 12:38:19 +00:00
Mikhail Glukhikh 4ed7504d87 FIR deserializer: apply attributes on type parameter-based types
#KT-62578 Fixed
2023-10-18 10:30:31 +00:00
Leonid Startsev dcfc20f1ff Do not attempt to get field initializer if it is not available.
This may happen on Native if the property is in another module.

#KT-62522 Fixed
Related to: KT-62523
2023-10-13 14:27:36 +00:00
Svyatoslav Kuzmich 0295057520 Refactor: extract test generation regexp into a common util object 2023-10-12 13:26:58 +00:00
Mikhail Glukhikh 9d3bf69212 Raw FIR/LT: use similar sources for delegated constructor calls
After this commit all IR source range tests behave in the same way
for FIR/PSI and FIR/LT, test data is now consistent
2023-10-10 13:38:52 +00:00
Alexander Udalov 72b5123fc8 JVM: reduce usages of GenerationState in favor of JvmBackendConfig
To help in decoupling JVM IR from the old JVM backend.
2023-10-02 14:58:23 +00:00
Nikolay Lunyak ec9cb8beb6 [FIR] Rename JvmNames -> JvmStandardClassIds
This is more consistent with the code of
the common compiler checkers.

It would be nice to refactor the contents
of this object further, but it's out
of scope of the current branch.

^KT-54596
2023-09-19 22:14:09 +00:00
Nikolay Lunyak 986f1624ec [FIR] Remove jvm-specific annotations from common compiler code
^KT-54596 Fixed
2023-09-19 22:14:09 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +00:00
Alexander.Likhachev 6f96be0b76 [Build] Get rid of the testApiJUnit5 method
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Dmitriy Novozhilov e4a51dfa1b [Serialization] Don't report errors on properties from supertypes
^KT-53926 Fixed
2023-09-01 09:35:43 +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
Dmitriy Novozhilov efb96e31fb [FIR] Fix implementation of primaryConstructorSymbol utility
Originally it used list of declarations, which is incorrect, because
  some constructors may be contributed by compiler plugin. And those
  constructors will be contained only in scope
2023-08-21 13:51:12 +00:00