diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt
index 920e7e7d7cd..f6aa4ddd26d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt
@@ -85,10 +85,18 @@ private fun KtExpression.isValidCandidateExpression(): Boolean {
fun KtExpression.hasSuspendCalls(bindingContext: BindingContext = analyze(BodyResolveMode.PARTIAL)): Boolean {
if (!isValidCandidateExpression()) return false
- val resolvedCall = if (this is KtForExpression) {
- bindingContext[BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL, loopRange]
- } else {
- this.getResolvedCall(bindingContext)
- } ?: return false
- return (resolvedCall.resultingDescriptor as? FunctionDescriptor)?.isSuspend == true
+ return when (this) {
+ is KtForExpression -> {
+ val iteratorResolvedCall = bindingContext[BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange]
+ val loopRangeHasNextResolvedCall = bindingContext[BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, loopRange]
+ val loopRangeNextResolvedCall = bindingContext[BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL, loopRange]
+ listOf(iteratorResolvedCall, loopRangeHasNextResolvedCall, loopRangeNextResolvedCall).any {
+ it?.resultingDescriptor?.isSuspend == true
+ }
+ }
+ else -> {
+ val resolvedCall = getResolvedCall(bindingContext)
+ (resolvedCall?.resultingDescriptor as? FunctionDescriptor)?.isSuspend == true
+ }
+ }
}
diff --git a/idea/testData/inspections/redundantSuspendModifier/inspectionData/expected.xml b/idea/testData/inspections/redundantSuspendModifier/inspectionData/expected.xml
index 82c8d6a142c..ceefadf6a64 100644
--- a/idea/testData/inspections/redundantSuspendModifier/inspectionData/expected.xml
+++ b/idea/testData/inspections/redundantSuspendModifier/inspectionData/expected.xml
@@ -31,15 +31,6 @@
Redundant 'suspend' modifier
Redundant 'suspend' modifier
-
-
- test.kt
- 57
- light_idea_test_case
-
- Redundant 'suspend' modifier
- Redundant 'suspend' modifier
-
operators.kt
5