[NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new inference. Note that as for `SamConversionPerArgument`, this feature is enabled in the compiler and not in the IDE to avoid breaking code for those users that already enabled new inference in the compiler
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun bar1(body: (String) -> String): String {
|
||||
return body("something")
|
||||
}
|
||||
|
||||
fun bar2(body: (String, Int) -> String): String {
|
||||
return body("something", 0)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
bar1(<!NI;UNSUPPORTED_FEATURE, OI;TYPE_MISMATCH!>::foo<!>)
|
||||
bar2(::foo)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun bar1(/*0*/ body: (kotlin.String) -> kotlin.String): kotlin.String
|
||||
public fun bar2(/*0*/ body: (kotlin.String, kotlin.Int) -> kotlin.String): kotlin.String
|
||||
public fun foo(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int = ...): kotlin.String
|
||||
public fun test(): kotlin.Unit
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType
|
||||
|
||||
fun foo(a: String, b: Int = 5): String {
|
||||
return a + b
|
||||
}
|
||||
|
||||
fun bar1(body: (String) -> String): String {
|
||||
return body("something")
|
||||
}
|
||||
|
||||
fun bar2(body: (String, Int) -> String): String {
|
||||
return body("something", 0)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
bar1(::foo)
|
||||
bar2(::foo)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun bar1(/*0*/ body: (kotlin.String) -> kotlin.String): kotlin.String
|
||||
public fun bar2(/*0*/ body: (kotlin.String, kotlin.Int) -> kotlin.String): kotlin.String
|
||||
public fun foo(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int = ...): kotlin.String
|
||||
public fun test(): kotlin.Unit
|
||||
Reference in New Issue
Block a user