mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #10624 from tamasvajk/kotlin-java-fn-equivalence-remove
Kotlin: find java-kotlin equivalent functions by erased parameter types
This commit is contained in:
@@ -1277,10 +1277,7 @@ open class KotlinUsesExtractor(
|
||||
javaClass.declarations.findSubType<IrFunction> { decl ->
|
||||
decl.name.asString() == jvmName &&
|
||||
decl.valueParameters.size == f.valueParameters.size &&
|
||||
// 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 }
|
||||
decl.valueParameters.zip(f.valueParameters).all { p -> erase(p.first.type) == erase(p.second.type) }
|
||||
} ?:
|
||||
// Or if there is none, look for the only viable overload
|
||||
javaClass.declarations.singleOrNullSubType<IrFunction> { decl ->
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
fun test(m: Map<Int, Int>) = m.getOrDefault(1, 2)
|
||||
|
||||
fun test2(s: String) = s.length
|
||||
|
||||
fun remove(l: MutableList<Int>) {
|
||||
l.remove(5)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user