Commit Graph

104713 Commits

Author SHA1 Message Date
Pavel Kunyavskiy aef5290210 [K/N] Change test to make aggregate green.
The test is using error suppressing, so breaking it is fine.


^KT-62015
2023-09-18 20:02:36 +00:00
Yan Zhulanow 40ecd4bc1e [fir2ir] Fix annotation conversion on partial module compilation
Backend requires annotation constructors to be fully resolved for the
'IrConst' default value lowering. However, in the IDE there is usually
no need in complete annotation class resolution.

^KTIJ-27061 Fixed
2023-09-18 19:48:08 +00:00
Yan Zhulanow 480bac7537 [fir2ir] Fix conversion of modules with source built-ins
In the Kotlin compiler project, built-in classes are resolved to source
declarations. It's not an issue for usual file analysis in the IDE, as
referenced built-ins are analyzed on demand.

Fir2ir, however, fetches built-in classes at once without checking its
resolution state, breaking code compilation in the IDE.

^KTIJ-27061 Fixed
2023-09-18 19:48:08 +00:00
Yahor Berdnikau ac18f6e16e [Gradle] Fix common sources are not included for kaptGenerateStubs task
^KT-61622 Fixed
2023-09-18 18:52:28 +00:00
Yahor Berdnikau 005e3c0939 [Gradle] Update test verifying MPP/Jvm project is working with Kapt
We have such test, but it was using long deprecated platform plugins.

^KT-61622 In Progress
2023-09-18 18:52:28 +00:00
Dmitriy Dolovov a2e148173d [JS] Don't produce metadata-only (IR-less) KLIBs in JS
The scenario when JS source code is shared between a few JS common
source sets is not supported in Kotlin Multiplatform.

^KT-61136
2023-09-18 17:58:43 +00:00
Vladimir Sukharev 9a2eff6487 [FIR2IR] Don't replace while loop and when branch body blocks with single expression. Skip some empty blocks.
https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression

Merge-request: KT-MR-12035
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-18 15:27:19 +00:00
Dmitrii Gridin f4df4f8007 [FIR] do not invoke body resolution for properties with excplicit type on implicit type phase
`property.backingField != null` is too soft condition because currently
each property has a backing field. We should trigger the full body
resolution only in the case of an implicit type on the property or on
the backing field

^KT-61991 Fixed
2023-09-18 15:26:53 +00:00
Dmitriy Novozhilov 97cf240450 [FIR] Reuse enhancement storage during creation of synthetic properies
^KT-61972 Fixed
2023-09-18 15:09:07 +00:00
Jinseong Jeon cec299ac0a K2 UAST: Improve performance of PSI declaration provider
When it comes to finding regular class (of `PsiClass`) from the given
`ClassId`, we've reinvented the wheel in a worse way. `JavaFileManager`
is there to find `PsiClass`, and we already build/populate index for
that while initializing AA standalone mode's own project environment.
We can simply load that manager and send a query, that's it.

However, our efforts so far on binary PSI declaration providers are not
entirely useless. `JavaFileManager` can't handle top-level declarations
and search for all callables/classes in a given package in general. So,
we can still use existing logic for non-ClassId queries. We just need to
cache the intermediate results: fq name to `VirtualFile`s.

To fully utilize the aforementioned cache, we also need to cache an
instance of `KotlinPsiDeclarationProvider`.

Combing these three ideas, now running K2 UAST on a very large module is
"on par", e.g.,
K1:
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 112.8s
  Stats over 7 runs: max = 112.8s, min = 104.3s, avg = 107.9s, dev = 3.6s
K2 (before):
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 303.0s
  Stats over 7 runs: max = 303.0s, min = 286.8s, avg = 294.4s, dev = 5.0s
K2 (after):
//tools/adt/idea/android:intellij.android.core_lint_test PASSED in 112.8s
  Stats over 7 runs: max = 112.8s, min = 105.7s, avg = 108.9s, dev = 2.4s
2023-09-18 14:55:11 +00:00
Ilya Goncharov 6a514c3209 [Gradle, Wasm] Binaryen to wasm targets
^KT-62024 fixed
^KT-62025 fixed
2023-09-18 14:42:20 +00:00
Alexander Udalov bb381e7aef IR: check visibility when building fake overrides
This fixes the difference at least in the IR text test
testFakeOverridesForJavaNonStaticMembers. There's no fake override
created anymore for `packagePrivateMethod` in Test2.

 #KT-61366 Fixed
