Commit Graph

3136 Commits

Author SHA1 Message Date
Anastasia.Nekrasova 9864c5c386 Expected type was changed from KtFirNamedClassOrObjectSymbol to KtFirNamedClassOrObjectSymbolBase in getAnnotationApplicableTargets function
Required to support symbols from java file, see KTIJ-26302
2023-07-24 15:17:59 +00:00
Anastasia.Nekrasova 67d8346f5c Added a public function that allows to get the actual annotation target list
The logic to get the actual target is required on the IDE side, see KTIJ-26302
2023-07-24 15:17:59 +00:00
Brian Norman 42ebbb937c [FIR] Recursively search dependsOn modules in visibility checks
#KT-59071 Fixed
2023-07-24 14:20:57 +00:00
Anna Kozlova 40a6c81d97 [AA] retrieve overridden symbols for parameter from generated property
Merge-request: KT-MR-11215
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-07-24 11:09:56 +00:00
Roman Efremov 1a4ab9bb4b [FE] Implement FE logic of expect actual annotations matching
This implementation only checks annotations set on expect/actual
declarations and requires further refinement (e.g. checking of other
annotation targets, class scopes within typealiases).

^KT-58551
2023-07-24 09:48:48 +00:00
Jinseong Jeon 72de540fc9 AA: try finding a module for an associated analysisContext from KtPsiFactory if any 2023-07-24 11:34:51 +02:00
Jinseong Jeon 2dee644f7a AA FE1.0: restore an option to register AnalysisHandlerExtension w/o use-site module 2023-07-24 11:34:51 +02:00
Alexander Korepanov 89c3781c8e [JS FIR] Support NAME_CONTAINS_ILLEGAL_CHARS diagnostic
^KT-59392 Fixed
2023-07-21 13:54:34 +00:00
Alexander Korepanov 37c8ec1e51 [JS FIR] Support JS_BUILTIN_NAME_CLASH diagnostic
^KT-59391 Fixed
2023-07-21 13:54:34 +00:00
Dmitrii Gridin 88da053408 [AA] forbid analyze from write action
Analysis is not supposed to be called from write action.
Such actions can lead to IDE freezes and incorrect behavior

^KT-60586 Fixed
2023-07-21 13:03:04 +00:00
Dmitrii Gridin 8820867341 [FIR] support flexible types in ConeKotlinType#independentInstance
^KT-60580 Fixed
2023-07-20 17:22:56 +00:00
Dmitrii Gridin dc56c5cf9e [LL FIR] FileStructure: avoid synchronizations on cache access
From `ConcurrentMap#compute`
>The entire method invocation is performed atomically.
>Some attempted update operations on this map by other threads may
>be blocked while computation is in progress, so the computation
>should be short and simple

And we can call resolution (`reanalyze()`) under this synchronized
block that can take unpredictable time.

This fix drops all heavy operations from synchronization
2023-07-20 14:20:51 +00:00
Kirill Rakhman 6ca95dc338 [Tests] Fix test data after bed6cb7154 2023-07-20 13:37:38 +00:00
Nikolay Lunyak 84dd1acec1 [FIR] Check typealiases in supertypes
^KT-59830 Fixed

Merge-request: KT-MR-11187
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-20 12:50:06 +00:00
Ivan Kochurkin 529d5a1df2 [FIR] Add description to NO_ELSE_IN_WHEN and fill it for expect enum or sealed declarations 2023-07-20 11:04:18 +00:00
Ivan Kochurkin d8ccf21894 [FIR] Fix false positive "suspension point is inside a critical section"
^KT-55072 Fixed
2023-07-20 10:38:59 +00:00
Kirill Rakhman bed6cb7154 [FIR] Make FirFile.annotationsContainer nullable
Previously, when no file annotations were present, the FIR element
didn't have a source.
By making it nullable, it will only be created when appropriate and the
source will never be null.

#KT-55835
2023-07-20 07:29:18 +00:00
Roman Golyshev b8052761db KT-60341 [Analysis API] Provide a type for a FirNameReference only when it refers to an actual property/variable
We cannot always return null, because in such case some expressions
would become not fully explorable from the types perspective (see
the documentation on the `getCorrespondingTypeIfPossible`)

