Don't generate UNNECESSARY_SAFE_CALL on variables of generic type <T: Any?>

This commit is contained in:
Andrey Breslav
2012-10-25 12:00:27 +04:00
parent 3e38870ecc
commit b5385788a3
6 changed files with 70 additions and 6 deletions
@@ -4,7 +4,7 @@ package outer
fun Int?.optint() : Unit {}
val Int?.optval : Unit = Unit.VALUE
fun <T, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T {
fun <T: Any, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T {
y.plus(1)
y plus 1
y + 1.0
@@ -0,0 +1,13 @@
fun <T> test(t: T): String {
if (t != null) {
return t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
}
return t?.toString()
}
fun <T> T.testThis(): String {
if (this != null) {
return this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
}
return this?.toString()
}