108 Commits

Author SHA1 Message Date
Egor Kulikov 36b89f5e84 [FIR] Fix resolve for java synthetic properties in KDoc
^KT-62880 fixed
2024-03-18 17:35:32 +00:00
Vadim.Mishenev df1d44b15f KT-64051 [AA] Fix resolve of KDoc references to a typealias by full name 2024-03-11 21:38:09 +00:00
Denis.Zharkov 81414d758d K2: repeat K1 representation for flexible type parameters
This commit changes the behavior of KT-59138 effectively declining it in 2.0.
However, we plan to implement KT-59138 behavior under a feature
flag in 2.0 (see KT-66447), and switch this feature on version 2.x.

Also, this commit implements the LC resolution about postponing
KT-57014 change. We don't have KT-57014 described behavior in 2.0 anymore.
However, we plan to implement a deprecation warning here, see KT-65578.

After this commit, 6 diagnostic tests become incorrectly broken:
- 5 tests from PurelyImplementedCollection group
- a test platformTypes/nullableTypeArgument.kt

This commit also breaks currently fixed-in-k2 KT-50134
(it is fixed again in the following commits),
as well as KT-58933 (it will remain not fixed till we enable KT-59138
behavior again).

#KT-65596 In Progress
#KT-57014 In Progress
#KT-58933 Submitted
2024-03-11 13:38:05 +00:00
Roman Golyshev b765cf3f99 KT-66411 [AA] Add fake source kind for single expression block around array assignments
A wrapper block was introduced as a part of fixing KT-59748, but was
assigned a real source, which had `getOrBuildFir` confused because
of the incorrectly built `KtToFirMapping`

It is relevant for:
- `if`, `when` expressions with an assignment as a single expression
- Kotlin code fragments,
when the assignment is being analysed as a single expression
in the fragment

^KT-66411 Fixed
2024-03-10 15:35:47 +00:00
Roman Golyshev 83a80a45a9 KT-66411 [AA] Add more tests for resolving compound set operators 2024-03-10 15:35:47 +00:00
Ilya Chernikov 9037975758 K2 Scripting: Skip base class params from resolution scope
The base class in scripting considered obsolete and therefore supported
via some ad-hoc mechanisms. In particular parameters to the base class
c-tor are passed via script provided properties. But in combination
with the resolution logic, this leads to issues described in KT-60452
This commits filters out such parameters from script resolution
scope and avoids this problem for now.
Bot it should be noted that proper diagnostics for properties shadowing
should still be implemented - see #KT-65809
#KT-60452 fixed
2024-02-23 22:03:44 +00:00
Nikolay Lunyak 7056ad5325 [FIR] Set status.isOverride for fake overrides
Even though SO may not be correct
overrides sometimes, it feels more
natural to treat fake overrides as...
well, "overrides". And without it
we'd need to make the code in
`FirOverrideChecker` less intuitive.
2024-02-15 16:10:13 +00:00
vladislav.grechko 9aa8fb80e7 Set correct IR origins for inc/dec operations
NB: in order to produce correct IR origins, the source element kinds for
some FIR elements has been changed. As a side effect, mapping PSI to FIR
slightly changed: namely, for `a[b]++`, `a[b]` used to be mapped on
`set` call or callable reference, but now it is mapped on `get` call.

^KT-61891: Fixed
^KT-64387: Fixed
2024-01-30 14:26:10 +00:00
Yan Zhulanow e001fa4e72 [Analysis API] Explicitly specify the context module in a directive 2024-01-30 11:41:26 +00:00
Yan Zhulanow 892212bdf6 [Analysis API] Add type code fragment test for a local class 2024-01-30 11:41:26 +00:00
Yan Zhulanow ef890e9b76 [Analysis API] Add reference resolution tests for code fragments 2024-01-30 11:41:26 +00:00
Roman Golyshev d45662c2c3 KT-62695 [AA] Better resolve ambiguous receiver types in KDocReferenceResolver
When encountering multiple available same named types,
resolve all of them together with corresponding extensions.
This aligns well with the current resolve behavior of classes
with the same name (see `SameNameClassesFromStarImports.kt`)

Also, add extra test for resolving the ambiguous type without
the extension function. The behavior is the same - resolve to the
both classes.
2024-01-26 10:12:09 +00:00
Roman Golyshev fb225f5f20 [tests] Return caret names from ExpressionMarkerProvider
Render caret names in resolve testData, so that we don't have to guess
the indices of the carets;
it makes the multi-caret testData less error-prone.

