Commit Graph

470 Commits

Author SHA1 Message Date
Nikolay Lunyak c656a83a02 [FIR] Don't miss non-const annotation args
This code with `b()` crashes the JVM
backend.

^KT-59822 Fixed
^KT-59874
2023-11-14 15:19:33 +00:00
Nikolay Lunyak 5a1a23afac [FIR] Don't miss annotations on inits
^KT-59874
2023-11-14 15:19:33 +00:00
Nikolay Lunyak 63f461a6cd [FIR] Don't miss annotations on for loops variables
^KT-59874
2023-11-14 15:19:32 +00:00
Dmitrii Gridin 28895a2613 [FIR] FirAnnotationArgumentsTransformer: fix scope problem with type parameters
We should wrap outer declaration to avoid FirTowerDataMode.CLASS_HEADER_ANNOTATIONS

^KT-63396 Fixed
2023-11-14 10:46:43 +00:00
Dmitrii Gridin 2ee9fcab9b [FIR] add diagnostic test for annotations inside type parameters
^KT-63396
2023-11-14 10:46:43 +00:00
Dmitrii Gridin a25bac4bf9 add tests on implicit type with inaccessible annotations
^KT-63042
2023-11-09 13:07:14 +00:00
Kirill Rakhman d91000e39c [FIR] Report INAPPLICABLE_CANDIDATE or more specific diagnostic for callable references
... instead of just UNRESOLVED_REFERENCE when something went wrong
during resolution.

#KT-59401 related
2023-11-08 15:45:48 +00:00
Ilya Chernikov 1ad4f19181 Fix default positioning strategy handling
that causes flaky tests because the default positioning strategy
was dependent on the order of the reported messages.
The code led to it was introduced in an attempt to extract common
PSI-independent strategy because PSI is leaking into the abstract
diagnostic infrastructure. The approach is definitely problematic,
but to fix it now, the leaking dependency to the psi-based module
is introduced. This should be fixed in the future by introducing
better abstractions.
Fixes flaky tests touched in the commit.
#KT-63002 fixed
2023-11-06 21:21:16 +00:00
Kirill Rakhman 2613a337ae [FIR] Improve symbol rendering in *_NOT_IMPLEMENTED diagnostics 2023-10-27 13:27:35 +00:00
Ivan Kochurkin bb937a8a21 [FIR] Initialize annotations in FirErrorTypeRef
^KT-62447 Fixed
^KT-62628 Fixed
2023-10-24 10:53:33 +00:00
Dmitrii Gridin d689c1a38f [FIR] FirJavaFacade: fix contract violation from annotations
`isJavaDeprecatedAnnotation` can't be used here because it triggers
the resolution of an annotation ClassId

^KT-62705 Fixed
2023-10-20 09:24:43 +00:00
Alejandro Serrano Mena b9b15cba08 [K2] Warn about deprecation and opt-in markers for overrides of Any
^KT-62620 Fixed

Include opt-in markers in the diagnostics
2023-10-18 12:34:58 +00:00
Dmitrii Gridin dfdd86da1f [FIR] do not capture class context during class annotations processing
^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin b03e3f0b0d [LL FIR] pass correct context during class annotation arguments mapping
The root cause of the problem is that we visit class annotations more
accurately than in the regular compiler transformer, so we have
a difference: the compiler assumes that annotation processing
of the class is called already inside this class, so it should enable
CLASS_HEADER_ANNOTATIONS mode to not capture extra context.
But we in LL FIR do this out of the class, so such context switching
is redundant and results in cutting out the outer class context

^KT-62587 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin bbd09c6272 [LL FIR] add tests for nested class as annotation argument
^KT-62587
2023-10-17 20:32:11 +00:00
Vladimir Sukharev 242c1cf5f0 [FIR] Fix disappeared REPEATED_ANNOTATION for dynamic types
https://youtrack.jetbrains.com/issue/KT-59916/K2-Disappeared-REPEATEDANNOTATION
FirAnnotationChecker does not detect repeated annotation on dynamic type, since FirTypeResolverImpl wrongly did not convert source annotations to attributes of ConeDynamicType.
This MR improves FirTypeResolverImpl to convert attributes of FirDynamicTypeRef to annotations and attach them to ConeDynamicType.

