Commit Graph

2550 Commits

Author SHA1 Message Date
Ilya Kirillov 167ed5e049 [Analysis API] add a KDoc for the LLFirSymbolProviderNameCache 2023-04-19 16:09:07 +00:00
Ilya Kirillov 806fff0887 [Analysis API] forbid Analysis inside KtResolveExtensionProvider
As it's called during FIR sessions initialization

^KT-57930
2023-04-19 16:09:06 +00:00
Ilya Kirillov 0d0b1b7945 [Analysis API] add ability for a custom element navigation for a KtResolveExtensionFile
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov 51eaa3f9cf [Analysis API] provide tests for the KtResolveExtensionProvider
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov d68587de77 [Analysis API] implement API to extend Kotlin resolution by generated declarations
^KT-57930 fixed
2023-04-19 16:09:04 +00:00
Ilya Kirillov 0dbc948616 [LL FIR] introduce CompositeKotlinDeclarationProvider
^KT-57930
2023-04-19 16:09:01 +00:00
Ilya Kirillov 9ca99ba7c7 [LL FIR] introduce CompositeKotlinPackageProvider
^KT-57930
2023-04-19 16:09:00 +00:00
Ilya Kirillov 9dcc9d0d10 [LL FIR] introduce LLFirCompositeSymbolProviderNameCache
^KT-57930
2023-04-19 16:09:00 +00:00
Ilya Kirillov 3b681cd2eb [LL FIR] extract base class from LLFirSymbolProviderNameCache
^KT-57930
2023-04-19 16:08:59 +00:00
Denis.Zharkov 4e2107abe7 K2: Fix false positive NotImplemented error for size property
The problem appeared because not all of the `realOverridden` have been
collected because inside AbstractSerializableListDecorator some of the
scopes returned the same instance as direct overridden and after that
overridden tree traversal stopped without detecting real overrides.

Thus, the modality of intersection for
AbstractSerializableListDecorator::size and MutableSet::size
was incorrectly computed to ABSTRACT

The similar thing is already done at the place where we're obtaining
all overrides.
See https://github.com/JetBrains/kotlin/commit/c80cfb0fdb00323ba9b5e1dd98c5cbd0bfab6b8b#diff-182d90c9b8050557e4e2eb319a84b9a51fd0600c728dd0fce85cf6491c13e16dR152

^KT-57693 Fixed
2023-04-19 15:20:49 +00:00
Nikita Bobko 8314812ef9 2/2 FirUnsupportedSyntheticCallableReferenceChecker: don't report error on FirJavaOverriddenSyntheticPropertySymbol
Meta issue: KT-8575
^KT-58061 Fixed
Review: https://jetbrains.team/p/kt/reviews/9677

This commit fixes an inconsistency between
FirUnsupportedSyntheticCallableReferenceChecker and
UnsupportedSyntheticCallableReferenceChecker

In K1 such properties were not considered synthetic and are called
JavaPropertyDescriptor. That's why we need to do an additional check in
K2 checker, while in K1 we didn't need to do it

Also see the previous commit for more related tests that already was
green without this fix but are related to KT-58061 problem
2023-04-19 14:33:45 +00:00
Nikita Bobko 11f376ae84 1/2 Covert FirUnsupportedSyntheticCallableReferenceChecker with more tests
Review: https://jetbrains.team/p/kt/reviews/9677

I'm going to fix KT-58061 in the next commit. Firstly, let's cover
FirUnsupportedSyntheticCallableReferenceChecker with more tests that
already pass, but are related to KT-58061 problem.
2023-04-19 14:33:45 +00:00
Jinseong Jeon 0ca86c86be SLC: add nullability annotation to value param of non-synthetic enum members
^KT-57567
2023-04-19 16:14:23 +02:00
Jinseong Jeon 9fe30bfc12 SLC: regression test for final modifier on enum members
^KT-57567
2023-04-19 16:14:23 +02:00
Mikhail Glukhikh f9a7a7fda2 K2: reproduce KT-57889 2023-04-18 17:05:00 +00:00
Dmitriy Novozhilov f8dc8057f0 [FIR] Prohibit referencing type parameters in contracts ...
...if they are not reified or not belong to owner declaration of the contract

KT-57911
2023-04-18 13:31:28 +00:00
Mikhail Glukhikh 7bd5491498 K2: reproduce KT-57873 2023-04-18 09:23:20 +00:00
Mikhail Glukhikh c8b74e5655 K2: reproduce KT-57991 2023-04-17 18:05:43 +00:00
Nikita Bobko 5a96754aec Shift ReferencesToSyntheticJavaProperties feature release from 1.9 to 2.1
Other related tests:
- testGenericJavaProperty
- testFunInterfaceConstructorReference

Meta issue: KT-8575
Review: https://jetbrains.team/p/kt/reviews/9595

