Serialize annotations on type parameters in builtins

This commit is contained in:
Denis Zharkov
2016-01-19 14:04:20 +03:00
parent 4cf1393e81
commit d7e035fd9b
4 changed files with 24 additions and 0 deletions
@@ -71,4 +71,10 @@ open class KotlinSerializerExtensionBase(private val protocol: SerializerExtensi
proto.addExtension(protocol.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
}
override fun serializeTypeParameter(typeParameter: TypeParameterDescriptor, proto: ProtoBuf.TypeParameter.Builder) {
for (annotation in typeParameter.annotations) {
proto.addExtension(protocol.typeParameterAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
}
}
@@ -0,0 +1,6 @@
package test
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.TYPE_PARAMETER)
annotation class Ann(val value: String)
inline fun <reified @Ann("abc") T> foo() {}
@@ -0,0 +1,8 @@
package test
public inline fun </*0*/ reified @test.Ann(value = "abc") T> foo(): kotlin.Unit
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class Ann : kotlin.Annotation {
public constructor Ann(/*0*/ value: kotlin.String)
public final val value: kotlin.String
}
@@ -62,6 +62,10 @@ class BuiltInsSerializerTest : TestCaseWithTmpdir() {
doTest("simple.kt")
}
fun testTypeParameterAnnotation() {
doTest("typeParameterAnnotation.kt")
}
fun testNestedClassesAndObjects() {
doTest("nestedClassesAndObjects.kt")
}