Commit Graph

109329 Commits

Author SHA1 Message Date
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
Mikhail Glukhikh 38aec7333b Drop mentioning of KT-63955 in some ABI difference comments
In fact, the commit c3926219 should do it before because the relevant
difference was removed in this commit
2024-01-30 19:44:00 +00:00
Mikhail Glukhikh 672b5ba0d7 K2/Java: implement platform-dependent function filtering in JvmMappedScope
We drop Kotlin function 'remove' or 'getOrDefault' from JvmMappedScope,
if it has platform-dependent annotation, and the bound Java class scope
does not contain a function with the same signature.

#KT-57268 Fixed
2024-01-30 19:44:00 +00:00
Alexander Udalov 7d584e0eb4 K2/Java: add initial version of FirJvmPlatformDeclarationFilter
#KT-57268 In Progress
2024-01-30 19:44:00 +00:00
Brian Norman 76b9ba05fd [FIR] Lambda reassigned arguments should not have contracts applied
When applying function contracts to arguments, make sure the argument
variable hasn't been reassigned within a lambda. Contracts can only be
applied to unchanged variables, otherwise outdated type statements could
be added to the variable.

^KT-63151 Fixed
2024-01-30 17:23:56 +00:00
Brian Norman a2c9e5b36a [FIR] Copy implications from previous data flows when there is only one
Postponed lambdas introduce a host of challenges in data-flow analysis.
While inheriting type statements was disabled while these challenges are
being considered, we must still copy type statements from non-postponed
lambda edges. It seems the same is true for implications.

Implications are copied from previous flows when there is only a single
previous flow. That is because it never seemed to be required based on
test results. However, a recent test case revealed that copying is
required when there are multiple previous flows, but only one flow is
from a non-postponed-lambda node.

Combining implications from multiple non-postponed-lambda nodes did not
have an impact on test results, so until such a test case can be
created, the overhead of calculating common implications from multiple
flows will be avoided.

^KT-63351 Fixed
2024-01-30 17:22:31 +00:00
Dmitriy Dolovov 478205e6e8 [build] Don't use dependencies on Native backend in KLIB tool
^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov c1a4c33301 [build] Migrate kotlin-native/klib/build.gradle to KTS
^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov ca0c2f1405 [KLIB tool] Introduce a new CLI command: "dump-abi"
With this command it is possble to make an ABI snapshot of any IR-ful library

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov 9d6266d6ad [KLIB tool] Use more correct wording in HELP output
"dump ... of all public declarations"
->
"dump ... of all non-private declarations"

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov ab09a3d0fe [KLIB tool] Dump metadata for all non-private declarations
This is done to make the output of "dump-metadata" command consistent
with the output of "dump-metadata-signatures" and "dump-ir-signatures",
which dump signatures for all non-private declarations.

^KT-62340
2024-01-30 16:12:56 +00:00
Dmitriy Dolovov 1f3da86021 [KLIB tool] Don't print stack trace on CLI args parsing errors
^KT-62340
2024-01-30 16:12:56 +00:00
Igor Chevdar f220074d8a [K/N][IR] Fixed a problem with top-level fields
#KT-65324 Fixed
2024-01-30 14:49:34 +00:00
Nataliya.Valtman 6000596673 Report FUS metrics only from FusMetrics.kt
#KT-65213 Fixed
2024-01-30 14:26:43 +00:00
vladislav.grechko 3da1efc94a Set correct IR origin for getting array element operators
^KT-60246: Fixed
2024-01-30 14:26:10 +00:00
vladislav.grechko 9aa8fb80e7 Set correct IR origins for inc/dec operations
NB: in order to produce correct IR origins, the source element kinds for
some FIR elements has been changed. As a side effect, mapping PSI to FIR
slightly changed: namely, for `a[b]++`, `a[b]` used to be mapped on
`set` call or callable reference, but now it is mapped on `get` call.

^KT-61891: Fixed
^KT-64387: Fixed
2024-01-30 14:26:10 +00:00
vladislav.grechko 8b1d87848d [FIR2IR] Fix unwrapping of single-statement blocks
Unwrapping should be done with respect to `forceUnitType` parameter.

^KT-65019: Fixed
2024-01-30 14:26:10 +00:00
Artem Kobzar 5b7478c0a6 [K/JS] Automatiacally add runtime dependency for JS Plain Objects plugin inside its Gradle plugin 2024-01-30 13:54:51 +00:00
strangepleasures effcdd5e71 KT-65330 Fix the DuckDuckGo benchmark 2024-01-30 13:23:21 +00:00
Yahor Berdnikau 09f2f36545 [Gradle] Fix warnings in KotlinJsIrTarget
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau c43a0228b9 [Gradle] Fix warnings in KotlinJsIrSubTarget
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau cc29ee9f7a [Gradle] Removed unused method in KotlinJsIrLink
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau ed82ca5c09 [Gradle] Fix warnings in KotlinJsBinaryContainer
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau d0b0774c6d [Gradle] Fix warnings in KotlinBrowserJsIr
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau f4d9d98a5e [Gradle] Fix warnings in D8Exec
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau 5cf1572995 [Gradle] Fix warnings in KotlinJsCompilation
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Yahor Berdnikau 0f29ae48ee [Gradle] Fix warnings in InternalKotlinTargetPreset
^KT-56904 In Progress
2024-01-30 11:49:07 +00:00
Marco Pennekamp 9a4bf0601e [AA] Add KtClass-based KotlinSealedInheritorsProvider
- The compiler's `SealedClassInheritorsProvider` should not be exposed
  outside LL FIR, as it is an internal compiler component and also
  exposes `FirRegularClass`. `KotlinSealedInheritorsProvider` is an
  Analysis API provider for sealed inheritors that accepts a `KtClass`
  instead.

^KT-64718 fixed
2024-01-30 11:48:09 +00:00