KT-2841 Can't infer a type for function literal parameter if the return type is error

#KT-2841 fixed
This commit is contained in:
Svetlana Isakova
2012-10-15 13:54:33 +04:00
parent c82ef0522d
commit 9d89eb0e58
8 changed files with 115 additions and 10 deletions
@@ -0,0 +1,15 @@
package a
trait Closeable {}
class C : Closeable {}
public inline fun <T: Closeable, R> T.use1(block: (T)-> R) : R {
return block(this)
}
fun main(args: Array<String>) {
C().<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use1<!> {
w -> // ERROR here
<!UNRESOLVED_REFERENCE!>x<!>
}
}
@@ -0,0 +1,18 @@
package a
trait Closeable {
fun close() {}
}
class C : Closeable
public inline fun <T: Closeable, R> T.use(block: (t: T)-> R) : R {
return block(this)
}
fun test() {
C().<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!> {
it.close()
<!UNRESOLVED_REFERENCE!>x<!>
}
}
@@ -0,0 +1,19 @@
package a
trait Closeable {
fun close() {}
}
class C : Closeable
public inline fun <T: Closeable, R> use(t: T, block: T.(T)-> R) : R {
return t.block(t)
}
fun test() {
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!>(C()) {
this.close()
it.close()
<!UNRESOLVED_REFERENCE!>xx<!>
}
}
@@ -0,0 +1,18 @@
package a
trait Closeable {
fun close() {}
}
class C : Closeable
public inline fun <T: Closeable, R> T.use(block: T.()-> R) : R {
return this.block()
}
fun test() {
C().<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>use<!> {
this.close()
<!UNRESOLVED_REFERENCE!>x<!>
}
}