From 354f8f0bf16844936fd8a6c9cffcf27ec322bc7d Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Fri, 17 May 2019 17:14:37 +0900 Subject: [PATCH] Redundant 'suspend' modifier inspection: don't report when function has suspend operator invoke #KT-25465 Fixed --- .../idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt | 1 + .../inspections/redundantSuspendModifier/operators.kt | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt index 53689bd3b32..c346aa32a1e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt @@ -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 } diff --git a/idea/testData/inspections/redundantSuspendModifier/operators.kt b/idea/testData/inspections/redundantSuspendModifier/operators.kt index 053b6f46563..a0d7150576e 100644 --- a/idea/testData/inspections/redundantSuspendModifier/operators.kt +++ b/idea/testData/inspections/redundantSuspendModifier/operators.kt @@ -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()