Commit Graph

108456 Commits

Author SHA1 Message Date
Xuan-Son Trinh f4f009cb9a [JPS] Fix KotlinJvmModuleBuildTarget.findJavaSourceRoots to only return Java source roots
This change is needed because otherwise, source files that are not Java will be added as `JavaSourceRoot`, this is incorrect and causes assertion error in `com.intellij.core.JavaCoreProjectEnvironment.addSourcesToClasspath`. Refer to KT-65325 for more context.


Merge-request: KT-MR-14088
Merged-by: Xuan Son Trinh <xuanson.trinh@jetbrains.com>
2024-01-31 16:52:42 +00:00
Nikita Bobko d69deb97fe K2: Put boolean DFA variables under a feature flag
^KT-62547 Fixed

I also tested the commit by disabling DfaBooleanVariables in all tests
and checking what tests will fail

I didn't find anything that worked in K1, but doesn't work in K2 with
DfaBooleanVariables disabled

Related tests:
- DiagnosticCompilerTestFirTestdataTestGenerated$Resolve$Smartcasts
- LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated$Resolve$Smartcasts
- PreFirIdeSpecTestGenerated$NotLinked$Dfa
- DiagnosticCompilerTestFE10TestdataTestGenerated$Tests$SmartCasts
- FirPsiDiagnosticTestGenerated$Resolve$Expresssions.testSyntheticSmartCast
2024-01-31 16:31:02 +00:00
Vladimir Sukharev 118a5cee06 [K/N][Tests] Cleanup tests code from old infra
^KT-61259
2024-01-31 16:17:21 +00:00
Vladimir Sukharev 2276abfb85 [K/N][Tests] Use GTest patterns for ignored tests
^KT-61259
2024-01-31 16:17:21 +00:00
Vladimir Sukharev 1ca79e645a [K/N][Tests] Use runProcess for code signing
^KT-61259
2024-01-31 16:17:21 +00:00
Vladimir Sukharev 524f0d335e [K/N][Tests] Migrate objcSmoke & objcTests tests
^KT-61259
2024-01-31 16:17:21 +00:00
Alexander.Likhachev 58f7dd1c83 [Daemon] Change default Kotlin daemon JVM options
Now, the Kotlin daemon enables parallel GC and uses code cache flushing by default. Also, the default reserved code cache size is adjusted.

^KT-64283 Verification Pending
2024-01-31 15:13:02 +00:00
Alexander.Likhachev dbdcce0655 [Daemon] Fix a typo in the jvm arguments 2024-01-31 15:13:02 +00:00
Kirill Rakhman 853ad54699 [FIR] Fix incorrect updating of callable reference type in delegated property
... if the delegate happens to be a function call whose second
argument is a callable reference but not actually a provideDelegate
call.
The fix is to ensure that the call is _actually_ a desugared
provideDelegate call.

This fixes a CCE in a case where the delegate expression is a regular
function call and the second argument is a callable reference.

#KT-65165 Fixed
2024-01-31 14:51:51 +00:00
Brian Norman fced126c9f [FIR] Properties defined in a do-while may not always be initialized
Local properties defined within the body of a do-while loop can be used
in the condition of the loop. However, use of a `continue` may mean the
property isn't always initialized, even if it is initialized when it is
defined. So while a local property may be within scope and has an
initializer, this doesn't always mean that the property is initialized.

As such, properties that are defined within a do-while loop and also
used in the condition of the same do-while loop should be tracked. Then,
these properties should still be checked for proper initialization even
if they have an initializer.

^KT-64872 Fixed
2024-01-31 13:37:30 +00:00
Igor Chevdar 4af8b70f62 [K/N][IR] Skip static fields in initializers lowering
#KT-65010 Fixed
2024-01-31 12:22:36 +00:00
Alexander.Likhachev 5c4fbcb623 [Gradle] Fix warnings in DefaultCInteropSettings
^KT-56904 In Progress
2024-01-31 12:20:06 +00:00
Alexander.Likhachev 839723e4de [Gradle] Fix warnings in KotlinCocoapodsPlugin
^KT-56904 In Progress
2024-01-31 12:20:06 +00:00
Alexander.Likhachev 8833193349 [Gradle] Fix warnings in GenerateArtifactPodspecTask
^KT-56904 In Progress
2024-01-31 12:20:05 +00:00
Alexander.Likhachev de504c9e93 [Gradle] Fix warnings in KotlinCompilationNpmResolution
^KT-56904 In Progress
2024-01-31 12:20:05 +00:00
Alexander.Likhachev 4de2f7ef27 [Gradle] Fix warnings in KotlinRootNpmResolver
^KT-56904 In Progress
2024-01-31 12:20:05 +00:00
Alexander.Likhachev e159524c43 [Gradle] Fix warnings in forAllAndroidVariants extension
^KT-56904 In Progress
2024-01-31 12:20:05 +00:00
Alexander.Likhachev 8fe65d2fee [Gradle] Fix warnings in ClassLoadersCache
This check is required due to the way of generic type declaration in the Guava code
^KT-56904 In Progress
2024-01-31 12:20:05 +00:00
Marco Pennekamp 64ad40e863 [LL] LLFirAbstractSessionFactory: Fix eager loading of anchor module sessions
- `LLFirAbstractSessionFactory` should not load other sessions eagerly
  because session creation occurs inside a `computeIfAbsent`, which does
  not allow recursive updates to the session cache.
