Support local suspend functions

Treat them like lambdas. This means:
1) Like local suspend lambdas, which become "non-suspend" after creating
jvmSuspendView, they do this as well
2) They both are generated with the same codegen.
3) They are treated differently only on front-end side.
 #KT-20364: Fixed
This commit is contained in:
Ilmir Usmanov
2018-04-02 21:50:56 +03:00
parent 5a752da9e9
commit bd0ad26dcf
29 changed files with 797 additions and 29 deletions
@@ -58,7 +58,7 @@ fun String.test() {
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
suspend fun SuperInterface.fun1() {
superFun()
superExtFun()
with("") {
@@ -66,7 +66,7 @@ fun String.test() {
superExtFun()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
suspend fun RestrictedController.fun2() {
superFun()
superExtFun()
memberFun()
@@ -78,7 +78,7 @@ fun String.test() {
memberExtFun()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
suspend fun SubClass.fun3() {
superFun()
superExtFun()
memberFun()
@@ -76,7 +76,7 @@ fun A.test() {
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
suspend fun SuperInterface.fun1() {
extAny()
memExtAny()
extSuper()
@@ -88,7 +88,7 @@ fun A.test() {
memExtSuper()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
suspend fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
@@ -105,7 +105,7 @@ fun A.test() {
memExt()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
suspend fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
@@ -43,7 +43,7 @@ fun A.test() {
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SuperInterface.fun1() {
suspend fun SuperInterface.fun1() {
topLevel()
member()
with(A()) {
@@ -51,7 +51,7 @@ fun A.test() {
member()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun RestrictedController.fun2() {
suspend fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
@@ -59,7 +59,7 @@ fun A.test() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
}
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun SubClass.fun3() {
suspend fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
@@ -2,16 +2,16 @@ suspend fun baz() = 1
suspend fun unit() {}
suspend fun foo() {
<!WRONG_MODIFIER_TARGET!>suspend<!> fun bar() {
suspend fun bar() {
baz()
return unit()
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun foobar1(): Int {
suspend fun foobar1(): Int {
return baz()
}
<!WRONG_MODIFIER_TARGET!>suspend<!> fun foobar2() {
suspend fun foobar2() {
return unit()
}
}