diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index f4865943e78..1dbfc7eef8c 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -487,30 +487,35 @@ public operator fun MutableMap.plusAssign(map: Map) { /** * Creates a new read-only map by removing a [key] from this map. */ +@Deprecated("This operation will be removed soon.") public operator fun Map.minus(key: K): Map = this.toLinkedMap().apply { minusAssign(key) } /** * Creates a new read-only map by removing a collection of [keys] from this map. */ +@Deprecated("This operation will be removed soon.") public operator fun Map.minus(keys: Iterable): Map = this.toLinkedMap().apply { minusAssign(keys) } /** * Creates a new read-only map by removing a array of [keys] from this map. */ +@Deprecated("This operation will be removed soon.") public operator fun Map.minus(keys: Array): Map = this.toLinkedMap().apply { minusAssign(keys) } /** * Creates a new read-only map by removing a sequence of [keys] from this map. */ +@Deprecated("This operation will be removed soon.") public operator fun Map.minus(keys: Sequence): Map = this.toLinkedMap().apply { minusAssign(keys) } /** * Removes the given [key] from this mutable map. */ +@Deprecated("This operation will be removed soon, use remove(key) instead.", ReplaceWith("this.keys -= key")) public operator fun MutableMap.minusAssign(key: K) { remove(key) } @@ -518,6 +523,7 @@ public operator fun MutableMap.minusAssign(key: K) { /** * Removes all the given [keys] from this mutable map. */ +@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys")) public operator fun MutableMap.minusAssign(keys: Iterable) { for (key in keys) remove(key) } @@ -525,6 +531,7 @@ public operator fun MutableMap.minusAssign(keys: Iterable) { /** * Removes all the given [keys] from this mutable map. */ +@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys")) public operator fun MutableMap.minusAssign(keys: Array) { for (key in keys) remove(key) } @@ -532,6 +539,7 @@ public operator fun MutableMap.minusAssign(keys: Array) { /** * Removes all the given [keys] from this mutable map. */ +@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys")) public operator fun MutableMap.minusAssign(keys: Sequence) { for (key in keys) remove(key) } diff --git a/libraries/stdlib/test/collections/MapTest.kt b/libraries/stdlib/test/collections/MapTest.kt index bdd0bced623..25e5ea796f4 100644 --- a/libraries/stdlib/test/collections/MapTest.kt +++ b/libraries/stdlib/test/collections/MapTest.kt @@ -357,16 +357,18 @@ class MapTest { assertEquals("A" to 1, original.entries.single().toPair()) } +/* @test fun minusAssign() = testMinusAssign { - it -= "B" - it -= "C" + it.keys -= "B" + it.keys -= "C" } - @test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") } + @test fun minusAssignList() = testMinusAssign { it.keys -= listOf("B", "C") } - @test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") } + @test fun minusAssignArray() = testMinusAssign { it.keys -= arrayOf("B", "C") } - @test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") } + @test fun minusAssignSequence() = testMinusAssign { it.keys -= sequenceOf("B", "C") } +*/ fun testIdempotent(operation: (Map) -> Map) { @@ -383,16 +385,16 @@ class MapTest { @test fun plusEmptyList() = testIdempotent { it + listOf() } - @test fun minusEmptyList() = testIdempotent { it - listOf() } +// @test fun minusEmptyList() = testIdempotent { it - listOf() } @test fun plusEmptySet() = testIdempotent { it + setOf() } - @test fun minusEmptySet() = testIdempotent { it - setOf() } +// @test fun minusEmptySet() = testIdempotent { it - setOf() } @test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() } - @test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() } +// @test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() } @test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() } - @test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() } +// @test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() } }