Has suspend calls: fix suspend iterator case
This commit is contained in:
+14
-6
@@ -85,10 +85,18 @@ private fun KtExpression.isValidCandidateExpression(): Boolean {
|
|||||||
fun KtExpression.hasSuspendCalls(bindingContext: BindingContext = analyze(BodyResolveMode.PARTIAL)): Boolean {
|
fun KtExpression.hasSuspendCalls(bindingContext: BindingContext = analyze(BodyResolveMode.PARTIAL)): Boolean {
|
||||||
if (!isValidCandidateExpression()) return false
|
if (!isValidCandidateExpression()) return false
|
||||||
|
|
||||||
val resolvedCall = if (this is KtForExpression) {
|
return when (this) {
|
||||||
bindingContext[BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL, loopRange]
|
is KtForExpression -> {
|
||||||
} else {
|
val iteratorResolvedCall = bindingContext[BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange]
|
||||||
this.getResolvedCall(bindingContext)
|
val loopRangeHasNextResolvedCall = bindingContext[BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, loopRange]
|
||||||
} ?: return false
|
val loopRangeNextResolvedCall = bindingContext[BindingContext.LOOP_RANGE_NEXT_RESOLVED_CALL, loopRange]
|
||||||
return (resolvedCall.resultingDescriptor as? FunctionDescriptor)?.isSuspend == true
|
listOf(iteratorResolvedCall, loopRangeHasNextResolvedCall, loopRangeNextResolvedCall).any {
|
||||||
|
it?.resultingDescriptor?.isSuspend == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
val resolvedCall = getResolvedCall(bindingContext)
|
||||||
|
(resolvedCall?.resultingDescriptor as? FunctionDescriptor)?.isSuspend == true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -31,15 +31,6 @@
|
|||||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'suspend' modifier</problem_class>
|
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'suspend' modifier</problem_class>
|
||||||
<description>Redundant 'suspend' modifier</description>
|
<description>Redundant 'suspend' modifier</description>
|
||||||
</problem>
|
</problem>
|
||||||
<!-- FIXME: Incorrect problem -->
|
|
||||||
<problem>
|
|
||||||
<file>test.kt</file>
|
|
||||||
<line>57</line>
|
|
||||||
<module>light_idea_test_case</module>
|
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
|
||||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant 'suspend' modifier</problem_class>
|
|
||||||
<description>Redundant 'suspend' modifier</description>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
<problem>
|
||||||
<file>operators.kt</file>
|
<file>operators.kt</file>
|
||||||
<line>5</line>
|
<line>5</line>
|
||||||
|
|||||||
Reference in New Issue
Block a user