[IR] Introduce new IdSignatures
FileSignature, CompositeSignature, LocalSignature They are needed to make possible reference any non-local declaration via signature, including private signature, type parameters and so on. - Support those new signatures in proto and klibs - Rename `isPublic` -> `isPubliclyVisible` due to changed semantic - Fix FIR - clean up code
This commit is contained in:
committed by
TeamCityServer
parent
7139785036
commit
6cdac22a23
+1
-1
@@ -28,7 +28,7 @@ class GeneratorContext(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
val symbolTable: SymbolTable,
|
||||
val extensions: GeneratorExtensions,
|
||||
val typeTranslator: TypeTranslator,
|
||||
val typeTranslator: TypeTranslatorImpl,
|
||||
val constantValueGenerator: ConstantValueGenerator,
|
||||
override val irBuiltIns: IrBuiltIns
|
||||
) : IrGeneratorContext {
|
||||
|
||||
+4
-19
@@ -23,13 +23,10 @@ import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.linkage.IrDeserializer
|
||||
import org.jetbrains.kotlin.ir.linkage.IrProvider
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.StubGeneratorExtensions
|
||||
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi2ir.transformations.insertImplicitCasts
|
||||
@@ -47,26 +44,14 @@ class ModuleGenerator(
|
||||
IrModuleFragmentImpl(context.moduleDescriptor, context.irBuiltIns).also { irModule ->
|
||||
val irDeclarationGenerator = DeclarationGenerator(context)
|
||||
ktFiles.toSet().mapTo(irModule.files) { ktFile ->
|
||||
generateSingleFile(irDeclarationGenerator, ktFile, irModule)
|
||||
context.typeTranslator.inFile(ktFile) {
|
||||
generateSingleFile(irDeclarationGenerator, ktFile, irModule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateUnboundSymbolsAsDependencies(
|
||||
irModule: IrModuleFragment,
|
||||
deserializer: IrDeserializer? = null,
|
||||
extensions: StubGeneratorExtensions = StubGeneratorExtensions.EMPTY
|
||||
) {
|
||||
val fullIrProvidersList = generateTypicalIrProviderList(
|
||||
irModule.descriptor, context.irBuiltIns, context.symbolTable, deserializer,
|
||||
extensions
|
||||
)
|
||||
ExternalDependenciesGenerator(context.symbolTable, fullIrProvidersList)
|
||||
.generateUnboundSymbolsAsDependencies()
|
||||
}
|
||||
|
||||
fun generateUnboundSymbolsAsDependencies(irProviders: List<IrProvider>) {
|
||||
ExternalDependenciesGenerator(context.symbolTable, irProviders)
|
||||
.generateUnboundSymbolsAsDependencies()
|
||||
ExternalDependenciesGenerator(context.symbolTable, irProviders).generateUnboundSymbolsAsDependencies()
|
||||
}
|
||||
|
||||
private fun generateSingleFile(irDeclarationGenerator: DeclarationGenerator, ktFile: KtFile, module: IrModuleFragment): IrFileImpl {
|
||||
|
||||
+23
@@ -6,8 +6,12 @@
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
class TypeTranslatorImpl(
|
||||
@@ -38,4 +42,23 @@ class TypeTranslatorImpl(
|
||||
|
||||
override fun commonSupertype(types: Collection<KotlinType>): KotlinType =
|
||||
CommonSupertypes.commonSupertype(types)
|
||||
|
||||
override fun isTypeAliasAccessibleHere(typeAliasDescriptor: TypeAliasDescriptor): Boolean {
|
||||
if (typeAliasDescriptor.visibility != DescriptorVisibilities.PRIVATE) return true
|
||||
|
||||
val psiFile = typeAliasDescriptor.source.getPsi()?.containingFile ?: return false
|
||||
|
||||
return psiFile == currentFile
|
||||
}
|
||||
|
||||
private var currentFile: KtFile? = null
|
||||
|
||||
fun <R> inFile(ktFile: KtFile?, block: () -> R): R {
|
||||
try {
|
||||
currentFile = ktFile
|
||||
return block()
|
||||
} finally {
|
||||
currentFile = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user