2023-09-18 12:33:07 +00:00
Roman Efremov a23f2894b2 [K2] Support reporting of EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
^KT-59982 Fixed
2023-09-18 12:22:42 +00:00
Roman Efremov 5623427c6d [Test] Extract test for EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER
...to separate file. Also, add 3 cases with true-negative reporting:
annotation class, value class and secondary constructor.

^KT-59982
2023-09-18 12:22:42 +00:00
Roman Efremov 489371219f [K2] Support reporting of EXPECTED_ENUM_CONSTRUCTOR
^KT-59980 Fixed
2023-09-18 12:22:42 +00:00
Roman Efremov 6112c4ab2c [K2] Rewrite condition for EXPECTED_PRIVATE_DECLARATION
...without `isTopLevelOrInsideClass` property. Behavior stays the same,
because in fact we require all `expect` member declarations to be non-private
except constructors and property setter.
Enhance already existing test.

^KT-59899
2023-09-18 12:22:41 +00:00
Roman Efremov 1fdc607898 [K2] Fix EXPECTED_DECLARATION_WITH_BODY not reporting on property accessors
We don't want any `expect` function to have body. So we're sure no
new false-positive reports are introduced because of removal of
`isTopLevelOrInsideClass` condition.

^KT-59899 Fixed
2023-09-18 12:22:41 +00:00
Roman Efremov 4404e5f036 [K2] Refactor: extract conditions in FirExpectConsistencyChecker
...to separate methods.

After the change each diagnostic report has its own condition,
independent from others, so you don't have to keep in mind
"we're in else branch, so this is already not a FirConstructor
and also it either top-level or inside classs".
This makes changes in next commits more clear and verifiable.

`isTopLevelOrInsideClass` condition for
`getConstructorDelegationCall` is not needed, because
constructor is always inside class.

^KT-59899
2023-09-18 12:22:41 +00:00
Kirill Rakhman dda6d20520 [FIR] Add test for WRONG_MULTIPLE_INHERITANCE with typealias
#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 6a2b6e03d4 [FIR] Fix false negative ILLEGAL_JAVA_LANG_RECORD_SUPERTYPE
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 0d279dd652 [FIR] Fix false negative JVM_STATIC_ON_CONST_OR_JVM_FIELD
... in presence of typealias.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 7a65c36bfc [FIR] Add test for CLASS_CANNOT_BE_EXTENDED_DIRECTLY with typealias
#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 2d4646a285 [FIR] Fix false negative sealed diagnostics
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 36c0c2c76b [FIR] Fix false negative TYPE_PARAMETER_AS_REIFIED_ARRAY
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman f5f77d43bf [FIR] Fix false negative NO_REFLECTION_IN_CLASS_PATH
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 5d7e6f2aab [FIR] Use fullyExpandedClassId in FirTypeAliasExpandsToArrayOfNothingsChecker 2023-09-18 12:13:02 +00:00
Kirill Rakhman 98e6c0278a [FIR] Fix false negative REPEATED_BOUND
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 9949de36c9 [FIR] Fix false negative ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:02 +00:00
Kirill Rakhman 9475bc250c [FIR] Fix false negative REDUNDANT_CALL_OF_CONVERSION_METHOD
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:01 +00:00
Kirill Rakhman e788c7166a [FIR] Fix false negative REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE
... in presence of typealiases.

#KT-61921
2023-09-18 12:13:01 +00:00
Kirill Rakhman 373ffbc779 [FIR] Fix false positive CONST_VAL_WITH_NON_CONST_INITIALIZER
... in presence of typealiases.

#KT-61499 Fixed
2023-09-18 12:13:01 +00:00
Kirill Rakhman b72ac4f560 [FIR] Introduce helper method ConeKotlinType.fullyExpandedClassId 2023-09-18 12:13:01 +00:00
Nikolay Lunyak 93958ec73d [FIR] Check conflicts between nested classes' constructors and member functions
For an example of an object with
an implicit primary constructor,
see `FirPsiOldFrontendDiagnosticsTestGenerated.testSingletonAndFunctionSameName`.

^KT-62005 Fixed


