JavaMapForEachInspection: don't report if argument is not single
#KT-39151 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
7d3b28d75b
commit
2a36a8acac
@@ -31,6 +31,7 @@ class JavaMapForEachInspection : AbstractApplicabilityBasedInspection<KtDotQuali
|
||||
val callExpression = element.callExpression ?: return false
|
||||
val calleeExpression = callExpression.calleeExpression ?: return false
|
||||
if (calleeExpression.text != "forEach") return false
|
||||
if (callExpression.valueArguments.size != 1) return false
|
||||
|
||||
val lambda = callExpression.lambda() ?: return false
|
||||
val lambdaParameters = lambda.valueParameters
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: none
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
fun test(map: ConcurrentHashMap<Int, String>) {
|
||||
map.<caret>forEach(1) { key, value ->
|
||||
foo(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(i: Int, s: String) {}
|
||||
+5
@@ -5160,6 +5160,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
public void testKotlin2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/javaMapForEach/kotlin2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notSingleArgument.kt")
|
||||
public void testNotSingleArgument() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/javaMapForEach/notSingleArgument.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/kdocMissingDocumentation")
|
||||
|
||||
Reference in New Issue
Block a user