diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/blockingCallsDetection/CoroutineNonBlockingContextChecker.kt.183 b/idea/src/org/jetbrains/kotlin/idea/inspections/blockingCallsDetection/CoroutineNonBlockingContextChecker.kt.183 index 4fb01f7e247..63c07dffaa7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/blockingCallsDetection/CoroutineNonBlockingContextChecker.kt.183 +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/blockingCallsDetection/CoroutineNonBlockingContextChecker.kt.183 @@ -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() diff --git a/idea/testData/inspections/blockingCallsDetection/NestedFunctionsInsideSuspendLambda.kt.183 b/idea/testData/inspections/blockingCallsDetection/NestedFunctionsInsideSuspendLambda.kt.183 new file mode 100644 index 00000000000..ca3c749a015 --- /dev/null +++ b/idea/testData/inspections/blockingCallsDetection/NestedFunctionsInsideSuspendLambda.kt.183 @@ -0,0 +1,11 @@ +fun runBlocking(block: suspend CoroutineScope.() -> T): T = TODO() + +class CoroutineScope + +fun test() { + runBlocking { + repeat(1) { + java.lang.Thread.sleep(2) + } + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/CoroutineNonBlockingontextDetectionTest.kt.183 b/idea/tests/org/jetbrains/kotlin/idea/inspections/CoroutineNonBlockingontextDetectionTest.kt.183 index 04ac6cac445..a5c8a189bda 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/CoroutineNonBlockingontextDetectionTest.kt.183 +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/CoroutineNonBlockingontextDetectionTest.kt.183 @@ -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") + } } \ No newline at end of file