Optimize retaining most specific methods in LazyJavaScope

See 62a55b7b00
Previously, it was working for O(n^2)
Now, we first group it by jvm descriptor,
then for each groups of size g_i finding the most specific for O(g_i^2)

It should help for the cases when we have a lot of overloads with
different JVM descriptors (modulo return type)
NB: Having the same JVM descriptors is rather rare, because
in Java one cannot generate such a class.

Looks like it's only possible for Scala or some other JVM languages (KT-17560)

It should help a lot for KT-35135
This commit is contained in:
Denis Zharkov
2020-02-14 15:10:59 +03:00
parent d06e35b061
commit 842e2dc02f
5 changed files with 44 additions and 25 deletions
@@ -11,7 +11,7 @@ public class A {
void foo(Map<Object, Object> x) {}
void foo(Map.Entry<Object, Object> x) {}
void foo(List<List<Object>> x) {}
void foo1(List<List<Object>> x) {}
}
// FILE: main.kt
@@ -59,9 +59,9 @@ fun main(
a.foo(me as Map.Entry<Any, Any>)
// Lists of lists
a.foo(mll)
a.foo(ll)
a.foo(mll as MutableList<MutableList<Any>>)
a.foo(ll as List<List<Any>>)
a.foo1(mll)
a.foo1(ll)
a.foo1(mll as MutableList<MutableList<Any>>)
a.foo1(ll as List<List<Any>>)
}
@@ -11,7 +11,7 @@ public class A {
void foo(Map<Object, Object> x) {}
void foo(Map.Entry<Object, Object> x) {}
void foo(List<List<Object>> x) {}
void foo1(List<List<Object>> x) {}
}
// FILE: main.kt
@@ -59,9 +59,9 @@ fun main(
a.foo(me as Map.Entry<Any, Any>)
// Lists of lists
a.foo(<!JAVA_TYPE_MISMATCH!>mll<!>)
a.foo(ll)
a.foo(mll <!UNCHECKED_CAST!>as MutableList<MutableList<Any>><!>)
a.foo(ll as List<List<Any>>)
a.foo1(<!JAVA_TYPE_MISMATCH!>mll<!>)
a.foo1(ll)
a.foo1(mll <!UNCHECKED_CAST!>as MutableList<MutableList<Any>><!>)
a.foo1(ll as List<List<Any>>)
}
@@ -8,10 +8,10 @@ public open class A {
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)Iterable<kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)Iterator<kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)List<kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)List<kotlin.collections.(Mutable)List<kotlin.Any!>!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)Map.(Mutable)Entry<kotlin.Any!, kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)Map<kotlin.Any!, kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo(/*0*/ x: kotlin.collections.(Mutable)Set<kotlin.Any!>!): kotlin.Unit
public/*package*/ open fun foo1(/*0*/ x: kotlin.collections.(Mutable)List<kotlin.collections.(Mutable)List<kotlin.Any!>!>!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}