- The issue has not surfaced so far because the default implementation
  of `computeIfAbsent` is not sensitive to recursive updates.

^KT-65418 fixed
2024-01-31 12:19:42 +00:00
Abduqodiri Qurbonzoda e4a8fc01c3 Fix typo in stdlib KDocs, behavoir -> behavior 2024-01-31 12:11:48 +00:00
Abduqodiri Qurbonzoda c9d8ecc599 Detect concurrent modifications in ArrayDeque #KT-63355
Remove the ArrayDeque.subList().subList() test for comodification detection.
For types that extend AbstractList and to not override subList function,
the behavior varies depending on JDK version. With JKD8, the test fails for ArrayDeque.
While with JDK9+, it passes.
2024-01-31 12:11:48 +00:00
Abduqodiri Qurbonzoda 5f16fb2e4d Introduce Common protected property AbstractMutableList.modCount #KT-57150 2024-01-31 12:11:48 +00:00
Kirill Rakhman 1626057f75 [FIR] Improve rendering of override related diagnostics
Render symbols completely and add containing declaration.
2024-01-31 11:16:50 +00:00
Kirill Rakhman 1238f081b7 [FIR] Defer computation of intersection override return type if overridden has implicit return type
#KT-59921
2024-01-31 11:16:50 +00:00
Kirill Rakhman 9ec0210c04 [FIR] Support enhancing intersection overrides
When a type annotated with @PurelyImplements (explicitly or implicitly)
inherited some methods from a java supertype and the purely implemented
Kotlin supertype, it was inconsistent which of the signatures the
intersection override would have (with or without flexible types).
This commit adds support for the enhancement of intersection overrides.
If one of the overridden methods has non-flexible types, the enhanced
method will have non-flexible types.
This fixes some false negative nullability type mismatches.

#KT-59921 Fixed
2024-01-31 11:16:50 +00:00
Kirill Rakhman 3b841dcb98 [FIR] Don't remove subsumed members from intersection overrides's overriddens
This fixes a bunch of missing overridden symbols in IR.
This is also required for fixing KT-59921 in the following commit
where we need to keep all overridden symbols of intersection overrides
so that we can enhance them properly.

#KT-57300 Fixed
#KT-57299 Fixed
#KT-59921
#KT-57300
#KT-62788
#KT-64271
#KT-64382
2024-01-31 11:16:50 +00:00
Dmitry Savvinov d80dee6e1c [k2] Convert allDependsOnDependencies to FirModuleData member property
This essentially caches topological sort of dependsOn-dependencies in
FirModuleData. Caching it became more necessary after previous commits
that started to call it quite frequently in
VariableStorageImpl.getStability
2024-01-31 09:53:45 +00:00
Dmitry Savvinov f28863b983 [k2, dfa] Use transitive closure of dependsOn for stability checks 2024-01-31 09:53:45 +00:00
Dmitry Savvinov 337330f8c8 [Tests] Add a test on smartcasts on properties from dependsOn modules
Behaviour is undesired, will be fixed in the next commit
2024-01-31 09:53:45 +00:00
Dmitry Savvinov 74fa6fc12c [k2, dfa] Smartcasts are not allowed on FirJavaField from other module
Handle case with FirField properly. Previously the code was returning
STABLE_VALUE in that case.

Note that in fact the changed 'when' branch expects only FirJavaField,
as FirFieldImpl should be handled by FirBackingFieldSymbol-check at
the beginning of the method. However, it is impossible to refer to
FirJavaField directly due to module visibility

Enumerate all cases more carefully via exhaustive 'when',
it's more readable and will prevent potential issues in future in case
more subclasses are added.

^KT-58279 Fixed
2024-01-31 09:53:45 +00:00
Dmitry Savvinov 6661a66fc3 [Tests] Add tests on smartcasts on static Java fields
Current behavior for different modules is undesired, will be fixed in
the next commit

^KT-58279
2024-01-31 09:53:45 +00:00
Dmitry Savvinov 008d670469 [Tests] Fix exception from SealedClassInheritorsProviderForTests
'getValue' throws if the key isn't present.

