Commit Graph

59 Commits

Author SHA1 Message Date
Nikita Bobko c42d19f0e5 Cover KT-60646 with regression tests
This behavior wasn't intended during KT-15470 coding. I only intended to
prohibit `@get:` target on things different from properties. But I
accidentally prohibited `@property` on things different from properties
too

But it's a bug fix anyway, so let's keep it.

I also re-checked the implementation of KT-15470, I don't see any other
unintentional prohibitions
2023-08-23 12:35:51 +00:00
Alexander Udalov 40c628d431 FIR: fix order of property accessor annotations
#KT-57219 Fixed
2023-05-22 20:12:29 +00:00
Nikita Bobko 48ed6c4cc7 2/2 Implement deprecation for use-site '@get:' target
^KT-15470 Fixed
Review: https://jetbrains.team/p/kt/reviews/9250
2023-03-21 13:29:10 +01:00
Nikita Bobko 8cf5216555 1/2 Refactoring: split GetterAnnotations & PropertyAnnotations tests for K1 and K2
These tests won't be FIR_IDENTICAL after the next commit. That's why I
split them prematurely. This allows me to have a nicer diff in `2/2`
commit.

In scope of KT-15470
Review: https://jetbrains.team/p/kt/reviews/9250
2023-03-21 13:28:55 +01:00
Nikolay Lunyak 1378d730d6 [FIR] Forbid all use-site targets of FirTypeRef annotations 2023-03-07 11:35:47 +00:00
Nikolay Lunyak 93ba0c3e70 [FIR] KT-56769: Ensure @receiver: is only allowed on receivers
Note that there's no code that checks that
FirReceiverParameter's annotation's use-site target
is indeed `@receiver:`, because otherwise the
annotation wouldn't have made it into
the FirReceiverParameter.

In contrast, in K1 all such annotations are treated
as annotations on a KtTypeReference.

^KT-56769 Fixed
2023-03-07 11:35:46 +00:00
Victor Petukhov 27fa632630 [FE 1.0] Update test data with new error type representation 2022-03-23 21:13:33 +00:00
Mikhail Glukhikh 7243d30869 Split property use-site targets during FIR building 2021-10-12 16:22:58 +03:00
Ivan Kochurkin 55f33999f1 [FIR] Add REPEATED_ANNOTATION, REPEATED_ANNOTATION_WARNING 2021-09-10 00:49:07 +03:00
Dmitriy Novozhilov b584fed93d [FIR] Migrate warning/error pairs to DiagnosticFactoryForDeprecation 2021-08-03 00:20:11 +03:00
Dmitriy Novozhilov d17f984edf [FE 1.0] Migrate most of warning/error pairs to DiagnosticFactoryForDeprecation 2021-08-03 00:17:33 +03:00
Mikhael Bogdanov ff26a471b4 Update diagnostics test affected by ApproximateIntegerLiteralTypesInReceiverPosition and ProhibitSimplificationOfNonTrivialConstBooleanExpressions features 2021-07-20 12:19:57 +00:00
Dmitriy Novozhilov 3fc7e0ed03 [FIR] Remove COMPARE_WITH_LIGHT_TREE from default directives of fir diagnostic tests 2021-05-20 20:20:40 +03:00
Mikhail Glukhikh 6dd41b617a FIR: position INAPPLICABLE_FILE_TARGET on file use-site (when possible) 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh 6572010eed Introduce use-site annotation target checks for FIR 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh 9a13ec9b76 FIR: report WRONG_ANNOTATION_TARGET on types 2021-05-20 12:22:22 +03:00
Mikhail Glukhikh 2a33a6927c FIR: report WRONG_ANNOTATION_TARGET(_WITH_USE_SITE_TARGET) on declarations 2021-05-20 12:22:21 +03:00
Mikhail Glukhikh 4b00a43b22 FIR: add ANNOTATION_ON_SUPERCLASS diagnostic 2021-05-20 12:22:20 +03:00
Dmitriy Novozhilov cd890d5833 [Test] Disable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite 2021-03-29 16:12:29 +03:00
Jinseong Jeon e009b71f88 FIR checker: report uninitialized member/extension properties 2021-03-04 17:56:29 +03:00
Dmitriy Novozhilov 2536fa0cd5 [FIR-TEST] Add new testdata generated after changes in previous commit 2019-12-12 16:11:46 +03:00
Dmitriy Novozhilov 677987c85f Add diagnostics on annotations on super types. KT-23992 fixed 2019-02-22 10:28:21 +03:00
Dmitriy Novozhilov 1fc6f30c50 Add test for KT-23992 2019-02-22 10:22:19 +03:00
Dmitriy Novozhilov 92bd907983 Fix checking repeatablilty of use-site target annotations. KT-26638 fixed 2019-02-22 10:15:37 +03:00
Dmitriy Novozhilov cfda468f13 Add test for KT-26638 2019-02-22 10:15:37 +03:00
Alexander Udalov 4692247897 Do not check backing field presence in AnnotationSplitter
This code can be invoked early, during body resolution and before the
fact that a property has backing field (which is only known for certain
after body resolution, because an implicit 'field' identifier may be
used). Since split annotations are cached until the end of the program,
they may end up on incorrect elements in the bytecode (or disappear
completely) as in KT-29507 or KT-28182.

Because the FIELD target has the lowest priority among implicit
annotation targets (see TARGET_PRIORITIES), it's safe to always assume
that FIELD is a valid target when splitting annotations. This only
changes the way annotations are split in case of incorrect code, as
changes in test data show.

 #KT-28182 Fixed
 #KT-29507 Fixed
