Rename: auto cast -> smart cast

This commit is contained in:
Svetlana Isakova
2014-09-29 23:09:05 +04:00
parent 20f3403c80
commit ce01c61811
294 changed files with 840 additions and 842 deletions
@@ -1,8 +1,8 @@
fun set(<!UNUSED_PARAMETER!>key<!> : String, <!UNUSED_PARAMETER!>value<!> : String) {
val a : String? = ""
when (a) {
"" -> <!DEBUG_INFO_AUTOCAST!>a<!>.get(0)
is String, is Any -> <!DEBUG_INFO_AUTOCAST!>a<!>.compareTo("")
"" -> <!DEBUG_INFO_SMARTCAST!>a<!>.get(0)
is String, is Any -> <!DEBUG_INFO_SMARTCAST!>a<!>.compareTo("")
else -> a.toString()
}
}
@@ -2,6 +2,6 @@
trait Tree {}
fun Any?.TreeValue() : Tree {
if (this is Tree) return <!DEBUG_INFO_AUTOCAST!>this<!>
if (this is Tree) return <!DEBUG_INFO_SMARTCAST!>this<!>
throw Exception()
}
@@ -1,6 +1,6 @@
// KT-201 Allow to call extension with nullable receiver with a '.'
fun <T : Any> T?.npe() : T = if (this == null) throw NullPointerException() else <!DEBUG_INFO_AUTOCAST!>this<!>
fun <T : Any> T?.npe() : T = if (this == null) throw NullPointerException() else <!DEBUG_INFO_SMARTCAST!>this<!>
fun foo() {
val i : Int? = 1
@@ -7,5 +7,5 @@ fun <T> Iterable<T>.join(separator : String?) : String {
fun <T : Any> T?.npe() : T {
if (this == null)
throw NullPointerException()
return <!DEBUG_INFO_AUTOCAST!>this<!>;
return <!DEBUG_INFO_SMARTCAST!>this<!>;
}
@@ -22,6 +22,6 @@ fun doSmth(<!UNUSED_PARAMETER!>a<!>: String) {}
val testIt : (Any) -> Unit = {
if (it is String) {
doSmth(<!DEBUG_INFO_AUTOCAST!>it<!>)
doSmth(<!DEBUG_INFO_SMARTCAST!>it<!>)
}
}
@@ -2,8 +2,6 @@
package StringBuilder
import java.lang.StringBuilder
//import kotlin.io.*
//import java.io.*
@@ -13,4 +11,4 @@ fun main(args : Array<String>) {
val Int.bd : StringBuilder get() = StringBuilder(this.toString())
fun StringBuilder.plus(other : StringBuilder) : StringBuilder = this.append(other).sure1() // !!!
fun <T : Any> T?.sure1() : T { return if (this != null) <!DEBUG_INFO_AUTOCAST!>this<!> else throw NullPointerException() }
fun <T : Any> T?.sure1() : T { return if (this != null) <!DEBUG_INFO_SMARTCAST!>this<!> else throw NullPointerException() }
@@ -2,13 +2,13 @@
fun <T> Array<T>?.get(i: Int) : T {
if (this != null)
return <!DEBUG_INFO_AUTOCAST!>this<!>.get(i) // <- inferred type is Any? but &T was excepted
return <!DEBUG_INFO_SMARTCAST!>this<!>.get(i) // <- inferred type is Any? but &T was excepted
else throw NullPointerException()
}
fun Int?.inc() : Int {
if (this != null)
return <!DEBUG_INFO_AUTOCAST!>this<!>.inc()
return <!DEBUG_INFO_SMARTCAST!>this<!>.inc()
else
throw NullPointerException()
}
@@ -1,6 +1,6 @@
//KT-600 Problem with 'sure' extension function type inference
fun <T : Any> T?._sure() : T { if (this != null) return <!DEBUG_INFO_AUTOCAST!>this<!> else throw NullPointerException() }
fun <T : Any> T?._sure() : T { if (this != null) return <!DEBUG_INFO_SMARTCAST!>this<!> else throw NullPointerException() }
fun test() {
val i : Int? = 10