mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Allow imprecise matching for Kotlin -> Java method translation
This allows the particular case of Collection.toArray(IntFunction<T>) to match, since both Java and Kotlin functions take an IntFunction<T> but they use different function-local type variables. This would also allow toArray(Array<T>) to work similarly.
This commit is contained in:
@@ -911,7 +911,10 @@ open class KotlinUsesExtractor(
|
|||||||
decl is IrFunction &&
|
decl is IrFunction &&
|
||||||
decl.name == f.name &&
|
decl.name == f.name &&
|
||||||
decl.valueParameters.size == f.valueParameters.size &&
|
decl.valueParameters.size == f.valueParameters.size &&
|
||||||
decl.valueParameters.zip(f.valueParameters).all { p -> p.first.type == p.second.type }
|
// Note matching by classifier not the whole type so that generic arguments are allowed to differ,
|
||||||
|
// as they always will for method type parameters occurring in parameter types (e.g. <T> toArray(T[] array)
|
||||||
|
// Differing only by nullability would also be insignificant if it came up.
|
||||||
|
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
|
// Or if there is none, look for the only viable overload
|
||||||
javaClass.declarations.singleOrNull { decl ->
|
javaClass.declarations.singleOrNull { decl ->
|
||||||
|
|||||||
Reference in New Issue
Block a user