IR: remove convenience factory for IrTypeAliasImpl
This commit is contained in:
+14
-14
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrErrorDeclarationImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl
|
||||
@@ -79,20 +82,17 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
||||
fun generateClassOrObjectDeclaration(ktClassOrObject: KtPureClassOrObject): IrClass =
|
||||
ClassGenerator(this).generateClass(ktClassOrObject)
|
||||
|
||||
private fun generateTypeAliasDeclaration(ktTypeAlias: KtTypeAlias): IrTypeAlias {
|
||||
val typeAliasDescriptor = getOrFail(BindingContext.TYPE_ALIAS, ktTypeAlias)
|
||||
val irTypeAlias = context.symbolTable.declareTypeAlias(typeAliasDescriptor) { symbol ->
|
||||
IrTypeAliasImpl.fromSymbolDescriptor(
|
||||
ktTypeAlias.startOffsetSkippingComments, ktTypeAlias.endOffset,
|
||||
symbol,
|
||||
typeAliasDescriptor.expandedType.toIrType(),
|
||||
IrDeclarationOrigin.DEFINED,
|
||||
typeAliasDescriptor
|
||||
)
|
||||
private fun generateTypeAliasDeclaration(ktTypeAlias: KtTypeAlias): IrTypeAlias =
|
||||
with(getOrFail(BindingContext.TYPE_ALIAS, ktTypeAlias)) {
|
||||
context.symbolTable.declareTypeAlias(this) { symbol ->
|
||||
IrTypeAliasImpl(
|
||||
ktTypeAlias.startOffsetSkippingComments, ktTypeAlias.endOffset, symbol,
|
||||
name, visibility, expandedType.toIrType(), isActual, IrDeclarationOrigin.DEFINED
|
||||
)
|
||||
}.also {
|
||||
generateGlobalTypeParametersDeclarations(it, declaredTypeParameters)
|
||||
}
|
||||
}
|
||||
generateGlobalTypeParametersDeclarations(irTypeAlias, typeAliasDescriptor.declaredTypeParameters)
|
||||
return irTypeAlias
|
||||
}
|
||||
|
||||
fun generateGlobalTypeParametersDeclarations(
|
||||
irTypeParametersOwner: IrTypeParametersContainer,
|
||||
|
||||
+4
-8
@@ -110,14 +110,10 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeAliasDescriptor,
|
||||
symbol: IrTypeAliasSymbol
|
||||
): IrTypeAlias {
|
||||
val irAlias = IrTypeAliasImpl.fromSymbolDescriptor(
|
||||
startOffset, endOffset, symbol, descriptor.expandedType.toIrType(), origin, descriptor
|
||||
)
|
||||
|
||||
generateGlobalTypeParametersDeclarations(irAlias, descriptor.declaredTypeParameters)
|
||||
|
||||
return irAlias
|
||||
): IrTypeAlias = with(descriptor) {
|
||||
IrTypeAliasImpl(startOffset, endOffset, symbol, name, visibility, expandedType.toIrType(), isActual, origin).also {
|
||||
generateGlobalTypeParametersDeclarations(it, declaredTypeParameters)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement): IrValueParameter {
|
||||
|
||||
@@ -61,24 +61,4 @@ class IrTypeAliasImpl(
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
typeParameters = typeParameters.transformIfNeeded(transformer, data)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun fromSymbolDescriptor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
symbol: IrTypeAliasSymbol,
|
||||
expandedType: IrType,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeAliasDescriptor
|
||||
) =
|
||||
IrTypeAliasImpl(
|
||||
startOffset, endOffset,
|
||||
symbol,
|
||||
descriptor.name,
|
||||
descriptor.visibility,
|
||||
expandedType,
|
||||
descriptor.isActual,
|
||||
origin
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user