183: Fix exception about unmapped lambda argument from IDE inspection
Intention: obtain lambda argument for some parent call, then get that call (for the lambda argument) and map the argument to the parameter. Before the fix, we were getting call for inner element, not for the lambda argument and as a result, there were exceptions. #KT-26873 Fixed
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ class CoroutineNonBlockingContextChecker : NonBlockingContextChecker {
|
||||
.firstOrNull { it is KtLambdaExpression && it.analyze().get(BindingContext.LAMBDA_INVOCATIONS, it) == null }
|
||||
val containingArgument = PsiTreeUtil.getParentOfType(containingLambda, KtValueArgument::class.java)
|
||||
if (containingArgument != null) {
|
||||
val callExpression = PsiTreeUtil.getParentOfType(element, KtCallExpression::class.java) ?: return false
|
||||
val callExpression = PsiTreeUtil.getParentOfType(containingArgument, KtCallExpression::class.java) ?: return false
|
||||
val call = callExpression.resolveToCall(BodyResolveMode.FULL) ?: return false
|
||||
|
||||
val hasBlockingAnnotation = call.getFirstArgument()?.resolveToCall()
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun <T> runBlocking(<warning descr="[UNUSED_PARAMETER] Parameter 'block' is never used">block</warning>: suspend CoroutineScope.() -> T): T = TODO()
|
||||
|
||||
class CoroutineScope
|
||||
|
||||
fun test() {
|
||||
runBlocking {
|
||||
repeat(1) {
|
||||
java.lang.Thread.<warning descr="Inappropriate blocking method call">sleep</warning>(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -38,4 +38,9 @@ class CoroutineNonBlockingontextDetectionTest: KotlinLightCodeInsightFixtureTest
|
||||
myFixture.configureByFile("LambdaReceiverTypeCheck.kt")
|
||||
myFixture.testHighlighting(true, false, false, "LambdaReceiverTypeCheck.kt")
|
||||
}
|
||||
|
||||
fun testNestedFunctionsInsideSuspendLambda() {
|
||||
myFixture.configureByFile("NestedFunctionsInsideSuspendLambda.kt")
|
||||
myFixture.testHighlighting(true, false, false, "NestedFunctionsInsideSuspendLambda.kt")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user