Support checks for annotation RestrictSuspension.

This commit is contained in:
Stanislav Erokhin
2016-12-15 14:52:57 +03:00
parent d1a3c4c48b
commit b88c8ea2e7
16 changed files with 571 additions and 0 deletions
@@ -0,0 +1,99 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE
interface SuperInterface {
suspend fun superFun() {}
suspend fun String.superExtFun() {}
}
@kotlin.coroutines.RestrictSuspension
open class RestrictedController : SuperInterface {
suspend fun memberFun() {}
suspend fun String.memberExtFun() {}
}
class SubClass : RestrictedController() {
suspend fun subFun() {}
suspend fun String.subExtFun() {}
}
fun generate1(f: suspend SuperInterface.() -> Unit) {}
fun generate2(f: suspend RestrictedController.() -> Unit) {}
fun generate3(f: suspend SubClass.() -> Unit) {}
fun String.test() {
generate1 {
superFun()
superExtFun()
with("") {
superFun()
superExtFun()
}
}
generate2 {
superFun()
superExtFun()
memberFun()
memberExtFun()
with("") {
superFun()
superExtFun()
memberFun()
memberExtFun()
}
}
generate3 {
superFun()
superExtFun()
memberFun()
memberExtFun()
subFun()
superExtFun()
with("") {
superFun()
superExtFun()
memberFun()
memberExtFun()
subFun()
superExtFun()
}
}
suspend fun SuperInterface.fun1() {
superFun()
superExtFun()
with("") {
superFun()
superExtFun()
}
}
suspend fun RestrictedController.fun2() {
superFun()
superExtFun()
memberFun()
memberExtFun()
with("") {
superFun()
superExtFun()
memberFun()
memberExtFun()
}
}
suspend fun SubClass.fun3() {
superFun()
superExtFun()
memberFun()
memberExtFun()
subFun()
superExtFun()
with("") {
superFun()
superExtFun()
memberFun()
memberExtFun()
subFun()
superExtFun()
}
}
}
@@ -0,0 +1,38 @@
package
public fun generate1(/*0*/ f: suspend SuperInterface.() -> kotlin.Unit): kotlin.Unit
public fun generate2(/*0*/ f: suspend RestrictedController.() -> kotlin.Unit): kotlin.Unit
public fun generate3(/*0*/ f: suspend SubClass.() -> kotlin.Unit): kotlin.Unit
public fun kotlin.String.test(): kotlin.Unit
@kotlin.coroutines.RestrictSuspension public open class RestrictedController : SuperInterface {
public constructor RestrictedController()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final suspend fun memberFun(): kotlin.Unit
public open suspend override /*1*/ /*fake_override*/ fun superFun(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun kotlin.String.memberExtFun(): kotlin.Unit
public open suspend override /*1*/ /*fake_override*/ fun kotlin.String.superExtFun(): kotlin.Unit
}
public final class SubClass : RestrictedController {
public constructor SubClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final suspend override /*1*/ /*fake_override*/ fun memberFun(): kotlin.Unit
public final suspend fun subFun(): kotlin.Unit
public open suspend override /*1*/ /*fake_override*/ fun superFun(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend override /*1*/ /*fake_override*/ fun kotlin.String.memberExtFun(): kotlin.Unit
public final suspend fun kotlin.String.subExtFun(): kotlin.Unit
public open suspend override /*1*/ /*fake_override*/ fun kotlin.String.superExtFun(): kotlin.Unit
}
public interface SuperInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open suspend fun superFun(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public open suspend fun kotlin.String.superExtFun(): kotlin.Unit
}
@@ -0,0 +1,129 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE
interface SuperInterface
@kotlin.coroutines.RestrictSuspension
open class RestrictedController : SuperInterface
class SubClass : RestrictedController()
suspend fun Any?.extAny() {}
suspend fun SuperInterface.extSuper() {}
suspend fun RestrictedController.ext() {}
suspend fun SubClass.extSub() {}
class A {
suspend fun Any?.memExtAny() {}
suspend fun SuperInterface.memExtSuper() {}
suspend fun RestrictedController.memExt() {}
suspend fun SubClass.memExtSub() {}
}
fun generate1(f: suspend SuperInterface.() -> Unit) {}
fun generate2(f: suspend RestrictedController.() -> Unit) {}
fun generate3(f: suspend SubClass.() -> Unit) {}
fun A.test() {
generate1 {
extAny()
memExtAny()
extSuper()
memExtSuper()
with(A()) {
extAny()
memExtAny()
extSuper()
memExtSuper()
}
}
generate2 {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
}
}
generate3 {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
extSub()
memExtSub()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
extSub()
memExtSub()
}
}
suspend fun SuperInterface.fun1() {
extAny()
memExtAny()
extSuper()
memExtSuper()
with(A()) {
extAny()
memExtAny()
extSuper()
memExtSuper()
}
}
suspend fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
}
}
suspend fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
extSub()
memExtSub()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtAny<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extSuper<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>memExtSuper<!>()
ext()
memExt()
extSub()
memExtSub()
}
}
}
@@ -0,0 +1,41 @@
package
public fun generate1(/*0*/ f: suspend SuperInterface.() -> kotlin.Unit): kotlin.Unit
public fun generate2(/*0*/ f: suspend RestrictedController.() -> kotlin.Unit): kotlin.Unit
public fun generate3(/*0*/ f: suspend SubClass.() -> kotlin.Unit): kotlin.Unit
public suspend fun RestrictedController.ext(): kotlin.Unit
public suspend fun kotlin.Any?.extAny(): kotlin.Unit
public suspend fun SubClass.extSub(): kotlin.Unit
public suspend fun SuperInterface.extSuper(): kotlin.Unit
public fun A.test(): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final suspend fun RestrictedController.memExt(): kotlin.Unit
public final suspend fun kotlin.Any?.memExtAny(): kotlin.Unit
public final suspend fun SubClass.memExtSub(): kotlin.Unit
public final suspend fun SuperInterface.memExtSuper(): kotlin.Unit
}
@kotlin.coroutines.RestrictSuspension public open class RestrictedController : SuperInterface {
public constructor RestrictedController()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class SubClass : RestrictedController {
public constructor SubClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface SuperInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,72 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE
interface SuperInterface
@kotlin.coroutines.RestrictSuspension
open class RestrictedController : SuperInterface
class SubClass : RestrictedController()
suspend fun topLevel() {}
class A {
suspend fun member() {}
}
fun generate1(f: suspend SuperInterface.() -> Unit) {}
fun generate2(f: suspend RestrictedController.() -> Unit) {}
fun generate3(f: suspend SubClass.() -> Unit) {}
fun A.test() {
generate1 {
topLevel()
member()
with(A()) {
topLevel()
member()
}
}
generate2 {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
}
}
generate3 {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
}
}
suspend fun SuperInterface.fun1() {
topLevel()
member()
with(A()) {
topLevel()
member()
}
}
suspend fun RestrictedController.fun2() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
}
}
suspend fun SubClass.fun3() {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
with(A()) {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>topLevel<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
}
}
}
@@ -0,0 +1,35 @@
package
public fun generate1(/*0*/ f: suspend SuperInterface.() -> kotlin.Unit): kotlin.Unit
public fun generate2(/*0*/ f: suspend RestrictedController.() -> kotlin.Unit): kotlin.Unit
public fun generate3(/*0*/ f: suspend SubClass.() -> kotlin.Unit): kotlin.Unit
public suspend fun topLevel(): kotlin.Unit
public fun A.test(): kotlin.Unit
public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final suspend fun member(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.coroutines.RestrictSuspension public open class RestrictedController : SuperInterface {
public constructor RestrictedController()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class SubClass : RestrictedController {
public constructor SubClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface SuperInterface {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE
@kotlin.coroutines.RestrictSuspension
class RestrictedController {
suspend fun member() {}
}
suspend fun RestrictedController.extension() {}
fun generate(f: suspend RestrictedController.() -> Unit) {}
fun test() {
generate() l@ {
member()
extension()
// todo
this.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
this.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extension<!>()
val foo = this
foo.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
foo.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extension<!>()
// todo
this@l.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
this@l.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extension<!>()
with(1) {
// todo
this@l.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>member<!>()
this@l.<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extension<!>()
}
}
}
@@ -0,0 +1,13 @@
package
public fun generate(/*0*/ f: suspend RestrictedController.() -> kotlin.Unit): kotlin.Unit
public fun test(): kotlin.Unit
public suspend fun RestrictedController.extension(): kotlin.Unit
@kotlin.coroutines.RestrictSuspension public final class RestrictedController {
public constructor RestrictedController()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final suspend fun member(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,14 @@
@kotlin.coroutines.RestrictSuspension
class RestrictedController
suspend fun Any?.extFun() {}
suspend fun suspendFun() {}
fun generate(<!UNUSED_PARAMETER!>c<!>: suspend RestrictedController.() -> Unit) {}
fun test() {
generate {
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>extFun<!>()
<!ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL!>suspendFun<!>()
}
}
@@ -0,0 +1,13 @@
package
public fun generate(/*0*/ c: suspend RestrictedController.() -> kotlin.Unit): kotlin.Unit
public suspend fun suspendFun(): kotlin.Unit
public fun test(): kotlin.Unit
public suspend fun kotlin.Any?.extFun(): kotlin.Unit
@kotlin.coroutines.RestrictSuspension public final class RestrictedController {
public constructor RestrictedController()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}