Merge-request: KT-MR-12242
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-09-18 11:41:42 +00:00
strangepleasures 777df2d923 KT-60092 Fix suppression logic for EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR 2023-09-18 11:17:10 +00:00
Roman Golyshev a78d631b16 KTIJ-27050 [Analysis API] Correctly handle type parameters in KtFirReferenceShortener
Make `FirShorteningContext` correctly return symbols for type
parameters, so they are not ignored when scopes are inspected

Add additional type of `PartialOrderOfScope` - `TypeParameter`, because
otherwise it would have been classified as `Unclassified`, and that
breaks scopes comparison

Add missing type parameters to the scope of class header in
`ContextCollector`, add testdata for that

There is a bug in the compiler with type parameters leaking to nested
classes headers (KT-61959). After it's fixed, the testData with
incorrect expected shortenings/scopes should be adjusted and fixed too

^KTIJ-27050 Fixed
2023-09-18 10:23:30 +00:00
Roman Golyshev e2019ceb95 KTIJ-27050 [Analysis API] Refactor FirShorteningContext
Use `AvailableSymbol<FirClassLikeSymbol<*>>` instead
of `AvailableSymbol<ClassId>`
2023-09-18 10:23:29 +00:00
Roman Golyshev 020f8c0742 KTIJ-27050 [Analysis API] Refactor FirShorteningContext
Remove duplication from `findFirstClassifier*` functions
2023-09-18 10:23:29 +00:00
Dmitriy Novozhilov 9a6c6a40a9 [FIR2IR] Allow symbolTable cache lookups for generated Any methods
^KT-61972 Fixed
2023-09-18 09:16:15 +00:00
Ilya Goncharov afbfc9ce8e [Gradle, wasm] add checker about changed wasm source sets
^KT-61950 fixed
2023-09-15 20:56:31 +00:00
strangepleasures c31a3869c6 [KAPT] Fix package names org.jetbrains.kotlin.base.kapt3 -> org.jetbrains.kotlin.kapt3.base 2023-09-15 19:36:30 +00:00
Roman Golyshev b4209a4196 KT-61889 [Analysis API] Remove last usage of onAirResolve from Reference shortener
Add factory function `create` to
`FirTowerContextProviderByContextCollector`

^KT-61889 Fixed
2023-09-15 19:18:09 +00:00
Evgenii Mazhukin 7d762c9754 [KGP] Drop link to removed documentation 2023-09-15 18:26:42 +00:00
Vladimir Sukharev 56b951152f [FIR] K2: Fix introduced diagnostic UNDERSCORE_USAGE_WITHOUT_BACKTICKS
^KT-60105 Fixed


Merge-request: KT-MR-12214
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-15 16:37:50 +00:00
Mikhail Glukhikh 5e8741db1a K2: deal with callable copy return type update more accurately
Related to KT-61443
2023-09-15 15:21:10 +00:00
Mikhail Glukhikh f8ada456e4 K2: rename FakeOverrideTypeCalculator to CallableCopyTypeCalculator
This commits performs a rename.
According to KT-61443 this calculator is applicable not only to
fake (substitution/intersection) overrides.
2023-09-15 15:21:10 +00:00
Mikhail Glukhikh 53e4e2f6b1 K2: update return type properly for delegated members #KT-61443 Fixed 2023-09-15 15:21:10 +00:00
Mikhail Glukhikh 1b9197dd17 K2: reproduce KT-61443 2023-09-15 15:21:10 +00:00
Roman Efremov e79851910e [FE, IR] Check annotations compatibility on expect and actual getters and setters
^KT-60671
2023-09-15 14:41:38 +00:00
Roman Efremov 8fb2935ef6 [FE, IR] Check annotations compatibility on expect and actual type parameters
^KT-60671
2023-09-15 14:41:37 +00:00
Roman Efremov 420dceb7d8 [FE, IR] Store PsiElement for mismatched annotation's actual target
There is IDE quick fix which suggests to copy mismatched annotation
from `expect` to `actual` (see KTIJ-26633). It needs to find
`actual` PsiElement where to add annotation. Before previous commit, it
was easy - just get source of `Incompatibility.actualSymbol`.
After previous commit, the problem might be in value parameter, while
`actualSymbol` would contain function symbol. This is solved by adding
new field `Incompatibility.actualAnnotationTargetElement`.

`SourceElementMarker` introduced, because it's needed to be used in
abstract checker. Existing `DeclarationSymbolMarker` doesn't fit
because in next PR for this issue annotations set on types will be reported,
and types are not declarations.

^KT-60671
2023-09-15 14:41:37 +00:00