IR: use default parameters in Ir...Impl constructors
This commit is contained in:
@@ -38,17 +38,17 @@ class IrClassImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrClassSymbol,
|
||||
override val name: Name,
|
||||
override val kind: ClassKind,
|
||||
visibility: Visibility,
|
||||
modality: Modality,
|
||||
override val isCompanion: Boolean,
|
||||
override val isInner: Boolean,
|
||||
override val isData: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isInline: Boolean,
|
||||
override val isExpect: Boolean,
|
||||
override val isFun: Boolean
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val kind: ClassKind = symbol.descriptor.kind,
|
||||
visibility: Visibility = symbol.descriptor.visibility,
|
||||
modality: Modality = symbol.descriptor.modality,
|
||||
override val isCompanion: Boolean = symbol.descriptor.isCompanionObject,
|
||||
override val isInner: Boolean = symbol.descriptor.isInner,
|
||||
override val isData: Boolean = symbol.descriptor.isData,
|
||||
override val isExternal: Boolean = symbol.descriptor.isEffectivelyExternal(),
|
||||
override val isInline: Boolean = symbol.descriptor.isInline,
|
||||
override val isExpect: Boolean = symbol.descriptor.isExpect,
|
||||
override val isFun: Boolean = symbol.descriptor.isFun
|
||||
) :
|
||||
IrDeclarationBase<ClassCarrier>(startOffset, endOffset, origin),
|
||||
IrClass,
|
||||
|
||||
+6
-6
@@ -32,13 +32,13 @@ class IrConstructorImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrConstructorSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
name: Name = symbol.descriptor.name,
|
||||
visibility: Visibility = symbol.descriptor.visibility,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isPrimary: Boolean,
|
||||
isExpect: Boolean
|
||||
isInline: Boolean = symbol.descriptor.isInline,
|
||||
isExternal: Boolean = symbol.descriptor.isEffectivelyExternal(),
|
||||
override val isPrimary: Boolean = symbol.descriptor.isPrimary,
|
||||
isExpect: Boolean = symbol.descriptor.isExpect
|
||||
) :
|
||||
IrFunctionBase<ConstructorCarrier>(
|
||||
startOffset, endOffset, origin, name,
|
||||
|
||||
@@ -36,13 +36,13 @@ class IrFieldImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrFieldSymbol,
|
||||
override val name: Name,
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val type: IrType,
|
||||
override val visibility: Visibility,
|
||||
override val isFinal: Boolean,
|
||||
override val isExternal: Boolean,
|
||||
override val isStatic: Boolean,
|
||||
override val isFakeOverride: Boolean
|
||||
override val visibility: Visibility = symbol.descriptor.visibility,
|
||||
override val isFinal: Boolean = !symbol.descriptor.isVar,
|
||||
override val isExternal: Boolean = symbol.descriptor.isEffectivelyExternal(),
|
||||
override val isStatic: Boolean = symbol.descriptor.dispatchReceiverParameter == null,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
) : IrDeclarationBase<FieldCarrier>(startOffset, endOffset, origin),
|
||||
IrField,
|
||||
FieldCarrier {
|
||||
|
||||
+10
-10
@@ -23,17 +23,17 @@ class IrFunctionImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrSimpleFunctionSymbol,
|
||||
name: Name,
|
||||
visibility: Visibility,
|
||||
override val modality: Modality,
|
||||
name: Name = symbol.descriptor.name,
|
||||
visibility: Visibility = symbol.descriptor.visibility,
|
||||
override val modality: Modality = symbol.descriptor.modality,
|
||||
returnType: IrType,
|
||||
isInline: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val isTailrec: Boolean,
|
||||
override val isSuspend: Boolean,
|
||||
override val isOperator: Boolean,
|
||||
isExpect: Boolean,
|
||||
override val isFakeOverride: Boolean
|
||||
isInline: Boolean = symbol.descriptor.isInline,
|
||||
isExternal: Boolean = symbol.descriptor.isExternal,
|
||||
override val isTailrec: Boolean = symbol.descriptor.isTailrec,
|
||||
override val isSuspend: Boolean = symbol.descriptor.isSuspend,
|
||||
override val isOperator: Boolean = symbol.descriptor.isOperator,
|
||||
isExpect: Boolean = symbol.descriptor.isExpect,
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
) :
|
||||
IrFunctionBase<FunctionCarrier>(startOffset, endOffset, origin, name, visibility, isInline, isExternal, isExpect, returnType),
|
||||
IrSimpleFunction,
|
||||
|
||||
+2
-2
@@ -32,9 +32,9 @@ class IrLocalDelegatedPropertyImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrLocalDelegatedPropertySymbol,
|
||||
override val name: Name,
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val type: IrType,
|
||||
override val isVar: Boolean
|
||||
override val isVar: Boolean = symbol.descriptor.isVar
|
||||
) :
|
||||
IrDeclarationBase<LocalDelegatedPropertyCarrier>(startOffset, endOffset, origin),
|
||||
IrLocalDelegatedProperty,
|
||||
|
||||
+4
-18
@@ -34,29 +34,15 @@ class IrTypeParameterImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrTypeParameterSymbol,
|
||||
override val name: Name,
|
||||
override val index: Int,
|
||||
override val isReified: Boolean,
|
||||
override val variance: Variance
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val index: Int = symbol.descriptor.index,
|
||||
override val isReified: Boolean = symbol.descriptor.isReified,
|
||||
override val variance: Variance = symbol.descriptor.variance
|
||||
) :
|
||||
IrDeclarationBase<TypeParameterCarrier>(startOffset, endOffset, origin),
|
||||
IrTypeParameter,
|
||||
TypeParameterCarrier {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrTypeParameterSymbol
|
||||
) :
|
||||
this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
symbol.descriptor.name,
|
||||
symbol.descriptor.index,
|
||||
symbol.descriptor.isReified,
|
||||
symbol.descriptor.variance
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
|
||||
+4
-4
@@ -35,12 +35,12 @@ class IrValueParameterImpl(
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
override val symbol: IrValueParameterSymbol,
|
||||
override val name: Name,
|
||||
override val index: Int,
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val index: Int = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1,
|
||||
override val type: IrType,
|
||||
override val varargElementType: IrType?,
|
||||
override val isCrossinline: Boolean,
|
||||
override val isNoinline: Boolean
|
||||
override val isCrossinline: Boolean = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false,
|
||||
override val isNoinline: Boolean = symbol.descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false
|
||||
) :
|
||||
IrDeclarationBase<ValueParameterCarrier>(startOffset, endOffset, origin),
|
||||
IrValueParameter,
|
||||
|
||||
@@ -36,11 +36,11 @@ class IrVariableImpl(
|
||||
override val endOffset: Int,
|
||||
override var origin: IrDeclarationOrigin,
|
||||
override val symbol: IrVariableSymbol,
|
||||
override val name: Name,
|
||||
override val name: Name = symbol.descriptor.name,
|
||||
override val type: IrType,
|
||||
override val isVar: Boolean,
|
||||
override val isConst: Boolean,
|
||||
override val isLateinit: Boolean
|
||||
override val isVar: Boolean = symbol.descriptor.isVar,
|
||||
override val isConst: Boolean = symbol.descriptor.isConst,
|
||||
override val isLateinit: Boolean = symbol.descriptor.isLateInit
|
||||
) : IrVariable {
|
||||
|
||||
private var _parent: IrDeclarationParent? = null
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
||||
|
||||
interface IrProvider {
|
||||
@@ -87,7 +86,10 @@ interface ReferenceSymbolTable {
|
||||
fun leaveScope(owner: DeclarationDescriptor)
|
||||
}
|
||||
|
||||
open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: NameProvider = NameProvider.DEFAULT) : ReferenceSymbolTable {
|
||||
open class SymbolTable(
|
||||
val signaturer: IdSignatureComposer,
|
||||
private val nameProvider: NameProvider = NameProvider.DEFAULT
|
||||
) : ReferenceSymbolTable {
|
||||
|
||||
@Suppress("LeakingThis")
|
||||
val lazyWrapper = IrLazySymbolTable(this)
|
||||
@@ -375,15 +377,8 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
classFactory: (IrClassSymbol) -> IrClass = {
|
||||
IrClassImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor), descriptor.kind,
|
||||
visibility, modality,
|
||||
isCompanion = descriptor.isCompanionObject,
|
||||
isInner = descriptor.isInner,
|
||||
isData = descriptor.isData,
|
||||
isExternal = descriptor.isExternal,
|
||||
isInline = descriptor.isInline,
|
||||
isExpect = descriptor.isExpect,
|
||||
isFun = descriptor.isFun
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
visibility = visibility, modality = modality,
|
||||
).apply { metadata = MetadataSource.Class(it.descriptor) }
|
||||
}
|
||||
): IrClass {
|
||||
@@ -430,12 +425,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
IrConstructorImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
descriptor.visibility,
|
||||
returnType = IrUninitializedType,
|
||||
isInline = descriptor.isInline,
|
||||
isExternal = descriptor.isEffectivelyExternal(),
|
||||
isPrimary = descriptor.isPrimary,
|
||||
isExpect = descriptor.isExpect
|
||||
returnType = IrUninitializedType
|
||||
).apply {
|
||||
metadata = MetadataSource.Function(it.descriptor)
|
||||
}
|
||||
@@ -530,10 +520,6 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
type, visibility ?: it.descriptor.visibility,
|
||||
isFinal = !descriptor.isVar,
|
||||
isExternal = descriptor.isExternal,
|
||||
isStatic = descriptor.dispatchReceiverParameter == null,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(it.descriptor)
|
||||
}
|
||||
@@ -678,16 +664,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
IrFunctionImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
returnType = IrUninitializedType,
|
||||
visibility = descriptor.visibility,
|
||||
modality = descriptor.modality,
|
||||
isInline = descriptor.isInline,
|
||||
isExternal = descriptor.isExternal,
|
||||
isTailrec = descriptor.isTailrec,
|
||||
isSuspend = descriptor.isSuspend,
|
||||
isOperator = descriptor.isOperator,
|
||||
isExpect = descriptor.isExpect,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
returnType = IrUninitializedType
|
||||
).apply {
|
||||
metadata = MetadataSource.Function(it.descriptor)
|
||||
}
|
||||
@@ -739,11 +716,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeParameterDescriptor,
|
||||
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
||||
IrTypeParameterImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
descriptor.index, descriptor.isReified, descriptor.variance
|
||||
)
|
||||
IrTypeParameterImpl(startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor))
|
||||
}
|
||||
): IrTypeParameter =
|
||||
globalTypeParameterSymbolTable.declare(
|
||||
@@ -767,11 +740,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeParameterDescriptor,
|
||||
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
||||
IrTypeParameterImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
descriptor.index, descriptor.isReified, descriptor.variance
|
||||
)
|
||||
IrTypeParameterImpl(startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor))
|
||||
}
|
||||
): IrTypeParameter =
|
||||
scopedTypeParameterSymbolTable.declare(
|
||||
@@ -799,14 +768,10 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
type: IrType,
|
||||
varargElementType: IrType? = null,
|
||||
valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = {
|
||||
val valueParameterDescriptor = descriptor as? ValueParameterDescriptor
|
||||
IrValueParameterImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
valueParameterDescriptor?.index ?: -1,
|
||||
type, varargElementType,
|
||||
isCrossinline = valueParameterDescriptor?.isCrossinline ?: false,
|
||||
isNoinline = valueParameterDescriptor?.isNoinline ?: false
|
||||
type = type, varargElementType = varargElementType,
|
||||
)
|
||||
}
|
||||
): IrValueParameter =
|
||||
@@ -843,14 +808,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
descriptor: VariableDescriptor,
|
||||
type: IrType,
|
||||
variableFactory: (IrVariableSymbol) -> IrVariable = {
|
||||
IrVariableImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
nameProvider.nameForDeclaration(descriptor),
|
||||
type,
|
||||
isVar = descriptor.isVar,
|
||||
isConst = descriptor.isConst,
|
||||
isLateinit = descriptor.isLateInit
|
||||
)
|
||||
IrVariableImpl(startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor), type)
|
||||
}
|
||||
|
||||
): IrVariable =
|
||||
@@ -885,11 +843,7 @@ open class SymbolTable(val signaturer: IdSignatureComposer, val nameProvider: Na
|
||||
localDelegatedPropertySymbolTable.declareLocal(
|
||||
descriptor,
|
||||
{ IrLocalDelegatedPropertySymbolImpl(descriptor) },
|
||||
{
|
||||
IrLocalDelegatedPropertyImpl(
|
||||
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor), type, descriptor.isVar
|
||||
)
|
||||
}
|
||||
{ IrLocalDelegatedPropertyImpl(startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor), type) }
|
||||
)
|
||||
|
||||
fun referenceLocalDelegatedProperty(descriptor: VariableDescriptorWithAccessors) =
|
||||
|
||||
Reference in New Issue
Block a user