[NI] Make behaviour of anonymous functions consistent with lambdas
Fix completion of anonymous functions with expression body without expected type. Premature completion led to losing type info from outer calls. Also report type mismatches on empty lambda expressions. KT-34729 In progress
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun take(fn: () -> List<String>) {}
|
||||
fun <L> inferFromLambda(fn: () -> L): L = TODO()
|
||||
|
||||
fun <T> materialize(): T = TODO()
|
||||
fun <I> id(arg: I) = arg
|
||||
|
||||
fun testFunctions() {
|
||||
take { materialize() }
|
||||
take(fun() = materialize())
|
||||
take(fun(): List<String> = materialize())
|
||||
take(fun(): List<String> {
|
||||
return materialize()
|
||||
})
|
||||
}
|
||||
|
||||
fun testNestedCalls() {
|
||||
id<String>(inferFromLambda { materialize() })
|
||||
id<String>(inferFromLambda(fun() = materialize()))
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun take(fn: () -> List<String>) {}
|
||||
fun <L> inferFromLambda(fn: () -> L): L = TODO()
|
||||
|
||||
fun <T> materialize(): T = TODO()
|
||||
fun <I> id(arg: I) = arg
|
||||
|
||||
fun testFunctions() {
|
||||
take { materialize() }
|
||||
take(fun() = materialize())
|
||||
take(fun(): List<String> = materialize())
|
||||
take(fun(): List<String> {
|
||||
return materialize()
|
||||
})
|
||||
}
|
||||
|
||||
fun testNestedCalls() {
|
||||
id<String>(inferFromLambda { materialize() })
|
||||
id<String>(inferFromLambda(fun() = materialize()))
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ I> id(/*0*/ arg: I): I
|
||||
public fun </*0*/ L> inferFromLambda(/*0*/ fn: () -> L): L
|
||||
public fun </*0*/ T> materialize(): T
|
||||
public fun take(/*0*/ fn: () -> kotlin.collections.List<kotlin.String>): kotlin.Unit
|
||||
public fun testFunctions(): kotlin.Unit
|
||||
public fun testNestedCalls(): kotlin.Unit
|
||||
Reference in New Issue
Block a user