Common kotlin.Throws annotation

Leave kotlin.native.Throws as a deprecated typealias
#KT-34848

(cherry picked from commit 10fac5c96f915e0e008504a211ee70a3e1c9bdea)
This commit is contained in:
Ilya Gorbunov
2020-04-16 00:31:27 +03:00
committed by Vasily Levchenko
parent 3d6a5e0e74
commit 29aa2a75f9
3 changed files with 25 additions and 20 deletions
@@ -21,7 +21,7 @@ object KonanFqNames {
val nativePtr = internalPackageName.child(Name.identifier(NATIVE_PTR_NAME)).toUnsafe()
val nonNullNativePtr = internalPackageName.child(Name.identifier(NON_NULL_NATIVE_PTR_NAME)).toUnsafe()
val Vector128 = packageName.child(Name.identifier(VECTOR128))
val throws = FqName("kotlin.native.Throws")
val throws = FqName("kotlin.Throws")
val threadLocal = FqName("kotlin.native.concurrent.ThreadLocal")
val sharedImmutable = FqName("kotlin.native.concurrent.SharedImmutable")
val frozen = FqName("kotlin.native.internal.Frozen")
+21 -1
View File
@@ -8,6 +8,7 @@ package kotlin
import kotlin.annotation.AnnotationRetention.BINARY
import kotlin.annotation.AnnotationRetention.SOURCE
import kotlin.annotation.AnnotationTarget.*
import kotlin.reflect.KClass
/**
* Marks the annotated declaration as deprecated.
@@ -148,4 +149,23 @@ public annotation class DslMarker
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@SinceKotlin("1.1")
public annotation class PublishedApi
public annotation class PublishedApi
/**
* This annotation indicates what exceptions should be declared by a function when compiled to a platform method.
*
* When compiling to Objective-C/Swift framework, functions having or inheriting
* this annotation are represented as `NSError*`-producing methods in Objective-C
* and as `throws` methods in Swift.
*
* When Kotlin function called from Swift/Objective-C code throws an exception
* which is an instance of one of the [exceptionClasses] or their subclasses,
* it is propagated as `NSError`. Other Kotlin exceptions reaching Swift/Objective-C
* are considered unhandled and cause program termination.
*
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
*/
@SinceKotlin("1.4")
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
@Retention(AnnotationRetention.BINARY)
public actual annotation class Throws(actual vararg val exceptionClasses: KClass<out Throwable>)
@@ -32,24 +32,9 @@ public annotation class Retain
public annotation class RetainForTarget(val target: String)
// TODO: merge with [kotlin.jvm.Throws]
/**
* This annotation indicates what exceptions should be declared by a function when compiled to a platform method.
*
* When compiling to Objective-C/Swift framework, functions having or inheriting
* this annotation are represented as `NSError*`-producing methods in Objective-C
* and as `throws` methods in Swift.
*
* When Kotlin function called from Swift/Objective-C code throws an exception
* which is an instance of one of the [exceptionClasses] or their subclasses,
* it is propagated as `NSError`. Other Kotlin exceptions reaching Swift/Objective-C
* are considered unhandled and cause program termination.
*
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
*/
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
@Retention(AnnotationRetention.BINARY)
public annotation class Throws(vararg val exceptionClasses: KClass<out Throwable>)
/** @suppress */
@Deprecated("Use common kotlin.Throws annotation instead.", ReplaceWith("kotlin.Throws"), DeprecationLevel.WARNING)
public typealias Throws = kotlin.Throws
public typealias ThreadLocal = kotlin.native.concurrent.ThreadLocal