Commit Graph

104356 Commits

Author SHA1 Message Date
Timofey Solonin 14bed668d4 Revert "[MPP] Emit a warning when kotlin-test testing framework couldn't be inferred"
This reverts commit 256d9da24c.

Revert "[MPP] Only add test framework dependency once per configuration"

This reverts commit 65649673a7.

^KT-56828
2023-09-05 18:55:15 +00:00
Dmitrii Gridin 5e63d1a5e5 [LL FIR] drop obsolete workaround
The original problem is already fixed

^KTIJ-26848
2023-09-05 18:39:41 +00:00
Ilya Kirillov af1cfa1cb6 [LL FIR] fix resolution ambiguities on a complex project structure with multiple overloads on the same function
Previously, If we had multiple overloads of the same function in the same file,
then `LLFirProvider.SymbolProvider.getTopLevelPropertySymbols`
might be called with multiple copies of the same `KtFile`,
thus providing multiple copies of the same `FirNamedFunctionSymbol`.

It might be reproduced when `LLFirCombinedKotlinSymbolProvider` is used
and if nobody accessed `LLFirProvider.SymbolProvider` without a context.
A wrong result with multiple duplicating symbols will be cached in this case.

The commit fixes KT-61683 as `ConeOverloadConflictResolver` prefers actuals over expects
only in a case of valid code when an actual has a single corresponding expect.
It was not true because of the bug; thus, the problem from KT-61683 arose.

^KT-61683 fixed
2023-09-05 15:52:14 +00:00
Vladimir Sukharev f14b48a4b0 [K/N] Don't use KonanIrModuleFragmentImpl in irText test pipeline
^KT-58240
2023-09-05 15:33:25 +00:00
Ilmir Usmanov ae8b896c7b Minor. Add regression test for KT-59051
FIR2IR generates correct IR, unlike PSI2IR.
 #KT-59051 Fixed
2023-09-05 15:11:36 +00:00
Ilmir Usmanov 184b5cebe7 Minor. Add regression test for KT-60136
Spread operator works incorrectly in K1, but correctly in K2.
 #KT-60136 Fixed
2023-09-05 15:11:36 +00:00
Dmitriy Novozhilov 2d334c4e71 [Test] Merge multiple abstract legacy test runners into a single one
There was only one real inheritor of AbstractFirBaseDiagnosticTest,
  so there is no need in the whole hierarchy of abstract test runners

Also AbstractFirOldFrontendLightClassesTest is not intended to check any
  diagnostics or CFG dumps, so this logic was removed (they still can be
  checked using non-legacy AbstractFirDiagnosticTest from the main test
  infrastructure)
2023-09-05 14:59:36 +00:00
Dmitriy Novozhilov fa4c6d55c1 [FIR] Store mapped jvm declarations in session component, share it between MPP modules
^KT-61640 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.testJavaMethodWithTypeParameter
2023-09-05 14:43:43 +00:00
Dmitriy Novozhilov bb36beb364 [FIR] Share enhancedSymbolStorage between common and platform sessions
This is needed for two reasons:
1. common and platform modules are analyzed in the same setup with same
   dependencies and configurations, so the results of the enhancement for
   any function will be completely identical. So by sharing enhanced
   symbol storage, we avoid recomputation enhanced functions and improve
   performance
2. There is a goal to have some unique key for IR declarations in FIR2IR.
   For regular declarations, the key is just Fir symbol, and for fake-overrides
   it is a pair of original symbol and fake override owners lookup tag.
   But for enhanced functions the symbol is not unique, because we create
   different symbols for the same enhanced function for different modules.
   So this change fixes this problem

^KT-60397 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there are some test breaks in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.testStarImportOfExpectEnumWithActualTypeAlias
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.DefaultArguments.testNestedEnumEntryValue
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.Basic.testEnumEntryNameCall
2023-09-05 14:43:43 +00:00
Alexander Shabalin f4289e1287 [K/N] Enable concurrent weak processing ^KT-61093 2023-09-05 13:53:35 +00:00
Dmitrii Gridin bd10ee10fe [psi] avoid usage of SAFE_IDENTIFIER_FOR_NO_NAME
This name leads to inconsistency between FqName from stub and
FqName from ClassId.
The first one is `no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40`
but the second one is `<no name provided>`.
We can't just replace SAFE_IDENTIFIER_FOR_NO_NAME to NO_NAME_PROVIDED
due to many places with unsafe logic inside type mapping.

