RedundantLambdaArrowInspection: fix false positive when receiver is qualified expression
#KT-37502 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
487e1ddddc
commit
e5b4b03314
@@ -90,9 +90,9 @@ class RedundantLambdaArrowInspection : AbstractKotlinInspection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KtCallExpression.isApplicableCall(lambdaExpression: KtLambdaExpression, lambdaContext: BindingContext): Boolean {
|
private fun KtCallExpression.isApplicableCall(lambdaExpression: KtLambdaExpression, lambdaContext: BindingContext): Boolean {
|
||||||
val offset = lambdaExpression.textOffset - textOffset
|
|
||||||
val dotQualifiedExpression = parent as? KtDotQualifiedExpression
|
val dotQualifiedExpression = parent as? KtDotQualifiedExpression
|
||||||
return if (dotQualifiedExpression == null) {
|
return if (dotQualifiedExpression == null) {
|
||||||
|
val offset = lambdaExpression.textOffset - textOffset
|
||||||
replaceWithCopyWithResolveCheck(
|
replaceWithCopyWithResolveCheck(
|
||||||
resolveStrategy = { expr, context ->
|
resolveStrategy = { expr, context ->
|
||||||
expr.getResolvedCall(context)?.resultingDescriptor
|
expr.getResolvedCall(context)?.resultingDescriptor
|
||||||
@@ -103,6 +103,7 @@ private fun KtCallExpression.isApplicableCall(lambdaExpression: KtLambdaExpressi
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
val offset = lambdaExpression.textOffset - dotQualifiedExpression.textOffset
|
||||||
dotQualifiedExpression.replaceWithCopyWithResolveCheck(
|
dotQualifiedExpression.replaceWithCopyWithResolveCheck(
|
||||||
resolveStrategy = { expr, context ->
|
resolveStrategy = { expr, context ->
|
||||||
expr.selectorExpression.getResolvedCall(context)?.resultingDescriptor
|
expr.selectorExpression.getResolvedCall(context)?.resultingDescriptor
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
object A {
|
||||||
|
fun <T> foo(f: (T) -> Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.foo { <caret>_: String -> 24 }
|
||||||
|
}
|
||||||
+5
@@ -7712,6 +7712,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt");
|
runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeParameter4.kt")
|
||||||
|
public void testTypeParameter4() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter4.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("underscore.kt")
|
@TestMetadata("underscore.kt")
|
||||||
public void testUnderscore() throws Exception {
|
public void testUnderscore() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/underscore.kt");
|
runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/underscore.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user