2019-02-15 17:53:27 +01:00
victor.petukhov 46bd5ba107 Add alphabetical sorting diagnostics with same ranges 2019-02-14 12:31:42 +03:00
Alexander Udalov d1e1e274d9 Render property accessor annotations in .txt test data
If property accessor rendering is disabled in a test, render annotations
on accessors as use-site-targeted, as was done with
`@setparam:`-annotations. Otherwise they were lost
2018-10-24 18:17:12 +02:00
Alexander Udalov f9b9b6908a Remove use-site targeted annotations from LazyAnnotations
LazyAnnotations are only used for classes and files, and in the latter
case it will now contain file annotations as normal annotations, without
the target "file:"
2018-09-06 19:13:15 +03:00
Alexander Udalov 87c0d56618 Drop Annotations.getAllAnnotations 2018-09-06 19:13:14 +03:00
Alexander Udalov fc87043cb3 Merge use-site targeted annotations into corresponding Annotations
Add PropertyDescriptor.backingField/delegateField to store annotations
on the field directly in an otherwise almost empty descriptor instance,
instead of storing them with use-sites in the corresponding property
descriptor. Instead of AnnotationWithTarget, create AnnotationDescriptor
instances in AnnotationSplitter. Change DescriptorRenderer to render
annotations on "related" declarations when needed, with the explicit
use-site target if applicable.

Most changes in diagnostic test data are related to the fact that
annotations which are known to have an incompatible use-site to the
declaration they're applied at (such as `@param:`-annotation on a
function), are now not loaded at all. It's fine because the code is
erroneous, so it doesn't really matter how do we load annotations with
invalid targets (some of this logic is also changed freely in subsequent
commits). Some changes are also explained by the fact that for example
an annotation on the property which is only applicable to FIELD is now
rendered with an explicit use-site target `@field:`, regardless of
whether it did have that use-site target syntactically or not.

Basically, after this change there's no point in calling
Annotations.getUseSiteTargetedAnnotations/getAllAnnotations anymore
because it's easier and more intuitive to just use Annotations of the
corresponding descriptor -- the backing / delegate field (introduced in
this commit) or the extension receiver / setter parameter (related
behavior was fixed in previous commits). Usages of
use-site-target-related methods will be refactored out in subsequent
commits
2018-09-06 19:13:11 +03:00
Mikhail Zarechenskiy de60c9b635 Fix language features in tests for gradual migration to 1.3 version 2018-07-02 12:13:11 +03:00
Mikhail Glukhikh e76debb12b Report UNUSED_PARAMETER in setter #KT-21129 Fixed 2018-05-04 18:04:57 +03:00
Mikhail Zarechenskiy effdfe8ec0 Prohibit incorrect annotations with use-site targets more precisely
#KT-21696 Fixed

The problem is coming from the fact that `AnnotationTarget.VALUE_PARAMETER` is mapped to receiver parameter and to value parameter, but annotation with use-site target `receiver` can be used only on type reference of receiver parameter
2018-03-22 04:03:08 +03:00
Mikhail Zarechenskiy e16d16fdb7 Do not report diagnostic about annotation with receiver target twice 2017-09-12 17:39:24 +03:00
Mikhail Zarechenskiy 2048a74302 Introduce Language Feature for annotations with wrong targets
#KT-9580 Fixed
2017-09-12 17:39:23 +03:00
Mikhail Zarechenskiy a4766cc293 Report errors on annotations with wrong use site targets
#KT-9580 In Progress
2017-09-12 17:39:22 +03:00
Mikhail Zarechenskiy 8f8143d3ed Fix IAE for wrong use-site @file annotation
#EA-100189 Fixed
2017-08-07 18:49:57 +03:00
Mikhail Glukhikh 5f3c1dfc41 More accurate check of repeated use-site annotations #KT-13859 Fixed 2016-12-28 19:01:20 +03:00
Valentin Kipyatkov ec51076355 DescriptorRenderer to render annotations for all types + separate option to render annotation arguments + use it in IdeDescriptorRenderers 2016-10-11 23:38:54 +03:00
Mikhail Glukhikh b78d481bb1 delegate use-site targeted annotations: parser, front-end, codegen with some tests #KT-10502 Fixed 2016-01-19 11:38:41 +03:00
Mikhail Glukhikh 474076a550 Annotation use-site refactoring: field, property, getter 2016-01-19 11:38:36 +03:00
Mikhail Glukhikh 3fb04aceb9 Check backing field availability for AnnotationTarget.FIELD #KT-10387 Fixed
Some duplicated checks deleted (UseSiteTargetChecker / JvmFieldApplicabilityChecker)
2015-12-17 15:06:58 +03:00
Alexey Tsvetkov dc27363452 Remove @annotation from test data 2015-10-19 20:45:01 +03:00
Alexander Udalov ec1b4776fe Deprecate PropertyMetadata, use KProperty<*> for delegated properties instead 2015-10-14 20:45:25 +03:00
Denis Zharkov f0e3fd617d Adjust testData to CharSequence.length transformation 2015-10-14 20:39:35 +03:00
Yan Zhulanow dc8e796e49 getValue()/setValue() should be marked with 'operator' 2015-10-14 01:29:09 +03:00
Yan Zhulanow 1f2b4e20fe Replace get() and set() to getValue() and setValue() (property delegates) 2015-10-09 22:49:16 +03:00
Yan Zhulanow 9eeb89a6aa Rename sparam to setparam 2015-10-08 18:31:06 +03:00
Nikolay Krasko e92a95eebb Fix typo in extension 2015-09-28 15:58:54 +03:00