Remove error on annotated types as arguments to typeOf
Instead, document that `KType.annotations` returns an empty list for types created with `typeOf`. Annotations might be supported in the future. #KT-49573 Fixed #KT-29919
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
inline fun <reified X> f() = g<List<X>>()
|
||||
inline fun <reified Y> g() = typeOf<Y>()
|
||||
|
||||
inline fun <reified Z> a() = typeOf<@Runtime Z>()
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Runtime
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class Binary
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Source
|
||||
|
||||
fun test() {
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>typeOf<String.() -> Int>()<!>
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>f<Int.(Int) -> Unit>()<!>
|
||||
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE, TYPEOF_SUSPEND_TYPE!>typeOf<suspend Int.() -> List<String>>()<!>
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE, TYPEOF_SUSPEND_TYPE!>f<suspend Unit.() -> Array<*>>()<!>
|
||||
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>typeOf<@Runtime Int.() -> List<String>>()<!>
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>f<@Runtime Unit.() -> Array<*>>()<!>
|
||||
|
||||
<!TYPEOF_ANNOTATED_TYPE!>typeOf<@Runtime String>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>f<@Runtime String>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>typeOf<@Binary String>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>f<@Binary String>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>typeOf<@Source String>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>f<@Source String>()<!>
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
<!TYPEOF_ANNOTATED_TYPE!>typeOf<@kotlin.internal.Exact String>()<!>
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
<!TYPEOF_ANNOTATED_TYPE!>f<@kotlin.internal.Exact String>()<!>
|
||||
|
||||
<!TYPEOF_ANNOTATED_TYPE!>typeOf<Map<String, List<@Runtime Int>>>()<!>
|
||||
<!TYPEOF_ANNOTATED_TYPE!>f<Map<String, List<@Runtime Int>>>()<!>
|
||||
|
||||
// TODO: https://youtrack.jetbrains.com/issue/KT-29919#focus=Comments-27-5065356.0-0
|
||||
a<String>()
|
||||
|
||||
test2<String>()
|
||||
}
|
||||
|
||||
inline fun <reified R> test2() {
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>typeOf<@Runtime R.()->Unit>()<!>
|
||||
<!TYPEOF_EXTENSION_FUNCTION_TYPE!>typeOf<R.()->Unit>()<!>
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package
|
||||
|
||||
public inline fun </*0*/ reified Z> a(): kotlin.reflect.KType
|
||||
public inline fun </*0*/ reified X> f(): kotlin.reflect.KType
|
||||
public inline fun </*0*/ reified Y> g(): kotlin.reflect.KType
|
||||
public fun test(): kotlin.Unit
|
||||
public inline fun </*0*/ reified R> test2(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class Binary : kotlin.Annotation {
|
||||
public constructor Binary()
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Runtime : kotlin.Annotation {
|
||||
public constructor Runtime()
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Source : kotlin.Annotation {
|
||||
public constructor Source()
|
||||
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
|
||||
}
|
||||
@@ -9,4 +9,7 @@ inline fun <reified Y> g() = typeOf<Y>()
|
||||
fun test() {
|
||||
<!TYPEOF_SUSPEND_TYPE!>typeOf<suspend () -> Int>()<!>
|
||||
<!TYPEOF_SUSPEND_TYPE!>f<suspend (String) -> Unit>()<!>
|
||||
|
||||
<!TYPEOF_SUSPEND_TYPE!>typeOf<suspend Int.() -> List<String>>()<!>
|
||||
<!TYPEOF_SUSPEND_TYPE!>f<suspend Unit.() -> Array<*>>()<!>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user