@@ -10,9 +10,7 @@ import org.jetbrains.kotlin.ir.builders.*
10
10
import org.jetbrains.kotlin.ir.builders.declarations.*
11
11
import org.jetbrains.kotlin.ir.declarations.*
12
12
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
13
- import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
14
13
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
15
- import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
16
14
import org.jetbrains.kotlin.ir.types.IrSimpleType
17
15
import org.jetbrains.kotlin.ir.types.getClass
18
16
import org.jetbrains.kotlin.ir.types.typeOrNull
@@ -59,7 +57,7 @@ fun IrPluginContext.createSuspendLambdaWithCoroutineScope(
59
57
lambdaType : IrSimpleType ,
60
58
originFunction : IrFunction ,
61
59
): IrClass {
62
- return IrFactoryImpl .buildClass {
60
+ return irFactory .buildClass {
63
61
name = SpecialNames .NO_NAME_PROVIDED
64
62
kind = ClassKind .CLASS
65
63
/*
@@ -149,35 +147,15 @@ fun IrPluginContext.createSuspendLambdaFunctionWithCoroutineScope(
149
147
function : IrFunction ,
150
148
blockBodyBuilder : IrBlockBodyBuilder
151
149
): IrSimpleFunction {
152
- val func = IrFunctionImpl (
153
- startOffset = - 1 ,
154
- endOffset = - 1 ,
155
- origin = IrDeclarationOrigin .LOCAL_FUNCTION_FOR_LAMBDA ,
156
- name = SpecialNames .NO_NAME_PROVIDED ,
157
- visibility = DescriptorVisibilities .LOCAL ,
158
- isInline = false ,
159
- isExpect = false ,
160
- returnType = function.returnType,
161
- modality = Modality .FINAL ,
162
- symbol = IrSimpleFunctionSymbolImpl (),
163
- isSuspend = true ,
164
- isTailrec = false ,
165
- isOperator = false ,
166
- isInfix = false ,
167
- isExternal = false ,
168
- )
169
-
170
- // val func1 = IrFactoryImpl.buildFun {
171
- // name = SpecialNames.NO_NAME_PROVIDED
172
- // visibility = DescriptorVisibilities.LOCAL
173
- // isSuspend = true
174
- // returnType = function.returnType
175
- // }
176
-
177
- with (func) {
150
+ return irFactory.buildFun {
151
+ origin = IrDeclarationOrigin .LOCAL_FUNCTION_FOR_LAMBDA
152
+ name = SpecialNames .NO_NAME_PROVIDED
153
+ visibility = DescriptorVisibilities .LOCAL
154
+ returnType = function.returnType
155
+ modality = Modality .FINAL
156
+ isSuspend = true
157
+ }.apply {
178
158
parent = function
179
- // origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
180
-
181
159
body = createIrBuilder(symbol).run {
182
160
// don't use expr body, coroutine codegen can't generate for it.
183
161
irBlockBody {
@@ -198,8 +176,6 @@ fun IrPluginContext.createSuspendLambdaFunctionWithCoroutineScope(
198
176
}
199
177
}
200
178
}
201
-
202
- return func
203
179
}
204
180
205
181
fun IrFunction.paramsAndReceiversAsParamsList (): List <IrValueParameter > {
0 commit comments