Fix absence of annotation for function type in cls stubs and ignore @ExtensionFunctionType

This commit is contained in:
Nikolay Krasko
2016-10-24 14:53:05 +03:00
parent d1dfcfaca1
commit a344ad0644
2 changed files with 13 additions and 6 deletions
@@ -92,10 +92,15 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
val shouldBuildAsFunctionType = isNumberedFunctionClassFqName(classId.asSingleFqName().toUnsafe())
&& type.argumentList.none { it.projection == Projection.STAR }
if (shouldBuildAsFunctionType) {
val extension = annotations.any { annotation ->
annotation.asSingleFqName() == KotlinBuiltIns.FQ_NAMES.extensionFunctionType
}
createFunctionTypeStub(nullableTypeParent(parent, type), type, extension)
val (extensionAnnotations, notExtensionAnnotations) =
annotations.partition { it.asSingleFqName() == KotlinBuiltIns.FQ_NAMES.extensionFunctionType }
createTypeAnnotationStubs(parent, notExtensionAnnotations)
val isExtension = extensionAnnotations.isNotEmpty()
createFunctionTypeStub(nullableTypeParent(parent, type), type, isExtension)
return
}
@@ -252,6 +257,8 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
when (typeParameterProto.variance) {
Variance.IN -> modifiers.add(KtTokens.IN_KEYWORD)
Variance.OUT -> modifiers.add(KtTokens.OUT_KEYWORD)
Variance.INV -> { /* do nothing */ }
null -> { /* do nothing */ }
}
if (typeParameterProto.reified) {
modifiers.add(KtTokens.REIFIED_KEYWORD)
@@ -11,13 +11,13 @@ public class AnnotationsOnNullableTypes {
fun returnArgument(): B<@A C?> = null!!
val lambdaType: @A() (() -> C)? = null // TODO: Annotation is lost in stubs
val lambdaType: @A() (() -> C)? = null
val lambdaParameter: (@A C?) -> C = null!!
val lambdaReturnValue: () -> @A C? = null!!
val lambdaReceiver: @A C.() -> C = null!! // TODO: Annotation is lost in stubs
val lambdaReceiver: @A C.() -> C = null!!
}
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER)