[IR] Reorder parameters in IrFactory#createTypeParameter
This is to prepare for IrFactory auto-generation (KT-59308).
This commit is contained in:
committed by
Space Team
parent
b1f7b5e982
commit
2b4a08524d
+24
-12
@@ -440,10 +440,14 @@ class Fir2IrClassifierStorage(
|
|||||||
symbolFactory = { IrTypeParameterPublicSymbolImpl(signature) }
|
symbolFactory = { IrTypeParameterPublicSymbolImpl(signature) }
|
||||||
) { symbol ->
|
) { symbol ->
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
startOffset, endOffset, origin, symbol,
|
startOffset = startOffset,
|
||||||
name, if (index < 0) 0 else index,
|
endOffset = endOffset,
|
||||||
isReified,
|
origin = origin,
|
||||||
variance
|
name = name,
|
||||||
|
symbol = symbol,
|
||||||
|
variance = variance,
|
||||||
|
index = if (index < 0) 0 else index,
|
||||||
|
isReified = isReified,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -452,19 +456,27 @@ class Fir2IrClassifierStorage(
|
|||||||
symbolFactory = { IrTypeParameterPublicSymbolImpl(signature) }
|
symbolFactory = { IrTypeParameterPublicSymbolImpl(signature) }
|
||||||
) { symbol ->
|
) { symbol ->
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
startOffset, endOffset, origin, symbol,
|
startOffset = startOffset,
|
||||||
name, if (index < 0) 0 else index,
|
endOffset = endOffset,
|
||||||
isReified,
|
origin = origin,
|
||||||
variance
|
name = name,
|
||||||
|
symbol = symbol,
|
||||||
|
variance = variance,
|
||||||
|
index = if (index < 0) 0 else index,
|
||||||
|
isReified = isReified,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} ?: irFactory.createTypeParameter(
|
} ?: irFactory.createTypeParameter(
|
||||||
startOffset, endOffset, origin, IrTypeParameterSymbolImpl(),
|
startOffset = startOffset,
|
||||||
name, if (index < 0) 0 else index,
|
endOffset = endOffset,
|
||||||
isReified,
|
origin = origin,
|
||||||
variance
|
name = name,
|
||||||
|
symbol = IrTypeParameterSymbolImpl(),
|
||||||
|
variance = variance,
|
||||||
|
index = if (index < 0) 0 else index,
|
||||||
|
isReified = isReified,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -458,8 +458,14 @@ class IrBuiltInsOverFir(
|
|||||||
|
|
||||||
checkNotNullSymbol = run {
|
checkNotNullSymbol = run {
|
||||||
val typeParameter: IrTypeParameter = irFactory.createTypeParameter(
|
val typeParameter: IrTypeParameter = irFactory.createTypeParameter(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, BUILTIN_OPERATOR, IrTypeParameterSymbolImpl(), Name.identifier("T0"), 0, true,
|
startOffset = UNDEFINED_OFFSET,
|
||||||
Variance.INVARIANT
|
endOffset = UNDEFINED_OFFSET,
|
||||||
|
origin = BUILTIN_OPERATOR,
|
||||||
|
name = Name.identifier("T0"),
|
||||||
|
symbol = IrTypeParameterSymbolImpl(),
|
||||||
|
variance = Variance.INVARIANT,
|
||||||
|
index = 0,
|
||||||
|
isReified = true
|
||||||
).apply {
|
).apply {
|
||||||
superTypes = listOf(anyType)
|
superTypes = listOf(anyType)
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -219,7 +219,14 @@ class IrDescriptorBasedFunctionFactory(
|
|||||||
|
|
||||||
val pSymbol = descriptorFactory.typeParameterDescriptor(index) {
|
val pSymbol = descriptorFactory.typeParameterDescriptor(index) {
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
offset, offset, classOrigin, it, pName, index++, false, Variance.IN_VARIANCE
|
startOffset = offset,
|
||||||
|
endOffset = offset,
|
||||||
|
origin = classOrigin,
|
||||||
|
name = pName,
|
||||||
|
symbol = it,
|
||||||
|
variance = Variance.IN_VARIANCE,
|
||||||
|
index = index++,
|
||||||
|
isReified = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val pDeclaration = pSymbol.owner
|
val pDeclaration = pSymbol.owner
|
||||||
@@ -231,7 +238,14 @@ class IrDescriptorBasedFunctionFactory(
|
|||||||
|
|
||||||
val rSymbol = descriptorFactory.typeParameterDescriptor(index) {
|
val rSymbol = descriptorFactory.typeParameterDescriptor(index) {
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
offset, offset, classOrigin, it, Name.identifier("R"), index, false, Variance.OUT_VARIANCE
|
startOffset = offset,
|
||||||
|
endOffset = offset,
|
||||||
|
origin = classOrigin,
|
||||||
|
name = Name.identifier("R"),
|
||||||
|
symbol = it,
|
||||||
|
variance = Variance.OUT_VARIANCE,
|
||||||
|
index = index,
|
||||||
|
isReified = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val rDeclaration = rSymbol.owner
|
val rDeclaration = rSymbol.owner
|
||||||
|
|||||||
+8
-3
@@ -321,9 +321,14 @@ fun IrFunction.addValueParameter(name: Name, type: IrType, origin: IrDeclaration
|
|||||||
internal fun IrFactory.buildTypeParameter(builder: IrTypeParameterBuilder, parent: IrDeclarationParent): IrTypeParameter =
|
internal fun IrFactory.buildTypeParameter(builder: IrTypeParameterBuilder, parent: IrDeclarationParent): IrTypeParameter =
|
||||||
with(builder) {
|
with(builder) {
|
||||||
createTypeParameter(
|
createTypeParameter(
|
||||||
startOffset, endOffset, origin,
|
startOffset = startOffset,
|
||||||
IrTypeParameterSymbolImpl(),
|
endOffset = endOffset,
|
||||||
name, index, isReified, variance
|
origin = origin,
|
||||||
|
name = name,
|
||||||
|
symbol = IrTypeParameterSymbolImpl(),
|
||||||
|
variance = variance,
|
||||||
|
index = index,
|
||||||
|
isReified = isReified,
|
||||||
).also {
|
).also {
|
||||||
it.superTypes = superTypes
|
it.superTypes = superTypes
|
||||||
it.parent = parent
|
it.parent = parent
|
||||||
|
|||||||
@@ -183,11 +183,11 @@ interface IrFactory {
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrTypeParameterSymbol,
|
|
||||||
name: Name,
|
name: Name,
|
||||||
|
symbol: IrTypeParameterSymbol,
|
||||||
|
variance: Variance,
|
||||||
index: Int,
|
index: Int,
|
||||||
isReified: Boolean,
|
isReified: Boolean,
|
||||||
variance: Variance,
|
|
||||||
): IrTypeParameter
|
): IrTypeParameter
|
||||||
|
|
||||||
fun createValueParameter(
|
fun createValueParameter(
|
||||||
|
|||||||
@@ -224,11 +224,11 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrTypeParameterSymbol,
|
|
||||||
name: Name,
|
name: Name,
|
||||||
|
symbol: IrTypeParameterSymbol,
|
||||||
|
variance: Variance,
|
||||||
index: Int,
|
index: Int,
|
||||||
isReified: Boolean,
|
isReified: Boolean,
|
||||||
variance: Variance,
|
|
||||||
): IrTypeParameter =
|
): IrTypeParameter =
|
||||||
IrTypeParameterImpl(startOffset, endOffset, origin, symbol, name, index, isReified, variance, factory = this)
|
IrTypeParameterImpl(startOffset, endOffset, origin, symbol, name, index, isReified, variance, factory = this)
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -346,21 +346,21 @@ class IrFactoryImplForJsIC(override val stageController: StageController) : Abst
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrTypeParameterSymbol,
|
|
||||||
name: Name,
|
name: Name,
|
||||||
|
symbol: IrTypeParameterSymbol,
|
||||||
|
variance: Variance,
|
||||||
index: Int,
|
index: Int,
|
||||||
isReified: Boolean,
|
isReified: Boolean
|
||||||
variance: Variance
|
|
||||||
): IrTypeParameter {
|
): IrTypeParameter {
|
||||||
return super.createTypeParameter(
|
return super.createTypeParameter(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
origin,
|
origin,
|
||||||
symbol,
|
|
||||||
name,
|
name,
|
||||||
|
symbol,
|
||||||
|
variance,
|
||||||
index,
|
index,
|
||||||
isReified,
|
isReified,
|
||||||
variance,
|
|
||||||
).register()
|
).register()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,13 +185,13 @@ class LazyIrFactory(
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrTypeParameterSymbol,
|
|
||||||
name: Name,
|
name: Name,
|
||||||
|
symbol: IrTypeParameterSymbol,
|
||||||
|
variance: Variance,
|
||||||
index: Int,
|
index: Int,
|
||||||
isReified: Boolean,
|
isReified: Boolean
|
||||||
variance: Variance
|
|
||||||
): IrTypeParameter = if (symbol.isBound)
|
): IrTypeParameter = if (symbol.isBound)
|
||||||
symbol.owner
|
symbol.owner
|
||||||
else
|
else
|
||||||
delegate.createTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance)
|
delegate.createTypeParameter(startOffset, endOffset, origin, name, symbol, variance, index, isReified)
|
||||||
}
|
}
|
||||||
@@ -342,13 +342,14 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
|
|
||||||
private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter =
|
private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter =
|
||||||
declaration.factory.createTypeParameter(
|
declaration.factory.createTypeParameter(
|
||||||
declaration.startOffset, declaration.endOffset,
|
startOffset = declaration.startOffset,
|
||||||
mapDeclarationOrigin(declaration.origin),
|
endOffset = declaration.endOffset,
|
||||||
symbolRemapper.getDeclaredTypeParameter(declaration.symbol),
|
origin = mapDeclarationOrigin(declaration.origin),
|
||||||
symbolRenamer.getTypeParameterName(declaration.symbol),
|
name = symbolRenamer.getTypeParameterName(declaration.symbol),
|
||||||
declaration.index,
|
symbol = symbolRemapper.getDeclaredTypeParameter(declaration.symbol),
|
||||||
declaration.isReified,
|
variance = declaration.variance,
|
||||||
declaration.variance
|
index = declaration.index,
|
||||||
|
isReified = declaration.isReified,
|
||||||
).apply {
|
).apply {
|
||||||
transformAnnotations(declaration)
|
transformAnnotations(declaration)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -988,8 +988,14 @@ open class SymbolTable(
|
|||||||
descriptor: TypeParameterDescriptor,
|
descriptor: TypeParameterDescriptor,
|
||||||
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor),
|
startOffset = startOffset,
|
||||||
it.descriptor.index, it.descriptor.isReified, it.descriptor.variance
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
name = nameProvider.nameForDeclaration(descriptor),
|
||||||
|
symbol = it,
|
||||||
|
variance = it.descriptor.variance,
|
||||||
|
index = it.descriptor.index,
|
||||||
|
isReified = it.descriptor.isReified
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
): IrTypeParameter =
|
): IrTypeParameter =
|
||||||
@@ -1015,8 +1021,14 @@ open class SymbolTable(
|
|||||||
descriptor: TypeParameterDescriptor,
|
descriptor: TypeParameterDescriptor,
|
||||||
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
typeParameterFactory: (IrTypeParameterSymbol) -> IrTypeParameter = {
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor),
|
startOffset = startOffset,
|
||||||
it.descriptor.index, it.descriptor.isReified, it.descriptor.variance
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
name = nameProvider.nameForDeclaration(descriptor),
|
||||||
|
symbol = it,
|
||||||
|
variance = it.descriptor.variance,
|
||||||
|
index = it.descriptor.index,
|
||||||
|
isReified = it.descriptor.isReified
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
): IrTypeParameter =
|
): IrTypeParameter =
|
||||||
|
|||||||
+8
-8
@@ -283,14 +283,14 @@ class IrDeclarationDeserializer(
|
|||||||
|
|
||||||
val factory = { symbol: IrTypeParameterSymbol ->
|
val factory = { symbol: IrTypeParameterSymbol ->
|
||||||
irFactory.createTypeParameter(
|
irFactory.createTypeParameter(
|
||||||
coordinates.startOffset,
|
startOffset = coordinates.startOffset,
|
||||||
coordinates.endOffset,
|
endOffset = coordinates.endOffset,
|
||||||
deserializeIrDeclarationOrigin(proto.base.originName),
|
origin = deserializeIrDeclarationOrigin(proto.base.originName),
|
||||||
symbol,
|
name = name,
|
||||||
name,
|
symbol = symbol,
|
||||||
index,
|
variance = flags.variance,
|
||||||
flags.isReified,
|
index = index,
|
||||||
flags.variance
|
isReified = flags.isReified
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
|||||||
import org.jetbrains.kotlin.backend.common.ir.addDispatchReceiver
|
import org.jetbrains.kotlin.backend.common.ir.addDispatchReceiver
|
||||||
import org.jetbrains.kotlin.backend.common.lower.ConstructorDelegationKind
|
import org.jetbrains.kotlin.backend.common.lower.ConstructorDelegationKind
|
||||||
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.common.lower.callsSuper
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.delegationKind
|
import org.jetbrains.kotlin.backend.common.lower.delegationKind
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
@@ -346,8 +345,14 @@ private val IrClassifierSymbol.isFragment: Boolean
|
|||||||
private fun TranslationPluginContext.declareTypeParameterStub(typeParameterDescriptor: TypeParameterDescriptor): IrTypeParameter {
|
private fun TranslationPluginContext.declareTypeParameterStub(typeParameterDescriptor: TypeParameterDescriptor): IrTypeParameter {
|
||||||
val symbol = IrTypeParameterSymbolImpl(typeParameterDescriptor)
|
val symbol = IrTypeParameterSymbolImpl(typeParameterDescriptor)
|
||||||
return irFactory.createTypeParameter(
|
return irFactory.createTypeParameter(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.DEFINED, symbol, typeParameterDescriptor.name,
|
startOffset = UNDEFINED_OFFSET,
|
||||||
typeParameterDescriptor.index, typeParameterDescriptor.isReified, typeParameterDescriptor.variance
|
endOffset = UNDEFINED_OFFSET,
|
||||||
|
origin = IrDeclarationOrigin.DEFINED,
|
||||||
|
name = typeParameterDescriptor.name,
|
||||||
|
symbol = symbol,
|
||||||
|
variance = typeParameterDescriptor.variance,
|
||||||
|
index = typeParameterDescriptor.index,
|
||||||
|
isReified = typeParameterDescriptor.isReified,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user