Commit Graph

577 Commits

Author SHA1 Message Date
Nikolay Lunyak a9343aeb7d [FIR] KT-55840: Ensure everything actually works
This inconsistency is present due to not using the `// WITH_STDLIB`
in the above tests. When K1 creates the enum, it tries to generate
`entries()`, and for that it tries to load `kotlin.enums.EnumEntries`,
but this is actually an unresolved reference. K1 silently swallows it,
and proceeds.

The reason K2 doesn't fail is that in order to generate `entries()` it
simply creates the necessary `ConeClassLikeType` with the desired
`classId` instead of loading the whole `ClassDescriptor`.

The reason we can still observe `$ENTRIES` and `$entries` in K1
is because they are generated during the JVM codegen, and it
only checks if the `EnumEntries` language feature is supported. It
doesn't check if the `entries` property has really existed in IR
(by this time it's expected to have already been lowered to the
`get-entries` function - that's why "has ... existed").

The reason why the codegen doesn't fail when working with
`kotlin.enums.EnumEntries` is because it creates its
own `IrClassSymbol`.

^KT-55840 Fixed

Merge-request: KT-MR-8727
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-10 16:57:51 +00:00
Pavel Mikhailovskii 4c7f8ba196 KT-56457 Annotate Enum.entries with @NotNull 2023-02-09 20:13:56 +00:00
Alexander Udalov 1844869e8a Kapt+JVM_IR: fix ordering of properties in generated stubs
Apparently it depended on the ordering of the synthetic `$annotations`
methods generated for properties. And those methods were always
generated at the end of a Java stub by kapt because they lacked PSI
element, and thus `ClassFileToSourceStubConverter.convertClass` could
not compute their source position, and it placed them at the end as all
other synthetic methods.

The solution is to provide PSI element for `$annotations` methods in
JvmDeclarationOrigin. This origin is then collected in kapt in
`OriginCollectingClassBuilderFactory` and used for sorting, as in the
case of the old JVM backend.

 #KT-56360 Fixed
2023-02-06 21:34:10 +00:00
Alexander Udalov 94f1c579df Kapt+JVM_IR: do not generate SuspendFunction supertypes
#KT-54380 Fixed
2023-02-02 15:01:43 +00:00
Anna Kozlova 48b1456290 [CLI] create ArgumentParseErrors instances on request
spare memory for projects with big number of modules
currently 500kb for IJ monorepo of mostly empty errors
2023-01-31 16:08:23 +00:00
Alexander Udalov 2849e45111 Kapt tests: change _ir.txt to .ir.txt
To be consistent with test data of other compiler tests.
2023-01-31 13:49:44 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +00:00
Alexander Udalov 4b0d878873 Change KaptFlag.USE_JVM_IR default value to true
According to the comment on `Kapt3GradleSubplugin.BooleanOption` and the
change in a7b1bade85.

 #KT-53135
2023-01-26 12:07:19 +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
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
Mikhail Glukhikh 7a61578e08 Language version 2.0: fix compiler messages and minor details 2023-01-16 18:16:48 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01: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
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
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Alexander Udalov a594434a95 Kapt+JVM_IR: do not run IR plugins in kapt mode
Because in kapt stub generation mode (aka ClassBuilderMode.KAPT3, aka
generateBodies=false in psi2ir), method bodies are not generated and
compiler plugins such as kotlinx-serialization might not expect that.

 #KT-54245 Fixed
2022-12-07 21:14:30 +00:00
Alexander Udalov 5848b2fde6 Kapt+JVM_IR: add IrKotlinKapt3IntegrationTest 2022-12-07 21:14:29 +00:00
Andrey Uskov 41ff283856 Don't call File.getCanonicalPath in KGP
Relates to KT-54579.
2022-12-04 18:49:30 +00:00
Andrey Uskov ca8f234f28 Improve performance of KAPT on JDK 17
Getting canonical path is expensive on JDK 17, thus check, whether
file is belongs to some folder becomes expensive.
In this commit implementation was replaced to a new one based on
File.getParent. It gives profit 49seconds-> 500 ms/100k files.
Note! Now if there are present two files which are actually links of the
same file, they are treated as two different files.
#KT-54579 Fixed
2022-12-04 18:49:30 +00:00
Vyacheslav Gerasimov 50ad5027fe Build: Fix kotlin-annotation-processing pom dependencies
#KTI-878
2022-12-01 15:50:38 +01:00
Mads Ager 30002e29d1 [KAPT+JVM_IR] Do not generate initializers for delegated properties.
^KT-54870 Fixed
2022-11-28 22:27:09 +01:00
Alexander Udalov c813e03c1e Kapt+JVM_IR: do not generate nested enum as final
#KT-54187 Fixed
2022-10-24 12:48:22 +00:00
Daniel Santiago 189be2b117 [KAPT] Setup KaptJavaLog writers during initialization.
Migrate KaptJavaLog to not used deprecated constructor in newer JDKs and instead set up the writers during initialization. This enables us to get rid of KaptJavaLog17.

Fixes KT-54030
2022-10-11 23:48:18 +02:00
Nicklas Ansman Giertz b02948b5f7 KAPT: Kapt generates illegal stubs for private interface methods
Interface methods that were private got both the `default` and `private`
modifiers when using `jvm-default=all` which is not valid.

The stub will now just contain `private` in this case.

This fixes KT-48013.
2022-09-26 12:21:56 +02:00
Nikolay Krasko 1630386712 Move to JDK_X_Y variables 2022-09-21 22:53:19 +00:00
Vladimir Sukharev c8864369fd Use main class as test generator name
Merge-request: KT-MR-7031
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-09-09 12:51:18 +00:00
Nikita Bobko 70ed76e0bd Drop unused ':dist' dependency in some tests
Review: https://jetbrains.team/p/kt/reviews/6753

This commit doesn't fix any issue except for "cleanup". If you find a
mistake in this commit feel free to revert part of it/the whole commit

I checked every module where I drop ':dist' dependency. Tests still pass
in those modules
2022-08-22 15:42:34 +02:00
Dmitry Gridin 4ceb170917 regenerate tests 2022-08-05 14:12:41 +02:00
Dmitriy Novozhilov af8caae387 [KAPT] Fix formatting 2022-07-20 10:12:25 +00:00
Dmitriy Novozhilov 8b960de76a [KAPT] Add additional test tasks for running tests on JDK 11 2022-07-20 10:12:24 +00:00
Dmitriy Novozhilov 9c41e75802 [KAPT] Migrate kapt tests to new test infrastructure 2022-07-20 10:12:24 +00:00
Dmitriy Novozhilov fdf1b8b1c0 [KAPT] Migrate tests in kapt3-base and kapt3-cli to JUnit 5 2022-07-20 10:12:24 +00:00
Alexander Udalov bd0fe2f146 Remove dependency of compiler tests on fir2ir tests
Compiler tests use the old test infrastructure, but fir2ir tests use the
new one (tests-common-new). Removing this dependency means that now the
two big modules, `:compiler:compileTestKotlin` and
`:compiler:tests-common-new:compileTestKotlin` can be compiled in
parallel, which improves the total build time.
2022-07-18 13:13:01 +02:00
Dmitriy Novozhilov 1a8496757e [Compiler] Mark all entrypoints to compiler API as experimental 2022-06-29 12:00:01 +00:00
Dmitriy Novozhilov f587c02d38 [FE] Move ServiceLoaderLite to :compiler:frontend.common
This is needed to be able to use this class inside FIR part of IDE plugin
2022-06-29 12:00:00 +00:00
Dmitriy Novozhilov c979e1edcf [Plugins] Deprecate ComponentRegistrar
^KT-52665 In Progress
2022-06-29 11:59:58 +00:00
Pavel Mikhailovskii c3c09aa95a KT-4107 Data objects 2022-06-28 16:58:20 +02:00
Mikhael Bogdanov 162ca4ac2b KAPT+IR: support IR error types
#KT-49682
2022-06-20 11:42:53 +00:00
Simon Ogorodnik e3c7929fee KT-52284 Clarify message in Kapt with K2 error 2022-06-20 10:39:25 +00:00