FIR: resolve conflicts around SAM calls properly
This commit is contained in:
+1
-1
@@ -6,4 +6,4 @@ object X2
|
||||
fun <T1> foo(x: T1, f: (T1) -> T1) = X1
|
||||
fun <T2> foo(xf: () -> T2, f: (T2) -> T2) = X2
|
||||
|
||||
val test: X2 = foo({ 0 }, { it -> it + 1 })
|
||||
val test: X2 = <!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>({ 0 }, { it -> it + 1 })
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces
|
||||
// !CHECK_TYPE
|
||||
// FILE: Fn.java
|
||||
public interface Fn<T, R> {
|
||||
R apply(T t);
|
||||
}
|
||||
|
||||
// FILE: Fn2.java
|
||||
public interface Fn2<T, R> extends Fn<T, R> {}
|
||||
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
String foo(Fn<String, Object> f, Object o);
|
||||
int foo(Fn<Object, Object> f, String s); // (Any) -> Any <: (String) -> Any <=> String <: Any
|
||||
|
||||
String bas(Fn<Object, Object> f, Object o);
|
||||
int bas(Fn<Object, String> f, String s); // (Any) -> String <: (Any) -> Any <=> String <: Any
|
||||
|
||||
String bar(Fn<String, Object> f);
|
||||
int bar(Fn2<String, Object> f); // Fn2 seems more specific one even function type same
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun test(j: J) {
|
||||
j.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>({ <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any>() }; "" }, "") <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
|
||||
|
||||
j.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bas<!>({ <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any>() }; "" }, "") <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
|
||||
|
||||
j.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces
|
||||
// !CHECK_TYPE
|
||||
// FILE: Fn.java
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces +SamConversionForKotlinFunctions +SamConversionPerArgument
|
||||
// !CHECK_TYPE
|
||||
// FILE: Fn.java
|
||||
public interface Fn<T, R> {
|
||||
R apply(T t);
|
||||
}
|
||||
|
||||
// FILE: Fn2.java
|
||||
public interface Fn2<T, R> extends Fn<T, R> {}
|
||||
|
||||
// FILE: 1.kt
|
||||
interface K {
|
||||
fun foo(f: Fn<String, Any>): String
|
||||
fun foo(f: Fn<Any, Any>): Int
|
||||
|
||||
fun bas(f: Fn<Any, Any>): String
|
||||
fun bas(f: Fn<Any, String>): Int
|
||||
|
||||
fun bar(f: Fn<String, Any>): String
|
||||
fun bar(f: Fn2<String, Any>): Int
|
||||
}
|
||||
|
||||
fun test(k: K) {
|
||||
k.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any>() }; "" } <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
|
||||
|
||||
k.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bas<!> { <!UNRESOLVED_REFERENCE!>it<!> checkType { _<Any?>() }; "" } <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
|
||||
|
||||
k.bar { it checkType { _<String>() }; "" } checkType { _<Int>() }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +EliminateAmbiguitiesOnInheritedSamInterfaces +SamConversionForKotlinFunctions +SamConversionPerArgument
|
||||
// !CHECK_TYPE
|
||||
// FILE: Fn.java
|
||||
|
||||
Reference in New Issue
Block a user