Add intention to replace "Map.getOrDefault"
#KT-21503 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
e09ae645b3
commit
f5c0a30c51
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ReplaceMapGetOrDefaultIntention
|
||||
@@ -0,0 +1,4 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(map: Map<Int, String>) {
|
||||
map.<caret>getOrDefault(1, "bar") + "baz"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(map: Map<Int, String>) {
|
||||
(map[1] ?: "bar") + "baz"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun main() {
|
||||
val map = mapOf(1 to "", 2 to null)
|
||||
val b = map.getOrDefault<caret>(2, "bar") == null
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(map: Map<Int, String>) {
|
||||
map.getOrDefault<caret>(1, "bar")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
fun test(map: Map<Int, String>) {
|
||||
map<caret>[1] ?: "bar"
|
||||
}
|
||||
Reference in New Issue
Block a user