Commit Graph

174 Commits

Author SHA1 Message Date
Brian Norman 6bf987e772 [AllOpen] Do not open members of non-class type classes
The logic of the AllOpen compiler plugin for opening classes and opening
declarations of classes does not match. This leads to declarations being
open when the containing class is not open. There is a warning reported,
for exactly this situation.

However, creating meta-annotations of AllOpen annotation is quite common
in certain ecosystems. In particular, Spring. This can lead to a warning
if the meta-annotation has properties.

Align the class kind check for members, so they are not opened if the
containing class cannot be opened.

^KT-63507 Fixed
2024-03-08 14:55:39 +00:00
Brian Norman bdaacb9427 [AllOpen] Test case to recreate open annotation member warning
The AllOpen compiler plugin opens all declarations of the annotated
class, regardless of class type. However, it only opens classes (not
interfaces, objects, enums, etc). This leads to a warning where members
of an annotation are open when annotated. Spring has many such
annotations, as it is common to create meta-annotations from the core
set of AllOpen supported annotations.

^KT-63507
2024-03-08 14:55:39 +00:00
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Alexander Udalov 968dfddbc9 Tests: adjust test data for bytecode listing tests
- remove obsolete `IGNORE_BACKEND: JVM` directives
- move contents of .ir.txt files to the corresponding .txt
2023-11-02 10:59:29 +00:00
Alexander Udalov 1cf04916d6 Tests: remove bytecode listing tests for old JVM backend
These tests are mostly used to check ABI in case you're compiling a
library or library-like code, which is no longer possible (since old JVM
backend is only used in the IDE).
2023-11-02 10:59:29 +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
Dmitrii Gridin 7620289f6f [FIR] fix contract violation from meta annotations
^KT-60448 Fixed
2023-07-18 16:50:25 +00:00
Brian Norman 70662007a5 [AllOpen] Private properties can be considered stable even when open
The AllOpen plugin can make private members open. But for private
properties, they can be considered stable for smart-casting if they do
not have a custom getter.

#KT-58049 Fixed
2023-07-17 11:49:24 +00:00
Nikolay Lunyak e3d313dd02 [FIR] Introduce the proper Fir2IrResultsConverter
Sometimes when running MPP tests we may
observe js-specific modules running with
the jvm-specific fir2ir converter
(probably because the name didn't contain
the JVM affix).
2023-04-25 11:29:34 +00:00
Nikolay Krasko 9e00bb8a21 [213] More dependencies aalto + stax2
KTI-1114
2023-04-21 13:19:05 +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
Alexander Udalov 562b27db4e JVM IR: initialize enum entries without invokedynamic
#KT-57316 Fixed
2023-03-24 13:38:32 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00
Ilya Kirillov 69c024a5ce [FIR] optimize deprecation calculation for symbols
All symbols except member callables can be deprecated if they have non-empty annotation list

^KT-56800 fixed
2023-02-24 16:10:57 +01:00
Dmitriy Novozhilov da581f38e1 [Test] Require specifying parser for FIR test. Unify names for FIR tests
Now all tests with `Fir` in name are named accordingly to parser which
  is used in them -- `FirPsi` or `FirLightTree`. This is needed to keep
  consistency between different types of tests, because there is no
  single default in parser mode between different scenarios of using FIR
2023-02-24 11:15:26 +00:00
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
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +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
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
Steven Schäfer 6af616d3c3 FIR: make declarations marked with 'override' implicitly open
#KT-52236 Fixed
2022-12-14 21:46:41 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Dmitriy Novozhilov 6b343515e1 [Test] Save IR bytecode dumps from BytecodeListingHandler to .ir.txt file instead of _ir.txt
This is needed to keep consistency with other dumps and to allow
  test helper plugin to recognize those dumps
2022-12-01 07:29:37 +00:00
Dmitriy Novozhilov 246dc985a6 [FIR] Rework predicates system
Now predicates are split into LookupPredicate and DeclarationPredicate
  hierarchies. First one allows to perform global search for declarations
  and second one allows to check if some declaration matches the predicate.
Predicates with meta annotations are excluded from LookupPredicates,
  because it's impossible to create index of annotations with meta-annotations,
  because they can be located inside binary dependencies (so to achieve
  this we need to scan the whole classpath).
Also only one predicate with meta-annotations is left in DeclarationPredicate
  hierarchy (AnnotatedWithMeta)

^KT-53874 Fixed
^KT-53590 Fixed
2022-12-01 07:29:37 +00:00
Dmitriy Novozhilov ebc879ed1e [AllOpen] Update testdata 2022-12-01 07:29:36 +00:00
Dmitriy Novozhilov 700a117476 [Build] Add forgotten compiler plugins tests to aggregate build 2022-12-01 07:29:35 +00:00
Nikolay Lunyak 4b3dc008f0 [FIR] KT-54260: Fix the compiler crash
AllOpen plugin makes the properties all-open, but the annotation class
is left closed, because allopen for k2 literally checks
`classKind == CLASS`.

Since the properties are open, a
`NON_FINAL_MEMBER_IN_FINAL_CLASS` diagnostic is reported for them. It's
positioning strategy seeks for the explicit `open` modifier which is
not present.

