mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Kotlin: Specialise findSubType to IrDeclaration
We only use it on that type, and this makes the uses a bit quieter.
This commit is contained in:
@@ -326,7 +326,7 @@ open class KotlinUsesExtractor(
|
||||
if (replacementClass === parentClass)
|
||||
return f
|
||||
return globalExtensionState.syntheticToRealFunctionMap.getOrPut(f) {
|
||||
val result = replacementClass.declarations.findSubType<IrDeclaration,IrSimpleFunction> { replacementDecl ->
|
||||
val result = replacementClass.declarations.findSubType<IrSimpleFunction> { replacementDecl ->
|
||||
replacementDecl is IrSimpleFunction && replacementDecl.name == f.name && replacementDecl.valueParameters.size == f.valueParameters.size && replacementDecl.valueParameters.zip(f.valueParameters).all {
|
||||
erase(it.first.type) == erase(it.second.type)
|
||||
}
|
||||
@@ -351,7 +351,7 @@ open class KotlinUsesExtractor(
|
||||
if (replacementClass === parentClass)
|
||||
return f
|
||||
return globalExtensionState.syntheticToRealFieldMap.getOrPut(f) {
|
||||
val result = replacementClass.declarations.findSubType<IrDeclaration,IrField> { replacementDecl ->
|
||||
val result = replacementClass.declarations.findSubType<IrField> { replacementDecl ->
|
||||
replacementDecl.name == f.name
|
||||
}
|
||||
if (result == null) {
|
||||
@@ -1097,7 +1097,7 @@ open class KotlinUsesExtractor(
|
||||
return f.returnType
|
||||
}
|
||||
|
||||
val otherKeySet = parentClass.declarations.findSubType<IrDeclaration,IrFunction> { it.name.asString() == "keySet" && it.valueParameters.size == 1 }
|
||||
val otherKeySet = parentClass.declarations.findSubType<IrFunction> { it.name.asString() == "keySet" && it.valueParameters.size == 1 }
|
||||
?: return f.returnType
|
||||
|
||||
return otherKeySet.returnType.codeQlWithHasQuestionMark(false)
|
||||
@@ -1177,7 +1177,7 @@ open class KotlinUsesExtractor(
|
||||
getJavaEquivalentClass(parentClass)?.let { javaClass ->
|
||||
if (javaClass != parentClass)
|
||||
// Look for an exact type match...
|
||||
javaClass.declarations.findSubType<IrDeclaration,IrFunction> { decl ->
|
||||
javaClass.declarations.findSubType<IrFunction> { decl ->
|
||||
decl.name == f.name &&
|
||||
decl.valueParameters.size == f.valueParameters.size &&
|
||||
// Note matching by classifier not the whole type so that generic arguments are allowed to differ,
|
||||
@@ -1193,7 +1193,7 @@ open class KotlinUsesExtractor(
|
||||
} ?:
|
||||
// Or check property accessors:
|
||||
if (f.isAccessor) {
|
||||
val prop = javaClass.declarations.findSubType<IrDeclaration,IrProperty> { decl ->
|
||||
val prop = javaClass.declarations.findSubType<IrProperty> { decl ->
|
||||
decl.name == (f.propertyIfAccessor as IrProperty).name
|
||||
}
|
||||
if (prop?.getter?.name == f.name)
|
||||
|
||||
Reference in New Issue
Block a user