[NI] Prototype for SAM-conversion.
Supported: - conversion in resolution parts. Also sam-with-receiver is supported automatically - separate flag for kotlin function with java SAM as parameters TODO: - fix overload conflict error when function type is the same byte origin types is ordered - consider case when parameter type is T, T <:> Runnable - support vararg of Runnable [NI] Turn off synthetic scope with SAM adapter functions if NI enabled
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +NewInference +SamConversionForKotlinFunctions
|
||||
// !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.foo { it checkType { _<Any>() }; "" } checkType { _<Int>() }
|
||||
|
||||
k.bas { it checkType { _<Any?>() }; "" } checkType { _<Int>() }
|
||||
|
||||
// NI: TODO
|
||||
k.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!> { <!UNRESOLVED_REFERENCE!>it<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Any>() }; "" } <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
}
|
||||
Reference in New Issue
Block a user