The added test should not crash the compiler.

^KT-54260 Fixed
2022-11-22 20:25:38 +00:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01: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 8f79e833a8 Drop all redundant kotlin-reflect, kotlin-reflect-api dependencies
Review: https://jetbrains.team/p/kt/reviews/6753

All redundant I managed to find, of course.

Why: I'm going to process all reflect dependencies in the next commits.
Cleanup reflect dependency before processing.

They are redundant because:
1. if `compileOnly` then compilation didn't break after dropping the
   dependency
2. if `test*` then tests didn't break after dropping the dependency.
3. `analysis/analysis-api-fir/analysis-api-fir-generator/build.gradle.kts`
   `compiler/fir/checkers/checkers-component-generator/build.gradle.kts`
   Drop `implementation(project(":kotlin-reflect-api"))` because the
   module already depends on
   `implementation(project(":kotlin-reflect"))`
4. `compiler/daemon/daemon-client/build.gradle.kts`. Drop `runtimeOnly`
   because after dropping `compileOnly` compilation didn't break (so
   `runtimeOnly` looks suspicious). Less safe than 1-3
2022-08-22 15:42:57 +02:00
Dmitry Gridin 4ceb170917 regenerate tests 2022-08-05 14:12:41 +02:00
Dmitriy Novozhilov 1a8496757e [Compiler] Mark all entrypoints to compiler API as experimental 2022-06-29 12:00:01 +00:00
Dmitriy Novozhilov 8b42638afa [Plugins] Introduce new API for registering compiler plugins
Original `ComponentRegistrar` exposes Project to its registration method,
  so plugins should manually register extensions to it. To prepare for
  possible unbound compiler from Project API in future new  `K2ComponentRegistrar`
  introduced which provides registration method without Project at all
2022-06-29 11:59:58 +00:00
Pavel Mikhailovskii ecb3cc193c KT-51883 Don't use "-" in generated unique lifted declaration names 2022-06-10 18:36:04 +00:00
Dmitriy Novozhilov 66c2679673 [Plugins] Extract parts of cli modules which were used from IDE into common modules
This is needed to avoid IDE dependencies on cli modules, because they
  include FIR classes, which are inaccessible in regular Kotlin IDE plugin
2022-06-07 14:12:26 +00:00
Dmitriy Novozhilov 23c69f8d17 [FIR] Add to new types of annotation predicates
- `ParentAnnotatedWith` matches declarations, which parent is annotated
- `HasAnnotatedWith` matches declarations, which have at least one
     direct child with annotation

Also, `DeclarationPredicate.Any` is removed, because there is no
  intention to support lookup for all declarations in module

^KT-52486 Fixed
2022-06-07 14:12:22 +00:00
Dmitriy Novozhilov 8acb8aa043 [FIR] Introduce utility service for plugins for matching common predicate pattern 2022-06-07 14:12:17 +00:00
Dmitriy Novozhilov 2a7dc1cc0c [AllOpen] Reorganize module structure of AllOpen plugin
This scheme will be common for all compiler plugins with K1 and K2 support:
- `plugin-common` contains classes shared with K1 and K2 implementations (if any)
- `plugin-k1` contains implementation for K1 compiler
- `plugin-k2` contains implementation for K2 compiler
- `plugin-backend` contains implementation for backend extensions (if any)
- `plugin-cli` is module for registration of plugin in CLI compiler
- `plugin` is a root module with tests and all submodules embedded

This structure is needed to distinguish parts related to different frontends,
  which is needed for proper dependencies settings for Kotlin IDE plugins
2022-06-07 14:12:15 +00:00
Dmitriy Novozhilov 22ebea8174 [FIR] Support FIR version of all-open plugin 2022-06-07 14:12:14 +00:00
Dmitriy Novozhilov b0c2332b4c [AllOpen] Fix package structure 2022-06-07 14:12:11 +00:00
Dmitriy Novozhilov 01664da0a3 [AllOpen] Migrate AllOpen tests to new test infrastructure 2022-06-07 14:12:11 +00:00
Vyacheslav Gerasimov f7a9065b75 Build: Use intellij maven repo instead of downloaded IDEA
#KTI-82
2021-12-16 21:48:23 +03:00
Vyacheslav Gerasimov bc2f0936bd Build: Rename commonDep -> commonDependency 2021-12-16 21:48:19 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Victor Petukhov 3530840da3 Don't report TAILREC_ON_VIRTUAL_MEMBER on private opened functions instead of leaving private members final by allopen plugin
^KT-48117 Fixed
2021-09-30 20:08:49 +03:00
Victor Petukhov c3773d14bb Revert "[all-open] Don't affect private declarations to change their modality to open"
This reverts commit baeee8988e.
2021-09-30 20:08:48 +03:00
Dmitriy Novozhilov e933c7b6d9 [Build] Remove testApi(intellijDep()) dependencies from all modules
Since IDEA moved most of it's jars to java 11 it's illegal to use them
  in our dependencies, so all modules which use `intellijDep()` should
  carefully specify which jars they use
2021-09-30 14:41:31 +03:00