Add "Replace 'associate' with 'associateBy' or 'associateWith'" inspection
#KT-26269 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
42120b93b8
commit
f1e66d0654
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ReplaceAssociateFunctionInspection
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
arrayOf(1).<caret>associate { getKey(it) to it }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
arrayOf(1).associateBy { getKey(it) }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { getKey(it) to it }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy { getKey(it) }
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
arrayOf(1).<caret>associate { getKey(it) to getValue(it) }
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
arrayOf(1).associateBy({ getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { getKey(it) to getValue(it) }
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy({ getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { i -> getKey(i) to getValue(i) }
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy({ i -> getKey(i) }, { i -> getValue(i) })
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { Pair(getKey(it), getValue(it)) }
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy({ getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate({ getKey(it) to getValue(it) })
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy({ getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { "$it" to "$it" }
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associate' with 'associateBy'
|
||||
// FIX: Replace with 'associateBy'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateBy({ "$it" }, { "$it" })
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate {
|
||||
val key = getKey(it)
|
||||
val value = getValue(it)
|
||||
key to value
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, Int>()
|
||||
arrayOf(1).<caret>associateTo(destination) { getKey(it) to it }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, Int>()
|
||||
arrayOf(1).associateByTo(destination) { getKey(it) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, Int>()
|
||||
listOf(1).<caret>associateTo(destination) { getKey(it) to it }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, Int>()
|
||||
listOf(1).associateByTo(destination) { getKey(it) }
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
arrayOf(1).<caret>associateTo(destination) { getKey(it) to getValue(it) }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
arrayOf(1).associateByTo(destination, { getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).<caret>associateTo(destination) { getKey(it) to getValue(it) }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).associateByTo(destination, { getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).<caret>associateTo(destination) { i -> getKey(i) to getValue(i) }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).associateByTo(destination, { i -> getKey(i) }, { i -> getValue(i) })
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).<caret>associateTo(destination) { Pair(getKey(it), getValue(it)) }
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).associateByTo(destination, { getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).<caret>associateTo(destination, { getKey(it) to getValue(it) })
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// HIGHLIGHT: INFORMATION
|
||||
// PROBLEM: Replace 'associateTo' with 'associateByTo'
|
||||
// FIX: Replace with 'associateByTo'
|
||||
// WITH_RUNTIME
|
||||
fun getKey(i: Int): Long = 1L
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
val destination = mutableMapOf<Long, String>()
|
||||
listOf(1).associateByTo(destination, { getKey(it) }, { getValue(it) })
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
arrayOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith { getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associate<caret> { i -> i to getValue(i) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith { i -> getValue(i) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { Pair(it, getValue(it)) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith { getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate({ it to getValue(it) })
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith({ getValue(it) })
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { it to "$it" }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith { "$it" }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
intArrayOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test(b: Boolean) {
|
||||
listOf(1).<caret>associate {
|
||||
if (b) {
|
||||
return@associate it to ""
|
||||
}
|
||||
it to getValue(it)
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate {
|
||||
val value = getValue(it)
|
||||
it to value
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).associateWith {
|
||||
val value = getValue(it)
|
||||
value
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test(b: Boolean) {
|
||||
listOf(1).<caret>associate {
|
||||
if (b) {
|
||||
it to getValue(it)
|
||||
} else {
|
||||
it to ""
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
sequenceOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
sequenceOf(1).associateWith { getValue(it) }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
setOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: Replace 'associate' with 'associateWith'
|
||||
// FIX: Replace with 'associateWith'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
setOf(1).associateWith { getValue(it) }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
arrayOf(1).<caret>associateTo(destination) { it to getValue(it) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).<caret>associateTo(destination) { it to getValue(it) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).associateWithTo(destination) { getValue(it) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).<caret>associateTo(destination) { i -> i to getValue(i) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).associateWithTo(destination) { i -> getValue(i) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).<caret>associateTo(destination) { Pair(it, getValue(it)) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).associateWithTo(destination) { getValue(it) }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).<caret>associateTo(destination, { it to getValue(it) })
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).associateWithTo(destination, { getValue(it) })
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).<caret>associateTo(destination, { it to "$it" })
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: Replace 'associateTo' with 'associateWithTo'
|
||||
// FIX: Replace with 'associateWithTo'
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun associateWithTo() {
|
||||
val destination = mutableMapOf<Int, String>()
|
||||
listOf(1).associateWithTo(destination, { "$it" })
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun getValue(i: Int): String = ""
|
||||
|
||||
fun test() {
|
||||
listOf(1).<caret>associate { it to getValue(it) }
|
||||
}
|
||||
Reference in New Issue
Block a user