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
|
||||
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: StaticOverrides.java
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
|
||||
public class StaticOverrides {
|
||||
public static class A {
|
||||
public static int foo(Runnable x) { return 0; }
|
||||
public static boolean foo(Function0<Unit> x) { return true; }
|
||||
}
|
||||
|
||||
public static class B {
|
||||
public static String foo(Runnable x) { return ""; }
|
||||
}
|
||||
|
||||
public static class C extends A {
|
||||
public static String foo(Runnable x) { return ""; }
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
StaticOverrides.A.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> {} <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Boolean>() }
|
||||
StaticOverrides.B.foo {} checkType { _<String>() }
|
||||
StaticOverrides.C.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> {} <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Boolean>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: StaticOverrides.java
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
class Foo {
|
||||
interface FObject<T> {
|
||||
void invoke(T i);
|
||||
}
|
||||
|
||||
public String foo(FObject<Integer> f) { return ""; }
|
||||
public int foo(Function1<Integer, Unit> f) { return 1; }
|
||||
|
||||
public String bar(FObject<Object> f) { return ""; }
|
||||
public int bar(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun test() {
|
||||
Foo().<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> {} <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<Int>() }
|
||||
Foo().<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!> {} <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<String>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: Foo.java
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class Foo {
|
||||
interface FObject {
|
||||
void invoke(Object i);
|
||||
}
|
||||
|
||||
public String test(FObject f) { return ""; }
|
||||
public int test(Function1<Integer, Unit> f) { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
fun bar() {
|
||||
Foo().<!OVERLOAD_RESOLUTION_AMBIGUITY!>test<!> {} <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>checkType<!> { _<String>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user