Modules without .kt-files might be legitimately absent in inheritorsMap
(see org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.SealedClassesInheritorsCaclulatorPreAnalysisHandler)

Previously, such tests were not failing because if a module doesn't
contain .kt-files, then it contains only .java files. And there was
another bug in the tests infra that was essentially folding all the
.java-files in one main-module, effectively shadowing the bug in subject
of this commit.
2024-01-31 09:53:44 +00:00
Dmitry Savvinov f19859db4e [Tests] Do not add .java-files of whole project to contentScope in K2
Previously, the code was calling into
TopDownAnalyzerFacadeForJVM.newModuleSearchScope, which includes
AllJavaSourcesInProjectScope.

This lead to .java-sources being incorrectly attributed to wrong
modules in tests, which, in turn, could've introduced undesired
behaviour around module-dependent checks (e.g. whether a variable
is from the other module and thus can't be smartcasted)
2024-01-31 09:53:44 +00:00
Dmitry Savvinov d03ee3150b Minor: fix typo 2024-01-31 09:53:44 +00:00
Kirill Rakhman 9e72482f09 [FIR] Fix infinite loop in attribute substitution
#KT-65318 Fixed
2024-01-31 08:55:22 +00:00
Kirill Rakhman d047db850f [FIR] Fix nullability of function type created from custom function type
#KT-64706 Fixed
2024-01-31 08:52:58 +00:00
Nikolay Lunyak 811e8d7c3b [FIR] Add more corner cases for KT-65058
^KT-65058
2024-01-31 08:27:34 +00:00
Nikolay Lunyak 4ee03a3a0c [FIR] Allow accessing protected members via local inheritors
^KT-65058 Fixed
2024-01-31 08:27:34 +00:00
Nikolay Lunyak b6e913cde7 [FIR] Reproduce KT-65058
^KT-65058
2024-01-31 08:27:33 +00:00
Anton Keks 695119ca35 [stdlib] remove duplicate size checks, as the same is done inside of Array extension functions that are called here 2024-01-31 06:51:08 +00:00
Abduqodiri Qurbonzoda b67ebf36a2 Implement optimized removeRange for ArrayDeque #KT-64956
Test ArrayDeque with size 15. With the existing sizes the removeRange
implementation couldn't reach the maximum number of iterations - 3.

Benchmark results for ArrayDeque.subList().clear() that uses
removeRange() can be found here:
https://github.com/qurbonzoda/KotlinArrayDequeBenchmarks/tree/master/results
2024-01-30 22:37:25 +00:00
Abduqodiri Qurbonzoda 240a423bed Introduce Common protected function AbstractMutableList.removeRange #KT-57151 2024-01-30 22:37:25 +00:00
Sergej Jaskiewicz f84fa29fef [klib] Add a test ensuring that signature clash detection works w/ MPP 2024-01-30 20:47:09 +00:00
Sergej Jaskiewicz 03aa14b473 [klib] Use "IR signatures" i/o "KLIB signatures" in diagnostics
We already use the term "IR signatures" in other places.
2024-01-30 20:47:09 +00:00
Sergej Jaskiewicz 6900e20096 [klib] Fix exception for clashing signatures from different modules
If we encounter a declaration in the current module whose signature
is the same as that of a declaration in another module which we happen
to also reference from the current module, don't report any errors,
just like we don't do it in Kotlin/JVM. This leaves the user in the KLIB
hell situation, but this is intentional, because otherwise a legitimate
change like moving a declaration to another module and marking
the original one as `@Deprecated("", level = DeprecationLevel.HIDDEN)`
would lead to a error, and we don't want that.

Also, don't try to show the diagnostics on a declaration that doesn't
have an IrFile.

^KT-65063 Fixed
2024-01-30 20:47:09 +00:00
Sergej Jaskiewicz a5c8ecae0b [test] Support dumping rendered diagnostics from multiple modules 2024-01-30 20:47:09 +00:00
vladislav.grechko d27adf6677 [FIR] Forbid multiple labels per statement
^KT-53629: Fixed
2024-01-30 19:58:53 +00:00
vladislav.grechko cd5b38b958 [FIR] Unwrap error expressions when detecting USAGE_IS_NOT_INLINABLE
Otherwise, false positive USAGE_IS_NOT_INLINABLE may be detected

^KT-65316: Fixed
2024-01-30 19:58:53 +00:00
Mikhail Glukhikh ed246d372b K2: introduce platform-dependent filtering for non-JVM platforms
This commit fixes a false negative in testData/cli/metadata/getOrDefault
Related to KT-57268
2024-01-30 19:44:00 +00:00
Mikhail Glukhikh 7599ff0ef1 K2: add a reproducer for getOrDefault false negative in metadata compilation
This case is similar to KT-57268 in early JDKs
2024-01-30 19:44:00 +00:00