Relevant for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 2befd2bffb KT-62695 [AA] Implement resolution of extension functions in KDoc
The solution is not complete, since resolution of KDocs is not
fully specified and is rather tricky.
Many more corner cases are to be expected.
This solution should at least give some groundwork for the future
improvements/fixes of the resolver.

^KT-62695 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev f9d4a35d80 KT-62695 [AA] Preliminary set of tests for extensions resolve 2024-01-26 10:12:09 +00:00
Roman Golyshev c0d54f9bbf KT-65152 [AA] Add extra test for package resolution
Make sure that, when ambiguous, both the package
and the callable/class/property are resolved from
KDoc reference.

Do a slight refactoring of `KDocReferenceResolver`

This behavior is also true for K1
2024-01-26 10:12:09 +00:00
Roman Golyshev f402daba98 KT-65152 [AA] Fix resolve of partial package qualifiers in KDocs
^KT-65152 Fixed
2024-01-26 10:12:09 +00:00
Roman Golyshev 38e0b154c3 KT-65152 [AA] Add resolve testData for a package with multiple qualifiers resolve 2024-01-26 10:12:09 +00:00
Roman Golyshev ec97659462 [tests] Refactor AbstractReferenceResolveTest. Part 4
Allow multiple carets to be used in reference resolve tests.
Adjust the testdata for the only test case which has actually
had multiple carets in it.

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Roman Golyshev 304112cd8a [tests] Refactor AbstractReferenceResolveTest. Part 1
Instead of relying on UNRESOLVED_REFERENCE directive for the whole file,
just render the unresolved reference right in the .txt testdata

This will allow to introduce multi-caret resolve testdata more naturally

Required for KT-65152 and KT-62695
2024-01-26 10:12:09 +00:00
Pavel Kirpichenkov 8fbe376f25 [IDE, JS] Fix tests for asDynamic
Register JS configurator in tests for library sources
Ignore FE10 because of KTIJ-28546

KTIJ-27571
2024-01-22 18:28:24 +00:00
Pavel Kirpichenkov ed8d3092cd [IDE, JS] Add regression test for KTIJ-27571
Reference resolve for kotlin.js.asDynamic
2024-01-22 18:28:24 +00:00
Roman Golyshev 72a0f2023d KT-64988 [AA] Unwrap safe call when resolving named arguments in FirReferenceResolveHelper
^KT-64988 Fixed
2024-01-16 22:36:59 +00:00
Mikhail Glukhikh f5453690a6 K2: prefer base class sources for JVM mapped functions
This commit is a follow-up to 3cb9396b20
"K2: prefer derived class sources for callable copies (e.g. fake overrides)"

#KT-64044 Fixed
2024-01-06 07:11:27 +00:00
Marco Pennekamp af7eb8b7af [AA] Add reference resolve tests for Java enums with getName function
^KT-62524
2024-01-02 16:41:34 +00:00
Marco Pennekamp c611f1923f [AA] Refactoring: Move Java reference resolve tests to java subfolder 2024-01-02 16:41:34 +00:00
Jinseong Jeon f5d2ce3022 AA: render containing file and JvmClassName 2023-12-21 15:34:34 +00:00
Ilya Kirillov d2b9b487c7 [Analysis API] add test for resolution into declarations with the kotlin. package
^KT-63223
2023-11-08 17:32:49 +00:00
Ilya Kirillov c54d83dcad [Analysis API] fix resolution to declarations inside kotlin*. packages
`kotlin*.` packages should be always allowed.
`kotlin.` packages should be allowed if `AnalysisFlags.allowKotlinPackage` is `true`

^KT-63223 fixed
2023-11-08 17:32:48 +00:00
Marco Pennekamp f04b27b90b [AA] Add additional KDoc reference resolution tests for callables
- This adds KDoc reference resolution tests for callables in nested and
  inner classes, overloaded functions, and private callables.
- Private declarations are visible in KDoc from outside their containing
  classes. This is in line with K1 KDoc behavior.

^KTIJ-22324
2023-10-23 23:08:01 +00:00
Marco Pennekamp ef484c7518 [AA] Fix KDoc reference resolution of non-imported companion object members
- Similar to the fix for KTIJ-25995, the name interpretation collector
  needs to consider the companion object's member scope as well.