Merge-request: KT-MR-12551
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-17 10:18:36 +00:00
Nikolay Lunyak bc2eb546b4 [FIR] Report conflicts for data class generated members
^KT-59880
2023-10-11 08:54:09 +00:00
Brian Norman 79303ab2db [FIR] Ignore anonymous functions during annotation argument phase
Anonymous functions (lambdas) are not allowed as annotation arguments.
However, because it is still possible to parse code written this way, it
must be handled without exception. So ignore these expressions when
processing annotation arguments.

#KT-59565 Fixed
2023-10-09 20:03:33 +00:00
Dmitrii Gridin f124ba627d [FIR] implicit type: avoid redundant property and function transformations
This is a contract violation – we can touch only bodies during this phase

^KT-56551
2023-10-06 14:13:37 +00:00
Dmitrii Gridin 889c210576 [FIR] add more tests for implicit type phase
These tests demonstrate the implicit type phase problem - annotations
are also resolved, although they should not

^KT-56551
2023-10-06 14:13:36 +00:00
Ilya Kirillov d98da87278 [FIR] Render dot-separated FQNs instead of slash-separated ones in diagnostics
^KT-62030 fixed
2023-09-22 10:48:31 +00:00
Nikolay Lunyak 8755cf75ac [FIR] Improve the messages of the multiple defaults diagnostics
Mention the base functions where the default
values come from.
2023-09-21 07:48:30 +00:00
Kirill Rakhman 4e1dfcd2a8 [FIR] Improve readability of rendered types in diagnostics
#KT-61824 Fixed
#KT-61688 Fixed
2023-09-21 07:18:19 +00:00
Mikhail Glukhikh ffd77850ef K2: add proper catch parameter annotation targeting
In this commit we begin counting a catch parameter as
both a local variable and a value parameter for the purpose
of annotation targeting.

#KT-61691 Fixed
2023-09-13 11:27:14 +00:00
Mikhail Glukhikh 91aa679214 K2: reproduce KT-61691 2023-09-13 11:27:14 +00:00
Kirill Rakhman 1c446151e7 [FIR] Skip resolvable package names in front of UNRESOLVED_REFERENCE
#KT-55471
2023-09-04 08:05:08 +00:00
Kirill Rakhman 10f7989af6 [FIR] Report UNRESOLVED_REFERENCE on the first unresolved qualifier
#KT-55471 Fixed
2023-09-04 08:05:07 +00:00
Nikolay Lunyak 3f1bf6112f [FIR] Report MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES
Reporting it for `VIRTUAL_MEMBER_HIDDEN`
is ok, because `VIRTUAL_MEMBER_HIDDEN`
has always been an error, so we are
allowed to treat these as overrides
implicitly.

^KT-59408 Fixed
^KT-59419 Fixed
^KT-57076 Fixed
2023-08-28 10:57:40 +00:00
Nikolay Lunyak 6e732f2f4d [FIR] Report NON_SOURCE_ANNOTATION_ON_INLINED_LAMBDA_EXPRESSION
^KT-59422 Fixed
2023-08-23 12:39:23 +00:00
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
Kirill Rakhman 5b9c35de2e [Tests] Update test data with error suppression warnings
#KT-61129 Fixed
2023-08-18 13:29:20 +00:00
Nikolay Lunyak dc9ed5656e [FIR] Revert FirMultipleDefaultsInheritedFromSupertypesChecker
It's possible to write a fix that
would prevent false positives with
this checker, but the core
intuition behind it is invalid.

This checker assumes that it's
enough to only check direct
overriddens, while in reality
even simple `Source` override
functions are not allowed to
contain default values, so they
can't be used to make judgements
about them.

^KT-59408 Open
^KT-59408 Open

^KT-61095 Fixed
^KT-61165 Fixed
^KT-61029 Fixed
2023-08-17 13:55:19 +00:00
Nikolay Lunyak 61448531cb [FIR] Support MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES
^KT-59408 Fixed
2023-08-04 11:20:39 +00:00
Leonid Startsev 648c1f4599 Support instantiation of annotations with type parameters
By ignoring type parameters. Since type parameters in annotations are a
very limited feature, their sole use is to be able to specify them as
KClass argument: annotation class Foo<T: Any>(val bar: KClass<T>).
Since we can encounter type param only as a KClass type argument (and
never as a property type), simple approach of ignoring them works fine.
In that case, since we simply copy property types to synthetic
implementation class, its properties in IR start look like this:
annotation class FooImpl(override val bar: KClass<T of Foo>). This IR
seems to be not completely correct, since FooImpl.bar type contains T of
Foo param, which is out of its scope. However, so far I didn't
encounter any problems with this during testing and after MR discussion
this approach has been considered possible.

