CallableClsStubBuilder: correctly decide whether callable is extension
This commit is contained in:
+2
-2
@@ -52,7 +52,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
val local = c.childContext(property, proto.getTypeParameterList())
|
val local = c.childContext(property, proto.getTypeParameterList())
|
||||||
|
|
||||||
val hasGetter = Flags.HAS_GETTER.get(flags)
|
val hasGetter = Flags.HAS_GETTER.get(flags)
|
||||||
val receiverAnnotations = if (hasGetter && (proto.hasReceiverType() || proto.hasReceiverTypeId()))
|
val receiverAnnotations = if (hasGetter && proto.hasReceiver())
|
||||||
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.PROPERTY_GETTER)
|
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.PROPERTY_GETTER)
|
||||||
else
|
else
|
||||||
Annotations.EMPTY
|
Annotations.EMPTY
|
||||||
@@ -136,7 +136,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
|
|
||||||
public fun loadFunction(proto: ProtoBuf.Function): FunctionDescriptor {
|
public fun loadFunction(proto: ProtoBuf.Function): FunctionDescriptor {
|
||||||
val annotations = getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION)
|
val annotations = getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION)
|
||||||
val receiverAnnotations = if (proto.hasReceiverType() || proto.hasReceiverTypeId())
|
val receiverAnnotations = if (proto.hasReceiver())
|
||||||
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.FUNCTION)
|
getReceiverParameterAnnotations(proto, AnnotatedCallableKind.FUNCTION)
|
||||||
else Annotations.EMPTY
|
else Annotations.EMPTY
|
||||||
val function = DeserializedSimpleFunctionDescriptor.create(c.containingDeclaration, annotations, proto, c.nameResolver, c.typeTable)
|
val function = DeserializedSimpleFunctionDescriptor.create(c.containingDeclaration, annotations, proto, c.nameResolver, c.typeTable)
|
||||||
|
|||||||
+4
@@ -47,6 +47,8 @@ fun ProtoBuf.Function.returnType(typeTable: TypeTable): ProtoBuf.Type {
|
|||||||
return if (hasReturnType()) returnType else typeTable[returnTypeId]
|
return if (hasReturnType()) returnType else typeTable[returnTypeId]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ProtoBuf.Function.hasReceiver(): Boolean = hasReceiverType() || hasReceiverTypeId()
|
||||||
|
|
||||||
fun ProtoBuf.Function.receiverType(typeTable: TypeTable): ProtoBuf.Type? {
|
fun ProtoBuf.Function.receiverType(typeTable: TypeTable): ProtoBuf.Type? {
|
||||||
return when {
|
return when {
|
||||||
hasReceiverType() -> receiverType
|
hasReceiverType() -> receiverType
|
||||||
@@ -59,6 +61,8 @@ fun ProtoBuf.Property.returnType(typeTable: TypeTable): ProtoBuf.Type {
|
|||||||
return if (hasReturnType()) returnType else typeTable[returnTypeId]
|
return if (hasReturnType()) returnType else typeTable[returnTypeId]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ProtoBuf.Property.hasReceiver(): Boolean = hasReceiverType() || hasReceiverTypeId()
|
||||||
|
|
||||||
fun ProtoBuf.Property.receiverType(typeTable: TypeTable): ProtoBuf.Type? {
|
fun ProtoBuf.Property.receiverType(typeTable: TypeTable): ProtoBuf.Type? {
|
||||||
return when {
|
return when {
|
||||||
hasReceiverType() -> receiverType
|
hasReceiverType() -> receiverType
|
||||||
|
|||||||
+3
-6
@@ -29,10 +29,7 @@ import org.jetbrains.kotlin.serialization.Flags
|
|||||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf.MemberKind
|
import org.jetbrains.kotlin.serialization.ProtoBuf.MemberKind
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Modality
|
import org.jetbrains.kotlin.serialization.ProtoBuf.Modality
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.receiverType
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.returnType
|
|
||||||
|
|
||||||
fun createCallableStubs(
|
fun createCallableStubs(
|
||||||
parentStub: StubElement<out PsiElement>,
|
parentStub: StubElement<out PsiElement>,
|
||||||
@@ -150,7 +147,7 @@ private class FunctionClsStubBuilder(
|
|||||||
callableName.ref(),
|
callableName.ref(),
|
||||||
isTopLevel,
|
isTopLevel,
|
||||||
c.containerFqName.child(callableName),
|
c.containerFqName.child(callableName),
|
||||||
isExtension = functionProto.hasReceiverType(),
|
isExtension = functionProto.hasReceiver(),
|
||||||
hasBlockBody = true,
|
hasBlockBody = true,
|
||||||
hasBody = Flags.MODALITY.get(functionProto.flags) != Modality.ABSTRACT,
|
hasBody = Flags.MODALITY.get(functionProto.flags) != Modality.ABSTRACT,
|
||||||
hasTypeParameterListBeforeFunctionName = functionProto.typeParameterList.isNotEmpty()
|
hasTypeParameterListBeforeFunctionName = functionProto.typeParameterList.isNotEmpty()
|
||||||
@@ -201,7 +198,7 @@ private class PropertyClsStubBuilder(
|
|||||||
hasDelegate = false,
|
hasDelegate = false,
|
||||||
hasDelegateExpression = false,
|
hasDelegateExpression = false,
|
||||||
hasInitializer = false,
|
hasInitializer = false,
|
||||||
isExtension = propertyProto.hasReceiverType(),
|
isExtension = propertyProto.hasReceiver(),
|
||||||
hasReturnTypeRef = true,
|
hasReturnTypeRef = true,
|
||||||
fqName = c.containerFqName.child(callableName)
|
fqName = c.containerFqName.child(callableName)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user