`FirNamedReference` might appear when resolving method references (like
`foo::bar`), but also when IJ Platform tries to resolve other parts of
the Kotlin PSI, notably a `KtNameReferenceExpression` in a
function call (`bar` in `foo.bar(baz)` expression).

N.B. FE10 implementation does not support returning `null` as a type -
currently it always returns `Unit` type in case it cannot figure out
the actual type. This issue should probably be tackled together with
KT-60166, so that both implementations are more or less aligned

^KT-60341 Fixed
^KT-59077 Fixed
^KTIJ-25745 Fixed
2023-07-19 22:01:37 +00:00
Kirill Rakhman 97024d9ccb [FIR] Resolve array literal argument for non-primitive-array parameter as arrayOf call in annotation calls
This allows us to properly complete array literals arguments of
annotation calls fixing several false-negative type mismatch errors
as well as enabling the inference of generic type arguments.

#KT-59581 Fixed
#KT-58883 Fixed
2023-07-19 13:34:58 +00:00
Roman Golyshev 5e30adec06 KTIJ-26276 [Analysis API] Do not consider single aliased import from the same package as unused
Even when the aliased import comes from the same package, it cannot be
removed, because it will break the code

Also, add more tests for the imports coming from the same package

^KTIJ-26276 Fixed
2023-07-19 12:40:57 +00:00
Dmitrii Gridin d0854d5b45 [FIR] propagate copy of original ConeKotlinType to anonymous functions to avoid concurrent modification
It is required to avoid leakage of annotations instance from
the original type
It should be enough to just create a new instance of an annotation
without a deep copy, because transformer shouldn't touch it

^KT-60387 Fixed
2023-07-19 11:50:12 +00:00
Dmitrii Gridin b59e66c217 [LL FIR] add test on annotation type copy
^KT-60387
2023-07-19 11:50:12 +00:00
Dmitrii Gridin 14327d51ed [LL FIR] invalidateAfterInBlockModification: do not treat adding of body as in-block modification
It is an out-of-block modification because some diagnostics depend
on a fact of a body's existence

^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin 5f24ad114c [LL FIR] AbstractInBlockModificationTest: add more tests
^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin f0d8a1cbe9 [LL FIR] AbstractInBlockModificationTest: cover getNonLocalReanalyzableContainingDeclaration
^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin c2fd245ca1 [LL FIR] getSelectedElement should return PsiElement
^KT-60518
2023-07-19 10:32:10 +00:00
Dmitrii Gridin 32ad4380b3 [FIR] make java annotation mapping lazily
to avoid contract violations from getDeprecation

^KT-59342 Fixed
^KT-60520
2023-07-18 16:48:53 +00:00
Alexander Korepanov 08d158f901 [JS FIR] Support JS module system FE diagnostics
Support CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM diagnostic
^KT-59377 Fixed

Support CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM diagnostic
^KT-59381 Fixed