#KT-59558 Fixed
#KT-59036 Fixed
2023-07-26 17:16:13 +00:00
Kirill Rakhman 2f3293f99e [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument
A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
2023-07-20 07:29:18 +00:00
Dmitrii Gridin 4366164b65 [FIR] ConeAttributes: fix plus method
The 'plus' method was actually creating a new 'ConeAttributes' with
only one new attribute due to a typo inside 'buildList'

^KT-60451
^KT-60504
2023-07-19 10:40:03 +00:00
Mikhail Glukhikh c839cd3c11 K2: don't use debugging type renderer in error messages 2023-07-13 09:07:39 +00:00
Ilya Chernikov b1b1eab35b K2 Scripting: fix testdata for scripts diagnostics tests 2023-07-05 19:46:04 +00:00
Kirill Rakhman 5abab2197b [FIR] Adapt positioning of NO_VALUE_FOR_PARAMETER to match K1 2023-07-04 16:00:45 +00:00
Brian Norman 269dfc61c8 [FIR] Display actual type for argument type mismatch error
Previously the argument type was being used for the actual type error
display. However, safe-call arguments are unwrapped which causes
nullable types to be displayed as non-null. Change to use the actual
type provided by the diagnostic instead of extracting the type from
the argument.

#KT-58844 Fixed
2023-06-16 11:44:14 +00:00
Kirill Rakhman 0ac02be534 [FIR] Generate annotations to data class copy method parameters
#KT-57003 Fixed
2023-05-26 11:29:13 +00:00
Alexander Udalov 40c628d431 FIR: fix order of property accessor annotations
#KT-57219 Fixed
2023-05-22 20:12:29 +00:00
Alexander Udalov e4e1bcefbd JVM: remove tests on JVM target 1.6 2023-05-19 13:23:59 +00:00
Egor Kulikov 6f20ac4f38 [FIR] Enable asserts for not building AST tree in lazy mode
Make interface delegate expressions lazy
2023-05-10 11:49:42 +00:00
Kirill Rakhman 3c66ae0f8b [FIR, LT] Report syntax error by traversing LT after parsing
#KT-57756 Fixed
2023-05-05 09:34:24 +00:00
Dmitriy Novozhilov 82653855ab [FIR] Report missing ASSIGNMENT_TYPE_MISMATCH on functional types
^KT-45989
2023-04-30 16:12:54 +00:00
Dmitrii Gridin 7b91cd0ff3 [FIR] calculate java Target annotation on COMPILER_REQUIRED_ANNOTATIONS phase
^KT-57849
^KT-57949
2023-04-21 10:14:05 +00:00
Dmitrii Gridin 6170d83301 [FIR] update reversed testData
^KT-56543
2023-04-19 20:12:41 +00:00
Dmitrii Gridin 1c5aa6c45b [FIR] add reversed testData to update it in the next commit
^KT-56543
2023-04-19 20:12:41 +00:00
Dmitrii Gridin 72def186a3 [LL FIR] rework transformers, so transformers resolve only a specific set of declarations
The change is needed for the parallel resolution (^KT-55750), so we can resolve the declaration
under a lock that is specific to this declaration.
Previously, if LL FIR was resolving some FirClass, LL FIR  resolved all its children too, and it had no control over what parts of the FIR tree were modified.
The same applied to the designation path, sometimes the classes on the designation path
might be unexpectedly (and without lock) modified.

This commit introduces LLFirResolveTarget, which specifies which exact declarations should be resolved during the lazy resolution of the declaration.
All elements outside the declarations specified for resolve in LLFirResolveTarget, should not be modified.

The logic of lazy transformers is the following:
- Go to target declaration collecting all scopes from the file and containing classes
- Resolve only declarations that are specified by the LLFirResolveTarget, performing the resolve under a separate lock for each declaration

^KT-56543
^KT-57619 Fixed
2023-04-19 20:12:38 +00:00