Commit Graph

85 Commits

Author SHA1 Message Date
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
Egor Kulikov bff1520c9e [FIR] Resolve where subjects to corresponding type argument
^KTIJ-25295 fixed

Merge-request: KT-MR-10044
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-05-17 15:28:02 +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
aleksandrina-streltsova b23dbd359f [AA] Flatten composite scopes when building scope context for position
^KTIJ-25048 Fixed
2023-03-24 07:42:58 +00:00
Marco Pennekamp fb43e53ca3 [LL FIR] KTIJ-24574 Fix containing declaration finder for init blocks
- KTIJ-24574 occurred because a local destructuring declaration was
  erroneously returned as the non-local containing declaration of an
  element by `getNonLocalContainingOrThisDeclaration`. This occurred in
  `init` blocks.

KTIJ-24574 fixed
2023-02-13 10:38:26 +00:00
Jaebaek Seo 860dee2cb1 Fix reference resolver bug for companion object whose name is the same as class
FirReferenceResolveHelper internally checks whether the referenced class
id matches the qualifed access or not. If they do not match, it reports
an error. When the companion object has the same name as the class,
resolving a qualified expression access to a member of the companion
object causes an error because of the mismatch e.g.,

```
package my.sample

class Test {
    fun a() {
        my.sample.<caret>Test.say()
    }

    companion object Test {
        fun say() {}
    }
}
```

This commit fixes the issue.

TODO: When the companion object has a name difference from class, it
does not report an error but the resolution result is wrong in FIR. See
KT-56167.

---

Commentary from rebaser: the issue mentioned in this code is
fixed in 71a368e06e, so the actual
fix is omitted, and only test data is preserved
2023-02-08 18:39:11 +00:00
Roman Golyshev 71a368e06e [Analysis API] KTIJ-24107 Fix resolution of qualified invoke calls on objects
^KTIJ-24107 Fixed
^KTIJ-24344 Fixed
2023-01-27 16:49:30 +00:00
Marco Pennekamp 2922f85a98 [AA] KTIJ-23563 Add reference resolve tests for working cases
- Type arguments in invalid calls/property accesses are resolved
  correctly in many cases, for which this commit adds test cases.
2023-01-25 16:40:46 +00:00
Anna Kozlova 86cc57ac39 [AA] allow navigation from '==' to the equals method of lhs 2023-01-13 20:14:30 +00:00
Dmitriy Novozhilov bd26c29229 [FIR] Resolve arguments of error types during type resolution 2023-01-12 17:45:06 +00:00
Marco Pennekamp 5f554d0065 [FIR] KT-54980 Fix resolvability of too few/too many type arguments
- If too few or too many type arguments were provided, they were all
  thrown away in `TypeArgumentMapping`,
  `FirCallCompletionResultsWriterTransformer`, and `KtFirCallResolver`.
  The fix handles type arguments of the wrong arity more gracefully.
  - Note for `TypeArgumentMapping`: Excess type arguments are not needed
    for candidate resolution. Excess type arguments are still resolved
    due to the handling in `FirCallCompletionResultsWriterTransformer`.
- Post-processing in `AllCandidatesResolver`: When all candidates are
  resolved in `AllCandidatesResolver.getAllCandidates`, the function
  builds a FIR file. During that resolution, the
  `generic<String, String>` call (in example
  `functionCallWithTooFewTypeArguments.kt`) is correctly marked as
  inapplicable, but the missing type argument is inferred as an error
  type. `firFile` then contains a function call
  `generic<String, String, ERROR>` instead of `generic<String, String>`.
  This call is still marked as inapplicable. Despite that, the
  *subsequent* resolution by
  `bodyResolveComponents.callResolve.collectAllCandidates` disregards
  the call's inapplicability and resolves successfully into an
  applicable candidate. This is because `CandidateFactory` doesn't make
  any guarantees for already inapplicable calls. The fix adds
  post-processing to `AllCandidatesResolver` to preserve candidate
  inapplicability.
