Change resolution priority level for SAM adapters

After this change SAM adapters are being resolved in the same group
as members, thus their overload resolution happens simultaneously.

But in the case of overload resolution ambiguity try to filter out all
synthetic members and run the process again.

See the issue and new test for clarification

 #KT-11128 In Progress
This commit is contained in:
Denis Zharkov
2016-12-07 17:16:00 +03:00
parent a4adfb43d4
commit 891a036b59
22 changed files with 223 additions and 68 deletions
@@ -0,0 +1,36 @@
// !CHECK_TYPE
// FILE: A.java
public class A {
public int foo(Runnable r) { return 0; }
public String foo(Object r) { return null;}
public int bar(Runnable r) { return 1; }
public String bar(CharSequence r) { return null; }
}
// FILE: 1.kt
fun fn() {}
fun x(a: A, r: Runnable) {
a.foo(::fn) checkType { _<Int>() }
a.foo {} checkType { _<Int>() }
a.foo(null) checkType { _<Int>() }
a.foo(Runnable { }) checkType { _<Int>() }
a.foo(r) checkType { _<Int>() }
a.foo(123) checkType { _<String>() }
a.foo("") checkType { _<String>() }
a.bar(::fn) checkType { _<Int>() }
a.bar {} checkType { _<Int>() }
a.bar(r) checkType { _<Int>() }
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>(null)
a.bar(null as Runnable?) checkType { _<Int>() }
a.bar(null as CharSequence?) checkType { _<String>() }
a.bar("") checkType { _<String>() }
a.<!NONE_APPLICABLE!>bar<!>(123)
}