mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Kotlin: Implement and use singleOrNullSubType
Pulls another cast out into a utility function.
This commit is contained in:
@@ -1169,7 +1169,7 @@ open class KotlinUsesExtractor(
|
||||
"kotlin.Boolean", "kotlin.Byte", "kotlin.Char", "kotlin.Double", "kotlin.Float", "kotlin.Int", "kotlin.Long", "kotlin.Number", "kotlin.Short"
|
||||
)
|
||||
|
||||
private fun kotlinFunctionToJavaEquivalent(f: IrFunction, noReplace: Boolean) =
|
||||
private fun kotlinFunctionToJavaEquivalent(f: IrFunction, noReplace: Boolean): IrFunction =
|
||||
if (noReplace)
|
||||
f
|
||||
else
|
||||
@@ -1186,8 +1186,7 @@ open class KotlinUsesExtractor(
|
||||
decl.valueParameters.zip(f.valueParameters).all { p -> p.first.type.classifierOrNull == p.second.type.classifierOrNull }
|
||||
} ?:
|
||||
// Or if there is none, look for the only viable overload
|
||||
javaClass.declarations.singleOrNull { decl ->
|
||||
decl is IrFunction &&
|
||||
javaClass.declarations.singleOrNullSubType<IrFunction> { decl ->
|
||||
decl.name == f.name &&
|
||||
decl.valueParameters.size == f.valueParameters.size
|
||||
} ?:
|
||||
@@ -1213,7 +1212,7 @@ open class KotlinUsesExtractor(
|
||||
else
|
||||
null
|
||||
}
|
||||
} as IrFunction? ?: f
|
||||
} ?: f
|
||||
|
||||
fun <T: DbCallable> useFunction(f: IrFunction, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>? = null, noReplace: Boolean = false): Label<out T> {
|
||||
return useFunction(f, null, classTypeArgsIncludingOuterClasses, noReplace)
|
||||
|
||||
Reference in New Issue
Block a user