Redundant 'suspend' modifier inspection: don't report when function has suspend operator invoke
#KT-25465 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cf5577dfa6
commit
354f8f0bf1
@@ -79,6 +79,7 @@ private fun KtExpression.isValidCandidateExpression(): Boolean {
|
||||
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
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ class C(val x: Int, val y: Int) {
|
||||
suspend operator fun invoke() = x + y
|
||||
}
|
||||
|
||||
// Not redundant
|
||||
suspend fun bar(): Int {
|
||||
return C(1, 2)()
|
||||
}
|
||||
|
||||
// Not redundant
|
||||
suspend fun foo(c1: C, c2: C): Int {
|
||||
return c1() + c2()
|
||||
|
||||
Reference in New Issue
Block a user