From 5ec62108ee8580b651177cec0c4ba89e71f39260 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 16 Dec 2016 18:15:26 +0300 Subject: [PATCH] Rename RestrictsSuspendExtensions -> RestrictsSuspension --- .../calls/checkers/coroutineCallChecker.kt | 18 +++++++++--------- .../default/kotlin-coroutines.txt | 4 ++-- .../restrictSuspension/allMembersAllowed.kt | 2 +- .../restrictSuspension/allMembersAllowed.txt | 2 +- .../restrictSuspension/extensions.kt | 2 +- .../restrictSuspension/extensions.txt | 2 +- .../restrictSuspension/notRelatedFun.kt | 2 +- .../restrictSuspension/notRelatedFun.txt | 2 +- .../restrictSuspension/sameInstance.kt | 4 ++-- .../restrictSuspension/sameInstance.txt | 2 +- .../restrictSuspension/simpleForbidden.kt | 4 ++-- .../restrictSuspension/simpleForbidden.txt | 2 +- .../src/kotlin/coroutines/Coroutines.kt | 2 +- .../kotlin/resolve/annotationsForResolve.kt | 4 ++-- .../annotation/Annotation_verification.xml | 2 +- .../reference-public-api/kotlin-runtime.txt | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/coroutineCallChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/coroutineCallChecker.kt index 1f1baf542e7..b6f9ff6348c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/coroutineCallChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/coroutineCallChecker.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtThisExpression import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspendExtensionsAnnotation +import org.jetbrains.kotlin.resolve.descriptorUtil.hasRestrictsSuspensionAnnotation import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind @@ -67,7 +67,7 @@ object CoroutineSuspendCallChecker : CallChecker { // Here we only record enclosing function mapping (for backends purposes) context.trace.record(BindingContext.ENCLOSING_SUSPEND_FUNCTION_FOR_SUSPEND_FUNCTION_CALL, resolvedCall.call, enclosingSuspendFunction) - checkRestrictsSuspendExtensions(enclosingSuspendFunction, resolvedCall, reportOn, context) + checkRestrictsSuspension(enclosingSuspendFunction, resolvedCall, reportOn, context) } closestSuspensionLambdaDescriptor != null -> { val callElement = resolvedCall.call.callElement as KtExpression @@ -80,7 +80,7 @@ object CoroutineSuspendCallChecker : CallChecker { BindingContext.ENCLOSING_SUSPEND_LAMBDA_FOR_SUSPENSION_POINT, resolvedCall.call, closestSuspensionLambdaDescriptor ) - checkRestrictsSuspendExtensions(closestSuspensionLambdaDescriptor, resolvedCall, reportOn, context) + checkRestrictsSuspension(closestSuspensionLambdaDescriptor, resolvedCall, reportOn, context) } else -> { context.trace.report(Errors.ILLEGAL_SUSPEND_FUNCTION_CALL.on(reportOn)) @@ -110,7 +110,7 @@ fun checkCoroutinesFeature(languageVersionSettings: LanguageVersionSettings, dia } } -private fun checkRestrictsSuspendExtensions( +private fun checkRestrictsSuspension( enclosingCallableDescriptor: CallableDescriptor, resolvedCall: ResolvedCall<*>, reportOn: PsiElement, @@ -118,8 +118,8 @@ private fun checkRestrictsSuspendExtensions( ) { val enclosingSuspendReceiverValue = enclosingCallableDescriptor.extensionReceiverParameter?.value ?: return - fun ReceiverValue.isRestrictsSuspendExtensionsReceiver() = (type.supertypes() + type).any { - it.constructor.declarationDescriptor?.hasRestrictsSuspendExtensionsAnnotation() == true + fun ReceiverValue.isRestrictsSuspensionReceiver() = (type.supertypes() + type).any { + it.constructor.declarationDescriptor?.hasRestrictsSuspensionAnnotation() == true } infix fun ReceiverValue.sameInstance(other: ReceiverValue?): Boolean { @@ -134,13 +134,13 @@ private fun checkRestrictsSuspendExtensions( return this === (referenceTarget as? CallableDescriptor)?.extensionReceiverParameter?.value } - if (!enclosingSuspendReceiverValue.isRestrictsSuspendExtensionsReceiver()) return + if (!enclosingSuspendReceiverValue.isRestrictsSuspensionReceiver()) return // member of suspend receiver if (enclosingSuspendReceiverValue sameInstance resolvedCall.dispatchReceiver) return if (enclosingSuspendReceiverValue sameInstance resolvedCall.extensionReceiver && - resolvedCall.candidateDescriptor.extensionReceiverParameter!!.value.isRestrictsSuspendExtensionsReceiver()) return + resolvedCall.candidateDescriptor.extensionReceiverParameter!!.value.isRestrictsSuspensionReceiver()) return context.trace.report(Errors.ILLEGAL_RESTRICTED_SUSPENDING_FUNCTION_CALL.on(reportOn)) -} \ No newline at end of file +} diff --git a/compiler/testData/builtin-classes/default/kotlin-coroutines.txt b/compiler/testData/builtin-classes/default/kotlin-coroutines.txt index f34b04a67d6..2a68d04fe2f 100644 --- a/compiler/testData/builtin-classes/default/kotlin-coroutines.txt +++ b/compiler/testData/builtin-classes/default/kotlin-coroutines.txt @@ -19,6 +19,6 @@ package-fragment kotlin.coroutines public final inline suspend fun suspendCoroutineOrReturn(/*0*/ block: (kotlin.coroutines.Continuation) -> kotlin.Any?): T } -@kotlin.SinceKotlin(version = "1.1") @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class RestrictsSuspendExtensions : kotlin.Annotation { - /*primary*/ public constructor RestrictsSuspendExtensions() +@kotlin.SinceKotlin(version = "1.1") @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class RestrictsSuspension : kotlin.Annotation { + /*primary*/ public constructor RestrictsSuspension() } diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt index 5d61fc1bdf4..0acd4e42d22 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.kt @@ -5,7 +5,7 @@ interface SuperInterface { suspend fun String.superExtFun() {} } -@kotlin.coroutines.RestrictsSuspendExtensions +@kotlin.coroutines.RestrictsSuspension open class RestrictedController : SuperInterface { suspend fun memberFun() {} suspend fun String.memberExtFun() {} diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.txt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.txt index 7c65f4d7346..878ea579aff 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.txt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/allMembersAllowed.txt @@ -5,7 +5,7 @@ public fun generate2(/*0*/ f: suspend RestrictedController.() -> kotlin.Unit): k public fun generate3(/*0*/ f: suspend SubClass.() -> kotlin.Unit): kotlin.Unit public fun kotlin.String.test(): kotlin.Unit -@kotlin.coroutines.RestrictsSuspendExtensions public open class RestrictedController : SuperInterface { +@kotlin.coroutines.RestrictsSuspension 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 diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt index 9648527bcc4..047ccccfcd0 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.kt @@ -2,7 +2,7 @@ interface SuperInterface -@kotlin.coroutines.RestrictsSuspendExtensions +@kotlin.coroutines.RestrictsSuspension open class RestrictedController : SuperInterface class SubClass : RestrictedController() diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.txt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.txt index 67e9ee15e6b..8140a0d9dba 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.txt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/extensions.txt @@ -20,7 +20,7 @@ public final class A { public final suspend fun SuperInterface.memExtSuper(): kotlin.Unit } -@kotlin.coroutines.RestrictsSuspendExtensions public open class RestrictedController : SuperInterface { +@kotlin.coroutines.RestrictsSuspension 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 diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt index e3b2725aeb8..ecb28673439 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.kt @@ -2,7 +2,7 @@ interface SuperInterface -@kotlin.coroutines.RestrictsSuspendExtensions +@kotlin.coroutines.RestrictsSuspension open class RestrictedController : SuperInterface class SubClass : RestrictedController() diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.txt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.txt index d7f20469bd2..ea2894e4f21 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.txt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/notRelatedFun.txt @@ -14,7 +14,7 @@ public final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.coroutines.RestrictsSuspendExtensions public open class RestrictedController : SuperInterface { +@kotlin.coroutines.RestrictsSuspension 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 diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.kt index f785df621f5..5b620280c3a 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE -@kotlin.coroutines.RestrictsSuspendExtensions +@kotlin.coroutines.RestrictsSuspension class RestrictedController { suspend fun member() {} } @@ -50,4 +50,4 @@ suspend fun RestrictedController.l() { this@l.extension() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.txt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.txt index 4743848c055..38e0ff18dc7 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.txt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/sameInstance.txt @@ -5,7 +5,7 @@ public fun test(): kotlin.Unit public suspend fun RestrictedController.extension(): kotlin.Unit public suspend fun RestrictedController.l(): kotlin.Unit -@kotlin.coroutines.RestrictsSuspendExtensions public final class RestrictedController { +@kotlin.coroutines.RestrictsSuspension 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 diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.kt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.kt index 12ff77efd54..296aadf0748 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.kt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.kt @@ -1,4 +1,4 @@ -@kotlin.coroutines.RestrictsSuspendExtensions +@kotlin.coroutines.RestrictsSuspension class RestrictedController suspend fun Any?.extFun() {} @@ -11,4 +11,4 @@ fun test() { extFun() suspendFun() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.txt b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.txt index 0257f0a205e..7e1a2cfeee5 100644 --- a/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.txt +++ b/compiler/testData/diagnostics/tests/coroutines/restrictSuspension/simpleForbidden.txt @@ -5,7 +5,7 @@ public suspend fun suspendFun(): kotlin.Unit public fun test(): kotlin.Unit public suspend fun kotlin.Any?.extFun(): kotlin.Unit -@kotlin.coroutines.RestrictsSuspendExtensions public final class RestrictedController { +@kotlin.coroutines.RestrictsSuspension 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 diff --git a/core/builtins/src/kotlin/coroutines/Coroutines.kt b/core/builtins/src/kotlin/coroutines/Coroutines.kt index 470aee6c998..941b81090af 100644 --- a/core/builtins/src/kotlin/coroutines/Coroutines.kt +++ b/core/builtins/src/kotlin/coroutines/Coroutines.kt @@ -59,7 +59,7 @@ public interface ContinuationDispatcher { @SinceKotlin("1.1") @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -public annotation class RestrictsSuspendExtensions +public annotation class RestrictsSuspension /** * Contains intrinsic functions for coroutines. diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt index 51bf01c1489..ef8b94928d9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt @@ -32,7 +32,7 @@ val LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME = FqName("kotlin.internal.LowPri private val HIDES_MEMBERS_ANNOTATION_FQ_NAME = FqName("kotlin.internal.HidesMembers") private val ONLY_INPUT_TYPES_FQ_NAME = FqName("kotlin.internal.OnlyInputTypes") private val DYNAMIC_EXTENSION_FQ_NAME = FqName("kotlin.internal.DynamicExtension") -private val RESTRICTS_SUSPEND_EXTENSIONS_FQ_NAME = FqName("kotlin.coroutines.RestrictsSuspendExtensions") +private val RESTRICTS_SUSPENSION_FQ_NAME = FqName("kotlin.coroutines.RestrictsSuspension") // @HidesMembers annotation only has effect for members with these names val HIDES_MEMBERS_NAME_LIST = setOf(Name.identifier("forEach")) @@ -50,7 +50,7 @@ fun CallableDescriptor.hasLowPriorityInOverloadResolution(): Boolean = annotatio fun CallableDescriptor.hasHidesMembersAnnotation(): Boolean = annotations.hasAnnotation(HIDES_MEMBERS_ANNOTATION_FQ_NAME) fun CallableDescriptor.hasDynamicExtensionAnnotation(): Boolean = annotations.hasAnnotation(DYNAMIC_EXTENSION_FQ_NAME) -fun ClassifierDescriptor.hasRestrictsSuspendExtensionsAnnotation(): Boolean = annotations.hasAnnotation(RESTRICTS_SUSPEND_EXTENSIONS_FQ_NAME) +fun ClassifierDescriptor.hasRestrictsSuspensionAnnotation(): Boolean = annotations.hasAnnotation(RESTRICTS_SUSPENSION_FQ_NAME) fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME) diff --git a/idea/testData/hierarchy/withLib/annotation/Annotation_verification.xml b/idea/testData/hierarchy/withLib/annotation/Annotation_verification.xml index 42ce2f946d9..971fa6c7560 100644 --- a/idea/testData/hierarchy/withLib/annotation/Annotation_verification.xml +++ b/idea/testData/hierarchy/withLib/annotation/Annotation_verification.xml @@ -50,7 +50,7 @@ - + diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt index 0a8f98c897f..dc82fe9e390 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-runtime.txt @@ -204,7 +204,7 @@ public final class kotlin/coroutines/CoroutinesKt { public static final fun suspendWithCurrentContinuation (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public abstract interface annotation class kotlin/coroutines/RestrictsSuspendExtensions : java/lang/annotation/Annotation { +public abstract interface annotation class kotlin/coroutines/RestrictsSuspension : java/lang/annotation/Annotation { } public final class kotlin/jvm/JvmClassMappingKt {