[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:
Mikhail Zarechenskiy
2019-08-07 10:09:12 +03:00
parent 0219b86d06
commit 04e57f712e
29 changed files with 171 additions and 23 deletions
@@ -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)
}
@@ -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
@@ -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)
}
@@ -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