[Stubs] Pass proper container source to stub-based FIR declarations
Backend, which is used by the expression evaluator, relies on the class name in 'FacadeClassSource'. To pass the correct JVM class name, stubs for top-level functions and properties got the 'origin'.
This commit is contained in:
+4
-2
@@ -208,7 +208,8 @@ private class FunctionClsStubBuilder(
|
||||
mayHaveContract = hasContract,
|
||||
runIf(hasContract) {
|
||||
ClsContractBuilder(c, typeStubBuilder).loadContract(functionProto)
|
||||
}
|
||||
},
|
||||
origin = createStubOrigin(protoContainer)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -280,7 +281,8 @@ private class PropertyClsStubBuilder(
|
||||
isExtension = propertyProto.hasReceiver(),
|
||||
hasReturnTypeRef = true,
|
||||
fqName = c.containerFqName.child(callableName),
|
||||
initializer
|
||||
initializer,
|
||||
origin = createStubOrigin(protoContainer)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.decompiler.stub.flags.FlagsToModifiers
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.load.kotlin.FacadeClassSource
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
@@ -221,6 +222,23 @@ fun createTargetedAnnotationStubs(
|
||||
}
|
||||
}
|
||||
|
||||
internal fun createStubOrigin(protoContainer: ProtoContainer): KotlinStubOrigin? {
|
||||
if (protoContainer is ProtoContainer.Package) {
|
||||
val source = protoContainer.source
|
||||
if (source is FacadeClassSource) {
|
||||
val className = source.className.internalName
|
||||
val facadeClassName = source.facadeClassName?.internalName
|
||||
if (facadeClassName != null) {
|
||||
return KotlinStubOrigin.MultiFileFacade(className, facadeClassName)
|
||||
}
|
||||
|
||||
return KotlinStubOrigin.Facade(className)
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
val MessageLite.annotatedCallableKind: AnnotatedCallableKind
|
||||
get() = when (this) {
|
||||
is ProtoBuf.Property -> AnnotatedCallableKind.PROPERTY
|
||||
|
||||
Reference in New Issue
Block a user