@@ -326,11 +326,11 @@ open class KotlinUsesExtractor(
326
326
if (replacementClass == = parentClass)
327
327
return f
328
328
return globalExtensionState.syntheticToRealFunctionMap.getOrPut(f) {
329
- val result = replacementClass.declarations.find { replacementDecl ->
329
+ val result = replacementClass.declarations.findSubType< IrDeclaration , IrSimpleFunction > { replacementDecl ->
330
330
replacementDecl is IrSimpleFunction && replacementDecl.name == f.name && replacementDecl.valueParameters.size == f.valueParameters.size && replacementDecl.valueParameters.zip(f.valueParameters).all {
331
331
erase(it.first.type) == erase(it.second.type)
332
332
}
333
- } as IrFunction ?
333
+ }
334
334
if (result == null ) {
335
335
logger.warn(" Failed to replace synthetic class function ${f.name} " )
336
336
} else {
@@ -351,9 +351,9 @@ open class KotlinUsesExtractor(
351
351
if (replacementClass == = parentClass)
352
352
return f
353
353
return globalExtensionState.syntheticToRealFieldMap.getOrPut(f) {
354
- val result = replacementClass.declarations.find { replacementDecl ->
355
- replacementDecl is IrField && replacementDecl .name == f.name
356
- } as IrField ?
354
+ val result = replacementClass.declarations.findSubType< IrDeclaration , IrField > { replacementDecl ->
355
+ replacementDecl.name == f.name
356
+ }
357
357
if (result == null ) {
358
358
logger.warn(" Failed to replace synthetic class field ${f.name} " )
359
359
} else {
@@ -1097,7 +1097,7 @@ open class KotlinUsesExtractor(
1097
1097
return f.returnType
1098
1098
}
1099
1099
1100
- val otherKeySet = parentClass.declarations.filterIsInstance< IrFunction >().find { it.name.asString() == " keySet" && it.valueParameters.size == 1 }
1100
+ val otherKeySet = parentClass.declarations.findSubType< IrDeclaration , IrFunction > { it.name.asString() == " keySet" && it.valueParameters.size == 1 }
1101
1101
? : return f.returnType
1102
1102
1103
1103
return otherKeySet.returnType.codeQlWithHasQuestionMark(false )
@@ -1177,8 +1177,7 @@ open class KotlinUsesExtractor(
1177
1177
getJavaEquivalentClass(parentClass)?.let { javaClass ->
1178
1178
if (javaClass != parentClass)
1179
1179
// Look for an exact type match...
1180
- javaClass.declarations.find { decl ->
1181
- decl is IrFunction &&
1180
+ javaClass.declarations.findSubType<IrDeclaration ,IrFunction > { decl ->
1182
1181
decl.name == f.name &&
1183
1182
decl.valueParameters.size == f.valueParameters.size &&
1184
1183
// Note matching by classifier not the whole type so that generic arguments are allowed to differ,
@@ -1194,7 +1193,7 @@ open class KotlinUsesExtractor(
1194
1193
} ? :
1195
1194
// Or check property accessors:
1196
1195
if (f.isAccessor) {
1197
- val prop = javaClass.declarations.filterIsInstance< IrProperty >().find { decl ->
1196
+ val prop = javaClass.declarations.findSubType< IrDeclaration , IrProperty > { decl ->
1198
1197
decl.name == (f.propertyIfAccessor as IrProperty ).name
1199
1198
}
1200
1199
if (prop?.getter?.name == f.name)
0 commit comments