Commit Graph

94 Commits

Author SHA1 Message Date
Abduqodiri Qurbonzoda 65cfc578a8 Introduce constructor-like function for AutoCloseable #KT-66102 2024-02-27 20:52:49 +00:00
Abduqodiri Qurbonzoda 98ad68eb90 Promote AutoCloseable & use to stable #KT-65532 2024-02-27 20:52:49 +00:00
Ilya Gorbunov 709076acc9 [stdlib] Improve documentation of Char.isWhitespace and test it behaves the same in different targets 2024-02-20 03:48:08 +00:00
Abduqodiri Qurbonzoda 20b9ac9d55 Fix memory leak in MapBuilder #KT-65518 2024-02-08 07:46:09 +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
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
Abduqodiri Qurbonzoda e94b247835 Introduce Common StringBuilder.append/insert(Byte/Short) extensions #KT-63341 2023-11-26 02:48:19 +02:00
Abduqodiri Qurbonzoda db6a662631 Remove Common StringBuilder.append/insert(Byte/Short) members #KT-63341 2023-11-26 02:48:18 +02:00
Ilya Gorbunov cfa8a1dc0f [stdlib] Explicit visibility and return types: Wasm 2023-11-21 18:14:09 +00:00
Ilya Gorbunov 62700c3ec3 [stdlib] K/N ArrayList: restore constructor docs, correct modifier order 2023-11-20 02:24:40 +00:00
Ilya Gorbunov aa4419b7e3 [stdlib] Explicit visibility and return types: Collections 2023-11-20 02:24:40 +00:00
Ilya Gorbunov da1d3be7f2 [stdlib] Explicit visibility and return types: StringBuilder 2023-11-20 02:24:40 +00:00
Abduqodiri Qurbonzoda a3f5db566c Remove KDoc for K/N ArrayList primary constructor
The documentation is provided for ArrayList class but describes its
primary constructor. Thus, in documentation website it appears
as ArrayList documentation. When no KDoc is provided, website generator
takes it from other platforms.
2023-11-14 09:47:25 +00:00
Troels Bjerre Lund 5a8faa8775 Align ListBuilder with native ArrayList
Furthermore, add test for ListBuilder.subList detection of concurrent
modification, and fix error in ListBuilder and ArrayList.

Fix KT-62346
2023-11-14 09:47:25 +00:00
Troels Bjerre Lund d62dbbb1bd Simplify K/N ArrayList
This commit specializes the existing Kotlin/Native stdlib ArrayList into
two subclasses:
 * ArrayList
 * ArraySubList
This avoids repeatedly checking whether a basic ArrayList is created as a
sublist of another ArrayList.

In the iterators, checkForComodification is marked for inlining, since
this significantly improves iterations performance.

A number of benchmarks are added to the native ring benchmark suite, to
test whether the changed runtime type of ArrayList.subList(...) has an
impact.
2023-11-14 09:47:25 +00:00
Ilya Gorbunov 9ccce52915 Clean up WasExperimental annotation from declarations with SinceKotlin<=1.4
Since it is not possible to use -api-version < 1.4, this annotation has no effect
2023-11-10 12:20:52 +00:00
Nikita Bobko 4050285fef Drop unnecessary suppress from stdlib
^KT-62785 Fixed
Review: https://jetbrains.team/p/kt/reviews/12858/files
2023-11-06 19:00:35 +00:00
Nikita Bobko 14029b0ebc [STDLIB] 1/2 Drop AllowDifferentMembersInActual from stdlib
^KT-62656 Fixed

I blindly converted all `@AllowDifferentMembersInActual` to suppresses.
But some suppresses in stdlib are redundant. I'm too lazy properly
annotate only the necessary places. All these suppresses will go away
after the bootstrap update anyway

I drop allowDifferentMembersInActual_class and
allowDifferentMembersInActual_typealias tests because their only purpose
was to check that `@AllowDifferentMembersInActual` works as expected

Note: some tests are failing in the compiler because of that. I will fix
them in the next commit
2023-10-20 14:37:09 +00:00
Nikita Bobko 25c082f02b K1: Implement a checker that disallows to have different member scopes for expect open and its actual
^KT-22841 Fixed
Review: https://jetbrains.team/p/kt/reviews/11603/timeline

The commit also introduces `@AllowDifferentMembersInActual` annotation in
stdlib which allows to suppress the diagnostic
2023-08-21 19:51:08 +00:00
Nikita Bobko d39755b578 [FE] Convert specific diagnostic for actual function with default arguments into a common incompatibility
^KT-59665 Fixed
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

It's better to have this logic in common place
(AbstractExpectActualCompatibilityChecker) to avoid missing compilation
errors in the future

This commit fixes:
1. Missing compilation error for actual function with default arguments
   for 'actual typealias' KT-59665
2. Missing compilation error for actual function with default arguments
   for actual fake-override KT-59665

Alternative solution for KT-59665 is to create a special checker.

"incompatibility" vs "special checker":

Arguments for common incompatibility:
- What if we had a rule that expect and actual default params must
  match? If so then it certainly would be an incompatibility.
- Technically, we do the matching of expect and actual params (because
  we allow default params in common ancestors of expect and actual
  declarations).
- It's hard to check that the actual definition doesn't use default
  params because `ExpectedActualResolver.findActualForExpected` filters
  out fake-overrides and doesn't return them. It's not clear logic for
  me, that I'm afraid to touch.
  implicitActualFakeOverride_AbstractMap.kt test breaks if you drop this
  weird logic
