Commit Graph

3372 Commits

Author SHA1 Message Date
Nikolay Krasko 4f69f61ef7 Advance version of kotlinx serialization in imports-dumper
File separator are not escaped now, as there's no need to escape /
character in JSON strings.
2023-01-21 16:38:48 +00:00
Sergej Jaskiewicz 1f76d39e66 [IR] Make IrTypeArgument a sealed interface 2023-01-20 10:58:28 +00:00
Ilya Goncharov d7c31f79a8 Do not suppress NPM related tasks, but be aware about checking of them in task graph 2023-01-19 13:43:57 +00:00
Leonid Startsev dc0cd61b6f Handle @Serializable classes that implement interfaces by delegation
by filtering out delegated properties that end up in irClass.properties() list

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2157
2023-01-19 11:12:31 +00:00
Sergey.Shanshin d063db3ce0 Fixed missing fallback serializer in contextual serializer
Fixes Kotlin/kotlinx.serialization#2158

Merge-request: KT-MR-8338
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-01-18 15:47:26 +00:00
Alexander Likhachev 87db928b2d [IC] Support precise output backup for jvm-abi-gen plugin
#KT-49785 In Progress
2023-01-17 22:15:53 +00:00
Alexander Likhachev 4c2923f96f [IC] Support precise output backup for kapt stubs
#KT-49785 In Progress
2023-01-17 22:15:53 +00:00
Alexander Udalov 3197a118ab Update jvm-abi-gen to kotlinx-metadata-jvm's Km* node API 2023-01-17 22:00:30 +01:00
Alexander Udalov 5ef372aab5 Update jvm-abi-gen to kotlinx-metadata-jvm 0.6.0 2023-01-17 21:59:54 +01:00
Dmitriy Novozhilov 259303ca50 [FIR] Fix loading of classId for nested enums in java annotation arguments
^KT-55887 Fixed
^KT-55976
2023-01-17 14:51:29 +00:00
Dmitriy Novozhilov da0dd519d0 [Lombok] Fix substitution of java types in K2 implementation
^KT-54020 Fixed
2023-01-17 14:51:29 +00:00
Dmitriy Novozhilov 4363b0815c [FIR] Add ability to specify if meta annotation itself should match metaAnnotated predicate
^KT-55843 Fixed
2023-01-17 14:51:28 +00:00
Nicklas Ansman Giertz 115bc6ac89 KAPT: Fix an ISE when processing unresolved generic types
Error types that are generic could sometimes throw an ISE when
generating the stub.

This fixes KT-43786
2023-01-17 11:40:13 +01:00
Nikolay Lunyak 23301e3369 [FIR] Remove annotations.any from FirParcelizeAnnotationChecker 2023-01-17 06:26:39 +00:00
Nikolay Lunyak f671a8c8a7 [FIR] Rename FirAnnotation.coneClassLikeType to unexpanded
The same reason
2023-01-17 06:26:36 +00:00
Nikolay Lunyak cf73d59e29 [FIR] Remove FirAnnotation.classId from FirParcelize
The same reasoning as with the serialization. If we
decide to support it, we wouldn't need to think
about unexpanded types.
2023-01-17 06:26:35 +00:00
Nikolay Lunyak 647cdb1c9a [FIR] FirSerializationPluginClassChecker
This change affects nothing, because @Serializable is checked during
COMPILER_REQUIRED_ANNOTATIONS when typealiases
are not yet resolved, but in case we change something
in the Future and want to support it, we'd have one less problem
2023-01-17 06:26:35 +00:00
Nikolay Lunyak 6a1c9e9279 [FIR] Support typealiases in FirAssignAnnotationMatchingService 2023-01-17 06:26:35 +00:00
Mikhail Glukhikh 7a61578e08 Language version 2.0: fix compiler messages and minor details 2023-01-16 18:16:48 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01:00
Ilya Chernikov d8650d9b04 Scripting: support compiler plugins in hosted script compiler
Now the plugin-related compiler arguments are respected then used in
the compiler configuration (only in the static part, not supported
if set in a refinement callback)
Note that the "embeddable" version of the plugin should be used if
embeddable compiler is used.
#KT-54095 fixed
2023-01-15 11:14:41 +01:00
Ilya Kirillov bba8064413 [FIR] mute lazy resolving contract check in a test where it was recently enabled 2023-01-13 15:57:06 +00:00
Ilya Kirillov a55b4a977b [FIR] refactoring: extract registration of lazy declaration resolve contract checking to a separate function in tests 2023-01-13 15:57:05 +00:00
Ilya Kirillov 747ab5fdb3 [FIR] get rid of FirFrontendFacadeForDiagnosticTests 2023-01-13 15:57:05 +00:00
Ivan Kochurkin 31e2f0ba95 [FIR][Serialization] Set containingClassForStaticMemberAttr in generateConstructors 2023-01-13 12:55:58 +00:00
Ivan Kochurkin 5d273ce839 [FIR & FIR2IR] Prepare test and CLI infrastructure to support MPP
- Move out getAnalyzerServices from FirFrontendFacade to TestSetupUtils
- Simplify DependencyListForCliModule. Now it takes BinaryModuleData as input
- FirOutArtifact contains several FirOutputArtifactPart
- Simplify FirFrontendFacade
2023-01-13 12:55:57 +00:00
Ivan Kochurkin 041f9c4700 [Testing] Simplify test functions 2023-01-13 12:55:56 +00:00
Alexander Udalov d85b23ebb9 Kapt+JVM_IR: do not attempt to transform error types in InsertImplicitCasts 2023-01-13 02:38:40 +01:00
Alexander Udalov 690fe7ac9a Kapt+JVM_IR: support error types in suspend functions
JVM IR generates the continuation parameter with the name `$completion`
instead of `continuation`.
2023-01-13 02:38:40 +01:00
Alexander Udalov 4f2551497d Kapt+JVM_IR: do not require KtFile for each generated class
In particular, JVM IR doesn't provide KtFile for a multifile facade in
JvmDeclarationOrigin (JVM backend provides KtFile of a random multifile
part). This led to multifile classes being completely ignored in the
JVM_IR version of kapt. Now they are generated correctly and the changed
test passes, but there's a _ir.txt expectation file because the order of
'foo' and 'bar' is different (which is not a problem).
2023-01-13 02:38:40 +01:00
Alexander Udalov 725c066c78 Kapt: dump declaration origins produced by backend
This will be useful in diagnosing behavior differences between JVM and
JVM_IR versions of kapt.
2023-01-13 02:38:40 +01:00
Alexander Udalov 6d0628900e Kapt+JVM_IR: support annotations with error types
This is a hack to implement KT-32596 in the JVM IR version of kapt.
Basically we allow psi2ir to generate annotations whose classifier is
error class, which happens when it's unresolved. Because there's no
physical IR for an error class, we create stub IR for it via
SyntheticDeclarationsGenerator in case we'll need it.

