Commit Graph

30 Commits

Author SHA1 Message Date
Ilya Chernikov 266447120d K2 scripting: treat default import similarly to K1
namely, add them to importing scopes directly and according to the
schema used for other implicit imports, rather than adding them
to the regular script file imports. See KT-65982 for explanation.
#KT-65982 fixed
2024-02-23 22:03:44 +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
Dmitrii Gridin 8f987644ab [LL FIR] designation refactoring
Collect `FirDesignation` by default with `FirFile` instead of just
a separate path and additional repeated logic around

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 47e8d987b9 [LL FIR] ContextCollector: optimize collector for file elements
We shouldn't trigger declaration processing if we want to check just
annotations/package/imports.
But currently, we still will iterate over the entire file
if there is an element somewhere inside package/import
(see `fileImportInside.kt` test case)

^KT-65344
^KT-65560 Fixed
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 0c3a1dfd67 [LL FIR] ContextCollector: add tests for file package and imports
It reproduces redundant resolution

^KT-65344
^KT-65560
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 58ad26ee5b [LL FIR] make script initializers independent
Now we can resolve all script declarations independently

^KT-65344 Fixed
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 4f0bc86ad4 [LL FIR] make result$$ property independent
Now we can resolve this generated property in the same way
as other regular properties.
This is the pre-step for independent script initializers

^KT-65344
^KT-65523
2024-02-13 14:58:31 +00:00
Dmitrii Gridin 39131a7f30 [LL FIR] rework FirDesignation collector
The main change – now we collect not only `FirRegularClass`, but also
`FirScript`.
This allows us to have a proper context collector for
diagnostics for scripts.
Also, this change fixes dangling files for scripts in `IGNORE_SELF`
as now we have the correct patcher for this case, so we won't resolve
the copied script

^KT-65345
^KT-62841 Fixed
2024-02-05 09:32:45 +00:00
Yan Zhulanow 08727bf0be [Analysis API] Add more ContextCollector tests inspired by dependentCopy
As the on-air analysis is obsolete, related tests are going to be
deleted. Here we add cases not yet covered by 'ContextCollector' tests.
2024-01-18 17:12:28 +00:00
Yan Zhulanow a848a0233d [Analysis API] Add more ContextCollector tests inspired by on-air tests
As the on-air analysis is obsolete, related tests are going to be
deleted. Here we add cases not yet covered by 'ContextCollector' tests.
2024-01-18 17:12:28 +00:00
Yan Zhulanow f9c7ca3bdc [Analysis API] Test 'IGNORE_SELF' mode in context collector tests
Parent declarations of the file copy are typically unresolved in the
'IGNORE_SELF' mode, as the declaration designation contains declarations
from the original file.
2024-01-18 17:12:28 +00:00
Yan Zhulanow e4b574de38 [Analysis API] Update test data after rebase 2024-01-06 07:18:47 +00:00
Yan Zhulanow bed73fd650 [Analysis API] Collect designations only for autonomous declarations
Parameters, type parameters, and property accessors are not
self-sufficient declarations (their resolution depends on resolution
of their parent), so a proper designation path cannot be computed
for them.

Without a designation path, 'ContextCollector' performs analysis of the
whole file, which is inefficient.
2024-01-05 16:04:14 +00:00
Ivan Kochurkin 69b9bfc3e0 [FIR] Initialize public visibility for class-like declarations at FIR building phase if no modifier is presented
Java resolving subsystem requires calculated visibility for correct disambiguation of supertypes.
But visibility remains `Unknown` for Kotlin class-like declarations during supertypes resolving because `STATUS` resolve phase is performed after `SUPER_TYPES` phase.
To fix the problem, the visibility should be initialized to public at the FIR building phase if no modifier is presented.

^KT-64127 Fixed
2024-01-04 16:17:32 +00:00
Ilya Chernikov db804b7f93 K2 Scripting: fix CFG processing related testdata in LL 2023-12-12 09:58:19 +00:00
Roman Golyshev 78f492394c KT-64186 [LL] Correctly handle anonymous objects' headers in ContextCollector
This bug spilled into reference shortener, and then to
"redundant qualifier inspection" and code completion from there;
it caused KTIJ-26024 to reproduce again (but only for anonymous objects)

