[kotlin] SuspiciousImplicitCoroutineScopeReceiverAccess: avoid endless loop

- when parameter type is a flexible type

KTIJ-39388


(cherry picked from commit 915620ede97aa559cc284b4210492ded9a07e408)

IJ-CR-218907

GitOrigin-RevId: 408de3946732089f7ef2bd64a4f64b564453e31e
This commit is contained in:
Anna Kozlova
2026-08-18 10:57:22 +00:00
committed by intellij-monorepo-bot
parent 16fc65741d
commit 32b66c7d87
4 changed files with 33 additions and 1 deletions
@@ -162,7 +162,7 @@ internal class SuspiciousImplicitCoroutineScopeReceiverAccessInspection :
samConstructor?.samConstructorLambdaParameterType
} else {
parameterType
} ?: continue
} ?: return false
if (lambdaType.isSuspendFunctionType && !isAllowedSuspendingFunction(functionSymbol)) {
return true
@@ -16307,6 +16307,11 @@ public abstract class K2LocalInspectionTestGenerated extends AbstractK2LocalInsp
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/functionExtensionReceiver_suspendWrapper_suspendFunInterface.kt");
}
@TestMetadata("functionExtensionReceiver_suspendWrapper_suspendFunInterfaceJava.kt")
public void testFunctionExtensionReceiver_suspendWrapper_suspendFunInterfaceJava() throws Exception {
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/functionExtensionReceiver_suspendWrapper_suspendFunInterfaceJava.kt");
}
@TestMetadata("functionExtensionReceiver_suspendWrapper_suspendFunInterface_explicitSamConstructor.kt")
public void testFunctionExtensionReceiver_suspendWrapper_suspendFunInterface_explicitSamConstructor() throws Exception {
runTest("testData/inspectionsLocal/coroutines/ambiguousCoroutineScope/functionExtensionReceiver_suspendWrapper_suspendFunInterface_explicitSamConstructor.kt");
@@ -0,0 +1,13 @@
package test
import kotlinx.coroutines.CoroutineScope
interface CustomSuspendLambda {
void customInvoke();
}
class Main {
static void suspendWrapper(CustomSuspendLambda action) {
action.customInvoke();
}
}
@@ -0,0 +1,14 @@
// WITH_COROUTINES
// PROBLEM: none
package test
import kotlinx.coroutines.CoroutineScope
fun CoroutineScope.doStuff() {}
suspend fun CoroutineScope.test() {
Main.suspendWrapper {
<caret>doStuff()
}
}