Make builder collection implementations serializable KT-39328
Collections returned by collection builders are now serializable in their read-only state. The builder mutable collections inside collection builder lambda, however, are not.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -162,6 +162,8 @@ public inline fun <T> MutableList(size: Int, init: (index: Int) -> T): MutableLi
|
||||
* The list passed as a receiver to the [builderAction] is valid only inside that function.
|
||||
* Using it outside of the function produces an unspecified behavior.
|
||||
*
|
||||
* The returned list is serializable (JVM).
|
||||
*
|
||||
* @sample samples.collections.Builders.Lists.buildListSample
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@@ -185,6 +187,8 @@ internal expect inline fun <E> buildListInternal(builderAction: MutableList<E>.(
|
||||
* The list passed as a receiver to the [builderAction] is valid only inside that function.
|
||||
* Using it outside of the function produces an unspecified behavior.
|
||||
*
|
||||
* The returned list is serializable (JVM).
|
||||
*
|
||||
* [capacity] is used to hint the expected number of elements added in the [builderAction].
|
||||
*
|
||||
* @throws IllegalArgumentException if the given [capacity] is negative.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -132,6 +132,8 @@ public fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V> = p
|
||||
*
|
||||
* Entries of the map are iterated in the order they were added by the [builderAction].
|
||||
*
|
||||
* The returned map is serializable (JVM).
|
||||
*
|
||||
* @sample samples.collections.Builders.Maps.buildMapSample
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@@ -159,6 +161,8 @@ internal expect inline fun <K, V> buildMapInternal(builderAction: MutableMap<K,
|
||||
*
|
||||
* Entries of the map are iterated in the order they were added by the [builderAction].
|
||||
*
|
||||
* The returned map is serializable (JVM).
|
||||
*
|
||||
* @throws IllegalArgumentException if the given [capacity] is negative.
|
||||
*
|
||||
* @sample samples.collections.Builders.Maps.buildMapSample
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -118,6 +118,8 @@ public fun <T : Any> setOfNotNull(vararg elements: T?): Set<T> {
|
||||
*
|
||||
* Elements of the set are iterated in the order they were added by the [builderAction].
|
||||
*
|
||||
* The returned set is serializable (JVM).
|
||||
*
|
||||
* @sample samples.collections.Builders.Sets.buildSetSample
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@@ -145,6 +147,8 @@ internal expect inline fun <E> buildSetInternal(builderAction: MutableSet<E>.()
|
||||
*
|
||||
* Elements of the set are iterated in the order they were added by the [builderAction].
|
||||
*
|
||||
* The returned set is serializable (JVM).
|
||||
*
|
||||
* @throws IllegalArgumentException if the given [capacity] is negative.
|
||||
*
|
||||
* @sample samples.collections.Builders.Sets.buildSetSample
|
||||
|
||||
Reference in New Issue
Block a user