- WEAK incompatibilities can be considered as "checkers". So it doesn't
  matter how it's implemented, as a "incompatibility" or a "checker"

Arguments against common incompatibility:
- Although we match expect and actual declarations to allow default
  params in common ancestors of expect and actual declarations, it's
  still can be considered that we check that the actual declaration
  doesn't have default params. And it doesn't feel right that we check
  correctness of the actual declaration in expect-actual matcher.
- ~~It may change the rules of expect actual matching~~ (It's not true,
  because ActualFunctionWithDefaultParameters is declared as WEAK
  incompatibility)
2023-08-10 15:46:46 +00:00
Abduqodiri Qurbonzoda 21619264d0 [K/N] Add a note to Regex documentation about future changes of behavior
This note will allow us to fix https://youtrack.jetbrains.com/issue/KT-58198/Native-Regex-issues in the future.

Co-authored-by: Ilya Gorbunov <Ilya.Gorbunov@jetbrains.com>


Merge-request: KT-MR-11387
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-08-08 08:21:10 +00:00
Abduqodiri Qurbonzoda 7fc90c02f1 Rename copyToArrayImpl to collectionToArray 2023-07-27 11:16:58 +00:00
Abduqodiri Qurbonzoda 7010bf2c20 Move copyToArrayImpl implementation to Common source set 2023-07-27 11:16:58 +00:00
Abduqodiri Qurbonzoda 6fdfd4e8dd Null-terminate Collection.toArray destination only in JVM
In other platforms the elements following the collection elements
should not be changed.

As a part of efforts to stabilize Native stdlib.
2023-07-27 11:16:58 +00:00
Abduqodiri Qurbonzoda df16fa3306 [K/N] Regex matching zero length should split surrogate pairs #KT-57401
Merge-request: KT-MR-11110
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-26 14:19:25 +00:00
Abduqodiri Qurbonzoda db908aefff Detect concurrent modification of the parent list in subList
As a part of efforts to stabilize Native stdlib.
2023-07-25 16:00:42 +00:00
Abduqodiri Qurbonzoda 92de137cd6 Deprecate HashSet.getElement() and document that it's for ObjC interop.
Will become HIDDEN eventually.

As a part of efforts to stabilize Native #KT-55765.
2023-07-25 15:01:49 +00:00
Abduqodiri Qurbonzoda fed453fdea Provide Common StringBuilder.append/insert with primitive type arguments #KT-57359
Merge-request: KT-MR-10892
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-13 11:52:14 +00:00
Abduqodiri Qurbonzoda f152fa537d Collection.toString() should not throw if it contains itself
Merge-request: KT-MR-10591
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-11 09:58:38 +00:00
Abduqodiri Qurbonzoda 209c916a7e OptIn ExperimentalNativeApi 2023-06-30 15:27:09 +00:00
Abduqodiri Qurbonzoda bf1c9774aa Fix the ConcurrentModification test that fails in jdk9+
Modification registration seems to changed in Java 9. Now if the asked
capacity in `ensureCapacity` function is less than current capacity,
no modification is registered.
2023-06-28 19:00:46 +00:00
Vsevolod Tolstopyatov 175cf5e833 KT-53327 replace Enum.values() with Enum.entries in CharCategory
Also, replace it in stdlib tests where appropriate and disable already unsupported legacy JS tests


^KT-53327 fixed

Co-authored-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>

Merge-request: KT-MR-10632
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-06-21 14:40:16 +00:00
Abduqodiri Qurbonzoda af1630e270 [K/N] Catch concurrent modifications of HashMap
As a part of efforts to stabilize Native stdlib.
2023-06-20 18:35:39 +00:00
Abduqodiri Qurbonzoda 9d8d9d000f [K/N] Catch concurrent modifications of ArrayList
As a part of efforts to stabilize Native stdlib.
2023-06-20 18:35:39 +00:00
Abduqodiri Qurbonzoda e802ee05a7 [K/N] Do not override equals/hashCode for AbstractMutableMap.values collection 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 6015e12db8 [K/N] Remove redundant AbstractMutableMap.SimpleEntry 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 3be613ced8 [K/N] Use iterator in AbstractMutableList.indexOf/lastIndexOf
Instead of access by index. To avoid performance issues
when the subclass `get(index)` has non-constant time complexity.
It also aligns behavior with JVM.
2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 60cafc6623 Document the exceptions Iterator throws 2023-06-19 11:41:10 +00:00
Abduqodiri Qurbonzoda 830c78773c Align behavoir of collection constructors across platforms #KT-59192
The initialCapacity should be non-negative and loadFactor should be positive.

As a part of efforts to stabilize Native stdlib.
2023-06-08 12:41:40 +00:00
Abduqodiri Qurbonzoda 0bef1533e2 Improve documentation of collection constructors #KT-59192 2023-06-08 12:41:40 +00:00
Abduqodiri Qurbonzoda 3917ec94ab [K/N] Use AbstractList.checkIndex() functions instead of custom check functions 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 89d1cfe05b [K/N] ArrayList.ensureCapacity() should ignore negative arguments 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda ae394caf42 [K/N] Throw OutOfMemoryError when StringBuilder overflows 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda af7965d996 [K/N] Use AbstractList.newCapacity in HashMap.ensureCapacity 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 2ef50f8c34 Move ArrayDeque.newCapacity to AbstractList 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda d8cfc79d92 [K/N] Fix StringBuilder.setRange capacity expansion 2023-06-06 18:11:57 +00:00
Abduqodiri Qurbonzoda 21636efe38 [K/N] Small refactoring of StringBuilder 2023-06-06 18:11:56 +00:00