"Redundant 'suspend' modifier": do not report when function has 'suspend' calls by parenthesized expression
#KT-24869 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
31315e2c45
commit
4d1937b92d
+2
-1
@@ -76,10 +76,11 @@ class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider {
|
||||
}
|
||||
|
||||
private fun KtExpression.isValidCandidateExpression(): Boolean {
|
||||
if (this is KtParenthesizedExpression) return false
|
||||
if (this is KtOperationReferenceExpression || this is KtForExpression || this is KtProperty || this is KtNameReferenceExpression) return true
|
||||
val parent = parent
|
||||
if (parent is KtCallExpression && parent.calleeExpression == this) return true
|
||||
if (this is KtCallExpression && this.calleeExpression is KtCallExpression) return true
|
||||
if (this is KtCallExpression && (calleeExpression is KtCallExpression || calleeExpression is KtParenthesizedExpression)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
object Foo {
|
||||
val f: suspend SequenceScope<Int>.(low: Int, high: Int) -> Unit = { low, high ->
|
||||
(low until high).forEach {
|
||||
yield(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<caret>suspend fun SequenceScope<Int>.f2(low: Int, high: Int) {
|
||||
(Foo.f)(low, high)
|
||||
}
|
||||
+5
@@ -7909,6 +7909,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
public void testOverride() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSuspend/override.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parenthesized.kt")
|
||||
public void testParenthesized() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSuspend/parenthesized.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/redundantUnitExpression")
|
||||
|
||||
Reference in New Issue
Block a user