FIR deserializer: signature-aware annotation loading for constructors
This commit is contained in:
committed by
Denis Zharkov
parent
955c7a1e5b
commit
12181e55c0
Vendored
+1
-1
@@ -7,6 +7,6 @@ public final annotation class Anno : R|kotlin/Annotation| {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class Constructor : R|kotlin/Any| {
|
public final class Constructor : R|kotlin/Any| {
|
||||||
public constructor(): R|test/Constructor|
|
@R|test/Anno|(value = String(string)) public constructor(): R|test/Constructor|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -7,7 +7,7 @@ public sealed class Sealed : R|kotlin/Any| {
|
|||||||
public final val z: R|test/Z|
|
public final val z: R|test/Z|
|
||||||
public get(): R|test/Z|
|
public get(): R|test/Z|
|
||||||
|
|
||||||
private constructor(z: R|test/Z|): R|test/Sealed|
|
@R|test/Ann|() private constructor(z: R|test/Z|): R|test/Sealed|
|
||||||
|
|
||||||
public final class Derived : R|test/Sealed| {
|
public final class Derived : R|test/Sealed| {
|
||||||
public constructor(z: R|test/Z|): R|test/Sealed.Derived|
|
public constructor(z: R|test/Z|): R|test/Sealed.Derived|
|
||||||
@@ -20,11 +20,11 @@ public final class Test : R|kotlin/Any| {
|
|||||||
public final val z: R|test/Z|
|
public final val z: R|test/Z|
|
||||||
public get(): R|test/Z|
|
public get(): R|test/Z|
|
||||||
|
|
||||||
public constructor(z: R|test/Z|, a: R|kotlin/Int|): R|test/Test|
|
@R|test/Ann|() public constructor(z: R|test/Z|, a: R|kotlin/Int|): R|test/Test|
|
||||||
|
|
||||||
private constructor(z: R|test/Z|, s: R|kotlin/String|): R|test/Test|
|
@R|test/Ann|() private constructor(z: R|test/Z|, s: R|kotlin/String|): R|test/Test|
|
||||||
|
|
||||||
public constructor(z: R|test/Z|): R|test/Test|
|
@R|test/Ann|() public constructor(z: R|test/Z|): R|test/Test|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@ public final inline class Z : R|kotlin/Any| {
|
|||||||
public final val value: R|kotlin/Int|
|
public final val value: R|kotlin/Int|
|
||||||
public get(): R|kotlin/Int|
|
public get(): R|kotlin/Int|
|
||||||
|
|
||||||
internal constructor(value: R|kotlin/Int|): R|test/Z|
|
@R|kotlin/PublishedApi|() internal constructor(value: R|kotlin/Int|): R|test/Z|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-1
@@ -45,6 +45,16 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun loadConstructorAnnotations(
|
||||||
|
containerSource: DeserializedContainerSource?,
|
||||||
|
constructorProto: ProtoBuf.Constructor,
|
||||||
|
nameResolver: NameResolver,
|
||||||
|
typeTable: TypeTable
|
||||||
|
): List<FirAnnotationCall> {
|
||||||
|
val signature = getCallableSignature(constructorProto, nameResolver, typeTable, CallableKind.FUNCTION) ?: return emptyList()
|
||||||
|
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature)
|
||||||
|
}
|
||||||
|
|
||||||
override fun loadFunctionAnnotations(
|
override fun loadFunctionAnnotations(
|
||||||
containerSource: DeserializedContainerSource?,
|
containerSource: DeserializedContainerSource?,
|
||||||
functionProto: ProtoBuf.Function,
|
functionProto: ProtoBuf.Function,
|
||||||
@@ -84,7 +94,11 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
kind: CallableKind
|
kind: CallableKind
|
||||||
): MemberSignature? {
|
): MemberSignature? {
|
||||||
return when (proto) {
|
return when (proto) {
|
||||||
// TODO: ProtoBuf.Constructor
|
is ProtoBuf.Constructor -> {
|
||||||
|
MemberSignature.fromJvmMemberSignature(
|
||||||
|
JvmProtoBufUtil.getJvmConstructorSignature(proto, nameResolver, typeTable) ?: return null
|
||||||
|
)
|
||||||
|
}
|
||||||
is ProtoBuf.Function -> {
|
is ProtoBuf.Function -> {
|
||||||
val signature = JvmProtoBufUtil.getJvmMethodSignature(proto, nameResolver, typeTable) ?: return null
|
val signature = JvmProtoBufUtil.getJvmMethodSignature(proto, nameResolver, typeTable) ?: return null
|
||||||
// TODO: Investigate why annotations for accessors affect resolution, resulting in dangling type parameter.
|
// TODO: Investigate why annotations for accessors affect resolution, resulting in dangling type parameter.
|
||||||
|
|||||||
+6
-1
@@ -87,7 +87,12 @@ abstract class AbstractAnnotationDeserializer(
|
|||||||
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadConstructorAnnotations(constructorProto: ProtoBuf.Constructor, nameResolver: NameResolver): List<FirAnnotationCall> {
|
open fun loadConstructorAnnotations(
|
||||||
|
containerSource: DeserializedContainerSource?,
|
||||||
|
constructorProto: ProtoBuf.Constructor,
|
||||||
|
nameResolver: NameResolver,
|
||||||
|
typeTable: TypeTable
|
||||||
|
): List<FirAnnotationCall> {
|
||||||
if (!Flags.HAS_ANNOTATIONS.get(constructorProto.flags)) return emptyList()
|
if (!Flags.HAS_ANNOTATIONS.get(constructorProto.flags)) return emptyList()
|
||||||
val annotations = constructorProto.getExtension(protocol.constructorAnnotation).orEmpty()
|
val annotations = constructorProto.getExtension(protocol.constructorAnnotation).orEmpty()
|
||||||
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
return annotations.map { deserializeAnnotation(it, nameResolver) }
|
||||||
|
|||||||
+2
-1
@@ -371,7 +371,8 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
|||||||
valueParameters += local.memberDeserializer.valueParameters(
|
valueParameters += local.memberDeserializer.valueParameters(
|
||||||
proto.valueParameterList, addDefaultValue = classBuilder.symbol.classId == StandardClassIds.Enum
|
proto.valueParameterList, addDefaultValue = classBuilder.symbol.classId == StandardClassIds.Enum
|
||||||
)
|
)
|
||||||
annotations += local.annotationDeserializer.loadConstructorAnnotations(proto, local.nameResolver)
|
annotations +=
|
||||||
|
c.annotationDeserializer.loadConstructorAnnotations(c.containerSource, proto, local.nameResolver, local.typeTable)
|
||||||
}.build()
|
}.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user