@@ -102,90 +102,84 @@ internal class IrFunctionsTransformer(
102102
103103 context(context: IrPluginContext )
104104 private fun transformSetFunction (declaration : IrSimpleFunction ): IrSimpleFunction {
105- val function: IrSimpleFunction =
106- declaration.apply {
107- body =
108- DeclarationIrBuilder (declaration.symbol).irBlockBody {
109- val unitClass: IrClassSymbol = context.irBuiltIns.unitClass.owner.symbol
110- val unitCall: IrGetObjectValue = irGetObject(unitClass)
111- val irReturn: IrReturn = irReturn(unitCall)
112- + irReturn
113- }
114- }
105+ val function: IrSimpleFunction = declaration.apply {
106+ body =
107+ DeclarationIrBuilder (declaration.symbol).irBlockBody {
108+ val unitClass: IrClassSymbol = context.irBuiltIns.unitClass.owner.symbol
109+ val unitCall: IrGetObjectValue = irGetObject(unitClass)
110+ val irReturn: IrReturn = irReturn(unitCall)
111+ + irReturn
112+ }
113+ }
115114 return function
116115 }
117116
118117 context(context: IrPluginContext )
119118 private fun transformUpdateFunction (declaration : IrSimpleFunction ): IrSimpleFunction {
120- val function: IrSimpleFunction =
121- declaration.apply {
122- body =
123- DeclarationIrBuilder (declaration.symbol).irBlockBody {
124- val thisGet: IrGetValue = irGet(extensionReceiver!! )
125- val transformValueParameter: IrValueParameter = regularParameters.first()
126- val func1Invoke: IrSimpleFunction =
127- function1Class.findDeclaration<IrSimpleFunction > {
128- it.name == invokeName
129- }!!
130-
131- val transformCallDispatchReceiver: IrGetValue =
132- irGet(transformValueParameter).apply {
133- origin = IrStatementOrigin .VARIABLE_AS_FUNCTION
134- }
135-
136- val transformCall: IrMemberAccessExpression <* > =
137- irCallOp(
138- callee = func1Invoke.symbol,
139- type = declaration.typeParameters.first().defaultType,
140- dispatchReceiver = transformCallDispatchReceiver,
141- argument = thisGet,
142- origin = IrStatementOrigin .INVOKE ,
143- )
144- + typeOperator(
145- resultType = unitType,
146- argument = transformCall,
147- typeOperator = IrTypeOperator .IMPLICIT_COERCION_TO_UNIT ,
148- typeOperand = unitType,
119+ val function: IrSimpleFunction = declaration.apply {
120+ body =
121+ DeclarationIrBuilder (declaration.symbol).irBlockBody {
122+ val thisGet: IrGetValue = irGet(extensionReceiver!! )
123+ val transformValueParameter: IrValueParameter = regularParameters.first()
124+ val func1Invoke: IrSimpleFunction =
125+ function1Class.findDeclaration<IrSimpleFunction > { it.name == invokeName }!!
126+
127+ val transformCallDispatchReceiver: IrGetValue =
128+ irGet(transformValueParameter).apply {
129+ origin = IrStatementOrigin .VARIABLE_AS_FUNCTION
130+ }
131+
132+ val transformCall: IrMemberAccessExpression <* > =
133+ irCallOp(
134+ callee = func1Invoke.symbol,
135+ type = declaration.typeParameters.first().defaultType,
136+ dispatchReceiver = transformCallDispatchReceiver,
137+ argument = thisGet,
138+ origin = IrStatementOrigin .INVOKE ,
149139 )
150- }
151- }
140+ + typeOperator(
141+ resultType = unitType,
142+ argument = transformCall,
143+ typeOperator = IrTypeOperator .IMPLICIT_COERCION_TO_UNIT ,
144+ typeOperand = unitType,
145+ )
146+ }
147+ }
152148 return function
153149 }
154150
155151 context(context: IrPluginContext )
156152 private fun transformUpdateEachFunction (declaration : IrSimpleFunction ): IrSimpleFunction {
157- val function: IrSimpleFunction =
158- declaration.apply {
159- body =
160- DeclarationIrBuilder (declaration.symbol).irBlockBody {
161- val thisGet: IrGetValue = irGet(extensionReceiver!! )
162- val transformValueParameter: IrValueParameter = regularParameters.first()
163- val transformParameterIndex: Int =
164- transformValueParameter.indexInParameters - 1
165-
166- val transformCallType: IrSimpleType =
167- listClass.typeWith(typeParameters.map { it.defaultType })
168-
169- val typeParameterType: IrSimpleType =
170- declaration.typeParameters.map { it.defaultType }.first()
171-
172- val transformCall: IrCall =
173- irCall(callee = mapFunction.symbol).apply {
174- typeArguments[0 ] = typeParameterType
175- typeArguments[1 ] = typeParameterType
176- insertExtensionReceiver(thisGet)
177- arguments[transformParameterIndex] = irGet(transformValueParameter)
178- this .type = transformCallType
179- }
180-
181- + typeOperator(
182- resultType = unitType,
183- argument = transformCall,
184- typeOperator = IrTypeOperator .IMPLICIT_COERCION_TO_UNIT ,
185- typeOperand = unitType,
186- )
187- }
188- }
153+ val function: IrSimpleFunction = declaration.apply {
154+ body =
155+ DeclarationIrBuilder (declaration.symbol).irBlockBody {
156+ val thisGet: IrGetValue = irGet(extensionReceiver!! )
157+ val transformValueParameter: IrValueParameter = regularParameters.first()
158+ val transformParameterIndex: Int = transformValueParameter.indexInParameters - 1
159+
160+ val transformCallType: IrSimpleType =
161+ listClass.typeWith(typeParameters.map { it.defaultType })
162+
163+ val typeParameterType: IrSimpleType =
164+ declaration.typeParameters.map { it.defaultType }.first()
165+
166+ val transformCall: IrCall =
167+ irCall(callee = mapFunction.symbol).apply {
168+ typeArguments[0 ] = typeParameterType
169+ typeArguments[1 ] = typeParameterType
170+ insertExtensionReceiver(thisGet)
171+ arguments[transformParameterIndex] = irGet(transformValueParameter)
172+ this .type = transformCallType
173+ }
174+
175+ + typeOperator(
176+ resultType = unitType,
177+ argument = transformCall,
178+ typeOperator = IrTypeOperator .IMPLICIT_COERCION_TO_UNIT ,
179+ typeOperand = unitType,
180+ )
181+ }
182+ }
189183 return function
190184 }
191185
0 commit comments