diff --git a/libraries/stdlib/src/generated/_Generators.kt b/libraries/stdlib/src/generated/_Generators.kt index 77acb0b7327..51ba432eb21 100644 --- a/libraries/stdlib/src/generated/_Generators.kt +++ b/libraries/stdlib/src/generated/_Generators.kt @@ -385,6 +385,8 @@ public fun Iterable.minus(array: Array): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [array]. + * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(array: Array): Sequence { if (array.isEmpty()) return this @@ -417,6 +419,8 @@ public fun Iterable.minus(collection: Iterable): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]. + * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(collection: Iterable): Sequence { return object: Sequence { @@ -486,6 +490,8 @@ public fun Iterable.minus(sequence: Sequence): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]. + * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(sequence: Sequence): Sequence { return object: Sequence { @@ -747,6 +753,8 @@ public fun Iterable.plus(array: Array): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [array]. + * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(array: Array): Sequence { return this.plus(array.asList()) @@ -791,6 +799,8 @@ public fun Iterable.plus(collection: Iterable): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [collection]. + * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(collection: Iterable): Sequence { return sequenceOf(this, collection.asSequence()).flatten() @@ -866,6 +876,8 @@ public fun Iterable.plus(sequence: Sequence): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]. + * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(sequence: Sequence): Sequence { return sequenceOf(this, sequence).flatten() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 74fc7d794ca..8e2a0f7f31b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -88,7 +88,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [collection]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [collection]. + + Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return sequenceOf(this, collection.asSequence()).flatten() @@ -127,7 +134,14 @@ fun generators(): List { return result """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [array]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [array]. + + Note that the source sequence and the array being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return this.plus(array.asList()) @@ -169,7 +183,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]. + + Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return sequenceOf(this, sequence).flatten() @@ -244,7 +265,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]. + + Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return object: Sequence { @@ -281,7 +309,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [array]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [array]. + + Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ if (array.isEmpty()) return this @@ -318,7 +353,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]. + + Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return object: Sequence {