[FIR2IR] Merge declareParameters and bindAndDeclareParameters functions
This commit is contained in:
committed by
Space Team
parent
d4f55894b4
commit
3013e3549c
+19
-31
@@ -502,19 +502,32 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addContextReceiverParametersTo(
|
||||||
|
contextReceivers: List<FirContextReceiver>,
|
||||||
|
parent: IrFunction,
|
||||||
|
result: MutableList<IrValueParameter>,
|
||||||
|
) {
|
||||||
|
contextReceivers.mapIndexedTo(result) { index, contextReceiver ->
|
||||||
|
createIrParameterFromContextReceiver(contextReceiver, index).apply {
|
||||||
|
this.parent = parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In perfect world dispatchReceiverType should always be the default type of containing class
|
* In perfect world dispatchReceiverType should always be the default type of containing class
|
||||||
* But fake-overrides for members from Any have special rules for type of dispatch receiver
|
* But fake-overrides for members from Any have special rules for type of dispatch receiver
|
||||||
*/
|
*/
|
||||||
private fun <T : IrFunction> T.declareParameters(
|
private fun IrFunction.declareParameters(
|
||||||
function: FirFunction?,
|
function: FirFunction?,
|
||||||
containingClass: IrClass?,
|
irParent: IrDeclarationParent?,
|
||||||
dispatchReceiverType: IrType?, // has no sense for constructors
|
dispatchReceiverType: IrType?, // has no sense for constructors
|
||||||
isStatic: Boolean,
|
isStatic: Boolean,
|
||||||
forSetter: Boolean,
|
forSetter: Boolean,
|
||||||
// Can be not-null only for property accessors
|
// Can be not-null only for property accessors
|
||||||
parentPropertyReceiver: FirReceiverParameter?
|
parentPropertyReceiver: FirReceiverParameter? = null
|
||||||
) {
|
) {
|
||||||
|
val containingClass = computeContainingClass(irParent)
|
||||||
val parent = this
|
val parent = this
|
||||||
if (function is FirSimpleFunction || function is FirConstructor) {
|
if (function is FirSimpleFunction || function is FirConstructor) {
|
||||||
with(classifierStorage) {
|
with(classifierStorage) {
|
||||||
@@ -587,31 +600,6 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addContextReceiverParametersTo(
|
|
||||||
contextReceivers: List<FirContextReceiver>,
|
|
||||||
parent: IrFunction,
|
|
||||||
result: MutableList<IrValueParameter>,
|
|
||||||
) {
|
|
||||||
contextReceivers.mapIndexedTo(result) { index, contextReceiver ->
|
|
||||||
createIrParameterFromContextReceiver(contextReceiver, index).apply {
|
|
||||||
this.parent = parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun <T : IrFunction> T.bindAndDeclareParameters(
|
|
||||||
function: FirFunction?,
|
|
||||||
irParent: IrDeclarationParent?,
|
|
||||||
dispatchReceiverType: IrType?, // has no sense for constructors
|
|
||||||
isStatic: Boolean,
|
|
||||||
forSetter: Boolean,
|
|
||||||
parentPropertyReceiver: FirReceiverParameter? = null
|
|
||||||
): T {
|
|
||||||
val containingClass = computeContainingClass(irParent)
|
|
||||||
declareParameters(function, containingClass, dispatchReceiverType, isStatic, forSetter, parentPropertyReceiver)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T : IrFunction> T.putParametersInScope(function: FirFunction): T {
|
fun <T : IrFunction> T.putParametersInScope(function: FirFunction): T {
|
||||||
val contextReceivers = function.contextReceiversForFunctionOrContainingProperty()
|
val contextReceivers = function.contextReceiversForFunctionOrContainingProperty()
|
||||||
|
|
||||||
@@ -752,7 +740,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
metadata = FirMetadataSource.Function(function)
|
metadata = FirMetadataSource.Function(function)
|
||||||
enterScope(this.symbol)
|
enterScope(this.symbol)
|
||||||
setAndModifyParent(irParent)
|
setAndModifyParent(irParent)
|
||||||
bindAndDeclareParameters(
|
declareParameters(
|
||||||
function, irParent,
|
function, irParent,
|
||||||
dispatchReceiverType = computeDispatchReceiverType(this, simpleFunction, irParent),
|
dispatchReceiverType = computeDispatchReceiverType(this, simpleFunction, irParent),
|
||||||
isStatic = simpleFunction?.isStatic == true,
|
isStatic = simpleFunction?.isStatic == true,
|
||||||
@@ -863,7 +851,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
constructorCache[constructor] = this
|
constructorCache[constructor] = this
|
||||||
enterScope(this.symbol)
|
enterScope(this.symbol)
|
||||||
setAndModifyParent(irParent)
|
setAndModifyParent(irParent)
|
||||||
bindAndDeclareParameters(constructor, irParent, dispatchReceiverType = null, isStatic = false, forSetter = false)
|
declareParameters(constructor, irParent, dispatchReceiverType = null, isStatic = false, forSetter = false)
|
||||||
leaveScope(this.symbol)
|
leaveScope(this.symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -960,7 +948,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
setAndModifyParent(irParent)
|
setAndModifyParent(irParent)
|
||||||
val dispatchReceiverType = computeDispatchReceiverType(this, property, irParent)
|
val dispatchReceiverType = computeDispatchReceiverType(this, property, irParent)
|
||||||
bindAndDeclareParameters(
|
declareParameters(
|
||||||
propertyAccessor, irParent, dispatchReceiverType,
|
propertyAccessor, irParent, dispatchReceiverType,
|
||||||
isStatic = irParent !is IrClass || propertyAccessor?.isStatic == true, forSetter = isSetter,
|
isStatic = irParent !is IrClass || propertyAccessor?.isStatic == true, forSetter = isSetter,
|
||||||
parentPropertyReceiver = property.receiverParameter,
|
parentPropertyReceiver = property.receiverParameter,
|
||||||
|
|||||||
Reference in New Issue
Block a user