^KTIJ-26848 Fixed
2023-09-05 12:58:50 +00:00
Dmitrii Gridin ae02d78aff [PSI] ClassIdCalculator: cleanup code
^KTIJ-26848
^KTIJ-26896
2023-09-05 12:58:50 +00:00
Dmitrii Gridin 0701da6c59 [stub] simplify ClassId creation
We can create nested ClassId just from the parent stub instead of calculation by tree.
This commit simplified the complexity of ClassId building to liner.
Example:
```kotlin
package one
class A {
  class B {
    class C {
      class D
    }
  }
}
```
Previously, we had to create ClassId by traverse parents for each class.
Now we will visit each class only once.
It should improve performance and memory consumption during indexing.

^KTIJ-26848
2023-09-05 12:58:50 +00:00
Dmitrii Gridin 2421d3cdf1 [LL FIR] ClassId: add more tests
^KTIJ-26848
^KTIJ-26896
^KTIJ-26902
2023-09-05 12:58:50 +00:00
Brian Norman f51b7faa1b [FIR] Only track assignment nodes for uncaught exception edges in CFG
UncaughtExceptionPath edges are used to influence smart-casting within
catch and finally blocks. Previously these edges were added from every
node which could throw an exception. But only assignment nodes influence
smart-casts by resetting inference back to some less specific type.
Therefore, instead of tracking every possible node which could throw an
exception - even though almost every statement node can - only add edges
from assignment nodes to catch and finally blocks. This fixes many
missing exception cases and also reduces the total number of incoming
edges to catch and finally blocks.

