Do not allow using getOrPut on concurrent maps.

#KT-5800 In Progress
This commit is contained in:
Ilya Gorbunov
2015-07-01 18:38:36 +03:00
parent a47325cc30
commit 64379947fd
2 changed files with 21 additions and 0 deletions
@@ -1,5 +1,6 @@
package test.collections
import java.util.concurrent.ConcurrentHashMap
import kotlin.test.*
import org.junit.Test as test
@@ -37,4 +38,15 @@ class MapJVMTest {
assertEquals("A", prop.getProperty("a", "fail"))
assertEquals("B", prop.getProperty("b", "fail"))
}
test fun getOrPutFailsOnConcurrentMap() {
val map = ConcurrentHashMap<String, Int>()
fails {
map.getOrPut("x") { 1 }
}
expect(1) {
(map as MutableMap<String, Int>).getOrPut("x") { 1 }
}
}
}