Support CALL_FROM_UMD_MUST_BE_JS_MODULE_AND_JS_NON_MODULE diagnostic
^KT-59417 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov 6034d32d7c [JS FIR] Support DYNAMIC_NOT_ALLOWED diagnostic
^KT-59384 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov 39fba56de9 [JS FIR] Support PROPERTY_DELEGATION_BY_DYNAMIC diagnostic
^KT-59406 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov f6b7a07efe [JS FIR] Support EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT diagnostic
^KT-59416 Fixed
2023-07-18 14:02:30 +00:00
Ilya Kirillov 08400d930f [Analysis API, FIR] migrate ::class.java -> ::class inside error messages
They seem to provide similar results and the `.java` part is redundant
2023-07-18 11:49:21 +00:00
Ilya Kirillov 24db4e62f5 Migrate some FIR/Analysis API KotlinExceptionWithAttachment usages to buildErrorWithAttachment API 2023-07-18 11:49:21 +00:00
Ilya Kirillov a9cd881a07 [FIR] add utilities to FIR compiler to throw error with attachment 2023-07-18 11:49:20 +00:00
Ilya Kirillov c5014d4765 Move PsiElement.getElementTextWithContext to psi module with small adjustments
* replace existing function (the new one makes it more clear which element was printed)
* prints position for element
* handles invalid psi element
2023-07-18 11:49:20 +00:00
Ilya Kirillov 4b3bff3344 Rework checkWithAttachment/requireWithAttachment
* better naming
* throw corresponding KotlinIllegalStateExceptionWithAttachments/KotlinIllegalArgumentExceptionWithAttachments instead of general KotlinRuntimeExceptionWithAttachments
2023-07-18 11:49:20 +00:00
Ilya Kirillov 2d791eb292 Rename buildErrorWithAttachment -> errorWithAttachment to emphasise the similar semantics to kotlin.error 2023-07-18 11:49:20 +00:00
Ilya Kirillov 15f6fe2627 Move ExceptionAttachmentBuilder near KotlinExceptionWithAttachments so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Ilya Kirillov 25911b1fec Move SmartPrinter to kotlin.core.util.runtime so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Ilya Kirillov 6f429ec072 [Analysis] migrate ExceptionAttachmentBuilder to use SmartPrinter
So it can be moved to a compiler module
2023-07-18 11:49:20 +00:00
Ilya Kirillov 4b523825be [Analysis API] forbid providing custom KtLifetimeToken for every analyze call
^KT-60488 fixed
2023-07-18 08:47:34 +00:00
Dmitriy Novozhilov 73b580572b [FE] Move @PrivateForInline optIn into :core:compiler.common
This is needed to be able to use it in backend modules too
2023-07-17 21:02:40 +00:00
Dmitrii Gridin 38b55c659b [LL FIR] LLFirResolveSessionDepended: add missing mapping for resolveToFirSymbol
We should try to find a declaration from our mapping firstly
Otherwise we can find an invalid element

^KT-60451 Fixed
2023-07-17 17:15:35 +00:00
Mikhail Zarechenskiy 3cdb28e95f Remove last usage of ModelBranch API
It was decided to remove ModelBranch completely from Intellij API, see IDEA-309887
2023-07-17 13:52:53 +00:00
Dmitrii Gridin 1642eaa48a [FIR] getValueClassUnderlyingParameters: fix TODO
^KT-53573 Obsolete
2023-07-17 08:59:17 +00:00
Justin Paupore 9f85739599 [AA] Add KtResolveExtensionInfoProvider to AA.
This provider is responsible for answering queries related to resolve
extensions. At the moment, this includes retrieving a KtScope with all REx
top-level declarations (moved from KtSymbolFromResolveExtensionProvider), and
retrieving information necessary to supply a GeneratedSourcesFilter for REx
generated code. Future REx-related functions can be added to this interface.

^KT-59329
2023-07-14 19:32:09 +02:00
Justin Paupore fa0209a322 [AA] Expand functionality of TestScopeRenderer.
- Add package and constructor listings
- Add single-scope renderForTests() implementation, including a lambda
  to provide additional information about each symbol
- Remove special handling for empty scopes (interfered with single-scope
  rendering)

^KT-59329
2023-07-14 19:32:08 +02:00
Justin Paupore f01b824751 [AA] Show symbol origins in REx tests.
This is in preparation for adding a separate KtSymbolOrigin for
resolve extension symbols.

^KT-59351
2023-07-14 19:32:08 +02:00
Justin Paupore 734b87b97e [AA] Allow specifying REx file contents in testdata.
Tests can now specify the code generated by a resolve extension from
within the test's testdata. Module-level directives control whether
resolve extensions are enabled for that module, as well as package names
and source shadowing regexes. File-level directives allow a `// FILE:`
block within the testdata to be converted into a KtResolveExtensionFile
and removed from the module as a whole. (This requires a new
`ModuleStructureTransformer`, because we need to be able to entirely
remove the files in question.)

Any test can add support for these directives by calling
`KtResolveExtensionTestSupport.configure` from within their
`configureTest` stanza. This allows this functionality to be used in
conjuction with any test base class.

^KT-59329
2023-07-14 19:32:08 +02:00
Mikhail Glukhikh 00b4ae6ae9 K2: expand type before isSomeType checks properly
Related to KT-60229
2023-07-14 16:38:47 +00:00