UnsupportedSyntheticCallableReferenceChecker only existed for K1,
because we wanted to release the feature for 1.9 and the feature should
have been working for K2 unconditionally. But since, we're postponing
the release until 2.1, we also need to port the checker from K1 to K2
2023-04-17 17:42:01 +00:00
Jinseong Jeon fbe558a0de AA FIR: handle smartcasted arg when building call's argument mapping
^KTIJ-25112 Fixed
2023-04-17 13:57:08 +02:00
Marco Pennekamp 73d99019bd [AA] KT-57515 Add createCompositeModificationTracker 2023-04-17 11:20:52 +00:00
Mikhail Zarechenskiy fc37885d6d K1: report a warning for invisible setter accessed from a derived class
The issue is that during binding fake overrides, the compiler doesn't
 differ setters from its properties, so the compiler uses the same
 visibility for setter and entire property.

 Changing logic at the binding stage can cause some unpredictable consequences so
 the fix is to do this differentiation right at the reporting stage

 ^KT-56662 Fixed

Merge-request: KT-MR-9565
Merged-by: Michail Zarečenskij <Mikhail.Zarechenskiy@jetbrains.com>
2023-04-17 11:08:16 +00:00
Marco Pennekamp d8f253d07b [LL FIR] KT-57207 Choose combined Java symbol providers cache size 2023-04-17 11:07:48 +00:00
Marco Pennekamp e13d4f2328 [LL FIR] KT-57207 Combine Java symbol providers
- `LLFirCombinedJavaSymbolProvider` combines multiple
  `JavaSymbolProvider`s. Its advantages are: combined index access,
  caching, classpath order disambiguation.
- Scopes can still be optimized with a combined scope instead of a naive
  union scope.

^KT-57207 fixed
2023-04-17 11:07:48 +00:00
Marco Pennekamp 3da3e14543 [LL FIR] KT-57220 Get rid of duplicate providers field 2023-04-17 11:07:47 +00:00
Marco Pennekamp b50ecfddb7 [LL FIR] KT-57220 Make combined symbol provider constructors private
- The combined symbol provider should always be constructed using the
  dedicated `merge` function.
2023-04-17 11:07:47 +00:00
Marco Pennekamp 624164e183 [LL FIR] Remove unused "multi module lazy resolve" test data
- The test `AbstractFirMultiModuleLazyResolveTest` which used this test
  data was moved to `intellij` with the following commit: https://github.com/JetBrains/kotlin/commit/39fa2b0baf89b246348b1e9c33cfebfc3068c014
- In `intellij`, the test was later deleted with the following commit: https://github.com/JetBrains/intellij-community/commit/042a50dcdff50b0771e73c6948b020a5366ef137#diff-74605de26ac0b4a2a65e53e919001d51199769822a46620ac34ba7e08e85f5e0
2023-04-17 10:57:06 +00:00
Mikhail Glukhikh 089222cecc K2: reproduce KT-57880 2023-04-17 10:21:24 +00:00
Jinseong Jeon 5403cc7feb SLC: fix type mapping mode for var
^KT-57578
2023-04-17 10:59:03 +02:00
Alexander Korepanov e8be3043cc [JS IR] Allow restriction of function argument by external type
Add a special annotation @JsExternalTypeArgument for
 marking function parameters. The marked parameter
 accepts an argument with an external type only.

^KT-57479 Fixed
2023-04-17 08:21:10 +00:00
Jaebaek Seo 3fbd3d7e20 [FIR] Return K2 reference shortener result
This commit sets a list of `KtElement` as the return type of
`ShortenCommand::invokeShortening()`. It allows us to take the result
i.e., shortened PSIs. This can be used, for example, when we want to
run code-format only on the shortened PSI after running the reference
shortener.

^KT-57636 Fixed
2023-04-14 21:50:20 +02:00
Anna Kozlova f810d435f4 [cls] write flexible type information to cls
^KTIJ-25172
this information would be used to create resolved FirElements from stubs,
so no ProtoBuf would be kept in memory
2023-04-14 18:12:48 +00:00
Dmitrii Gridin ffb705fe2f [AA FIR] add missing new line to addImportToFile
^KTIJ-24928
2023-04-14 16:37:12 +00:00
Roman Golyshev f662908440 KTIJ-25232 [FIR IDE] Do not shorten properties with non-trivial receiver
If property call receiver is something real (like another property or a
function call), then it should not be shortened because the semantics
might change

