Commit Graph

67 Commits

Author SHA1 Message Date
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
Mikhail Glukhikh 446ee943e2 FIR analysis API: fix rendering of Java-based types 2022-05-31 11:34:53 +00:00
Denis.Zharkov d7f87e0182 FIR: Adjust analysis test data to changes in loading Java types 2022-05-19 16:54:02 +00:00
Jinseong Jeon a74a51b2d9 AA: add tests about resolution of implicit lambda parameter 2022-04-21 19:18:24 +02:00
Ilya Kirillov 6831bde751 [analysis api fir, tests] update parameter names in testdata 2022-04-13 12:53:18 +02:00
Ilya Kirillov 443ee4c860 [analysis api] allow generating test with for with more possible parameters 2022-04-13 12:52:59 +02:00
Roman Golyshev 32fa2fc476 [FIR] Resolve receiver in qualified expressions with no selector
In qualified expression like `foo().`, selector expression is null.
Because of that the whole expression was marked as an error FIR
expression, and `foo()` part was not resolved at all (including
arguments and everything else).

This commit fixes the problem by providing receiver's FIR expression
as an underlying expression for error FIR expression. That way
it will be seen by all resolve transformers and will be successfully
resolved.

^KTIJ-21484 Fixed
2022-04-12 10:55:12 +00:00
Jinseong Jeon 881a6bed35 AA: add tests about resolution to Java static method 2022-03-22 15:44:50 +01:00
Roman Golyshev 22830cf159 [FIR IDE] Fix resolving sugared compound operators (like +=, -=)
^KTIJ-21374 Fixed
2022-03-22 13:14:54 +00:00
Roman Golyshev 7bcd67068c [FIR IDE] Resolve explicit invoke calls more correctly
Also, enable some muted tests

^KTIJ-21343 Fixed
2022-03-15 21:29:36 +03:00
Jinseong Jeon 89725941df AA: showcase an error in resolution to stdlib in standalone mode 2022-03-15 19:50:16 +03:00
Jinseong Jeon a68fd25982 AA: relax the assertion about referenced ClassId and qualified access
If an import alias is involved, they could be not identical.
Since an import alias ends with a simple identifer, we can simply drop
the first segment of qualified access and try the assertion again.
2022-03-02 20:30:31 +01:00
Ilya Kirillov b8c36b7998 Analysis API FIR: remove compilation errors from new testdata 2022-02-01 16:31:29 +01:00
Ilya Kirillov 441de5cd75 Analysis API FIR: resolve Java synthetic properties KtSyntheticJavaPropertySymbol 2022-02-01 16:31:28 +01:00
Mads Ager d13e117a58 Change FIR analysis API resolution for super type calls.
The IDE expects the super type calls to resolve to the constructor
invoked and not the class. The frontend itself resolves to the
class, so an extra layer is needed to adjust that to the constructor.
2022-02-01 16:31:26 +01:00
Ilya Kirillov 4530041cbb Analysis API: move reference resolve testsdata with errors to dedicated folders 2022-01-31 21:12:30 +01:00
Ilya Kirillov 96e1f1e7d4 Analysis API: fix some compilation errors in reference resolve testdata 2022-01-31 21:11:54 +01:00
Roman Golyshev f0f2f67024 KT-50862 Unwrap use-site substitution overrides
Use-site substitution override happens in situations like this:

```
interface List<A> { fun get(i: Int): A }

fun take(list: List<String>) {
  list.get(10) // this call
}
```

We want to have those overrides unwrapped, because we don't want
to deal with a different KtSymbol for each possible use-site

^KT-50862 Fixed
2022-01-29 07:42:18 +00:00
Ilya Kirillov e1fece6402 Analysis API: fix testdata of reference resolve tests which started to pass 2022-01-21 16:46:28 +01:00