From 978f53414fc8272977c5b64f911a6d14defd2f09 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 12 Jan 2017 11:02:11 +0300 Subject: [PATCH] Prohibit local suspend functions #KT-15392 Fixed --- .../src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt | 2 +- .../coroutines/restrictSuspension/allMembersAllowed.kt | 6 +++--- .../tests/coroutines/restrictSuspension/extensions.kt | 6 +++--- .../tests/coroutines/restrictSuspension/notRelatedFun.kt | 6 +++--- .../tests/coroutines/tailCalls/localFunctions.kt | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index 541aca2adbd..186c1ed9528 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -82,7 +82,7 @@ object ModifierCheckerCore { INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER), NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER), TAILREC_KEYWORD to EnumSet.of(FUNCTION), - SUSPEND_KEYWORD to EnumSet.of(FUNCTION), + SUSPEND_KEYWORD to EnumSet.of(MEMBER_FUNCTION, TOP_LEVEL_FUNCTION), EXTERNAL_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER, CLASS), ANNOTATION_KEYWORD to EnumSet.of(ANNOTATION_CLASS), CROSSINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER), diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt index 0acd4e42d22..9e32259494f 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt @@ -58,7 +58,7 @@ fun String.test() { } } - suspend fun SuperInterface.fun1() { + suspend fun SuperInterface.fun1() { superFun() superExtFun() with("") { @@ -66,7 +66,7 @@ fun String.test() { superExtFun() } } - suspend fun RestrictedController.fun2() { + suspend fun RestrictedController.fun2() { superFun() superExtFun() memberFun() @@ -78,7 +78,7 @@ fun String.test() { memberExtFun() } } - suspend fun SubClass.fun3() { + suspend fun SubClass.fun3() { superFun() superExtFun() memberFun() diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt index 047ccccfcd0..7c4960ee341 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt @@ -76,7 +76,7 @@ fun A.test() { } } - suspend fun SuperInterface.fun1() { + suspend fun SuperInterface.fun1() { extAny() memExtAny() extSuper() @@ -88,7 +88,7 @@ fun A.test() { memExtSuper() } } - suspend fun RestrictedController.fun2() { + suspend fun RestrictedController.fun2() { extAny() memExtAny() extSuper() @@ -105,7 +105,7 @@ fun A.test() { memExt() } } - suspend fun SubClass.fun3() { + suspend fun SubClass.fun3() { extAny() memExtAny() extSuper() diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt index ecb28673439..3334e2247ec 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt @@ -43,7 +43,7 @@ fun A.test() { } } - suspend fun SuperInterface.fun1() { + suspend fun SuperInterface.fun1() { topLevel() member() with(A()) { @@ -51,7 +51,7 @@ fun A.test() { member() } } - suspend fun RestrictedController.fun2() { + suspend fun RestrictedController.fun2() { topLevel() member() with(A()) { @@ -59,7 +59,7 @@ fun A.test() { member() } } - suspend fun SubClass.fun3() { + suspend fun SubClass.fun3() { topLevel() member() with(A()) { diff --git a/compiler/testData/diagnostics/tests/coroutines/tailCalls/localFunctions.kt b/compiler/testData/diagnostics/tests/coroutines/tailCalls/localFunctions.kt index ed50fe169ab..ef284b46147 100644 --- a/compiler/testData/diagnostics/tests/coroutines/tailCalls/localFunctions.kt +++ b/compiler/testData/diagnostics/tests/coroutines/tailCalls/localFunctions.kt @@ -2,16 +2,16 @@ suspend fun baz() = 1 suspend fun unit() {} suspend fun foo() { - suspend fun bar() { + suspend fun bar() { baz() return unit() } - suspend fun foobar1(): Int { + suspend fun foobar1(): Int { return baz() } - suspend fun foobar2() { + suspend fun foobar2() { return unit() } }