^KTIJ-25995
2023-10-23 23:08:01 +00:00
Marco Pennekamp 71792f9ad6 [AA] Add test for KDoc reference resolution of sibling nested class 2023-10-23 23:08:00 +00:00
Marco Pennekamp 367b84d45e [AA] Add tests for KDoc reference resolution of companion object members
^KTIJ-25995
2023-10-23 23:08:00 +00:00
Marco Pennekamp 3dbae89cdd [AA] Add tests for KDoc reference resolution of non-static callables
^KTIJ-26003
2023-10-23 23:08:00 +00:00
Roman Golyshev 0747fc36de KTIJ-27434 [AA] Unwrap safe call expression when resolving implicit invoke calls
`FirSafeCallExpression` does not implement `FirResolvable`, so we need
to unwrap it to correctly resolve calls like `foo?.bar()` when `bar` is
a lambda with receiver parameter or a functional type property

^KTIJ-27434 Fixed
2023-10-20 13:27:31 +00:00
Dmitrii Gridin 0b45c6ce23 [FIR] FirScriptConfiguratorExtensionImpl: provide source for script parameters
We need this source to be able to find the parent declaration

^KT-62693 Fixed
2023-10-20 09:27:21 +00:00
Dmitrii Gridin 17ab005668 [Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations
This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
2023-10-20 09:27:21 +00:00
Ilya Kirillov c32e7c723d [Analysis API] resolve [this] in KDoc to extension receiver
^KT-62407 fixed
2023-10-10 14:03:49 +00:00
Kirill Rakhman fa77e3952d [FIR] Bring equivalent call behavior closer to K1
#KT-61159 Fixed
2023-08-21 12:11:58 +00:00
Egor Kulikov ae85c7bfe3 [FIR] Add missing tests to resolve
Merge-request: KT-MR-11666
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-08-17 10:54:39 +00:00
Ilya Kirillov de4224296d [Analysis API FIR] fix reference resolve to reified type parameter 2023-07-31 08:43:59 +00:00
Egor Kulikov 27f4b53570 [FIR] Do not expect builtin imports to be always resolved
Merge-request: KT-MR-10886
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-07-05 14:02:50 +00:00
Egor Kulikov d17c7d4729 [FIR] Correctly mute destructuring declaration test for 1.0
Merge-request: KT-MR-10847
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-27 16:17:07 +00:00
Egor Kulikov a7c1f53af8 [FIR] Correctly process invalid destructing declarations
^KTIJ-24730 fixed

Merge-request: KT-MR-10712
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-27 09:54:01 +00:00
Roman Golyshev b4c9a2616e KTIJ-25960 [Analysis API] Resolve static declarations in KDoc
^KTIJ-25960 Fixed
2023-06-26 12:27:26 +00:00
Egor Kulikov b147b7e929 [FIR] Store fir for invalid when branches
^KTIJ-25646 fixed

Merge-request: KT-MR-10646
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-20 16:11:31 +00:00
Ilya Kirillov 724386a5f1 [Analysis API] rework the resolve of the nested name references
To properly resolve qualifier parts in the middle,
we need to resolve the whole qualifier to understand
which parts of the qualifier are package or class qualifiers.
And then we will be able to resolve the qualifier
selected by the user to the proper class, package or callable.

^KT-59189
2023-06-09 21:18:45 +00:00
Ilya Kirillov 785778511b [Analysis API] rework KDoc resolution
1. Optimize it by removing a tower data context collection (KT-59189)
2. Rework the behavior, so it simulates the tower resolve by returning the set of symbols only from the first tower level, which is not empty

^KT-59189 fixed
2023-06-09 21:18:45 +00:00
Ilya Kirillov 481962d5f6 [LL FIR] get rid of on-air resolve of partial type qualifiers
It's very slow and leads to performance problems (see KT-58125)

Instead, we do the following:

- For a fully resolved type qualifier, when we want to resolve its part,
 we are looking for the corresponding symbol by traversing nested classes
 bottom up.
 - For an error qualifier, we are trying to resolve the maximum possible
  qualifier in the types transformer where all the type scopes are
  already available.

^KT-58125 fixed
2023-06-08 13:41:35 +00:00
Egor Kulikov 347c748182 [FIR] Add excessive delegated constructors to FIR tree
^KTIJ-25453 fixed

Merge-request: KT-MR-10379
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-05 14:27:53 +00:00