Prohibit local suspend functions

#KT-15392 Fixed
This commit is contained in:
Denis Zharkov
2017-01-12 11:02:11 +03:00
parent d43a4199f8
commit 978f53414f
5 changed files with 13 additions and 13 deletions
@@ -82,7 +82,7 @@ object ModifierCheckerCore {
INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER), INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER),
NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER), NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
TAILREC_KEYWORD to EnumSet.of(FUNCTION), 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), EXTERNAL_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER, CLASS),
ANNOTATION_KEYWORD to EnumSet.of(ANNOTATION_CLASS), ANNOTATION_KEYWORD to EnumSet.of(ANNOTATION_CLASS),
CROSSINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER), CROSSINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
@@ -58,7 +58,7 @@ fun String.test() {
} }
} }
suspend fun SuperInterface.fun1() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
superFun() superFun()
superExtFun() superExtFun()
with("") { with("") {
@@ -66,7 +66,7 @@ fun String.test() {
superExtFun() superExtFun()
} }
} }
suspend fun RestrictedController.fun2() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
superFun() superFun()
superExtFun() superExtFun()
memberFun() memberFun()
@@ -78,7 +78,7 @@ fun String.test() {
memberExtFun() memberExtFun()
} }
} }
suspend fun SubClass.fun3() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
superFun() superFun()
superExtFun() superExtFun()
memberFun() memberFun()
@@ -76,7 +76,7 @@ fun A.test() {
} }
} }
suspend fun SuperInterface.fun1() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
extAny() extAny()
memExtAny() memExtAny()
extSuper() extSuper()
@@ -88,7 +88,7 @@ fun A.test() {
memExtSuper() memExtSuper()
} }
} }
suspend fun RestrictedController.fun2() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
@@ -105,7 +105,7 @@ fun A.test() {
memExt() memExt()
} }
} }
suspend fun SubClass.fun3() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
@@ -43,7 +43,7 @@ fun A.test() {
} }
} }
suspend fun SuperInterface.fun1() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
topLevel() topLevel()
member() member()
with(A()) { with(A()) {
@@ -51,7 +51,7 @@ fun A.test() {
member() member()
} }
} }
suspend fun RestrictedController.fun2() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) { with(A()) {
@@ -59,7 +59,7 @@ fun A.test() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
} }
} }
suspend fun SubClass.fun3() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>() <!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) { with(A()) {
@@ -2,16 +2,16 @@ suspend fun baz() = 1
suspend fun unit() {} suspend fun unit() {}
suspend fun foo() { suspend fun foo() {
suspend fun bar() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun bar() {
baz() baz()
return unit() return unit()
} }
suspend fun foobar1(): Int { <!WRONG_MODIFIER_TARGET!>suspend<!> fun foobar1(): Int {
return baz() return baz()
} }
suspend fun foobar2() { <!WRONG_MODIFIER_TARGET!>suspend<!> fun foobar2() {
return unit() return unit()
} }
} }