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
@@ -47,6 +47,6 @@ fun main() {
x -> x.toString()
}
A.<!NONE_APPLICABLE!>baz<!>(block)
A.baz(<!TYPE_MISMATCH!>block<!>)
A.baz(block2)
}
@@ -11,7 +11,7 @@ class Data(var x: A)
class B : A() {
fun baz(a: A, b: B, d: Data) {
a.<!INVISIBLE_MEMBER!>foo<!> { }
a.<!INVISIBLE_MEMBER!>foo<!> <!TYPE_MISMATCH!>{ }<!>
b.foo { }
@@ -20,7 +20,7 @@ class B : A() {
}
if (d.x is B) {
d.x.<!INVISIBLE_MEMBER!>foo<!> {}
<!SMARTCAST_IMPOSSIBLE!>d.x<!>.foo <!TYPE_MISMATCH!>{}<!>
}
}
}
@@ -1,7 +1,7 @@
// FILE: KotlinFile.kt
fun foo(javaClass: JavaClass<Int>): Int {
val inner = javaClass.createInner<String>()
return inner.doSomething(1, "") { }
return <!TYPE_MISMATCH!>inner.doSomething(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "") <!TYPE_MISMATCH!>{ }<!><!>
}
// FILE: JavaClass.java
@@ -12,7 +12,7 @@ fun foo(javaClass: JavaClass) {
class X : JavaClass() {
fun foo(other: JavaClass) {
doSomething { bar() }
other.<!INVISIBLE_MEMBER!>doSomething<!> { bar() }
other.<!INVISIBLE_MEMBER!>doSomething<!> <!TYPE_MISMATCH!>{ bar() }<!>
}
}
@@ -21,4 +21,4 @@ fun bar(){}
// FILE: JavaClass.java
public class JavaClass {
protected void doSomething(Runnable runnable) { runnable.run(); }
}
}
@@ -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)
}
@@ -0,0 +1,15 @@
package
public fun fn(): kotlin.Unit
public fun x(/*0*/ a: A, /*1*/ r: java.lang.Runnable): kotlin.Unit
public open class A {
public constructor A()
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,36 @@
// !CHECK_TYPE
// FILE: A.java
public class A {
public static int foo(Runnable r) { return 0; }
public static String foo(Object r) { return null;}
public static int bar(Runnable r) { return 1; }
public static String bar(CharSequence r) { return null; }
}
// FILE: 1.kt
fun fn() {}
fun x(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)
}
@@ -0,0 +1,19 @@
package
public fun fn(): kotlin.Unit
public fun x(/*0*/ r: java.lang.Runnable): kotlin.Unit
public open class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun bar(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int
public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String!
public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int
public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int
public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String!
}