Skip to content

Commit ce1b32d

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Upgrade Kotlin version to 1.6.0
1 parent 0287015 commit ce1b32d

File tree

17 files changed

+34
-20
lines changed

17 files changed

+34
-20
lines changed

benchmarks/runner/src/csvPrinter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ fun printCsvResults(benchmarkResults: BenchmarkResults, outputPath: String) {
1515
File(outputPath).parentFile?.mkdirs()
1616
val fileWriter = FileWriter(outputPath)
1717

18-
fileWriter.appendln(csvHeader)
18+
fileWriter.appendLine(csvHeader)
1919
benchmarkResults.runResults.forEach { res ->
2020
val paramsValuesString = benchmarkResults.paramsNames.joinToString(",") { res.paramValue(it) }
2121
val csvRow = "${res.benchmark},$paramsValuesString,${res.score.formatted()},${res.scoreError.formatted()},${res.allocRate.formatted()}"
22-
fileWriter.appendln(csvRow)
22+
fileWriter.appendLine(csvRow)
2323
}
2424

2525
fileWriter.flush()

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
dependencies {
3-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
3+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
44
}
55
}
66

core/commonMain/src/extensions.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ inline fun <T> PersistentList<T>.mutate(mutator: (MutableList<T>) -> Unit): Pers
4848
* @return a new persistent map with the provided modifications applied;
4949
* or this instance if no modifications were made in the result of this operation.
5050
*/
51+
@Suppress("UNCHECKED_CAST")
5152
inline fun <K, V> PersistentMap<out K, V>.mutate(mutator: (MutableMap<K, V>) -> Unit): PersistentMap<K, V> =
5253
(this as PersistentMap<K, V>).builder().apply(mutator).build()
5354

@@ -321,6 +322,7 @@ infix fun <E> PersistentCollection<E>.intersect(elements: Iterable<E>): Persiste
321322
* @return a new persistent map with an entry from the specified key-value [pair] added;
322323
* or this instance if no modifications were made in the result of this operation.
323324
*/
325+
@Suppress("UNCHECKED_CAST")
324326
inline operator fun <K, V> PersistentMap<out K, V>.plus(pair: Pair<K, V>): PersistentMap<K, V>
325327
= (this as PersistentMap<K, V>).put(pair.first, pair.second)
326328

@@ -369,6 +371,7 @@ inline operator fun <K, V> PersistentMap<out K, V>.plus(map: Map<out K, V>): Per
369371
* @return a new persistent map with keys and values from the specified [map] associated;
370372
* or this instance if no modifications were made in the result of this operation.
371373
*/
374+
@Suppress("UNCHECKED_CAST")
372375
public fun <K, V> PersistentMap<out K, V>.putAll(map: Map<out K, V>): PersistentMap<K, V> =
373376
(this as PersistentMap<K, V>).putAll(map)
374377

@@ -406,6 +409,7 @@ public fun <K, V> PersistentMap<out K, V>.putAll(pairs: Sequence<Pair<K, V>>): P
406409
* @return a new persistent map with the specified [key] and its corresponding value removed;
407410
* or this instance if it contains no mapping for the key.
408411
*/
412+
@Suppress("UNCHECKED_CAST")
409413
public operator fun <K, V> PersistentMap<out K, V>.minus(key: K): PersistentMap<K, V>
410414
= (this as PersistentMap<K, V>).remove(key)
411415

