[kotlin] SuspiciousImplicitCoroutineScopeReceiverAccess: avoid endless loop

- when functional literal doesn't belong to any call

^KTIJ-39388 fixed


(cherry picked from commit 0a4f356027659d7ad1370b2224daedc023c2cddb)

IJ-CR-218907

GitOrigin-RevId: 440778a288dde343f88a6868cf0628586283bfc0
This commit is contained in:
Anna Kozlova
2026-08-18 10:57:22 +00:00
committed by intellij-monorepo-bot
parent d1f0f05ba8
commit 16fc65741d
3 changed files with 25 additions and 1 deletions
@@ -152,7 +152,7 @@ internal class SuspiciousImplicitCoroutineScopeReceiverAccessInspection :
}
// Check if the matching parameter's return type is a suspend type
val (functionSymbol, argumentSymbol) = getCallExpressionSymbol(current) ?: continue
val (functionSymbol, argumentSymbol) = getCallExpressionSymbol(current) ?: return false
// Resolve the outer call of the lambda
val parameterType = argumentSymbol.returnType
@@ -16347,6 +16347,11 @@ public abstract class K2LocalInspectionTestGenerated extends AbstractK2LocalInsp
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/lambdaExtensionReceiver_withLabel_suspendWrapper.kt");
}
@TestMetadata("selectBuilderProperty.kt")
public void testSelectBuilderProperty() throws Exception {
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/selectBuilderProperty.kt");
}
@TestMetadata("selectExpression.kt")
public void testSelectExpression() throws Exception {
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/selectExpression.kt");
@@ -0,0 +1,19 @@
// WITH_COROUTINES
// PROBLEM: none
package test
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.selects.SelectBuilder
fun CoroutineScope.doStuff() {}
suspend fun CoroutineScope.test() {
val deferred = async { 42 }
val p: SelectBuilder<Unit>.() -> Unit = {
deferred.onAwait {
<caret>doStuff()
}
}
}