^KTIJ-25232 Fixed
2023-04-13 15:48:08 +00:00
Dmitrii Gridin 9724febf88 [AA FIR] add missing new line to addImportToFile
^KTIJ-24928
2023-04-13 11:38:32 +00:00
Kirill Rakhman 1f29490118 [FIR] Report when typealias expansion contains deprecated type
#KT-57843 Fixed
2023-04-13 10:50:36 +00:00
Denis.Zharkov fa8eca7a7b K2: Fix invokeExtension resolution when property type is implicit
^KT-57947 Fixed
2023-04-12 14:40:56 +00:00
Denis.Zharkov 39639e08f9 K2: Fix incorrect inference of delegated property type
It was working incorrectly, because we've been trying to fix
P1 variable to intersectTypes(String?, StubForP2) that should result
to String? because we've got stubEqualsToAnything enabled there,
but nullability was being chosen incorrectly because
`StubForP2.isNullableType()` returned false

NB: The code inside `is ConeTypeVariable` case wasn't working properly
because it always `lookupTag.toSymbol(session)` always returned null,
thus there was effectively five dead lines of code there.

^KT-57814 Fixed
^KT-57921 Related
2023-04-12 11:31:43 +00:00
Dmitriy Novozhilov f8ef478647 [FIR] Assume smartacsts on member properties from friend modules as stable
^KT-57893 Fixed
2023-04-12 08:59:03 +00:00
Dmitriy Novozhilov cfa06dbf74 [FIR] Fix incorrect usages of getClassLikeSymbolByClassId with lookup tag
^KT-57839 Fixed
2023-04-11 14:45:36 +00:00
Nikolay Lunyak f826011c9f [FIR] KT-57655: Add the missing branch
^KT-57655 Fixed
2023-04-11 13:49:07 +00:00
Anna Kozlova 1aba9460f2 [LL] fix resolving of compiled type value parameter
KT-57917
occurs when UAST requests e.g. annotations for the target parameter
to check correctness of nullability or Nls
2023-04-11 12:04:50 +00:00
Dmitrii Gridin 7d37bb1f78 [LC] FakeFileForLightClass: drop stub access from equals/hashCode
^KT-57857 Fixed
2023-04-11 09:19:39 +00:00
Jaebaek Seo 820d027676 [K2] Avoid shortening duplicated PSI elements
The existing K2 reference shortener collects all the PSI elements to
shorten. As a result, it possibly shortens duplicated PSI elements. For
example,
```
// FILE: main.kt
package a.b.c

fun test(n: Int) {
    return if (<expr>x.y.z.Outer.Inner.VALUE0 > x.y.z.Outer.Inner.VALUE1</expr>) 1
    else n
}
// FILE: values.kt
package x.y.z

class Outer {
    object Inner {
        val VALUE0 = 13
        val VALUE1 = 17
    }
}
```
for the above code, the existing K2 reference shortener tried to shorten
- x.y.z.Outer.Inner -> Inner
- x.y.z.Outer.Inner.VALUE0 -> VALUE0
- x.y.z.Outer.Inner -> Inner
- x.y.z.Outer.Inner.VALUE1 -> VALUE1

`x.y.z.Outer.Inner` is included in the list to shorten twice.
When it actually shortens the PSI elements, it shortens only
- x.y.z.Outer.Inner.VALUE0 -> VALUE0
- x.y.z.Outer.Inner.VALUE1 -> VALUE1

but it imports all of
- x.y.z.Outer.Inner
- x.y.z.Outer.Inner.VALUE0
- x.y.z.Outer.Inner.VALUE1

As a result, it has unnecessary additional import directives.
This commit fixes the issue by avoiding duplicated shortening for a
single PSI element.
2023-04-10 11:00:11 +00:00
Anna Kozlova 22b0a8d9fb [FIR] reference shortener should not touch fake sources
e.g. implicit types can't be shortened.
On the other hand, requesting textRange means building ast
which might be slow, especially for compiled code
2023-04-06 15:44:02 +00:00
Bart van Helvert f7ec5885f5 KT-56200 Don't leak user code in reference resolve exception 2023-04-06 12:04:13 +00:00
Anna Kozlova de965d39be [LL] always get fir from decompiled stubs 2023-04-06 11:50:39 +00:00
Dmitrii Gridin 03eab387c0 [FIR] FirRenderer: render annotation resolve phase as well
^KT-56543
2023-04-06 08:09:41 +00:00
Nikolay Lunyak 03e2152957 [FIR JS] Support 2 JS diagnostics
The change in `FirDiagnosticsHandler` ensures
`DEBUG_INFO_DYNAMIC` is still reported in
`FirPsiJsOldFrontendDiagnosticsTestGenerated.testConventions`.

Support `SPREAD_OPERATOR_IN_DYNAMIC_CALL` and
`WRONG_OPERATION_WITH_DYNAMIC`
2023-04-05 16:51:51 +00:00
Roman Efremov b368b78faa [FE] Prohibit protected members in final expected or actual classes
^KT-28850 Fixed
2023-04-05 15:25:46 +00:00