Add LowPriority annotation to deprecated functions to allow star-importing their replacements from kotlin.reflect.full.

This commit is contained in:
Ilya Gorbunov
2017-02-02 20:46:40 +03:00
parent af443ac046
commit da81fb32a6
5 changed files with 40 additions and 1 deletions
@@ -15,11 +15,13 @@
*/
@file:JvmName("KAnnotatedElements")
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect
/**
* Returns an annotation of the given type on this element.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'findAnnotation' from kotlin.reflect.full package", ReplaceWith("this.findAnnotation<T>()", "kotlin.reflect.full.findAnnotation"), level = DeprecationLevel.WARNING)
@Suppress("UNCHECKED_CAST")
inline fun <reified T : Annotation> KAnnotatedElement.findAnnotation(): T? =
@@ -15,6 +15,7 @@
*/
@file:JvmName("KCallables")
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect
import kotlin.reflect.full.extensionReceiverParameter
@@ -26,6 +27,7 @@ import kotlin.reflect.full.valueParameters
* Returns a parameter representing the `this` instance needed to call this callable,
* or `null` if this callable is not a member of a class and thus doesn't take such parameter.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'instanceParameter' from kotlin.reflect.full package", ReplaceWith("this.instanceParameter", "kotlin.reflect.full.instanceParameter"), level = DeprecationLevel.ERROR)
@SinceKotlin("1.1")
inline val KCallable<*>.instanceParameter: KParameter?
@@ -35,6 +37,7 @@ inline val KCallable<*>.instanceParameter: KParameter?
* Returns a parameter representing the extension receiver instance needed to call this callable,
* or `null` if this callable is not an extension.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'extensionReceiverParameter' from kotlin.reflect.full package", ReplaceWith("this.extensionReceiverParameter", "kotlin.reflect.full.extensionReceiverParameter"), level = DeprecationLevel.ERROR)
@SinceKotlin("1.1")
inline val KCallable<*>.extensionReceiverParameter: KParameter?
@@ -43,6 +46,7 @@ inline val KCallable<*>.extensionReceiverParameter: KParameter?
/**
* Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'valueParameters' from kotlin.reflect.full package", ReplaceWith("this.valueParameters", "kotlin.reflect.full.valueParameters"), level = DeprecationLevel.ERROR)
@SinceKotlin("1.1")
inline val KCallable<*>.valueParameters: List<KParameter>
@@ -51,6 +55,7 @@ inline val KCallable<*>.valueParameters: List<KParameter>
/**
* Returns the parameter of this callable with the given name, or `null` if there's no such parameter.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'findParameterByName' from kotlin.reflect.full package", ReplaceWith("this.findParameterByName", "kotlin.reflect.full.findParameterByName"), level = DeprecationLevel.ERROR)
@SinceKotlin("1.1")
inline fun KCallable<*>.findParameterByName(name: String): KParameter? {
@@ -15,7 +15,7 @@
*/
@file:JvmName("KClasses")
@file:Suppress("UNCHECKED_CAST")
@file:Suppress("UNCHECKED_CAST", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect
@@ -50,6 +50,7 @@ import kotlin.reflect.full.superclasses
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/classes.html#constructors)
* for more information.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'primaryConstructor' from kotlin.reflect.full package", ReplaceWith("this.primaryConstructor", "kotlin.reflect.full.primaryConstructor"), level = DeprecationLevel.WARNING)
inline val <T : Any> KClass<T>.primaryConstructor: KFunction<T>?
get() = this.primaryConstructor
@@ -59,6 +60,7 @@ inline val <T : Any> KClass<T>.primaryConstructor: KFunction<T>?
* Returns a [KClass] instance representing the companion object of a given class,
* or `null` if the class doesn't have a companion object.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'companionObject' from kotlin.reflect.full package", ReplaceWith("this.companionObject", "kotlin.reflect.full.companionObject"), level = DeprecationLevel.WARNING)
inline val KClass<*>.companionObject: KClass<*>?
get() = this.companionObject
@@ -67,6 +69,7 @@ inline val KClass<*>.companionObject: KClass<*>?
* Returns an instance of the companion object of a given class,
* or `null` if the class doesn't have a companion object.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'companionObjectInstance' from kotlin.reflect.full package", ReplaceWith("this.companionObjectInstance", "kotlin.reflect.full.companionObjectInstance"), level = DeprecationLevel.WARNING)
inline val KClass<*>.companionObjectInstance: Any?
get() = this.companionObjectInstance
@@ -76,6 +79,7 @@ inline val KClass<*>.companionObjectInstance: Any?
* Returns a type corresponding to the given class with type parameters of that class substituted as the corresponding arguments.
* For example, for class `MyMap<K, V>` [defaultType] would return the type `MyMap<K, V>`.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'defaultType' from kotlin.reflect.full package", ReplaceWith("this.defaultType", "kotlin.reflect.full.defaultType"), level = DeprecationLevel.WARNING)
inline val KClass<*>.defaultType: KType
get() = this.defaultType
@@ -86,6 +90,7 @@ inline val KClass<*>.defaultType: KType
* Does not include members declared in supertypes.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredMembers' from kotlin.reflect.full package", ReplaceWith("this.declaredMembers", "kotlin.reflect.full.declaredMembers"), level = DeprecationLevel.ERROR)
inline val KClass<*>.declaredMembers: Collection<KCallable<*>>
get() = this.declaredMembers
@@ -94,6 +99,7 @@ inline val KClass<*>.declaredMembers: Collection<KCallable<*>>
* Returns all functions declared in this class, including all non-static methods declared in the class
* and the superclasses, as well as static methods declared in the class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'functions' from kotlin.reflect.full package", ReplaceWith("this.functions", "kotlin.reflect.full.functions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.functions: Collection<KFunction<*>>
get() = this.functions
@@ -101,6 +107,7 @@ inline val KClass<*>.functions: Collection<KFunction<*>>
/**
* Returns static functions declared in this class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'staticFunctions' from kotlin.reflect.full package", ReplaceWith("this.staticFunctions", "kotlin.reflect.full.staticFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.staticFunctions: Collection<KFunction<*>>
get() = this.staticFunctions
@@ -108,6 +115,7 @@ inline val KClass<*>.staticFunctions: Collection<KFunction<*>>
/**
* Returns non-extension non-static functions declared in this class and all of its superclasses.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'memberFunctions' from kotlin.reflect.full package", ReplaceWith("this.memberFunctions", "kotlin.reflect.full.memberFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.memberFunctions: Collection<KFunction<*>>
get() = this.memberFunctions
@@ -115,6 +123,7 @@ inline val KClass<*>.memberFunctions: Collection<KFunction<*>>
/**
* Returns extension functions declared in this class and all of its superclasses.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'memberExtensionFunctions' from kotlin.reflect.full package", ReplaceWith("this.memberExtensionFunctions", "kotlin.reflect.full.memberExtensionFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.memberExtensionFunctions: Collection<KFunction<*>>
get() = this.memberExtensionFunctions
@@ -124,6 +133,7 @@ inline val KClass<*>.memberExtensionFunctions: Collection<KFunction<*>>
* If this is a Java class, it includes all non-static methods (both extensions and non-extensions)
* declared in the class and the superclasses, as well as static methods declared in the class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredFunctions' from kotlin.reflect.full package", ReplaceWith("this.declaredFunctions", "kotlin.reflect.full.declaredFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.declaredFunctions: Collection<KFunction<*>>
get() = this.declaredFunctions
@@ -131,6 +141,7 @@ inline val KClass<*>.declaredFunctions: Collection<KFunction<*>>
/**
* Returns non-extension non-static functions declared in this class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredMemberFunctions' from kotlin.reflect.full package", ReplaceWith("this.declaredMemberFunctions", "kotlin.reflect.full.declaredMemberFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.declaredMemberFunctions: Collection<KFunction<*>>
get() = this.declaredMemberFunctions
@@ -138,6 +149,7 @@ inline val KClass<*>.declaredMemberFunctions: Collection<KFunction<*>>
/**
* Returns extension functions declared in this class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredMemberExtensionFunctions' from kotlin.reflect.full package", ReplaceWith("this.declaredMemberExtensionFunctions", "kotlin.reflect.full.declaredMemberExtensionFunctions"), level = DeprecationLevel.WARNING)
inline val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>>
get() = this.declaredMemberExtensionFunctions
@@ -146,6 +158,7 @@ inline val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>>
* Returns static properties declared in this class.
* Only properties representing static fields of Java classes are considered static.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'staticProperties' from kotlin.reflect.full package", ReplaceWith("this.staticProperties", "kotlin.reflect.full.staticProperties"), level = DeprecationLevel.WARNING)
inline val KClass<*>.staticProperties: Collection<KProperty0<*>>
get() = this.staticProperties
@@ -153,6 +166,7 @@ inline val KClass<*>.staticProperties: Collection<KProperty0<*>>
/**
* Returns non-extension properties declared in this class and all of its superclasses.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'memberProperties' from kotlin.reflect.full package", ReplaceWith("this.memberProperties", "kotlin.reflect.full.memberProperties"), level = DeprecationLevel.WARNING)
inline val <T : Any> KClass<T>.memberProperties: Collection<KProperty1<T, *>>
get() = this.memberProperties
@@ -160,6 +174,7 @@ inline val <T : Any> KClass<T>.memberProperties: Collection<KProperty1<T, *>>
/**
* Returns extension properties declared in this class and all of its superclasses.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'memberExtensionProperties' from kotlin.reflect.full package", ReplaceWith("this.memberExtensionProperties", "kotlin.reflect.full.memberExtensionProperties"), level = DeprecationLevel.WARNING)
inline val <T : Any> KClass<T>.memberExtensionProperties: Collection<KProperty2<T, *, *>>
get() = this.memberExtensionProperties
@@ -167,6 +182,7 @@ inline val <T : Any> KClass<T>.memberExtensionProperties: Collection<KProperty2<
/**
* Returns non-extension properties declared in this class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredMemberProperties' from kotlin.reflect.full package", ReplaceWith("this.declaredMemberProperties", "kotlin.reflect.full.declaredMemberProperties"), level = DeprecationLevel.WARNING)
inline val <T : Any> KClass<T>.declaredMemberProperties: Collection<KProperty1<T, *>>
get() = this.declaredMemberProperties
@@ -174,6 +190,7 @@ inline val <T : Any> KClass<T>.declaredMemberProperties: Collection<KProperty1<T
/**
* Returns extension properties declared in this class.
*/
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'declaredMemberExtensionProperties' from kotlin.reflect.full package", ReplaceWith("this.declaredMemberExtensionProperties", "kotlin.reflect.full.declaredMemberExtensionProperties"), level = DeprecationLevel.WARNING)
inline val <T : Any> KClass<T>.declaredMemberExtensionProperties: Collection<KProperty2<T, *, *>>
get() = this.declaredMemberExtensionProperties
@@ -184,6 +201,7 @@ inline val <T : Any> KClass<T>.declaredMemberExtensionProperties: Collection<KPr
* Includes superclasses and superinterfaces of the class, but does not include the class itself.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'superclasses' from kotlin.reflect.full package", ReplaceWith("this.superclasses", "kotlin.reflect.full.superclasses"), level = DeprecationLevel.ERROR)
inline val KClass<*>.superclasses: List<KClass<*>>
get() = this.superclasses
@@ -193,6 +211,7 @@ inline val KClass<*>.superclasses: List<KClass<*>>
* There is not more than one type in the returned collection that has any given classifier.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'allSupertypes' from kotlin.reflect.full package", ReplaceWith("this.allSupertypes", "kotlin.reflect.full.allSupertypes"), level = DeprecationLevel.ERROR)
inline val KClass<*>.allSupertypes: Collection<KType>
get() = this.allSupertypes
@@ -202,6 +221,7 @@ inline val KClass<*>.allSupertypes: Collection<KType>
* The returned collection does not contain more than one instance of any given class.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'allSuperclasses' from kotlin.reflect.full package", ReplaceWith("this.allSuperclasses", "kotlin.reflect.full.allSuperclasses"), level = DeprecationLevel.ERROR)
inline val KClass<*>.allSuperclasses: Collection<KClass<*>>
get() = this.allSuperclasses
@@ -209,6 +229,7 @@ inline val KClass<*>.allSuperclasses: Collection<KClass<*>>
* Returns `true` if `this` class is the same or is a (possibly indirect) subclass of [base], `false` otherwise.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'isSubclassOf' from kotlin.reflect.full package", ReplaceWith("this.isSubclassOf(base)", "kotlin.reflect.full.isSubclassOf"), level = DeprecationLevel.ERROR)
inline fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean =
this.isSubclassOf(base)
@@ -217,6 +238,7 @@ inline fun KClass<*>.isSubclassOf(base: KClass<*>): Boolean =
* Returns `true` if `this` class is the same or is a (possibly indirect) superclass of [derived], `false` otherwise.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'isSuperclassOf' from kotlin.reflect.full package", ReplaceWith("this.isSuperclassOf(derived)", "kotlin.reflect.full.isSuperclassOf"), level = DeprecationLevel.ERROR)
inline fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean =
this.isSuperclassOf(derived)
@@ -230,6 +252,7 @@ inline fun KClass<*>.isSuperclassOf(derived: KClass<*>): Boolean =
* @see [KClass.safeCast]
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'cast' from kotlin.reflect.full package", ReplaceWith("this.cast(value)", "kotlin.reflect.full.cast"), level = DeprecationLevel.ERROR)
inline fun <T : Any> KClass<T>.cast(value: Any?): T {
return this.cast(value)
@@ -243,6 +266,7 @@ inline fun <T : Any> KClass<T>.cast(value: Any?): T {
* @see [KClass.cast]
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'safeCast' from kotlin.reflect.full package", ReplaceWith("this.safeCast(value)", "kotlin.reflect.full.safeCast"), level = DeprecationLevel.ERROR)
inline fun <T : Any> KClass<T>.safeCast(value: Any?): T? {
return this.safeCast(value)
@@ -254,6 +278,7 @@ inline fun <T : Any> KClass<T>.safeCast(value: Any?): T? {
* (see [KParameter.isOptional]). If there are no or many such constructors, an exception is thrown.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'createInstance' from kotlin.reflect.full package", ReplaceWith("this.createInstance()", "kotlin.reflect.full.createInstance"), level = DeprecationLevel.ERROR)
inline fun <T : Any> KClass<T>.createInstance(): T {
return this.createInstance()
@@ -15,6 +15,7 @@
*/
@file:JvmName("KClassifiers")
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect
import kotlin.reflect.full.createType
@@ -32,6 +33,7 @@ import kotlin.reflect.full.starProjectedType
* not `inner`, or is declared on the top level.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'createType' from kotlin.reflect.full package", ReplaceWith("this.createType(arguments, nullable, annotations)", "kotlin.reflect.full.createType"), level = DeprecationLevel.ERROR)
inline fun KClassifier.createType(
arguments: List<KTypeProjection> = emptyList(),
@@ -46,6 +48,7 @@ inline fun KClassifier.createType(
* @see [KClassifier.createType]
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'starProjectedType' from kotlin.reflect.full package", ReplaceWith("this.starProjectedType", "kotlin.reflect.full.starProjectedType"), level = DeprecationLevel.ERROR)
inline val KClassifier.starProjectedType: KType
get() = this.starProjectedType
@@ -15,6 +15,7 @@
*/
@file:JvmName("KTypes")
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect
import kotlin.reflect.full.isSubtypeOf
@@ -25,6 +26,7 @@ import kotlin.reflect.full.withNullability
* Returns a new type with the same classifier, arguments and annotations as the given type, and with the given nullability.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'withNullability' from kotlin.reflect.full package", ReplaceWith("this.withNullability(nullable)", "kotlin.reflect.full.withNullability"), level = DeprecationLevel.ERROR)
inline fun KType.withNullability(nullable: Boolean): KType = this.withNullability(nullable)
@@ -33,6 +35,7 @@ inline fun KType.withNullability(nullable: Boolean): KType = this.withNullabilit
* Returns `true` if `this` type is the same or is a subtype of [other], `false` otherwise.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'isSubtypeOf' from kotlin.reflect.full package", ReplaceWith("this.isSubtypeOf(other)", "kotlin.reflect.full.isSubtypeOf"), level = DeprecationLevel.ERROR)
inline fun KType.isSubtypeOf(other: KType): Boolean = this.isSubtypeOf(other)
@@ -40,5 +43,6 @@ inline fun KType.isSubtypeOf(other: KType): Boolean = this.isSubtypeOf(other)
* Returns `true` if `this` type is the same or is a supertype of [other], `false` otherwise.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("Use 'isSupertypeOf' from kotlin.reflect.full package", ReplaceWith("this.isSupertypeOf(other)", "kotlin.reflect.full.isSupertypeOf"), level = DeprecationLevel.ERROR)
inline fun KType.isSupertypeOf(other: KType): Boolean = this.isSupertypeOf(other)