core/commonMain/src/implementations/immutableMap/PersistentHashMapBuilderContentViews.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import kotlinx.collections.immutable.internal.MapImplementation
1111
internal abstract class AbstractMapBuilderEntries<E : Map.Entry<K, V>, K, V> : AbstractMutableSet<E>() {
1212
final override fun contains(element: E): Boolean {
1313
// TODO: Eliminate this check after KT-30016 gets fixed.
14+
@Suppress("USELESS_CAST")
1415
if ((element as? Any?) !is Map.Entry<*, *>) return false
1516
return containsEntry(element)
1617
}
1718
abstract fun containsEntry(element: Map.Entry<K, V>): Boolean
1819

1920
final override fun remove(element: E): Boolean {
2021
// TODO: Eliminate this check after KT-30016 gets fixed.
22+
@Suppress("USELESS_CAST")
2123
if ((element as? Any?) !is Map.Entry<*, *>) return false
2224
return removeEntry(element)
2325
}

core/commonTest/src/contract/list/ImmutableListTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ImmutableListTest {
8484
var list = "abcxaxab12".toImmutableList().toPersistentList()
8585

8686
for (i in list.indices) {
87-
list = list.set(i, list[i] as Char + i)
87+
list = list.set(i, list[i] + i)
8888
}
8989

9090
assertEquals("ace{e}gi9;", list.joinToString(""))
@@ -120,7 +120,6 @@ class ImmutableListTest {
120120
@Test fun subList() {
121121
val list = "abcxaxyz12".toImmutableList()
122122
val subList = list.subList(2, 5) // 2, 3, 4
123-
assertTrue(subList is ImmutableList)
124123
compareLists(listOf('c', 'x', 'a'), subList)
125124

126125
assertFailsWith<IndexOutOfBoundsException> { list.subList(-1, 2) }
@@ -142,7 +141,7 @@ class ImmutableListTest {
142141
testMutation { add(0, 'K') }
143142
testMutation { addAll("kotlin".toList()) }
144143
testMutation { addAll(0, "kotlin".toList()) }
145-
testMutation { this[1] = this[1] as Char + 2 }
144+
testMutation { this[1] = this[1] + 2 }
146145
testMutation { removeAt(lastIndex) }
147146
testMutation { remove('x') }
148147
testMutation { removeAll(listOf('x')) }

core/commonTest/src/contract/map/ImmutableMapTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ImmutableHashMapTest : ImmutableMapTest() {
8080
// https://github.com/Kotlin/kotlinx.collections.immutable/issues/109
8181
val map0 = immutableMapOf<Int, Int>().put(0, 0).put(1, 1).put(32, 32)
8282
val map1 = map0.mutate { it.remove(0) }
83-
val map2 = map1.mutate {
83+
map1.mutate {
8484
it.remove(1)
8585
it.remove(0)
8686
}
@@ -251,7 +251,7 @@ abstract class ImmutableMapTest {
251251
@Test fun builder() {
252252

253253
val builder = immutableMapOf<Char, Int?>().builder()
254-
"abcxaxyz12".associateTo(builder) { it to it.toInt() }
254+
"abcxaxyz12".associateTo(builder) { it to it.code }
255255
val map = builder.build()
256256
assertEquals<Map<*, *>>(map, builder)
257257
assertSame(map, builder.build(), "Building the same list without modifications")

core/commonTest/src/implementations/list/TrieIteratorTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class TrieIteratorTest {
4040
leaves = newLeaves
4141
}
4242

43-
assert(leaves.size == 1)
44-
return leaves[0] as Array<Any?>
43+
check(leaves.size == 1)
44+
45+
@Suppress("UNCHECKED_CAST")
46+
return leaves.single() as Array<Any?>
4547
}
4648

4749
@Test

core/commonTest/src/implementations/map/HashMapTrieNodeTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class HashMapTrieNodeTest {
1616
private fun testEmptyMap(map: PersistentHashMap<IntWrapper, Int>) {
1717
map.node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
1818
assertEquals(0, shift)
19+
assertEquals(0, hash)
1920
assertEquals(0, dataMap)
2021
assertEquals(0, nodeMap)
2122
assertTrue(node.buffer.isEmpty())
@@ -33,6 +34,7 @@ class HashMapTrieNodeTest {
3334

3435
map.node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
3536
assertEquals(0, shift)
37+
assertEquals(0, hash)
3638
assertEquals(1 shl 0b01101, dataMap)
3739
assertEquals(0b0, nodeMap)
3840
assertTrue(arrayOf<Any?>(wrapper1, 1) contentEquals node.buffer)
@@ -74,6 +76,7 @@ class HashMapTrieNodeTest {
7476

7577
map.remove(wrapper1).node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
7678
assertEquals(0, shift)
79+
assertEquals(0, hash)
7780
assertEquals(0b10, dataMap)
7881
assertEquals(0b0, nodeMap)
7982
assertTrue(arrayOf<Any?>(wrapper33, 33) contentEquals node.buffer)
@@ -183,6 +186,7 @@ class HashMapTrieNodeTest {
183186

184187
map.remove(wrapper1).remove(wrapper1057).node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
185188
assertEquals(0, shift)
189+
assertEquals(0, hash)
186190
assertEquals(0b10, dataMap)
187191
assertEquals(0b0, nodeMap)
188192
assertTrue(arrayOf<Any?>(wrapper33, 33) contentEquals node.buffer)
@@ -228,6 +232,7 @@ class HashMapTrieNodeTest {
228232

229233
map.remove(wrapper1).node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
230234
assertEquals(0, shift)
235+
assertEquals(0, hash)
231236
assertEquals(0b10, dataMap)
232237
assertEquals(0b0, nodeMap)
233238
assertTrue(arrayOf(wrapper2, 2) contentEquals node.buffer)
@@ -351,6 +356,7 @@ class HashMapTrieNodeTest {
351356

352357
map.remove(wrapper3).remove(wrapper1).node.accept { node: TrieNode<IntWrapper, Int>, shift: Int, hash: Int, dataMap: Int, nodeMap: Int ->
353358
assertEquals(0, shift)
359+
assertEquals(0, hash)
354360
assertEquals(0b10, dataMap)
355361
assertEquals(0b0, nodeMap)
356362
assertTrue(arrayOf<Any?>(wrapper2, 2) contentEquals node.buffer)

core/commonTest/src/stress/ExecutionTimeMeasuringTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ package tests.stress
88
import kotlin.test.AfterTest
99
import kotlin.test.BeforeTest
1010
import kotlin.time.*
11+
import kotlin.time.Duration.Companion.seconds
1112

12-
@UseExperimental(ExperimentalTime::class)
13+
@OptIn(ExperimentalTime::class)
1314
abstract class ExecutionTimeMeasuringTest {
1415
private var clockMark: TimeMark? = null
1516

core/commonTest/src/stress/list/PersistentListBuilderTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import kotlin.random.nextInt
1919
import kotlin.test.*
2020
import kotlin.time.ExperimentalTime
2121

22-
@UseExperimental(ExperimentalTime::class)
22+
@OptIn(ExperimentalTime::class)
2323
class PersistentListBuilderTest : ExecutionTimeMeasuringTest() {
2424

2525
@Test
@@ -622,7 +622,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() {
622622
vectorGen.add( builders.map { it.build() } )
623623
expected.add(lists)
624624

625-
val maxSize = builders.maxBy { it.size }?.size
625+
val maxSize = builders.maxOf { it.size }
626626
println("Largest persistent list builder size: $maxSize")
627627
}
628628

0 commit comments

Comments
 (0)