@@ -1507,14 +1507,15 @@ open class KotlinFileExtractor(
1507
1507
}
1508
1508
is IrFunction -> {
1509
1509
if (s.isLocalFunction()) {
1510
- val classId = extractGeneratedClass(s, listOf (pluginContext.irBuiltIns.anyType))
1510
+ val compilerGeneratedKind = if (s.origin == IrDeclarationOrigin .ADAPTER_FOR_CALLABLE_REFERENCE ) {
1511
+ CompilerGeneratedKinds .DECLARING_CLASSES_OF_ADAPTER_FUNCTIONS
1512
+ } else {
1513
+ null
1514
+ }
1515
+ val classId = extractGeneratedClass(s, listOf (pluginContext.irBuiltIns.anyType), compilerGeneratedKind = compilerGeneratedKind)
1511
1516
extractLocalTypeDeclStmt(classId, s, callable, parent, idx)
1512
1517
val ids = getLocallyVisibleFunctionLabels(s)
1513
1518
tw.writeKtLocalFunction(ids.function)
1514
-
1515
- if (s.origin == IrDeclarationOrigin .ADAPTER_FOR_CALLABLE_REFERENCE ) {
1516
- tw.writeCompiler_generated(classId, CompilerGeneratedKinds .DECLARING_CLASSES_OF_ADAPTER_FUNCTIONS .kind)
1517
- }
1518
1519
} else {
1519
1520
logger.errorElement(" Expected to find local function" , s)
1520
1521
}
@@ -4685,7 +4686,7 @@ open class KotlinFileExtractor(
4685
4686
val baseClass = pluginContext.referenceClass(FqName (" kotlin.jvm.internal.FunctionReference" ))?.owner?.typeWith()
4686
4687
? : pluginContext.irBuiltIns.anyType
4687
4688
4688
- val classId = extractGeneratedClass(ids, listOf (baseClass, fnInterfaceType), locId, functionReferenceExpr, declarationParent, { it.valueParameters.size == 1 }) {
4689
+ val classId = extractGeneratedClass(ids, listOf (baseClass, fnInterfaceType), locId, functionReferenceExpr, declarationParent, null , { it.valueParameters.size == 1 }) {
4689
4690
// The argument to FunctionReference's constructor is the function arity.
4690
4691
extractConstantInteger(type.arguments.size - 1 , locId, it, 0 , ids.constructor , it)
4691
4692
}
@@ -5389,14 +5390,15 @@ open class KotlinFileExtractor(
5389
5390
locId : Label <DbLocation >,
5390
5391
elementToReportOn : IrElement ,
5391
5392
declarationParent : IrDeclarationParent ,
5393
+ compilerGeneratedKind : CompilerGeneratedKinds ? = null,
5392
5394
superConstructorSelector : (IrFunction ) -> Boolean = { it.valueParameters.isEmpty() },
5393
- extractSuperconstructorArgs : (Label <DbSuperconstructorinvocationstmt >) -> Unit = {}
5395
+ extractSuperconstructorArgs : (Label <DbSuperconstructorinvocationstmt >) -> Unit = {},
5394
5396
): Label <out DbClass > {
5395
5397
// Write class
5396
5398
val id = ids.type.javaResult.id.cast<DbClass >()
5397
5399
val pkgId = extractPackage(" " )
5398
5400
tw.writeClasses(id, " " , pkgId, id)
5399
- tw.writeCompiler_generated(id, CompilerGeneratedKinds .CALLABLE_CLASS .kind)
5401
+ tw.writeCompiler_generated(id, (compilerGeneratedKind ? : CompilerGeneratedKinds .CALLABLE_CLASS ) .kind)
5400
5402
tw.writeHasLocation(id, locId)
5401
5403
5402
5404
// Extract constructor
@@ -5443,11 +5445,15 @@ open class KotlinFileExtractor(
5443
5445
/* *
5444
5446
* Extracts the class around a local function or a lambda. The superclass must have a no-arg constructor.
5445
5447
*/
5446
- private fun extractGeneratedClass (localFunction : IrFunction , superTypes : List <IrType >) : Label <out DbClass > {
5448
+ private fun extractGeneratedClass (
5449
+ localFunction : IrFunction ,
5450
+ superTypes : List <IrType >,
5451
+ compilerGeneratedKind : CompilerGeneratedKinds ? = null
5452
+ ) : Label <out DbClass > {
5447
5453
with (" generated class" , localFunction) {
5448
5454
val ids = getLocallyVisibleFunctionLabels(localFunction)
5449
5455
5450
- val id = extractGeneratedClass(ids, superTypes, tw.getLocation(localFunction), localFunction, localFunction.parent)
5456
+ val id = extractGeneratedClass(ids, superTypes, tw.getLocation(localFunction), localFunction, localFunction.parent, compilerGeneratedKind = compilerGeneratedKind )
5451
5457
5452
5458
// Extract local function as a member
5453
5459
extractFunction(localFunction, id, extractBody = true , extractMethodAndParameterTypeAccesses = true , null , listOf ())
0 commit comments