KT-442 Type inference fails on with()
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// KT-442 Type inference fails on with()
|
||||
|
||||
fun <T> funny(f : fun() : T) : T = f()
|
||||
|
||||
fun testFunny() {
|
||||
val a : Int = funny {1}
|
||||
}
|
||||
|
||||
fun <T> funny2(f : fun(t : T) : T) : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
|
||||
fun testFunny2() {
|
||||
val a : Int = funny2 {it}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return generic_invoker { it }
|
||||
}
|
||||
|
||||
fun <T> generic_invoker(gen : fun (String) : T) : T {
|
||||
return gen("")
|
||||
}
|
||||
|
||||
fun <T> T.with(f : fun T.()) {
|
||||
f()
|
||||
}
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val a = 1 with {
|
||||
plus(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user