With this hack, annotations with unresolved classifiers magically
survive all the way until the codegen (with a minor change in
IrBasedDescriptors) where they are generated as
`@error.NonExistentClass`, which then gets corrected by the kapt's
"correct error types" mode as in all other cases of error types.
2023-01-13 02:38:40 +01:00
Alexander Udalov 4a91957ff0 Kapt+JVM_IR: fix "correct error types" mode for delegated properties
Use the property as PSI element origin for delegated property accessors
and field in JVM IR as it is done in the old JVM backend. Otherwise kapt
"correct error types" mode can't find the property type and thus cannot
succeed in "resolving" it, which led to java.lang.Object being used as a
fallback.

Note that in the unmuted test, .txt and _ir.txt dumps differ only in an
unrelated NotNull annotation on a delegate field.

See also KT-37586 for some related changes which fixed this problem
initially in kapt.
2023-01-13 02:38:40 +01:00
Alexander Udalov 549bfb2d9e Kapt+JVM_IR: generate annotation property initializers
#KT-55490 Fixed
2023-01-13 02:38:40 +01:00
Alexander Udalov 1a5aedd27a Kapt+JVM_IR: unignore some tests 2023-01-13 02:38:39 +01:00
Pavel Mikhailovskii 38a56ba8e8 KT-55308, KT-55769 Sort InnerClasses entries. Add DONT_SORT_DECLARATIONS directive 2023-01-13 01:07:10 +00:00
Dmitriy Novozhilov 1984a1615e [Serialization] Use new DSL for generating declarations 2023-01-12 17:45:41 +00:00
Dmitriy Novozhilov 5fedb2f72d [Parcelize] Use new DSL for generating declarations 2023-01-12 17:45:41 +00:00
Dmitriy Novozhilov 3744878b6d [FIR Plugin prototype] Use new DSL for generating declarations 2023-01-12 17:45:40 +00:00
Dmitriy Novozhilov 6783621eb0 [FIR] Change API for generating nested classes from plugins
`FirDeclarationGenerationExtension.generateClassLikeDeclaration` was split
  into two functions: one for generating top level classes, and one for
  nested classes. Such change reduces verbosity and error-proness of
  this extension and also allows to smoothly run plugins on local classes

^KT-55248 Fixed
2023-01-12 17:45:39 +00:00
Nicklas Ansman Giertz 22ab43838b KAPT: Skip importing java.lang.System in the stubs
This fixes KT-43117
2023-01-12 18:01:10 +01:00
Alexander Udalov 539f1b32a6 Minor, somewhat deduplicate code in ClassFileToSourceStubConverter 2023-01-12 02:13:08 +01:00
Nicklas Ansman Giertz 3c69a0493e KAPT: Fix error types for receivers and property setters in stubs
When using correct error types and there is a property setter or
receiver for an unknown type then the parameter type would be `Object` instead
of the error type.

This fixes KT-46965 and KT-46966
2023-01-12 02:13:08 +01:00
Nicklas Ansman Giertz dd051c1556 KAPT: Preserve the order of annotations in the stubs
Previously the annotations were included in reverse order. With this
change they are kept in the same order as in the source file.

This changes the test case for KT-23427 but that issue seems to relate
to annotation arguments that are missing, not the order of repeatable
annotations.

This fixes KT-51087
2023-01-11 22:01:22 +01:00
Ivan Kochurkin 978f937fa9 [FIR Serialization] Fix serialization of generated nested classifiers
^KT-55759 Fixed
2023-01-11 16:07:02 +01:00
Leonid Startsev 2634303055 Fix compilation error when @Serializable expect class has explicit companion
as it may have no primary constructor (only actual class has it).

Refactor & rename Fir2IrGeneratorUtils.kt as having 'Fir' in stacktrace
when actual K2 compiler is not used is very confusing.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2134
#KT-55683 Fixed
2023-01-11 13:00:15 +00:00
Kirill Rakhman 1b016d0bce FIR, Serialization: fix FirSerializationPluginClassChecker after DiagnosticsReporter refactoring related to reporting diagnostic on null source 2023-01-11 08:30:36 +00:00
Leonid Startsev bf60819824 Check for name when searching Companion.serializer() function to generate
Name check was forgotten during refactoring, so any user function with
matching signature could be overwritten by the plugin, while correct
function would not have body.

#KT-55682 Fixed
2023-01-09 18:43:10 +00:00
Leonid Startsev 0b4f534d35 Skip properties from Java classes for which the getter type is unknown
thus avoiding NPE when auto-generating external serializers.

#KT-55681 Fixed
2023-01-09 18:43:10 +00:00