KT-597 Type inference failed

Resolution rules changed: now autocast and non-autocast candidates are judged together
This commit is contained in:
Andrey Breslav
2011-11-29 21:03:42 +03:00
parent 2849c58d47
commit 8a93421ecb
6 changed files with 31 additions and 17 deletions
@@ -0,0 +1,20 @@
//KT-597 Type inference failed
// +JDK
fun <T> Array<T>?.get(i: Int) : T {
if (this != null)
return this.get(i) // <- inferred type is Any? but &T was excepted
else throw NullPointerException()
}
fun Int?.inc() : Int {
if (this != null)
return this.inc()
else
throw NullPointerException()
}
fun test() {
var i : Int? = 10
var <!UNUSED_VARIABLE!>i_inc<!> = <!UNUSED_CHANGED_VALUE!>i++<!> // <- expected Int?, but returns Any?
}