Redundant suspend modifier: do not report when the function has 'actual' modifier

#KT-37746 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-04-12 17:24:02 +09:00
committed by klunnii
parent 188bcf0e7b
commit 08588001be
3 changed files with 12 additions and 1 deletions
@@ -33,7 +33,7 @@ class RedundantSuspendModifierInspection : AbstractKotlinInspection() {
val suspendModifier = function.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) ?: return
if (!function.hasBody()) return
if (function.hasModifier(KtTokens.OVERRIDE_KEYWORD)) return
if (function.hasModifier(KtTokens.OVERRIDE_KEYWORD) || function.hasModifier(KtTokens.ACTUAL_KEYWORD)) return
val context = function.analyzeWithContent()
val descriptor = context[BindingContext.FUNCTION, function] ?: return
@@ -0,0 +1,6 @@
// PROBLEM: none
// DISABLE-ERRORS
expect suspend fun a()
actual <caret>suspend fun a() {
}
@@ -8327,6 +8327,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("actual.kt")
public void testActual() throws Exception {
runTest("idea/testData/inspectionsLocal/redundantSuspend/actual.kt");
}
public void testAllFilesPresentInRedundantSuspend() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/redundantSuspend"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
}