Commit Graph

104385 Commits

Author SHA1 Message Date
Artem Kobzar bff433f4e9 [K/JS] Support eager initialization for per-file granularity 2023-09-06 09:27:28 +00:00
Dmitriy Novozhilov f203681ffa [FIR] Make extensionReceiver and dispatchReceiver nullable
Get rid of FirNoReceiverExpression

^KT-59650 Fixed
2023-09-06 09:25:22 +00:00
Kirill Rakhman 585c3fe4b5 [Tests] Add test for #KT-61717 2023-09-06 08:34:04 +00:00
Alexander Udalov fec2d063c1 K2: report PRE_RELEASE_CLASS on JVM
Note that 3 tests are still muted, but for another reason: for FIR
versions of the tests, we need to compile the "pre-release library" with
the next language version which is 2.1. But since currently
LanguageVersion.LATEST_STABLE is 1.9, the compiler refuses to read
metadata of version 2.1, regardless of its own language version. Which
is correct, but it leads to irrelevant errors in the test output -- the
ones about the incompatible metadata version, NOT about the
prereleaseness.

These 3 tests can be unmuted once the default language version is
switched to 2.0.

 #KT-60780 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8738ffb84f K2: suppress exception when reading unsupported metadata
Before the change, the compiler threw exception in the unmuted tests,
because it tried to load metadata even though it had an unsupported
version. Use the same approach as in K1 (see
DeserializedDescriptorResolver).

Now the tests are unmuted, but note that test data differs from K1. K1
does not report errors related to the class `a.A` because it loads this
class as a _Java class_, so calling its constructor and methods somehow
works. This behavior is questionable since the compiler surely knows
that it is a Kotlin class, but with an unsupported metadata version.
Trying to interpret it as a Java class may lead to subtle problems. So
it's safer for now to avoid loading Kotlin classes with unsupported
metadata versions in K2.

 #KT-60795 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8f720ad24b K2: support -Xskip-metadata-version-check
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov 7d60b5df43 K2: report INCOMPATIBLE_CLASS in JVM
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov db8fb30343 K2: minor cleanup in JvmClassFileBasedSymbolProvider 2023-09-06 08:05:34 +00:00
Alexander Udalov 1d5ade1166 K2: minor, remove misleading FirMemberDeclaration.containerSource
"Container source" means "the source of the container". So, if you
called this extension on a class (`FirClassLikeDeclaration`), it was
reasonable to assume that you would get the source of its _containing
class_, whereas the function actually returned the source of the class
itself.

Instead of inventing another name for this function, I've decided to
inline and remove it because it has only one usage.
2023-09-06 08:05:34 +00:00
Alexander Udalov 54a5f7d8f2 Remove unused test data on JS metadata version
Apparently these tests are no longer being run after a6d461dbe8.
2023-09-06 08:05:33 +00:00
Kirill Rakhman 393a5d6c14 [FIR] Fix IAE in TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
IllegalArgumentException: class
org.jetbrains.kotlin.psi.KtLambdaArgument is not a subtype of class
org.jetbrains.kotlin.psi.KtExpression for factory
TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
was reported when TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM was
reported on a FirLambdaArgumentExpression, report it on its
`expression` instead.

#KT-60380 Fixed
2023-09-06 07:38:34 +00:00
Ilya Kirillov f7352585f4 [Analysis API Standalone] do not add non-supported file types to KtSourceModule
^KT-60884
2023-09-06 07:36:12 +00:00
Ilya Kirillov c76f365efb [Analysis API Standalone] change behavior of StandaloneAnalysisAPISession.getModulesWithFiles
- it now returns a map only for `KtSourceModule`
- every `KtSourceModule` is present there, even a module without source files

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov a2015a6eb5 [Analysis API Standalone] fix wrongly registered KtLifetimeTokenProvider for standalone mode tests
`KtAnalysisSessionProvider` cached the incorrect `KtLifetimeTokenFactory` before the proper one was registered

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 43a8ae98b7 [Analysis API Standalone] add basic tests for buildStandaloneAnalysisAPISession
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 0416e0423f [Analysis API Standalone] deduplicate binary roots for KtBinaryModuleBuilder
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov d459981974 [Analysis API Standalone] return as a result created module in KtModuleProviderBuilder.addModule so it can be reused
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov fcf062a252 [Analysis API Standalone] simplify initializing KtSdkModuleBuilder with JDK
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 1f290828e5 [Analysis API Standalone] use the full version of jdk root finding from IJ
partial ones only work for jdk >= 9

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 8f824dcff9 [Analysis API Standalone] copy JdkClassFinder from IntelliJ sources
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 180434951b [Analysis API Standalone] simplify adding source binary roots for KtSourceModuleBuilder
- allow providing source files instead of PsiFile
- automatically provide GlobalSearchScope for created `KtSourceModule`

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 67f4ebc022 [Analysis API Standalone] simplify adding multiple binary roots for KtBinaryModuleBuilder
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 52e9167675 [Analysis API Standalone] reuse existing local file system in getPsiFilesFromPaths
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov e6bd34b671 [Analysis API Standalone] refactoring, use Path instead of String for path representation
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov eb2c4e4015 [Analysis API Standalone] automatically collect GlobalSearchScope for KtBinaryModule
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 97a7c0b6ff [Analysis API Standalone] extract functions for getting GlobalSearchScope by roots to utils
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 3f689494ad [Analysis API Standalone] do not force users to provide a project for building KtModule as it's already known
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov dca4015cba [Analysis API Standalone] get rid of deprecated utils for initializing the standalone mode
they were deprecated and there are no clients for them now

^KT-60884
2023-09-06 07:36:11 +00:00
strangepleasures f2078caf64 [KAPT4] Support -Xmetadata-version in Kapt for testing with external projects 2023-09-05 23:23:24 +00:00
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