[LL] [cls] use stubBased symbol provider for builtins
this gives the following benefits: 1. no protobuf in memory, all data is already present in stubs 2. given that symbol provider for libraries is already stub based, we can get rid of complicated code to find source psi by deserialized fir 3. it's also possible to reduce number of index access, when fir is requested for given ktElement
This commit is contained in:
+16
-6
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.analysis.api.lifetime.KtDefaultLifetimeTokenProvider
|
|||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtReadActionConfinementDefaultLifetimeTokenProvider
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtReadActionConfinementDefaultLifetimeTokenProvider
|
||||||
import org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtensionProvider
|
import org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtensionProvider
|
||||||
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.StandaloneProjectFactory
|
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.StandaloneProjectFactory
|
||||||
|
import org.jetbrains.kotlin.analysis.decompiler.psi.BuiltInDefinitionFile
|
||||||
|
import org.jetbrains.kotlin.analysis.project.structure.KtBuiltinsModule
|
||||||
import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProvider
|
import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProvider
|
||||||
import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProviderImpl
|
import org.jetbrains.kotlin.analysis.project.structure.KtModuleScopeProviderImpl
|
||||||
import org.jetbrains.kotlin.analysis.providers.*
|
import org.jetbrains.kotlin.analysis.providers.*
|
||||||
@@ -49,16 +51,24 @@ object AnalysisApiBaseTestServiceRegistrar: AnalysisApiTestServiceRegistrar() {
|
|||||||
val roots = StandaloneProjectFactory.getVirtualFilesForLibraryRoots(
|
val roots = StandaloneProjectFactory.getVirtualFilesForLibraryRoots(
|
||||||
moduleStructure.binaryModules.flatMap { binary -> binary.getBinaryRoots() },
|
moduleStructure.binaryModules.flatMap { binary -> binary.getBinaryRoots() },
|
||||||
testServices.environmentManager.getProjectEnvironment()
|
testServices.environmentManager.getProjectEnvironment()
|
||||||
).distinct()
|
)
|
||||||
project.apply {
|
project.apply {
|
||||||
registerService(KtModuleScopeProvider::class.java, KtModuleScopeProviderImpl())
|
registerService(KtModuleScopeProvider::class.java, KtModuleScopeProviderImpl())
|
||||||
registerService(KotlinAnnotationsResolverFactory::class.java, KotlinStaticAnnotationsResolverFactory(allKtFiles))
|
registerService(KotlinAnnotationsResolverFactory::class.java, KotlinStaticAnnotationsResolverFactory(allKtFiles))
|
||||||
|
|
||||||
registerService(KotlinDeclarationProviderFactory::class.java, KotlinStaticDeclarationProviderFactory(
|
val filter = BuiltInDefinitionFile.FILTER_OUT_CLASSES_EXISTING_AS_JVM_CLASS_FILES
|
||||||
project,
|
try {
|
||||||
allKtFiles,
|
BuiltInDefinitionFile.FILTER_OUT_CLASSES_EXISTING_AS_JVM_CLASS_FILES = false
|
||||||
additionalRoots = roots
|
registerService(
|
||||||
))
|
KotlinDeclarationProviderFactory::class.java, KotlinStaticDeclarationProviderFactory(
|
||||||
|
project,
|
||||||
|
allKtFiles,
|
||||||
|
additionalRoots = roots
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
BuiltInDefinitionFile.FILTER_OUT_CLASSES_EXISTING_AS_JVM_CLASS_FILES = filter
|
||||||
|
}
|
||||||
registerService(KotlinPackageProviderFactory::class.java, KotlinStaticPackageProviderFactory(project, allKtFiles))
|
registerService(KotlinPackageProviderFactory::class.java, KotlinStaticPackageProviderFactory(project, allKtFiles))
|
||||||
registerService(KotlinReferenceProvidersService::class.java, HLApiReferenceProviderService::class.java)
|
registerService(KotlinReferenceProvidersService::class.java, HLApiReferenceProviderService::class.java)
|
||||||
registerService(KotlinResolutionScopeProvider::class.java, KotlinByModulesResolutionScopeProvider::class.java)
|
registerService(KotlinResolutionScopeProvider::class.java, KotlinByModulesResolutionScopeProvider::class.java)
|
||||||
|
|||||||
+17
-3
@@ -296,7 +296,11 @@ public class KotlinStaticDeclarationProviderFactory(
|
|||||||
ktFileStub.childrenStubs.forEach(::indexStub)
|
ktFileStub.childrenStubs.forEach(::indexStub)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBuiltIns().forEach { processStub(it) }
|
val builtins = mutableSetOf<String>()
|
||||||
|
loadBuiltIns().forEach { stub ->
|
||||||
|
processStub(stub)
|
||||||
|
builtins.add(stub.psi.virtualFile.name)
|
||||||
|
}
|
||||||
|
|
||||||
val binaryClassCache = ClsKotlinBinaryClassCache.getInstance()
|
val binaryClassCache = ClsKotlinBinaryClassCache.getInstance()
|
||||||
for (root in additionalRoots) {
|
for (root in additionalRoots) {
|
||||||
@@ -304,10 +308,20 @@ public class KotlinStaticDeclarationProviderFactory(
|
|||||||
val stubs = mutableListOf<KotlinFileStubImpl>()
|
val stubs = mutableListOf<KotlinFileStubImpl>()
|
||||||
VfsUtilCore.visitChildrenRecursively(additionalRoot, object : VirtualFileVisitor<Void>() {
|
VfsUtilCore.visitChildrenRecursively(additionalRoot, object : VirtualFileVisitor<Void>() {
|
||||||
override fun visitFile(file: VirtualFile): Boolean {
|
override fun visitFile(file: VirtualFile): Boolean {
|
||||||
if (!file.isDirectory && file.fileType == JavaClassFileType.INSTANCE) {
|
if (!file.isDirectory) {
|
||||||
val fileContent = FileContentImpl.createByFile(file)
|
val fileContent = FileContentImpl.createByFile(file)
|
||||||
if (!binaryClassCache.isKotlinJvmCompiledFile(file, fileContent.content)) return true
|
if (!binaryClassCache.isKotlinJvmCompiledFile(file, fileContent.content)) return true
|
||||||
val stub = KotlinClsStubBuilder().buildFileStub(fileContent) as? KotlinFileStubImpl ?: return true
|
val stub: KotlinFileStubImpl = when {
|
||||||
|
file.fileType == JavaClassFileType.INSTANCE -> {
|
||||||
|
if (!binaryClassCache.isKotlinJvmCompiledFile(file, fileContent.content)) return true
|
||||||
|
KotlinClsStubBuilder().buildFileStub(fileContent) as? KotlinFileStubImpl ?: return true
|
||||||
|
}
|
||||||
|
file.extension == BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION -> {
|
||||||
|
if (!builtins.add(file.name)) return true
|
||||||
|
builtInDecompiler.stubBuilder.buildFileStub(fileContent) as? KotlinFileStubImpl ?: return true
|
||||||
|
}
|
||||||
|
else -> return true
|
||||||
|
}
|
||||||
val fakeFile = object : KtFile(KtClassFileViewProvider(psiManager, fileContent.file), isCompiled = true) {
|
val fakeFile = object : KtFile(KtClassFileViewProvider(psiManager, fileContent.file), isCompiled = true) {
|
||||||
override fun getStub() = stub
|
override fun getStub() = stub
|
||||||
override fun isPhysical() = false
|
override fun isPhysical() = false
|
||||||
|
|||||||
+1
-1
@@ -226,7 +226,7 @@ object StandaloneProjectFactory {
|
|||||||
VirtualFileManager.getInstance().findFileByNioPath(path)
|
VirtualFileManager.getInstance().findFileByNioPath(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}.distinct()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun withAllTransitiveDependencies(ktModules: List<KtModule>): List<KtModule> {
|
private fun withAllTransitiveDependencies(ktModules: List<KtModule>): List<KtModule> {
|
||||||
|
|||||||
Vendored
+2
-32
@@ -1261,39 +1261,9 @@ KtKotlinPropertySymbol:
|
|||||||
deprecationStatus: null
|
deprecationStatus: null
|
||||||
callableIdIfNonLocal: kotlin/collections/List.size
|
callableIdIfNonLocal: kotlin/collections/List.size
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: ABSTRACT
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/Int
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
getDispatchReceiver(): KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: [
|
|
||||||
KtTypeParameterType:
|
|
||||||
annotationsList: []
|
|
||||||
type: E
|
|
||||||
]
|
|
||||||
type: kotlin/collections/List<E>
|
|
||||||
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
|
|
||||||
deprecationStatus: null
|
|
||||||
hasBackingField: false
|
hasBackingField: false
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
|
|||||||
+4
-64
@@ -337,39 +337,9 @@ KtKotlinPropertySymbol:
|
|||||||
deprecationStatus: null
|
deprecationStatus: null
|
||||||
callableIdIfNonLocal: kotlin/Enum.name
|
callableIdIfNonLocal: kotlin/Enum.name
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: FINAL
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/String
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
getDispatchReceiver(): KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: [
|
|
||||||
KtTypeParameterType:
|
|
||||||
annotationsList: []
|
|
||||||
type: E
|
|
||||||
]
|
|
||||||
type: kotlin/Enum<E>
|
|
||||||
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
|
|
||||||
deprecationStatus: null
|
|
||||||
hasBackingField: true
|
hasBackingField: true
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
@@ -428,39 +398,9 @@ KtKotlinPropertySymbol:
|
|||||||
deprecationStatus: null
|
deprecationStatus: null
|
||||||
callableIdIfNonLocal: kotlin/Enum.ordinal
|
callableIdIfNonLocal: kotlin/Enum.ordinal
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: FINAL
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/Int
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
getDispatchReceiver(): KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: [
|
|
||||||
KtTypeParameterType:
|
|
||||||
annotationsList: []
|
|
||||||
type: E
|
|
||||||
]
|
|
||||||
type: kotlin/Enum<E>
|
|
||||||
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
|
|
||||||
deprecationStatus: null
|
|
||||||
hasBackingField: true
|
hasBackingField: true
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
|
|||||||
Vendored
+4
-44
@@ -333,29 +333,9 @@ scopes:
|
|||||||
typeParameters: []
|
typeParameters: []
|
||||||
callableIdIfNonLocal: kotlin/Enum.name
|
callableIdIfNonLocal: kotlin/Enum.name
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: FINAL
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/String
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
hasBackingField: true
|
hasBackingField: true
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
@@ -397,29 +377,9 @@ scopes:
|
|||||||
typeParameters: []
|
typeParameters: []
|
||||||
callableIdIfNonLocal: kotlin/Enum.ordinal
|
callableIdIfNonLocal: kotlin/Enum.ordinal
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: FINAL
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/Int
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
hasBackingField: true
|
hasBackingField: true
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
|
|||||||
+2
-22
@@ -623,29 +623,9 @@ KtKotlinPropertySymbol:
|
|||||||
typeParameters: []
|
typeParameters: []
|
||||||
callableIdIfNonLocal: kotlin/collections/List.size
|
callableIdIfNonLocal: kotlin/collections/List.size
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: ABSTRACT
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/Int
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
hasBackingField: false
|
hasBackingField: false
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
|
|||||||
+2
-22
@@ -623,29 +623,9 @@ KtKotlinPropertySymbol:
|
|||||||
typeParameters: []
|
typeParameters: []
|
||||||
callableIdIfNonLocal: kotlin/collections/List.size
|
callableIdIfNonLocal: kotlin/collections/List.size
|
||||||
contextReceivers: []
|
contextReceivers: []
|
||||||
getter: KtPropertyGetterSymbol:
|
getter: null
|
||||||
annotationsList: []
|
|
||||||
callableIdIfNonLocal: null
|
|
||||||
contextReceivers: []
|
|
||||||
hasBody: false
|
|
||||||
hasStableParameterNames: true
|
|
||||||
isDefault: true
|
|
||||||
isExtension: false
|
|
||||||
isInline: false
|
|
||||||
isOverride: false
|
|
||||||
modality: ABSTRACT
|
|
||||||
origin: LIBRARY
|
|
||||||
receiverParameter: null
|
|
||||||
returnType: KtUsualClassType:
|
|
||||||
annotationsList: []
|
|
||||||
ownTypeArguments: []
|
|
||||||
type: kotlin/Int
|
|
||||||
symbolKind: ACCESSOR
|
|
||||||
typeParameters: []
|
|
||||||
valueParameters: []
|
|
||||||
visibility: Public
|
|
||||||
hasBackingField: false
|
hasBackingField: false
|
||||||
hasGetter: true
|
hasGetter: false
|
||||||
hasSetter: false
|
hasSetter: false
|
||||||
initializer: null
|
initializer: null
|
||||||
isConst: false
|
isConst: false
|
||||||
|
|||||||
+46
-2
@@ -7,9 +7,12 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure
|
|||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.ModificationTracker
|
import com.intellij.openapi.util.ModificationTracker
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.LLFirBuiltinSymbolProvider
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
|
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
||||||
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.LLFirBuiltinsAndCloneableSessionProvider
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.LLFirBuiltinsAndCloneableSessionProvider
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirBuiltinsAndCloneableSession
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirBuiltinsAndCloneableSession
|
||||||
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization.JvmStubBasedFirDeserializedSymbolProvider
|
||||||
import org.jetbrains.kotlin.analysis.project.structure.KtBuiltinsModule
|
import org.jetbrains.kotlin.analysis.project.structure.KtBuiltinsModule
|
||||||
import org.jetbrains.kotlin.analyzer.common.CommonPlatformAnalyzerServices
|
import org.jetbrains.kotlin.analyzer.common.CommonPlatformAnalyzerServices
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||||
@@ -17,8 +20,11 @@ import org.jetbrains.kotlin.fir.BuiltinTypes
|
|||||||
import org.jetbrains.kotlin.fir.PrivateSessionConstructor
|
import org.jetbrains.kotlin.fir.PrivateSessionConstructor
|
||||||
import org.jetbrains.kotlin.fir.SessionConfiguration
|
import org.jetbrains.kotlin.fir.SessionConfiguration
|
||||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmTypeMapper
|
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmTypeMapper
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||||
|
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.FirProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirBuiltinSyntheticFunctionInterfaceProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirCloneableSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirCloneableSymbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirExtensionSyntheticFunctionInterfaceProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirExtensionSyntheticFunctionInterfaceProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.scopes.wrapScopeWithJvmMapped
|
import org.jetbrains.kotlin.fir.resolve.scopes.wrapScopeWithJvmMapped
|
||||||
@@ -29,12 +35,15 @@ import org.jetbrains.kotlin.fir.session.registerCommonComponentsAfterExtensionsA
|
|||||||
import org.jetbrains.kotlin.fir.session.registerCommonJavaComponents
|
import org.jetbrains.kotlin.fir.session.registerCommonJavaComponents
|
||||||
import org.jetbrains.kotlin.fir.session.registerModuleData
|
import org.jetbrains.kotlin.fir.session.registerModuleData
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirLazyDeclarationResolver
|
import org.jetbrains.kotlin.fir.symbols.FirLazyDeclarationResolver
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.isCommon
|
import org.jetbrains.kotlin.platform.isCommon
|
||||||
import org.jetbrains.kotlin.platform.isJs
|
import org.jetbrains.kotlin.platform.isJs
|
||||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver
|
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleResolver
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
||||||
|
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
@OptIn(PrivateSessionConstructor::class, SessionConfiguration::class)
|
@OptIn(PrivateSessionConstructor::class, SessionConfiguration::class)
|
||||||
@@ -46,6 +55,11 @@ class LLFirBuiltinsSessionFactory(private val project: Project) {
|
|||||||
return builtinsAndCloneableSession.getOrPut(platform) { createBuiltinsAndCloneableSession(platform) }
|
return builtinsAndCloneableSession.getOrPut(platform) { createBuiltinsAndCloneableSession(platform) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestOnly
|
||||||
|
fun clearForTheNextTest() {
|
||||||
|
builtinsAndCloneableSession.clear()
|
||||||
|
}
|
||||||
|
|
||||||
private fun createBuiltinsAndCloneableSession(platform: TargetPlatform): LLFirBuiltinsAndCloneableSession {
|
private fun createBuiltinsAndCloneableSession(platform: TargetPlatform): LLFirBuiltinsAndCloneableSession {
|
||||||
val builtinsModule = KtBuiltinsModule(platform, platform.getAnalyzerServices(), project)
|
val builtinsModule = KtBuiltinsModule(platform, platform.getAnalyzerServices(), project)
|
||||||
|
|
||||||
@@ -64,7 +78,28 @@ class LLFirBuiltinsSessionFactory(private val project: Project) {
|
|||||||
register(FirKotlinScopeProvider::class, kotlinScopeProvider)
|
register(FirKotlinScopeProvider::class, kotlinScopeProvider)
|
||||||
|
|
||||||
val symbolProvider = createCompositeSymbolProvider(this) {
|
val symbolProvider = createCompositeSymbolProvider(this) {
|
||||||
add(LLFirBuiltinSymbolProvider(session, moduleData, kotlinScopeProvider))
|
val moduleDataProvider = SingleModuleDataProvider(moduleData)
|
||||||
|
add(
|
||||||
|
object : JvmStubBasedFirDeserializedSymbolProvider(
|
||||||
|
session,
|
||||||
|
moduleDataProvider,
|
||||||
|
kotlinScopeProvider,
|
||||||
|
project,
|
||||||
|
BuiltinsGlobalSearchScope(project),
|
||||||
|
FirDeclarationOrigin.BuiltIns
|
||||||
|
) {
|
||||||
|
private val syntheticFunctionInterfaceProvider = FirBuiltinSyntheticFunctionInterfaceProvider(
|
||||||
|
session,
|
||||||
|
moduleData,
|
||||||
|
kotlinScopeProvider
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun getClassLikeSymbolByClassId(classId: ClassId): FirClassLikeSymbol<*>? {
|
||||||
|
return super.getClassLikeSymbolByClassId(classId)
|
||||||
|
?: syntheticFunctionInterfaceProvider.getClassLikeSymbolByClassId(classId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
add(FirExtensionSyntheticFunctionInterfaceProvider(session, moduleData, kotlinScopeProvider))
|
add(FirExtensionSyntheticFunctionInterfaceProvider(session, moduleData, kotlinScopeProvider))
|
||||||
add(FirCloneableSymbolProvider(session, moduleData, kotlinScopeProvider))
|
add(FirCloneableSymbolProvider(session, moduleData, kotlinScopeProvider))
|
||||||
}
|
}
|
||||||
@@ -81,6 +116,15 @@ class LLFirBuiltinsSessionFactory(private val project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class BuiltinsGlobalSearchScope(project: Project) : DelegatingGlobalSearchScope(project, allScope(project)) {
|
||||||
|
override fun contains(file: VirtualFile): Boolean {
|
||||||
|
if (file.extension != BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return super.contains(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun TargetPlatform.getAnalyzerServices() = when {
|
private fun TargetPlatform.getAnalyzerServices() = when {
|
||||||
isJvm() -> JvmPlatformAnalyzerServices
|
isJvm() -> JvmPlatformAnalyzerServices
|
||||||
isJs() -> JvmPlatformAnalyzerServices/*TODO*/
|
isJs() -> JvmPlatformAnalyzerServices/*TODO*/
|
||||||
|
|||||||
+1
-1
@@ -239,7 +239,7 @@ class LLFirResolveExtensionToolDeclarationProvider internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun computePackageSetWithTopLevelCallableDeclarations(): Set<String> {
|
override fun computePackageSetWithTopLevelCallableDeclarations(): Set<String> {
|
||||||
return emptySet() //todo
|
return emptySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun getDeclarationProvidersByPackage(
|
private inline fun getDeclarationProvidersByPackage(
|
||||||
|
|||||||
+2
-3
@@ -11,8 +11,10 @@ import com.intellij.psi.util.CachedValuesManager
|
|||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.FirTowerContextProvider
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.FirTowerContextProvider
|
||||||
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.canBePartOfParentDeclaration
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.retryOnInvalidSession
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.retryOnInvalidSession
|
||||||
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.FirElementsRecorder
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirResolvableModuleSession
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirResolvableModuleSession
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSession
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSession
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSessionCache
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSessionCache
|
||||||
@@ -99,9 +101,6 @@ internal abstract class LLFirResolvableResolveSession(
|
|||||||
ktDeclaration: KtDeclaration,
|
ktDeclaration: KtDeclaration,
|
||||||
phase: FirResolvePhase
|
phase: FirResolvePhase
|
||||||
): FirBasedSymbol<*> {
|
): FirBasedSymbol<*> {
|
||||||
if (ktDeclaration.containingKtFile.isCompiled) {
|
|
||||||
return findFirCompiledSymbol(ktDeclaration)
|
|
||||||
}
|
|
||||||
val module = ktDeclaration.getKtModule()
|
val module = ktDeclaration.getKtModule()
|
||||||
retryOnInvalidSession {
|
retryOnInvalidSession {
|
||||||
return when (getModuleKind(module)) {
|
return when (getModuleKind(module)) {
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
|||||||
|
|
||||||
//required for LLFirDependenciesSymbolProvider#jvmClassName, to resolve ambiguities
|
//required for LLFirDependenciesSymbolProvider#jvmClassName, to resolve ambiguities
|
||||||
//todo check if moving builtins to stubs would solve the issue
|
//todo check if moving builtins to stubs would solve the issue
|
||||||
class JvmFromStubDecompilerSource(
|
internal class JvmFromStubDecompilerSource(
|
||||||
override val className: JvmClassName,
|
override val className: JvmClassName,
|
||||||
override val facadeClassName: JvmClassName? = null,
|
override val facadeClassName: JvmClassName? = null,
|
||||||
override val incompatibility: IncompatibleVersionErrorData<JvmMetadataVersion>? = null,
|
override val incompatibility: IncompatibleVersionErrorData<JvmMetadataVersion>? = null,
|
||||||
|
|||||||
+9
-5
@@ -12,8 +12,8 @@ import com.intellij.psi.search.GlobalSearchScope
|
|||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.JvmFirDeserializedSymbolProviderFactory
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.JvmFirDeserializedSymbolProviderFactory
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.LLFirModuleData
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.LLFirModuleData
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.createJavaSymbolProvider
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.createJavaSymbolProvider
|
||||||
import org.jetbrains.kotlin.analysis.providers.createDeclarationProvider
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
||||||
import org.jetbrains.kotlin.fir.java.FirJavaFacade
|
import org.jetbrains.kotlin.fir.java.FirJavaFacade
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.scopes.FirKotlinScopeProvider
|
|||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
||||||
|
|
||||||
class JvmStubBasedDeserializedSymbolProviderFactory : JvmFirDeserializedSymbolProviderFactory() {
|
internal class JvmStubBasedDeserializedSymbolProviderFactory : JvmFirDeserializedSymbolProviderFactory() {
|
||||||
override fun createJvmFirDeserializedSymbolProviders(
|
override fun createJvmFirDeserializedSymbolProviders(
|
||||||
project: Project,
|
project: Project,
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
@@ -42,12 +42,16 @@ class JvmStubBasedDeserializedSymbolProviderFactory : JvmFirDeserializedSymbolPr
|
|||||||
session,
|
session,
|
||||||
moduleDataProvider,
|
moduleDataProvider,
|
||||||
kotlinScopeProvider,
|
kotlinScopeProvider,
|
||||||
project.createDeclarationProvider(object : DelegatingGlobalSearchScope(project, scope) {
|
project,
|
||||||
|
object : DelegatingGlobalSearchScope(project, scope) {
|
||||||
override fun contains(file: VirtualFile): Boolean {
|
override fun contains(file: VirtualFile): Boolean {
|
||||||
if (file.extension == BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION) return false
|
if (file.extension == BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return super.contains(file)
|
return super.contains(file)
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
FirDeclarationOrigin.Library
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(createJavaSymbolProvider(session, moduleData, project, scope))
|
add(createJavaSymbolProvider(session, moduleData, project, scope))
|
||||||
|
|||||||
+25
-8
@@ -5,13 +5,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization
|
package org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization
|
||||||
|
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.LLFirKotlinSymbolProviderNameCache
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.LLFirKotlinSymbolProviderNameCache
|
||||||
import org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProvider
|
import org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProvider
|
||||||
|
import org.jetbrains.kotlin.analysis.providers.createDeclarationProvider
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.caches.FirCache
|
import org.jetbrains.kotlin.fir.caches.FirCache
|
||||||
import org.jetbrains.kotlin.fir.caches.createCache
|
import org.jetbrains.kotlin.fir.caches.createCache
|
||||||
import org.jetbrains.kotlin.fir.caches.firCachesFactory
|
import org.jetbrains.kotlin.fir.caches.firCachesFactory
|
||||||
import org.jetbrains.kotlin.fir.caches.getValue
|
import org.jetbrains.kotlin.fir.caches.getValue
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
|
||||||
import org.jetbrains.kotlin.fir.java.deserialization.KotlinBuiltins
|
import org.jetbrains.kotlin.fir.java.deserialization.KotlinBuiltins
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||||
@@ -40,18 +44,26 @@ typealias DeserializedTypeAliasPostProcessor = (FirTypeAliasSymbol) -> Unit
|
|||||||
*
|
*
|
||||||
* Same as [JvmClassFileBasedSymbolProvider], resulting fir elements are already resolved.
|
* Same as [JvmClassFileBasedSymbolProvider], resulting fir elements are already resolved.
|
||||||
*/
|
*/
|
||||||
class JvmStubBasedFirDeserializedSymbolProvider(
|
internal open class JvmStubBasedFirDeserializedSymbolProvider(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
moduleDataProvider: SingleModuleDataProvider,
|
moduleDataProvider: SingleModuleDataProvider,
|
||||||
private val kotlinScopeProvider: FirKotlinScopeProvider,
|
private val kotlinScopeProvider: FirKotlinScopeProvider,
|
||||||
private val declarationProvider: KotlinDeclarationProvider
|
project: Project,
|
||||||
|
scope: GlobalSearchScope,
|
||||||
|
private val initialOrigin: FirDeclarationOrigin
|
||||||
) : FirSymbolProvider(session) {
|
) : FirSymbolProvider(session) {
|
||||||
|
private val declarationProvider by lazy(LazyThreadSafetyMode.PUBLICATION) { project.createDeclarationProvider(scope) }
|
||||||
private val moduleData = moduleDataProvider.getModuleData(null)
|
private val moduleData = moduleDataProvider.getModuleData(null)
|
||||||
private val packageSetWithTopLevelCallableDeclarations: Set<String> by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
private val packageSetWithTopLevelCallableDeclarations: Set<String> by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
declarationProvider.computePackageSetWithTopLevelCallableDeclarations()
|
declarationProvider.computePackageSetWithTopLevelCallableDeclarations()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val namesByPackageCache = LLFirKotlinSymbolProviderNameCache(session, declarationProvider)
|
private val namesByPackageCache by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
|
LLFirKotlinSymbolProviderNameCache(
|
||||||
|
session,
|
||||||
|
declarationProvider
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private val typeAliasCache: FirCache<ClassId, FirTypeAliasSymbol?, StubBasedFirDeserializationContext?> =
|
private val typeAliasCache: FirCache<ClassId, FirTypeAliasSymbol?, StubBasedFirDeserializationContext?> =
|
||||||
session.firCachesFactory.createCacheWithPostCompute(
|
session.firCachesFactory.createCacheWithPostCompute(
|
||||||
@@ -92,7 +104,7 @@ class JvmStubBasedFirDeserializedSymbolProvider(
|
|||||||
classId.packageFqName,
|
classId.packageFqName,
|
||||||
classId.relativeClassName,
|
classId.relativeClassName,
|
||||||
classLikeDeclaration,
|
classLikeDeclaration,
|
||||||
null, null, symbol
|
null, null, symbol, initialOrigin
|
||||||
)
|
)
|
||||||
rootContext.memberDeserializer.loadTypeAlias(classLikeDeclaration, symbol)
|
rootContext.memberDeserializer.loadTypeAlias(classLikeDeclaration, symbol)
|
||||||
}
|
}
|
||||||
@@ -117,8 +129,13 @@ class JvmStubBasedFirDeserializedSymbolProvider(
|
|||||||
StubBasedAnnotationDeserializer(session),
|
StubBasedAnnotationDeserializer(session),
|
||||||
kotlinScopeProvider,
|
kotlinScopeProvider,
|
||||||
parentContext,
|
parentContext,
|
||||||
JvmFromStubDecompilerSource(JvmClassName.byClassId(classId)),
|
containerSource = if (initialOrigin == FirDeclarationOrigin.BuiltIns) null else JvmFromStubDecompilerSource(
|
||||||
|
JvmClassName.byClassId(
|
||||||
|
classId
|
||||||
|
)
|
||||||
|
),
|
||||||
deserializeNestedClass = this::getClass,
|
deserializeNestedClass = this::getClass,
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
return symbol
|
return symbol
|
||||||
}
|
}
|
||||||
@@ -135,12 +152,12 @@ class JvmStubBasedFirDeserializedSymbolProvider(
|
|||||||
val file = original.containingKtFile
|
val file = original.containingKtFile
|
||||||
val virtualFile = file.virtualFile
|
val virtualFile = file.virtualFile
|
||||||
if (virtualFile.extension == MetadataPackageFragment.METADATA_FILE_EXTENSION) return@mapNotNull null
|
if (virtualFile.extension == MetadataPackageFragment.METADATA_FILE_EXTENSION) return@mapNotNull null
|
||||||
if (file.packageFqName.asString()
|
if (initialOrigin != FirDeclarationOrigin.BuiltIns && file.packageFqName.asString()
|
||||||
.replace(".", "/") + "/" + virtualFile.nameWithoutExtension in KotlinBuiltins
|
.replace(".", "/") + "/" + virtualFile.nameWithoutExtension in KotlinBuiltins
|
||||||
) return@mapNotNull null
|
) return@mapNotNull null
|
||||||
val symbol = FirNamedFunctionSymbol(callableId)
|
val symbol = FirNamedFunctionSymbol(callableId)
|
||||||
val rootContext =
|
val rootContext =
|
||||||
StubBasedFirDeserializationContext.createRootContext(session, moduleData, callableId, original, symbol)
|
StubBasedFirDeserializationContext.createRootContext(session, moduleData, callableId, original, symbol, initialOrigin)
|
||||||
rootContext.memberDeserializer.loadFunction(original, null, session, symbol).symbol
|
rootContext.memberDeserializer.loadFunction(original, null, session, symbol).symbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +171,7 @@ class JvmStubBasedFirDeserializedSymbolProvider(
|
|||||||
if (origins != null && !origins.add(original)) return@mapNotNull null
|
if (origins != null && !origins.add(original)) return@mapNotNull null
|
||||||
val symbol = FirPropertySymbol(callableId)
|
val symbol = FirPropertySymbol(callableId)
|
||||||
val rootContext =
|
val rootContext =
|
||||||
StubBasedFirDeserializationContext.createRootContext(session, moduleData, callableId, original, symbol)
|
StubBasedFirDeserializationContext.createRootContext(session, moduleData, callableId, original, symbol, initialOrigin)
|
||||||
rootContext.memberDeserializer.loadProperty(original, null, symbol).symbol
|
rootContext.memberDeserializer.loadProperty(original, null, symbol).symbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-23
@@ -5,19 +5,21 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization
|
package org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization
|
||||||
|
|
||||||
import org.jetbrains.kotlin.constant.*
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.KtRealPsiSourceElement
|
import org.jetbrains.kotlin.KtRealPsiSourceElement
|
||||||
|
import org.jetbrains.kotlin.constant.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.collectEnumEntries
|
import org.jetbrains.kotlin.fir.declarations.collectEnumEntries
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.buildUnaryArgumentList
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.*
|
import org.jetbrains.kotlin.fir.expressions.builder.*
|
||||||
import org.jetbrains.kotlin.fir.references.builder.buildFromMissingDependenciesNamedReference
|
import org.jetbrains.kotlin.fir.references.builder.buildFromMissingDependenciesNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyDeclarationResolver
|
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
@@ -25,23 +27,24 @@ import org.jetbrains.kotlin.name.CallableId
|
|||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.name.StandardClassIds
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtAnnotated
|
||||||
|
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||||
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||||
import org.jetbrains.kotlin.psi.stubs.impl.*
|
import org.jetbrains.kotlin.psi.stubs.impl.KotlinAnnotationEntryStubImpl
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.impl.KotlinClassTypeBean
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.impl.KotlinPropertyStubImpl
|
||||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||||
|
|
||||||
class StubBasedAnnotationDeserializer(
|
class StubBasedAnnotationDeserializer(
|
||||||
private val session: FirSession,
|
private val session: FirSession,
|
||||||
) {
|
) {
|
||||||
//fun inheritAnnotationInfo(parent: StubBasedAnnotationDeserializer) {}
|
|
||||||
|
|
||||||
fun loadAnnotations(
|
fun loadAnnotations(
|
||||||
ktAnnotated: KtAnnotated,
|
ktAnnotated: KtAnnotated,
|
||||||
useSiteTarget: AnnotationUseSiteTarget? = null
|
|
||||||
): List<FirAnnotation> {
|
): List<FirAnnotation> {
|
||||||
val annotations = ktAnnotated.annotationEntries
|
val annotations = ktAnnotated.annotationEntries
|
||||||
if (annotations.isEmpty()) return emptyList()
|
if (annotations.isEmpty()) return emptyList()
|
||||||
return annotations.map { deserializeAnnotation(it, useSiteTarget) }
|
return annotations.map { deserializeAnnotation(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private val constantCache = mutableMapOf<CallableId, FirExpression>()
|
private val constantCache = mutableMapOf<CallableId, FirExpression>()
|
||||||
@@ -55,8 +58,7 @@ class StubBasedAnnotationDeserializer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun deserializeAnnotation(
|
private fun deserializeAnnotation(
|
||||||
ktAnnotation: KtAnnotationEntry,
|
ktAnnotation: KtAnnotationEntry
|
||||||
useSiteTarget: AnnotationUseSiteTarget? = null
|
|
||||||
): FirAnnotation {
|
): FirAnnotation {
|
||||||
val userType =
|
val userType =
|
||||||
ktAnnotation.getStubOrPsiChild(KtStubElementTypes.CONSTRUCTOR_CALLEE)?.getStubOrPsiChild(KtStubElementTypes.TYPE_REFERENCE)
|
ktAnnotation.getStubOrPsiChild(KtStubElementTypes.CONSTRUCTOR_CALLEE)?.getStubOrPsiChild(KtStubElementTypes.TYPE_REFERENCE)
|
||||||
@@ -65,7 +67,7 @@ class StubBasedAnnotationDeserializer(
|
|||||||
ktAnnotation,
|
ktAnnotation,
|
||||||
userType.classId(),
|
userType.classId(),
|
||||||
(ktAnnotation.stub as? KotlinAnnotationEntryStubImpl)?.valueArguments,
|
(ktAnnotation.stub as? KotlinAnnotationEntryStubImpl)?.valueArguments,
|
||||||
useSiteTarget
|
ktAnnotation.useSiteTarget?.getAnnotationUseSiteTarget()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,13 +80,11 @@ class StubBasedAnnotationDeserializer(
|
|||||||
return buildAnnotation {
|
return buildAnnotation {
|
||||||
source = KtRealPsiSourceElement(ktAnnotation)
|
source = KtRealPsiSourceElement(ktAnnotation)
|
||||||
annotationTypeRef = buildResolvedTypeRef {
|
annotationTypeRef = buildResolvedTypeRef {
|
||||||
type = classId.toLookupTag().constructClassType(emptyArray(), isNullable = false)
|
type = classId.toLookupTag().constructClassType(ConeTypeProjection.EMPTY_ARRAY, isNullable = false)
|
||||||
}
|
}
|
||||||
session.lazyDeclarationResolver.disableLazyResolveContractChecksInside {
|
this.argumentMapping = buildAnnotationArgumentMapping {
|
||||||
this.argumentMapping = buildAnnotationArgumentMapping {
|
valueArguments?.forEach { (name, constantValue) ->
|
||||||
valueArguments?.forEach { (name, constantValue) ->
|
mapping[name] = resolveValue(ktAnnotation, constantValue)
|
||||||
mapping[name] = resolveValue(ktAnnotation, constantValue)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useSiteTarget?.let {
|
useSiteTarget?.let {
|
||||||
@@ -102,7 +102,7 @@ class StubBasedAnnotationDeserializer(
|
|||||||
is KClassValue -> buildGetClassCall {
|
is KClassValue -> buildGetClassCall {
|
||||||
source = KtRealPsiSourceElement(sourceElement)
|
source = KtRealPsiSourceElement(sourceElement)
|
||||||
val lookupTag = (value.value as KClassValue.Value.NormalClass).classId.toLookupTag()
|
val lookupTag = (value.value as KClassValue.Value.NormalClass).classId.toLookupTag()
|
||||||
val referencedType = lookupTag.constructType(emptyArray(), isNullable = false)
|
val referencedType = lookupTag.constructType(ConeTypeProjection.EMPTY_ARRAY, isNullable = false)
|
||||||
val resolvedTypeRef = buildResolvedTypeRef {
|
val resolvedTypeRef = buildResolvedTypeRef {
|
||||||
type = StandardClassIds.KClass.constructClassLikeType(arrayOf(referencedType), false)
|
type = StandardClassIds.KClass.constructClassLikeType(arrayOf(referencedType), false)
|
||||||
}
|
}
|
||||||
@@ -118,9 +118,6 @@ class StubBasedAnnotationDeserializer(
|
|||||||
argumentList = buildArgumentList {
|
argumentList = buildArgumentList {
|
||||||
value.value.mapTo(arguments) { resolveValue(sourceElement, it) }
|
value.value.mapTo(arguments) { resolveValue(sourceElement, it) }
|
||||||
}
|
}
|
||||||
// typeRef = buildResolvedTypeRef {
|
|
||||||
// type = expectedArrayElementType.createArrayType() //todo
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
is AnnotationValue -> {
|
is AnnotationValue -> {
|
||||||
deserializeAnnotation(
|
deserializeAnnotation(
|
||||||
@@ -147,7 +144,12 @@ class StubBasedAnnotationDeserializer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <T> const(kind: ConstantValueKind<T>, value: T, typeRef: FirResolvedTypeRef, sourceElement: PsiElement): FirConstExpression<T> {
|
private fun <T> const(
|
||||||
|
kind: ConstantValueKind<T>,
|
||||||
|
value: T,
|
||||||
|
typeRef: FirResolvedTypeRef,
|
||||||
|
sourceElement: PsiElement
|
||||||
|
): FirConstExpression<T> {
|
||||||
return buildConstExpression(
|
return buildConstExpression(
|
||||||
KtRealPsiSourceElement(sourceElement),
|
KtRealPsiSourceElement(sourceElement),
|
||||||
kind,
|
kind,
|
||||||
|
|||||||
+15
-22
@@ -45,7 +45,7 @@ internal val KtDeclaration.modality: Modality
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeClassToSymbol(
|
internal fun deserializeClassToSymbol(
|
||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
classOrObject: KtClassOrObject,
|
classOrObject: KtClassOrObject,
|
||||||
symbol: FirRegularClassSymbol,
|
symbol: FirRegularClassSymbol,
|
||||||
@@ -55,7 +55,8 @@ fun deserializeClassToSymbol(
|
|||||||
scopeProvider: FirScopeProvider,
|
scopeProvider: FirScopeProvider,
|
||||||
parentContext: StubBasedFirDeserializationContext? = null,
|
parentContext: StubBasedFirDeserializationContext? = null,
|
||||||
containerSource: DeserializedContainerSource? = null,
|
containerSource: DeserializedContainerSource? = null,
|
||||||
deserializeNestedClass: (ClassId, StubBasedFirDeserializationContext) -> FirRegularClassSymbol?
|
deserializeNestedClass: (ClassId, StubBasedFirDeserializationContext) -> FirRegularClassSymbol?,
|
||||||
|
initialOrigin: FirDeclarationOrigin
|
||||||
) {
|
) {
|
||||||
val kind = when (classOrObject) {
|
val kind = when (classOrObject) {
|
||||||
is KtObjectDeclaration -> ClassKind.OBJECT
|
is KtObjectDeclaration -> ClassKind.OBJECT
|
||||||
@@ -98,17 +99,13 @@ fun deserializeClassToSymbol(
|
|||||||
moduleData,
|
moduleData,
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
containerSource,
|
containerSource,
|
||||||
symbol
|
symbol,
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
// if (status.isCompanion) {
|
|
||||||
// parentContext?.let {
|
|
||||||
// context.annotationDeserializer.inheritAnnotationInfo(it.annotationDeserializer)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
buildRegularClass {
|
buildRegularClass {
|
||||||
source = KtRealPsiSourceElement(classOrObject)
|
source = KtRealPsiSourceElement(classOrObject)
|
||||||
this.moduleData = moduleData
|
this.moduleData = moduleData
|
||||||
this.origin = FirDeclarationOrigin.Library
|
this.origin = initialOrigin
|
||||||
name = classId.shortClassName
|
name = classId.shortClassName
|
||||||
this.status = status
|
this.status = status
|
||||||
classKind = kind
|
classKind = kind
|
||||||
@@ -131,7 +128,7 @@ fun deserializeClassToSymbol(
|
|||||||
it.typeReference ?: error("Super entry doesn't have type reference $it")
|
it.typeReference ?: error("Super entry doesn't have type reference $it")
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else if (StandardClassIds.Any != classId) {
|
} else if (StandardClassIds.Any != classId && StandardClassIds.Nothing != classId) {
|
||||||
superTypeRefs.add(session.builtinTypes.anyType)
|
superTypeRefs.add(session.builtinTypes.anyType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,17 +156,21 @@ fun deserializeClassToSymbol(
|
|||||||
moduleData,
|
moduleData,
|
||||||
classId.packageFqName,
|
classId.packageFqName,
|
||||||
classId.relativeClassName,
|
classId.relativeClassName,
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
)
|
)
|
||||||
generateValueOfFunction(moduleData, classId.packageFqName, classId.relativeClassName, origin = FirDeclarationOrigin.Library)
|
generateValueOfFunction(moduleData, classId.packageFqName, classId.relativeClassName, origin = initialOrigin)
|
||||||
generateEntriesGetter(moduleData, classId.packageFqName, classId.relativeClassName, origin = FirDeclarationOrigin.Library)
|
generateEntriesGetter(moduleData, classId.packageFqName, classId.relativeClassName, origin = initialOrigin)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classOrObject.isData() && firPrimaryConstructor != null) {
|
if (classOrObject.isData() && firPrimaryConstructor != null) {
|
||||||
val zippedParameters =
|
val zippedParameters =
|
||||||
classOrObject.primaryConstructorParameters.filter { it.hasValOrVar() } zip declarations.filterIsInstance<FirProperty>()
|
classOrObject.primaryConstructorParameters.filter { it.hasValOrVar() } zip declarations.filterIsInstance<FirProperty>()
|
||||||
addDeclaration(createDataClassCopyFunction(classId, classOrObject, context.dispatchReceiver, zippedParameters,
|
addDeclaration(createDataClassCopyFunction(classId, classOrObject, context.dispatchReceiver, zippedParameters,
|
||||||
createClassTypeRefWithSourceKind = { firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(it) },
|
createClassTypeRefWithSourceKind = {
|
||||||
|
firPrimaryConstructor.returnTypeRef.copyWithNewSourceKind(
|
||||||
|
it
|
||||||
|
)
|
||||||
|
},
|
||||||
createParameterTypeRefWithSourceKind = { property, newKind ->
|
createParameterTypeRefWithSourceKind = { property, newKind ->
|
||||||
property.returnTypeRef.copyWithNewSourceKind(newKind)
|
property.returnTypeRef.copyWithNewSourceKind(newKind)
|
||||||
}) { src, kind ->
|
}) { src, kind ->
|
||||||
@@ -196,14 +197,6 @@ fun deserializeClassToSymbol(
|
|||||||
|
|
||||||
contextReceivers.addAll(memberDeserializer.createContextReceiversForClass(classOrObject))
|
contextReceivers.addAll(memberDeserializer.createContextReceiversForClass(classOrObject))
|
||||||
}.apply {
|
}.apply {
|
||||||
//todo sealed inheritors
|
|
||||||
//if (modality == Modality.SEALED) {
|
|
||||||
// val inheritors = classOrObject.sealedSubclassFqNameList.map { nameIndex ->
|
|
||||||
// ClassId.fromString(nameResolver.getQualifiedClassName(nameIndex))
|
|
||||||
// }
|
|
||||||
// setSealedClassInheritors(inheritors)
|
|
||||||
//}
|
|
||||||
|
|
||||||
valueClassRepresentation = computeValueClassRepresentation(this, session)
|
valueClassRepresentation = computeValueClassRepresentation(this, session)
|
||||||
|
|
||||||
replaceAnnotations(
|
replaceAnnotations(
|
||||||
|
|||||||
+5
-3
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
|||||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
import org.jetbrains.kotlin.psi.stubs.impl.*
|
import org.jetbrains.kotlin.psi.stubs.impl.*
|
||||||
|
|
||||||
class StubBasedFirContractDeserializer(
|
internal class StubBasedFirContractDeserializer(
|
||||||
private val simpleFunction: FirSimpleFunction,
|
private val simpleFunction: FirSimpleFunction,
|
||||||
private val typeDeserializer: StubBasedFirTypeDeserializer
|
private val typeDeserializer: StubBasedFirTypeDeserializer
|
||||||
) {
|
) {
|
||||||
@@ -123,8 +123,10 @@ class StubBasedFirContractDeserializer(
|
|||||||
booleanValueParameterReference: KtBooleanValueParameterReference<KotlinTypeBean, Nothing?>,
|
booleanValueParameterReference: KtBooleanValueParameterReference<KotlinTypeBean, Nothing?>,
|
||||||
data: Nothing?
|
data: Nothing?
|
||||||
): ConeContractDescriptionElement {
|
): ConeContractDescriptionElement {
|
||||||
return ConeBooleanValueParameterReference(booleanValueParameterReference.parameterIndex,
|
return ConeBooleanValueParameterReference(
|
||||||
getParameterName(booleanValueParameterReference.parameterIndex))
|
booleanValueParameterReference.parameterIndex,
|
||||||
|
getParameterName(booleanValueParameterReference.parameterIndex)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getParameterName(parameterIndex: Int): String {
|
private fun getParameterName(parameterIndex: Int): String {
|
||||||
|
|||||||
+56
-38
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.containingClassForStaticMemberAttr
|
import org.jetbrains.kotlin.fir.containingClassForStaticMemberAttr
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyBackingField
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.sourceElement
|
import org.jetbrains.kotlin.fir.declarations.utils.sourceElement
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
|
import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
|
||||||
@@ -35,7 +36,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
class StubBasedFirDeserializationContext(
|
internal class StubBasedFirDeserializationContext(
|
||||||
val moduleData: FirModuleData,
|
val moduleData: FirModuleData,
|
||||||
val packageFqName: FqName,
|
val packageFqName: FqName,
|
||||||
val relativeClassName: FqName?,
|
val relativeClassName: FqName?,
|
||||||
@@ -43,7 +44,8 @@ class StubBasedFirDeserializationContext(
|
|||||||
val annotationDeserializer: StubBasedAnnotationDeserializer,
|
val annotationDeserializer: StubBasedAnnotationDeserializer,
|
||||||
val containerSource: DeserializedContainerSource?,
|
val containerSource: DeserializedContainerSource?,
|
||||||
val outerClassSymbol: FirRegularClassSymbol?,
|
val outerClassSymbol: FirRegularClassSymbol?,
|
||||||
val outerTypeParameters: List<FirTypeParameterSymbol>
|
val outerTypeParameters: List<FirTypeParameterSymbol>,
|
||||||
|
private val initialOrigin: FirDeclarationOrigin
|
||||||
) {
|
) {
|
||||||
val session: FirSession = moduleData.session
|
val session: FirSession = moduleData.session
|
||||||
|
|
||||||
@@ -67,16 +69,18 @@ class StubBasedFirDeserializationContext(
|
|||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
typeDeserializer,
|
typeDeserializer,
|
||||||
containingDeclarationSymbol,
|
containingDeclarationSymbol,
|
||||||
owner
|
owner,
|
||||||
|
initialOrigin
|
||||||
),
|
),
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
containerSource,
|
containerSource,
|
||||||
outerClassSymbol,
|
outerClassSymbol,
|
||||||
if (capturesTypeParameters) allTypeParameters else emptyList()
|
if (capturesTypeParameters) allTypeParameters else emptyList(),
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
|
|
||||||
val memberDeserializer: StubBasedFirMemberDeserializer = StubBasedFirMemberDeserializer(this)
|
val memberDeserializer: StubBasedFirMemberDeserializer = StubBasedFirMemberDeserializer(this, initialOrigin)
|
||||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, false).defaultType(allTypeParameters) }
|
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, /* local = */ false).defaultType(allTypeParameters) }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -86,7 +90,8 @@ class StubBasedFirDeserializationContext(
|
|||||||
moduleData: FirModuleData,
|
moduleData: FirModuleData,
|
||||||
annotationDeserializer: StubBasedAnnotationDeserializer,
|
annotationDeserializer: StubBasedAnnotationDeserializer,
|
||||||
containerSource: DeserializedContainerSource?,
|
containerSource: DeserializedContainerSource?,
|
||||||
outerClassSymbol: FirRegularClassSymbol
|
outerClassSymbol: FirRegularClassSymbol,
|
||||||
|
initialOrigin: FirDeclarationOrigin
|
||||||
): StubBasedFirDeserializationContext = createRootContext(
|
): StubBasedFirDeserializationContext = createRootContext(
|
||||||
moduleData,
|
moduleData,
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
@@ -95,7 +100,8 @@ class StubBasedFirDeserializationContext(
|
|||||||
classOrObject,
|
classOrObject,
|
||||||
containerSource,
|
containerSource,
|
||||||
outerClassSymbol,
|
outerClassSymbol,
|
||||||
outerClassSymbol
|
outerClassSymbol,
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createRootContext(
|
fun createRootContext(
|
||||||
@@ -106,7 +112,8 @@ class StubBasedFirDeserializationContext(
|
|||||||
owner: KtTypeParameterListOwner,
|
owner: KtTypeParameterListOwner,
|
||||||
containerSource: DeserializedContainerSource?,
|
containerSource: DeserializedContainerSource?,
|
||||||
outerClassSymbol: FirRegularClassSymbol?,
|
outerClassSymbol: FirRegularClassSymbol?,
|
||||||
containingDeclarationSymbol: FirBasedSymbol<*>?
|
containingDeclarationSymbol: FirBasedSymbol<*>?,
|
||||||
|
initialOrigin: FirDeclarationOrigin
|
||||||
): StubBasedFirDeserializationContext = StubBasedFirDeserializationContext(
|
): StubBasedFirDeserializationContext = StubBasedFirDeserializationContext(
|
||||||
moduleData,
|
moduleData,
|
||||||
packageFqName,
|
packageFqName,
|
||||||
@@ -114,14 +121,16 @@ class StubBasedFirDeserializationContext(
|
|||||||
StubBasedFirTypeDeserializer(
|
StubBasedFirTypeDeserializer(
|
||||||
moduleData,
|
moduleData,
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
null,
|
parent = null,
|
||||||
containingDeclarationSymbol,
|
containingDeclarationSymbol,
|
||||||
owner
|
owner,
|
||||||
|
initialOrigin
|
||||||
),
|
),
|
||||||
annotationDeserializer,
|
annotationDeserializer,
|
||||||
containerSource,
|
containerSource,
|
||||||
outerClassSymbol,
|
outerClassSymbol,
|
||||||
emptyList()
|
outerTypeParameters = emptyList(),
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createRootContext(
|
fun createRootContext(
|
||||||
@@ -129,21 +138,27 @@ class StubBasedFirDeserializationContext(
|
|||||||
moduleData: FirModuleData,
|
moduleData: FirModuleData,
|
||||||
callableId: CallableId,
|
callableId: CallableId,
|
||||||
parameterListOwner: KtTypeParameterListOwner,
|
parameterListOwner: KtTypeParameterListOwner,
|
||||||
symbol: FirBasedSymbol<*>
|
symbol: FirBasedSymbol<*>,
|
||||||
|
initialOrigin: FirDeclarationOrigin
|
||||||
): StubBasedFirDeserializationContext = createRootContext(
|
): StubBasedFirDeserializationContext = createRootContext(
|
||||||
moduleData,
|
moduleData,
|
||||||
StubBasedAnnotationDeserializer(session),
|
StubBasedAnnotationDeserializer(session),
|
||||||
callableId.packageName,
|
callableId.packageName,
|
||||||
callableId.className,
|
callableId.className,
|
||||||
parameterListOwner,
|
parameterListOwner,
|
||||||
JvmFromStubDecompilerSource(callableId.packageName),
|
containerSource = if (initialOrigin == FirDeclarationOrigin.BuiltIns || callableId.packageName.isRoot)
|
||||||
null,
|
null else JvmFromStubDecompilerSource(callableId.packageName),
|
||||||
symbol
|
outerClassSymbol = null,
|
||||||
|
symbol,
|
||||||
|
initialOrigin
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationContext) {
|
internal class StubBasedFirMemberDeserializer(
|
||||||
|
private val c: StubBasedFirDeserializationContext,
|
||||||
|
private val initialOrigin: FirDeclarationOrigin
|
||||||
|
) {
|
||||||
|
|
||||||
fun loadTypeAlias(typeAlias: KtTypeAlias, aliasSymbol: FirTypeAliasSymbol): FirTypeAlias {
|
fun loadTypeAlias(typeAlias: KtTypeAlias, aliasSymbol: FirTypeAliasSymbol): FirTypeAlias {
|
||||||
val name = typeAlias.nameAsSafeName
|
val name = typeAlias.nameAsSafeName
|
||||||
@@ -151,7 +166,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
return buildTypeAlias {
|
return buildTypeAlias {
|
||||||
source = KtRealPsiSourceElement(typeAlias)
|
source = KtRealPsiSourceElement(typeAlias)
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
this.name = name
|
this.name = name
|
||||||
val visibility = typeAlias.visibility
|
val visibility = typeAlias.visibility
|
||||||
status = FirResolvedDeclarationStatusImpl(
|
status = FirResolvedDeclarationStatusImpl(
|
||||||
@@ -185,7 +200,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
return buildPropertyAccessor {
|
return buildPropertyAccessor {
|
||||||
source = KtRealPsiSourceElement(getter)
|
source = KtRealPsiSourceElement(getter)
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
this.returnTypeRef = returnTypeRef
|
this.returnTypeRef = returnTypeRef
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
isGetter = true
|
isGetter = true
|
||||||
@@ -198,9 +213,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
this.propertySymbol = propertySymbol
|
this.propertySymbol = propertySymbol
|
||||||
}.apply {
|
}.apply {
|
||||||
replaceAnnotations(
|
replaceAnnotations(
|
||||||
c.annotationDeserializer.loadAnnotations(
|
c.annotationDeserializer.loadAnnotations(getter)
|
||||||
getter, AnnotationUseSiteTarget.PROPERTY_GETTER
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
containingClassForStaticMemberAttr = c.dispatchReceiver?.lookupTag
|
containingClassForStaticMemberAttr = c.dispatchReceiver?.lookupTag
|
||||||
}
|
}
|
||||||
@@ -218,7 +231,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
return buildPropertyAccessor {
|
return buildPropertyAccessor {
|
||||||
source = KtRealPsiSourceElement(setter)
|
source = KtRealPsiSourceElement(setter)
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
this.returnTypeRef = FirImplicitUnitTypeRef(source)
|
this.returnTypeRef = FirImplicitUnitTypeRef(source)
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
isGetter = false
|
isGetter = false
|
||||||
@@ -235,9 +248,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
this.propertySymbol = propertySymbol
|
this.propertySymbol = propertySymbol
|
||||||
}.apply {
|
}.apply {
|
||||||
replaceAnnotations(
|
replaceAnnotations(
|
||||||
c.annotationDeserializer.loadAnnotations(
|
c.annotationDeserializer.loadAnnotations(setter)
|
||||||
setter, AnnotationUseSiteTarget.PROPERTY_SETTER
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
containingClassForStaticMemberAttr = c.dispatchReceiver?.lookupTag
|
containingClassForStaticMemberAttr = c.dispatchReceiver?.lookupTag
|
||||||
}
|
}
|
||||||
@@ -258,7 +269,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
val getter = property.getter
|
val getter = property.getter
|
||||||
val receiverTypeReference = property.receiverTypeReference
|
val receiverTypeReference = property.receiverTypeReference
|
||||||
val receiverAnnotations = if (getter != null && receiverTypeReference != null) {
|
val receiverAnnotations = if (getter != null && receiverTypeReference != null) {
|
||||||
c.annotationDeserializer.loadAnnotations(receiverTypeReference, AnnotationUseSiteTarget.PROPERTY_GETTER)
|
c.annotationDeserializer.loadAnnotations(receiverTypeReference)
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
@@ -269,7 +280,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
return buildProperty {
|
return buildProperty {
|
||||||
source = KtRealPsiSourceElement(property)
|
source = KtRealPsiSourceElement(property)
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
this.returnTypeRef = returnTypeRef
|
this.returnTypeRef = returnTypeRef
|
||||||
receiverParameter = receiverTypeReference?.toTypeRef(local)?.let { receiverType ->
|
receiverParameter = receiverTypeReference?.toTypeRef(local)?.let { receiverType ->
|
||||||
buildReceiverParameter {
|
buildReceiverParameter {
|
||||||
@@ -295,8 +306,18 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
|
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||||
annotations +=
|
val allAnnotations = c.annotationDeserializer.loadAnnotations(property)
|
||||||
c.annotationDeserializer.loadAnnotations(property, AnnotationUseSiteTarget.PROPERTY)
|
annotations += allAnnotations.filter { it.useSiteTarget == null }
|
||||||
|
val backingFieldAnnotations =
|
||||||
|
allAnnotations.filter { it.useSiteTarget == AnnotationUseSiteTarget.FIELD || it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD }
|
||||||
|
backingField = FirDefaultPropertyBackingField(
|
||||||
|
c.moduleData,
|
||||||
|
backingFieldAnnotations.toMutableList(),
|
||||||
|
returnTypeRef,
|
||||||
|
isVar,
|
||||||
|
symbol,
|
||||||
|
status
|
||||||
|
)
|
||||||
if (getter != null) {
|
if (getter != null) {
|
||||||
this.getter = loadPropertyGetter(
|
this.getter = loadPropertyGetter(
|
||||||
getter,
|
getter,
|
||||||
@@ -356,7 +377,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
|
|
||||||
val simpleFunction = buildSimpleFunction {
|
val simpleFunction = buildSimpleFunction {
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
source = KtRealPsiSourceElement(function)
|
source = KtRealPsiSourceElement(function)
|
||||||
returnTypeRef = function.typeReference?.toTypeRef(local) ?: session.builtinTypes.unitType
|
returnTypeRef = function.typeReference?.toTypeRef(local) ?: session.builtinTypes.unitType
|
||||||
receiverParameter = function.receiverTypeReference?.toTypeRef(local)?.let { receiverType ->
|
receiverParameter = function.receiverTypeReference?.toTypeRef(local)?.let { receiverType ->
|
||||||
@@ -436,7 +457,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
}.apply {
|
}.apply {
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
source = KtRealPsiSourceElement(constructor)
|
source = KtRealPsiSourceElement(constructor)
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
returnTypeRef = delegatedSelfType
|
returnTypeRef = delegatedSelfType
|
||||||
val visibility = constructor.visibility
|
val visibility = constructor.visibility
|
||||||
val isInner = classBuilder.status.isInner
|
val isInner = classBuilder.status.isInner
|
||||||
@@ -487,7 +508,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
source = KtRealPsiSourceElement(ktParameter)
|
source = KtRealPsiSourceElement(ktParameter)
|
||||||
moduleData = c.moduleData
|
moduleData = c.moduleData
|
||||||
this.containingFunctionSymbol = functionSymbol
|
this.containingFunctionSymbol = functionSymbol
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
returnTypeRef =
|
returnTypeRef =
|
||||||
ktParameter.typeReference?.toTypeRef(c) ?: error("KtParameter $ktParameter doesn't have type, $functionSymbol")
|
ktParameter.typeReference?.toTypeRef(c) ?: error("KtParameter $ktParameter doesn't have type, $functionSymbol")
|
||||||
isVararg = ktParameter.isVarArg
|
isVararg = ktParameter.isVarArg
|
||||||
@@ -498,12 +519,9 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
symbol = FirValueParameterSymbol(name)
|
symbol = FirValueParameterSymbol(name)
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
|
|
||||||
defaultValue = if (ktParameter.hasDefaultValue()) {
|
defaultValue = if (ktParameter.hasDefaultValue() || addDefaultValue) {
|
||||||
buildExpressionStub()
|
buildExpressionStub()
|
||||||
} else null
|
} else null
|
||||||
if (addDefaultValue) {
|
|
||||||
defaultValue = buildExpressionStub()
|
|
||||||
}
|
|
||||||
isCrossinline = ktParameter.hasModifier(KtTokens.CROSSINLINE_KEYWORD)
|
isCrossinline = ktParameter.hasModifier(KtTokens.CROSSINLINE_KEYWORD)
|
||||||
isNoinline = ktParameter.hasModifier(KtTokens.NOINLINE_KEYWORD)
|
isNoinline = ktParameter.hasModifier(KtTokens.NOINLINE_KEYWORD)
|
||||||
annotations += c.annotationDeserializer.loadAnnotations(
|
annotations += c.annotationDeserializer.loadAnnotations(
|
||||||
@@ -527,7 +545,7 @@ class StubBasedFirMemberDeserializer(private val c: StubBasedFirDeserializationC
|
|||||||
val enumEntry = buildEnumEntry {
|
val enumEntry = buildEnumEntry {
|
||||||
source = KtRealPsiSourceElement(declaration)
|
source = KtRealPsiSourceElement(declaration)
|
||||||
this.moduleData = c.moduleData
|
this.moduleData = c.moduleData
|
||||||
this.origin = FirDeclarationOrigin.Library
|
this.origin = initialOrigin
|
||||||
returnTypeRef = buildResolvedTypeRef { type = enumType }
|
returnTypeRef = buildResolvedTypeRef { type = enumType }
|
||||||
name = Name.identifier(enumEntryName)
|
name = Name.identifier(enumEntryName)
|
||||||
this.symbol = FirEnumEntrySymbol(CallableId(classId, name))
|
this.symbol = FirEnumEntrySymbol(CallableId(classId, name))
|
||||||
|
|||||||
+7
-7
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
|||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.unwrapNullability
|
import org.jetbrains.kotlin.psi.psiUtil.unwrapNullability
|
||||||
@@ -38,12 +37,13 @@ import org.jetbrains.kotlin.psi.stubs.impl.*
|
|||||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
class StubBasedFirTypeDeserializer(
|
internal class StubBasedFirTypeDeserializer(
|
||||||
private val moduleData: FirModuleData,
|
private val moduleData: FirModuleData,
|
||||||
private val annotationDeserializer: StubBasedAnnotationDeserializer,
|
private val annotationDeserializer: StubBasedAnnotationDeserializer,
|
||||||
private val parent: StubBasedFirTypeDeserializer?,
|
private val parent: StubBasedFirTypeDeserializer?,
|
||||||
private val containingSymbol: FirBasedSymbol<*>?,
|
private val containingSymbol: FirBasedSymbol<*>?,
|
||||||
owner: KtTypeParameterListOwner
|
owner: KtTypeParameterListOwner,
|
||||||
|
initialOrigin: FirDeclarationOrigin
|
||||||
) {
|
) {
|
||||||
private val typeParametersByName: Map<String, FirTypeParameterSymbol>
|
private val typeParametersByName: Map<String, FirTypeParameterSymbol>
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class StubBasedFirTypeDeserializer(
|
|||||||
source = KtRealPsiSourceElement(typeParameter)
|
source = KtRealPsiSourceElement(typeParameter)
|
||||||
moduleData = this@StubBasedFirTypeDeserializer.moduleData
|
moduleData = this@StubBasedFirTypeDeserializer.moduleData
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = initialOrigin
|
||||||
this.name = name
|
this.name = name
|
||||||
this.symbol = symbol
|
this.symbol = symbol
|
||||||
this.containingDeclarationSymbol = containingSymbol ?: error("Top-level type parameter ???")
|
this.containingDeclarationSymbol = containingSymbol ?: error("Top-level type parameter ???")
|
||||||
@@ -109,7 +109,7 @@ class StubBasedFirTypeDeserializer(
|
|||||||
annotations += buildAnnotation {
|
annotations += buildAnnotation {
|
||||||
annotationTypeRef = buildResolvedTypeRef {
|
annotationTypeRef = buildResolvedTypeRef {
|
||||||
type = StandardNames.FqNames.parameterNameClassId.toLookupTag()
|
type = StandardNames.FqNames.parameterNameClassId.toLookupTag()
|
||||||
.constructClassType(emptyArray(), isNullable = false)
|
.constructClassType(ConeTypeProjection.EMPTY_ARRAY, isNullable = false)
|
||||||
}
|
}
|
||||||
this.argumentMapping = buildAnnotationArgumentMapping {
|
this.argumentMapping = buildAnnotationArgumentMapping {
|
||||||
mapping[Name.identifier("name")] =
|
mapping[Name.identifier("name")] =
|
||||||
@@ -295,12 +295,12 @@ internal fun KtUserType.classId(): ClassId {
|
|||||||
return ClassId(
|
return ClassId(
|
||||||
FqName.fromSegments(packageFragments).parent(),
|
FqName.fromSegments(packageFragments).parent(),
|
||||||
FqName(packageFragments.last()),
|
FqName(packageFragments.last()),
|
||||||
false
|
/* local = */ false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return ClassId(
|
return ClassId(
|
||||||
FqName.fromSegments(packageFragments),
|
FqName.fromSegments(packageFragments),
|
||||||
FqName.fromSegments(classFragments),
|
FqName.fromSegments(classFragments),
|
||||||
false
|
/* local = */ false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+2
-2
@@ -16,8 +16,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol
|
import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||||
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
|
|
||||||
object FirSuperclassNotAccessibleFromInterfaceChecker : FirQualifiedAccessExpressionChecker() {
|
object FirSuperclassNotAccessibleFromInterfaceChecker : FirQualifiedAccessExpressionChecker() {
|
||||||
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
@@ -29,7 +29,7 @@ object FirSuperclassNotAccessibleFromInterfaceChecker : FirQualifiedAccessExpres
|
|||||||
val containingClassSymbol =
|
val containingClassSymbol =
|
||||||
expression.toResolvedCallableSymbol()?.getContainingClassSymbol(context.session) as? FirRegularClassSymbol ?: return
|
expression.toResolvedCallableSymbol()?.getContainingClassSymbol(context.session) as? FirRegularClassSymbol ?: return
|
||||||
|
|
||||||
if (containingClassSymbol.source != null && containingClassSymbol.classKind == ClassKind.CLASS) {
|
if (containingClassSymbol.source != null && containingClassSymbol.classKind == ClassKind.CLASS && containingClassSymbol.classId != StandardClassIds.Any) {
|
||||||
reporter.reportOn(expression.explicitReceiver?.source, FirErrors.SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE, context)
|
reporter.reportOn(expression.explicitReceiver?.source, FirErrors.SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-8
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.providers.impl
|
package org.jetbrains.kotlin.fir.resolve.providers.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.StandardNames
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
|
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.fir.FirModuleData
|
import org.jetbrains.kotlin.fir.FirModuleData
|
||||||
@@ -16,14 +16,18 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.buildRegularClass
|
import org.jetbrains.kotlin.fir.declarations.builder.buildRegularClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
|
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
|
||||||
import org.jetbrains.kotlin.fir.types.constructType
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
|
import org.jetbrains.kotlin.fir.toEffectiveVisibility
|
||||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||||
import org.jetbrains.kotlin.name.*
|
import org.jetbrains.kotlin.fir.types.constructType
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.name.StandardClassIds
|
||||||
|
|
||||||
@NoMutableState
|
@NoMutableState
|
||||||
class FirCloneableSymbolProvider(
|
class FirCloneableSymbolProvider(
|
||||||
@@ -35,12 +39,14 @@ class FirCloneableSymbolProvider(
|
|||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
origin = FirDeclarationOrigin.Library
|
origin = FirDeclarationOrigin.Library
|
||||||
this.moduleData = moduleData
|
this.moduleData = moduleData
|
||||||
status = FirDeclarationStatusImpl(
|
status = FirResolvedDeclarationStatusImpl(
|
||||||
Visibilities.Public,
|
Visibilities.Public,
|
||||||
Modality.ABSTRACT
|
Modality.ABSTRACT,
|
||||||
|
EffectiveVisibility.Public
|
||||||
)
|
)
|
||||||
classKind = ClassKind.INTERFACE
|
classKind = ClassKind.INTERFACE
|
||||||
symbol = FirRegularClassSymbol(StandardClassIds.Cloneable)
|
val classSymbol = FirRegularClassSymbol(StandardClassIds.Cloneable)
|
||||||
|
symbol = classSymbol
|
||||||
declarations += buildSimpleFunction {
|
declarations += buildSimpleFunction {
|
||||||
this.moduleData = moduleData
|
this.moduleData = moduleData
|
||||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||||
@@ -48,7 +54,10 @@ class FirCloneableSymbolProvider(
|
|||||||
returnTypeRef = buildResolvedTypeRef {
|
returnTypeRef = buildResolvedTypeRef {
|
||||||
type = session.builtinTypes.anyType.type
|
type = session.builtinTypes.anyType.type
|
||||||
}
|
}
|
||||||
status = FirDeclarationStatusImpl(Visibilities.Protected, Modality.OPEN)
|
status = FirResolvedDeclarationStatusImpl(
|
||||||
|
Visibilities.Protected,
|
||||||
|
Modality.OPEN,
|
||||||
|
Visibilities.Protected.toEffectiveVisibility(classSymbol))
|
||||||
name = StandardClassIds.Callables.clone.callableName
|
name = StandardClassIds.Callables.clone.callableName
|
||||||
symbol = FirNamedFunctionSymbol(StandardClassIds.Callables.clone)
|
symbol = FirNamedFunctionSymbol(StandardClassIds.Callables.clone)
|
||||||
dispatchReceiverType = this@buildRegularClass.symbol.constructType(emptyArray(), isNullable = false)
|
dispatchReceiverType = this@buildRegularClass.symbol.constructType(emptyArray(), isNullable = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user