^KT-64186 Fixed
2023-12-08 09:14:43 +00:00
Mikhail Glukhikh 83cfcc30c6 K2: handle type parameter vs nested class conflict in body resolve properly
This commit does two things:
- prioritize type parameter scopes against static scopes in body resolve
(effectively it's a revert of KT-58028 fix)
- consider type parameters as inapplicable callable, so during callable
resolve we can go up the tower and still resolve to static scope

This allows both KT-58028 and KT-63377 to work properly
#KT-63377 Fixed
2023-11-24 21:28:16 +00:00
Ivan Kochurkin 115d685d91 [FIR] Fix ambiguity of Throws and other std annotations importing
Including `SharedImmutable` and `ThreadLocal`

Simplify code, remove `DefaultImportPriority.KOTLIN_THROWS`

Introduce `FirNativeClassMapper`
2023-11-23 23:51:23 +00:00
Dmitrii Gridin 5183019cb8 [LL FIR] resolve class before constructor
This is required to have stable resolution order to avoid concurrent
modifications and correct resolution context.
This also fixes KT-63700 as a super call expands only during body
resolution in the case of secondary constructor

^KT-63042
^KT-63700 Fixed
2023-11-23 15:55:07 +00:00
Dmitrii Gridin e3d91741ca [LL FIR] resolve class before delegate field
This is required to have stable resolution order to avoid concurrent
modifications and correct resolution context.
E.g., this commit fixes the resolution behavior of delegate field for
ANNOTATION_ARGUMENTS phase – now annotation argument resolves in the
correct scope

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 5fa516e010 [LL FIR] resolve constructor parameter before generated property
This is required to have stable resolution order to avoid concurrent
modifications

^KT-63042
2023-11-23 15:55:06 +00:00
Roman Golyshev d865a44c94 KT-61890 [AA] Add test for ContextCollector at loop variable position
This turns out to be important for conflict resolution in
postfix completion in K2 IDE (see `KotlinDeclarationNameValidator`)
2023-11-14 22:15:05 +00:00
Roman Golyshev 4f136cde31 KT-61890 [AA] Add testdata to ensure KDoc completion support in IDE
Completion in the IDE relies on correct scopes for KDoc positions.
So we add testData for `KtScopeProvider` and `ContextCollector`
to ensure that there are no regressions
2023-11-14 22:15:04 +00:00
Mikhail Glukhikh 9cf1d36e5e K2: don't use outer class type parameters during nested class TP resolve
Before this commit, we allowed access to outer class type parameters
during resolve of type parameter bounds of a nested class.
In fact, outer type parameters are accessible in this situation
only if it's an inner class (or a local class).
This commit forbids such a usage. In the earlier fix of KT-57209
the same was done for regular type reference resolve.

#KT-61459 Fixed
#KT-61959 Fixed
2023-10-03 06:34:02 +00:00
Yan Zhulanow 624d35fefd Update test data for 'ContextCollector' after renderer changes
See also d98da87278 ([FIR] Render
dot-separated FQNs instead of slash-separated ones in diagnostics).
2023-09-23 07:01:04 +00:00
Yan Zhulanow 4690a430f4 [LL API] Fix smart-cast collection for special 'FirElement's
'DFANode' is not created for certain elements, such as types or
references. Before the change, only the target element itself was
queried for DFA, making the 'ContextCollector' return an empty map of
smart casts.

^KTIJ-26973 Fixed
2023-09-22 13:40:09 +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
Dmitrii Gridin 12dc6b1ebc [FIR] FirRenderer: render name for scripts
A script name is important information, so it is better to render it.
This also will fix the inconsistency with redundant space after 'SCRIPT:'.
2023-09-19 14:03:29 +00:00
Dmitrii Gridin 5981fb3022 [LL FIR] drop copyright from testData 2023-09-18 21:12:45 +00:00
Dmitrii Gridin 33e6a85a2d [LL FIR] rename testdata to testData to avoid copyright generation
We exclude testData pattern from copyright scope
2023-09-18 21:12:45 +00:00