FIR deserializer: load annotations on extension receiver parameters
This commit is contained in:
committed by
Denis Zharkov
parent
02f08b16d6
commit
c7a37eb6b2
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
public final class A : R|kotlin/Any| {
|
public final class A : R|kotlin/Any| {
|
||||||
public final fun R|kotlin/String|.myLength(@R|test/Ann|() q: R|kotlin/String|): R|kotlin/Int|
|
@R|test/Ann|() public final fun R|kotlin/String|.myLength(@R|test/Ann|() q: R|kotlin/String|): R|kotlin/Int|
|
||||||
|
|
||||||
public final val R|kotlin/String|.myLength2: R|kotlin/Int|
|
@R|test/Ann|() public final val R|kotlin/String|.myLength2: R|kotlin/Int|
|
||||||
public get(): R|kotlin/Int|
|
public get(): R|kotlin/Int|
|
||||||
|
|
||||||
public final var R|kotlin/String|.myLength3: R|kotlin/Int|
|
@R|test/Ann|() public final var R|kotlin/String|.myLength3: R|kotlin/Int|
|
||||||
public get(): R|kotlin/Int|
|
public get(): R|kotlin/Int|
|
||||||
public set(v: R|kotlin/Int|): R|kotlin/Unit|
|
public set(v: R|kotlin/Int|): R|kotlin/Unit|
|
||||||
|
|
||||||
|
|||||||
+12
@@ -160,6 +160,18 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun loadExtensionReceiverParameterAnnotations(
|
||||||
|
containerSource: DeserializedContainerSource?,
|
||||||
|
callableProto: MessageLite,
|
||||||
|
nameResolver: NameResolver,
|
||||||
|
typeTable: TypeTable,
|
||||||
|
kind: CallableKind
|
||||||
|
): List<FirAnnotationCall> {
|
||||||
|
val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList()
|
||||||
|
val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, 0)
|
||||||
|
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature)
|
||||||
|
}
|
||||||
|
|
||||||
private fun computeJvmParameterIndexShift(classProto: ProtoBuf.Class?, message: MessageLite): Int {
|
private fun computeJvmParameterIndexShift(classProto: ProtoBuf.Class?, message: MessageLite): Int {
|
||||||
return when (message) {
|
return when (message) {
|
||||||
is ProtoBuf.Function -> if (message.hasReceiver()) 1 else 0
|
is ProtoBuf.Function -> if (message.hasReceiver()) 1 else 0
|
||||||
|
|||||||
+10
@@ -148,6 +148,16 @@ abstract class AbstractAnnotationDeserializer(
|
|||||||
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun loadExtensionReceiverParameterAnnotations(
|
||||||
|
containerSource: DeserializedContainerSource?,
|
||||||
|
callableProto: MessageLite,
|
||||||
|
nameResolver: NameResolver,
|
||||||
|
typeTable: TypeTable,
|
||||||
|
kind: CallableKind
|
||||||
|
): List<FirAnnotationCall> {
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
abstract fun loadTypeAnnotations(typeProto: ProtoBuf.Type, nameResolver: NameResolver): List<FirAnnotationCall>
|
abstract fun loadTypeAnnotations(typeProto: ProtoBuf.Type, nameResolver: NameResolver): List<FirAnnotationCall>
|
||||||
|
|
||||||
fun deserializeAnnotation(
|
fun deserializeAnnotation(
|
||||||
|
|||||||
+23
-6
@@ -195,7 +195,16 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
|
|
||||||
val returnTypeRef = proto.returnType(c.typeTable).toTypeRef(local)
|
val returnTypeRef = proto.returnType(c.typeTable).toTypeRef(local)
|
||||||
|
|
||||||
val getter = if (Flags.HAS_GETTER.get(flags)) {
|
val hasGetter = Flags.HAS_GETTER.get(flags)
|
||||||
|
val receiverAnnotations = if (hasGetter && proto.hasReceiver()) {
|
||||||
|
c.annotationDeserializer.loadExtensionReceiverParameterAnnotations(
|
||||||
|
c.containerSource, proto, local.nameResolver, local.typeTable, AbstractAnnotationDeserializer.CallableKind.PROPERTY_GETTER
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
val getter = if (hasGetter) {
|
||||||
val getterFlags = if (proto.hasGetterFlags()) proto.getterFlags else defaultAccessorFlags
|
val getterFlags = if (proto.hasGetterFlags()) proto.getterFlags else defaultAccessorFlags
|
||||||
val visibility = ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))
|
val visibility = ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))
|
||||||
val modality = ProtoEnumFlags.modality(Flags.MODALITY.get(getterFlags))
|
val modality = ProtoEnumFlags.modality(Flags.MODALITY.get(getterFlags))
|
||||||
@@ -254,7 +263,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
session = c.session
|
session = c.session
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = FirDeclarationOrigin.Library
|
||||||
this.returnTypeRef = returnTypeRef
|
this.returnTypeRef = returnTypeRef
|
||||||
receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local)
|
receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local).apply {
|
||||||
|
annotations += receiverAnnotations
|
||||||
|
}
|
||||||
name = callableName
|
name = callableName
|
||||||
this.isVar = isVar
|
this.isVar = isVar
|
||||||
this.symbol = symbol
|
this.symbol = symbol
|
||||||
@@ -292,9 +303,13 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
fun loadFunction(proto: ProtoBuf.Function, classProto: ProtoBuf.Class? = null): FirSimpleFunction {
|
fun loadFunction(proto: ProtoBuf.Function, classProto: ProtoBuf.Class? = null): FirSimpleFunction {
|
||||||
val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags)
|
val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags)
|
||||||
|
|
||||||
val receiverAnnotations =
|
val receiverAnnotations = if (proto.hasReceiver()) {
|
||||||
// TODO: support annotations
|
c.annotationDeserializer.loadExtensionReceiverParameterAnnotations(
|
||||||
Annotations.EMPTY
|
c.containerSource, proto, c.nameResolver, c.typeTable, AbstractAnnotationDeserializer.CallableKind.OTHERS
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
val versionRequirementTable =
|
val versionRequirementTable =
|
||||||
// TODO: Support case for KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
|
// TODO: Support case for KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
|
||||||
@@ -309,7 +324,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
session = c.session
|
session = c.session
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = FirDeclarationOrigin.Library
|
||||||
returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local)
|
returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local)
|
||||||
receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local)
|
receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local).apply {
|
||||||
|
annotations += receiverAnnotations
|
||||||
|
}
|
||||||
name = callableName
|
name = callableName
|
||||||
status = FirDeclarationStatusImpl(
|
status = FirDeclarationStatusImpl(
|
||||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||||
|
|||||||
Reference in New Issue
Block a user