@@ -326,11 +326,11 @@ open class KotlinUsesExtractor(
326326 if (replacementClass == = parentClass)
327327 return f
328328 return globalExtensionState.syntheticToRealFunctionMap.getOrPut(f) {
329- val result = replacementClass.declarations.find { replacementDecl ->
329+ val result = replacementClass.declarations.findSubType< IrDeclaration , IrSimpleFunction > { replacementDecl ->
330330 replacementDecl is IrSimpleFunction && replacementDecl.name == f.name && replacementDecl.valueParameters.size == f.valueParameters.size && replacementDecl.valueParameters.zip(f.valueParameters).all {
331331 erase(it.first.type) == erase(it.second.type)
332332 }
333- } as IrFunction ?
333+ }
334334 if (result == null ) {
335335 logger.warn(" Failed to replace synthetic class function ${f.name} " )
336336 } else {
@@ -351,9 +351,9 @@ open class KotlinUsesExtractor(
351351 if (replacementClass == = parentClass)
352352 return f
353353 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+ }
357357 if (result == null ) {
358358 logger.warn(" Failed to replace synthetic class field ${f.name} " )
359359 } else {
@@ -1097,7 +1097,7 @@ open class KotlinUsesExtractor(
10971097 return f.returnType
10981098 }
10991099
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 }
11011101 ? : return f.returnType
11021102
11031103 return otherKeySet.returnType.codeQlWithHasQuestionMark(false )
@@ -1177,8 +1177,7 @@ open class KotlinUsesExtractor(
11771177 getJavaEquivalentClass(parentClass)?.let { javaClass ->
11781178 if (javaClass != parentClass)
11791179 // Look for an exact type match...
1180- javaClass.declarations.find { decl ->
1181- decl is IrFunction &&
1180+ javaClass.declarations.findSubType<IrDeclaration ,IrFunction > { decl ->
11821181 decl.name == f.name &&
11831182 decl.valueParameters.size == f.valueParameters.size &&
11841183 // Note matching by classifier not the whole type so that generic arguments are allowed to differ,
@@ -1194,7 +1193,7 @@ open class KotlinUsesExtractor(
11941193 } ? :
11951194 // Or check property accessors:
11961195 if (f.isAccessor) {
1197- val prop = javaClass.declarations.filterIsInstance< IrProperty >().find { decl ->
1196+ val prop = javaClass.declarations.findSubType< IrDeclaration , IrProperty > { decl ->
11981197 decl.name == (f.propertyIfAccessor as IrProperty ).name
11991198 }
12001199 if (prop?.getter?.name == f.name)
0 commit comments