Skip to content

Commit ee59bda

Browse files
authored
Merge pull request #10624 from tamasvajk/kotlin-java-fn-equivalence-remove
Kotlin: find java-kotlin equivalent functions by erased parameter types
2 parents 9be2ca2 + b79c10c commit ee59bda

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,7 @@ open class KotlinUsesExtractor(
12771277
javaClass.declarations.findSubType<IrFunction> { decl ->
12781278
decl.name.asString() == jvmName &&
12791279
decl.valueParameters.size == f.valueParameters.size &&
1280-
// Note matching by classifier not the whole type so that generic arguments are allowed to differ,
1281-
// as they always will for method type parameters occurring in parameter types (e.g. <T> toArray(T[] array)
1282-
// Differing only by nullability would also be insignificant if it came up.
1283-
decl.valueParameters.zip(f.valueParameters).all { p -> p.first.type.classifierOrNull == p.second.type.classifierOrNull }
1280+
decl.valueParameters.zip(f.valueParameters).all { p -> erase(p.first.type) == erase(p.second.type) }
12841281
} ?:
12851282
// Or if there is none, look for the only viable overload
12861283
javaClass.declarations.singleOrNullSubType<IrFunction> { decl ->
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
fun test(m: Map<Int, Int>) = m.getOrDefault(1, 2)
22

33
fun test2(s: String) = s.length
4+
5+
fun remove(l: MutableList<Int>) {
6+
l.remove(5)
7+
}

0 commit comments

Comments
 (0)