- Most tests that this commit changes had slightly different results due
  to type arguments becoming resolvable.
- `wrongNumberOfTypeArguments.kt` and
  `wrongNumberOfArgumentsInTypeAliasConstructor.kt`:
  `ConeDiagnostic.toFirDiagnostics` prefers specific errors. Because
  `ARGUMENT_TYPE_MISMATCH` is specific and `INAPPLICABLE_CANDIDATE` is
  not, only the former is reported. I see no reason to pass an illegally
  typed argument in either test, so the change reduces the errors to
  `INAPPLICABLE_CANDIDATE`.
- `typeAliasSamAdapterConstructors2.fir.kt`: See KT-55007.
- Disable `mismatchTypeParameters` JS backend test due to its handling
  of excess type arguments. See KT-55250.

^KT-54980 fixed
2023-01-02 16:36:02 +00:00
Anna Kozlova 15b1e429d7 [compiler] introduce dedicated Fir declaration for dangling modifier lists (KTIJ-23008)
ensure fir annotations are included in FirDanglingModifierList and resolved,
dedicated DanglingTopLevelModifierListStructureElement exists for top
level lists only, class level lists are processed by containing structure
element
2022-12-21 20:58:46 +00:00
Anna Kozlova b81c210535 [AA] resolve array access expression to corresponding set operator
k1 would suggest `get` as well
 but with current fir structure with fake desugaring
 get is moved to the separate fake psi which doesn't exist
 thus the problem is ignored for now
 ^ KTIJ-24025
2022-12-21 10:45:40 +00:00
Anna Kozlova a529f8510d [LL] ensure FirConstExpression's annotations are not lost (KTIJ-23968) 2022-12-15 14:31:48 +00:00
Anna Kozlova cdf6ffa167 [AA] do not try to build KtSymbol for FirErrorFunction
^KTIJ-23669
FirErrorFunctions are created for unknown labels
when the code in return statements is not complete yet.
Such labels cannot be resolved, and no symbols should be created for them
2022-11-24 13:09:29 +00:00
Ilya Kirillov 26ec7ec296 [Analysis API] update testdata after renderer rework
The new testdata seems to be more correct or just different

^KTIJ-23268
2022-11-11 11:59:59 +01:00
Simon Ogorodnik 513af2dfbc FIR. Refactor smart-cast representation in FIR tree
Make smart-casts non-transparent expression without delegation
to underlying FirQualifiedAccessExpression, as children delegation in
fir tree has unclear semantics
Remove two different kinds of tree nodes for smart-casts
2022-08-15 21:46:11 +00:00
Roman Golyshev bcd6a54ffb [Analysis API FIR] Fix small mistake in KDocReferenceResolver
`owner` is a PSI element, it can never be an instance of
`KtConstructorSymbol`

Also, make `MutableCollection` an extension receiver instead of context
receiver for the consistency
2022-07-29 17:13:52 +02:00
Ilya Kirillov 556add72ff [Analysis API FIR] fix KDoc reference resolve for aliased imports 2022-07-28 01:37:54 +02:00
Ilya Kirillov d9c4fda521 [Analysis API FIR] implement reference resolve inside KDoc
^KTIJ-22324 fixed
2022-07-28 01:37:53 +02:00
Ilya Kirillov d5113892df [Analysis API FE10] fix CallableId for synthetic java property descriptors 2022-06-22 09:31:48 +02:00
Mikhail Glukhikh 0ee04d0825 FE10 analysis API: revert resolving 'this' references to receivers
FE10 IDE plugin relies on resolving 'this' references to class or callable
2022-06-03 16:25:44 +00:00
Mikhail Glukhikh c3b5d83f31 FE10 Analysis API: create 17 separate test data files for resolve 2022-05-31 11:34:59 +00:00
Mikhail Glukhikh f4510773d0 FIR analysis API: add workaround for java.io.Serializable type 2022-05-31 11:34:54 +00:00