#KT-56872 Fixed
2023-09-05 11:59:13 +00:00
Vladimir Sukharev 2a4681b91d Adjust diagnostic tests for proper K1/N stdlib
^KT-58240
2023-09-05 11:42:46 +00:00
Vladimir Sukharev 3aa6c9e74d [K/N] Run irText tests for K1/Native
^KT-58240
2023-09-05 11:42:45 +00:00
Ivan Kylchik 40c9f831e2 [Native] Drop IrUtils2 file 2023-09-05 11:21:51 +00:00
Ivan Kylchik 8142ae2579 [Native] Drop irCatch from IrUtils2 2023-09-05 11:21:51 +00:00
Ivan Kylchik c2076a0227 [Native] Move hasNonConstInitializer from IrUtils2
This function could be useful for other backends.
2023-09-05 11:21:51 +00:00
Ivan Kylchik ddde95bd78 [Native] Move irByte from IrUtils2
We already have similar functions in `ExpressionHelpers`. Makes
sense to keep them together.
2023-09-05 11:21:51 +00:00
Ivan Kylchik d62323cdf1 [Native] Move addTopLevelInitializer from IrUtils2
This function is actually used only in `InteropLowering` and it
is too specific to be included into utils.
2023-09-05 11:21:51 +00:00
Ivan Kylchik 5cd96831dc [Native] Move isRestrictedSuspendFunction from IrUtils2
This function is also helpful for JVM backend.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 2657adc6dc [Native] Move addFile from IrUtils2
This function is actually used only in `BackendPhases` and it is
too specific to be included into utils.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 4fb29a5e12 [Native] Drop addArguments from IrUtils2
We can simplify single usage of this function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 20165dd699 [Native] Drop defaultOrNullableType from IrUtils2
We can simplify most usages of `defaultOrNullableType`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 583a5496d5 [Native] Drop irCall from IrUtils2
We can reuse the same function from common `ExpressionHelpers`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 5c68ea2b64 [Native] Simplify irCatch from IrUtils2 2023-09-05 11:21:50 +00:00
Ivan Kylchik 8cc4db39d2 [Native] Drop copy from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik b3474ac730 [Native] Drop irBuilder from IrUtils2
We can reuse `createIrBuilder` function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 9e750e900d [Native] Drop createField from IrUtils2
We can call `IrFieldImpl` directly, the same way it is done
for other IR declarations in `CBridgeGen` file.
2023-09-05 11:21:50 +00:00
Ivan Kylchik 7e71e778c9 [Native] Drop stub from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik b10d330cfd [Native] Drop getContainingFile from IrUtils2
We can reuse `fileOrNull` function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik a437e0378a [Native] Drop irCallOp from IrUtils2
It is not used anywhere
2023-09-05 11:21:50 +00:00
Ivan Kylchik 4376e58acb [Native] Drop createArrayOfExpression from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 962172f96d [Native] Drop irSetVar from IrUtils2
We can reuse `irSet` function
2023-09-05 11:21:50 +00:00
Ivan Kylchik 9ab053a3a6 [Native] Drop substitute from IrUtils2
We can reuse the same function from common `IrTypeUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik d0a5738499 [Native] Drop addChild from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:50 +00:00
Ivan Kylchik 3efe07d0cb [Native] Drop getArgumentsWithIr from IrUtils2
We can reuse the same function from common `IrUtils`
2023-09-05 11:21:49 +00:00
Ivan Kylchik abc061e17f [IR] Restore and fix ifConstVal test
It was accidentally dropped after KT-55196 fix.
2023-09-05 11:06:43 +00:00
Alexander Udalov 34f52aaeda Reflection: fix callBy for functions with 32 * N parameters
Optimization in 2439c22ff6 introduced an array `absentArguments` with
default values of all parameter types, which is copied in `callBy`
instead of being recomputed each time. Unfortunately, its size was
computed incorrectly: `maskSize` should only take into account
value parameters (see the `parameter.kind == KParameter.Kind.VALUE`
check in `callBy`).

This led to an issue where if the function had 32 * N value parameters
and 1 receiver parameter, `maskSize` was greater by 1 than expected,
which caused an exception due to mismatching argument array sizes.

 #KT-61304 Fixed
2023-09-05 11:05:29 +00:00
Jinseong Jeon 421cd9929b SLC: use optimal type mapping mode for receiver parameter
...and other kinds of parameters as well
2023-09-05 10:33:54 +00:00
Jinseong Jeon 4cdc22c9cc AA FIR: use fully expanded type when computing optimal type mapping mode
^KT-61460 Fixed
2023-09-05 10:33:53 +00:00
Dmitriy Novozhilov 1868b29cc9 [FIR] Don't map java functions which override kotlin builtin function with erased parameter type if it's not needed
There is a case when we shouldn't hide a function even if it overrides
  builtin member with value parameter erasure: if substituted kotlin
  overridden has the same parameters as current java override. Such
  situation may happen only in case when `Any`/`Object` is used as
  parameterization of supertype:

// java
class MySuperMap extends java.util.Map<Object, Object> {
    @Override
    public boolean containsKey(Object key) {...}

    @Override
    public boolean containsValue(Object key) {...}
}

In this case, the signature of override, made based on the correct
  kotlin signature, will be the same (because of { K -> Any, V -> Any }
  substitution for both functions). And since the list of all such
  functions is well-known, the only case when this may happen is when
  value parameter types of kotlin overridden are `Any`

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
`FirPsiBlackBoxCodegenTestGenerated.SpecialBuiltins.testMapGetOrDefault`
2023-09-05 10:18:24 +00:00
Pavel Kirpichenkov cf98fb5612 [Tests] Add .knm stub consistency test
The test compares stub trees built from .knm files directly and from
the decompiled text. Test data for .class decompiler is reused,
JVM-specific cases are ignored

KT-61354
2023-09-05 09:36:25 +00:00
Ivan Kylchik 2537ff94b7 [Native] Move StringTable and its builder to separate file 2023-09-05 08:35:48 +00:00
Ivan Kylchik 86b4d36b54 [Native] Make StringTable and its builder internal 2023-09-05 08:35:47 +00:00
Ivan Kylchik 70697af6b9 [Native] Move proto utils from KonanIrLinker into separate utils file 2023-09-05 08:35:47 +00:00
Ivan Kylchik 66b9c2f260 [Native] Move FORWARD_DECLARATION_ORIGIN into KonanForwardDeclarationModuleDeserializer 2023-09-05 08:35:47 +00:00
Ivan Kylchik cc906ad6d5 [Native] Move INVALID_INDEX into KonanPartialModuleDeserializer 2023-09-05 08:35:47 +00:00