deprecating types after colon

This commit is contained in:
Dmitry Jemerov
2015-04-21 18:32:31 +02:00
parent b7a4b3c17d
commit f374eec8f1
268 changed files with 1055 additions and 769 deletions
@@ -1,5 +1,7 @@
// !CHECK_TYPE
fun foo(arr: Array<out Number>): Int {
val result = (arr as Array<Int>)[0]
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
return result
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
trait G {
fun get(x: Int, y: Int): Int = x + y
fun set(x: Int, y: Int, value: Int) {}
@@ -5,22 +7,22 @@ trait G {
fun foo1(a: Int?, b: G) {
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
fun foo2(a: Int?, b: G) {
b[0, a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
fun foo3(a: Int?, b: G) {
val r = b[a!!, <!DEBUG_INFO_SMARTCAST!>a<!>]
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
r : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
checkSubtype<Int>(r)
}
fun foo4(a: Int?, b: G) {
val r = b[0, a!!]
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
r : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
checkSubtype<Int>(r)
}
@@ -1,9 +1,11 @@
// !CHECK_TYPE
fun foo1(a: Int?, b: Array<Array<Int>>) {
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
fun foo2(a: Int?, b: Array<Array<Int>>) {
b[0][a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
@@ -1,15 +1,17 @@
// !CHECK_TYPE
fun bar1(x: Number, y: Int) {
var yy = y
yy += x as Int
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun bar2(x: Number) {
<!UNRESOLVED_REFERENCE!>y<!> <!UNRESOLVED_REFERENCE!>+=<!> x as Int
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun bar3(x: Number, y: Array<Int>) {
y[0] += x as Int
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,10 +1,12 @@
// !CHECK_TYPE
fun arrayAccessRHS(a: Int?, b: Array<Int>) {
b[0] = a!!
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
fun arrayAccessLHS(a: Int?, b: Array<Int>) {
b[a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
@@ -1,23 +1,25 @@
// !CHECK_TYPE
fun foo1(x: Number, cond: Boolean): Boolean {
val result = cond && ((x as Int) == 42)
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
return result
}
fun foo2(x: Number, cond: Boolean): Boolean {
val result = ((x as Int) == 42) && cond
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
return result
}
fun foo3(x: Number, cond: Boolean): Boolean {
val result = cond || ((x as Int) == 42)
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
return result
}
fun foo4(x: Number, cond: Boolean): Boolean {
val result = ((x as Int) == 42) || cond
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
return result
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
trait A
trait B : A
@@ -5,12 +7,12 @@ fun B.compareTo(b: B) = if (this == b) 0 else 1
fun foo(a: A): Boolean {
val result = (a as B) < <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
fun bar(a: A, b: B): Boolean {
val result = b < (a as B)
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
@@ -1,5 +1,7 @@
// !CHECK_TYPE
fun foo(x: Number): Boolean {
val result = (x as Int) in 1..5
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
return result
}
@@ -1,14 +1,16 @@
// !CHECK_TYPE
fun foo(x: Int?): Int = x!!
fun elvis(x: Number?): Int {
val result = (x as Int?) ?: foo(<!DEBUG_INFO_SMARTCAST!>x<!>)
<!DEBUG_INFO_SMARTCAST!>x<!> : Int?
checkSubtype<Int?>(<!DEBUG_INFO_SMARTCAST!>x<!>)
return result
}
fun elvisWithRHSTypeInfo(x: Number?): Any? {
val result = x ?: x!!
<!TYPE_MISMATCH!>x<!> : Int?
checkSubtype<Int?>(<!TYPE_MISMATCH!>x<!>)
return result
}
@@ -1,14 +1,16 @@
// !CHECK_TYPE
trait A
trait B : A
fun foo1(a: A, b: B): Boolean {
val result = (a as B) == b
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
fun foo2(a: A, b: B): Boolean {
val result = b == (a as B)
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
@@ -1,11 +1,13 @@
// !CHECK_TYPE
fun foo(a: Number): Int {
val result = (a as Int) compareTo <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
fun bar(a: Number): Int {
val result = 42 compareTo (a as Int)
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
trait A
trait B : A
@@ -5,12 +7,12 @@ fun B.plus(b: B) = if (this == b) b else this
fun foo(a: A): B {
val result = (a as B) + <!DEBUG_INFO_SMARTCAST!>a<!>
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
fun bar(a: A, b: B): B {
val result = b + (a as B)
<!DEBUG_INFO_SMARTCAST!>a<!> : B
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
return result
}
@@ -1,5 +1,7 @@
// !CHECK_TYPE
fun foo(x: Int?): Boolean {
val result = ((x!! == 0) && ((<!DEBUG_INFO_SMARTCAST!>x<!> : Int) == 0))
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
val result = ((x!! == 0) && (checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>) == 0))
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
return result
}
@@ -1,11 +1,13 @@
// !CHECK_TYPE
fun whileLoop(x: Int?) {
outer@ while (x != 0) {
while (x != 1) {
if (x == 2) continue@outer
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun doWhileLoop(x: Int?) {
@@ -13,9 +15,9 @@ fun doWhileLoop(x: Int?) {
do {
if (x == 2) continue@outer
} while (x == null)
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun whileLoopContinueInnerOuter(x: Int?) {
@@ -24,9 +26,9 @@ fun whileLoopContinueInnerOuter(x: Int?) {
while (x != 2) {
if (x == 3) continue@inner
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,18 +1,20 @@
// !CHECK_TYPE
fun simpleDoWhile(x: Int?, y0: Int) {
var y = y0
do {
x : Int?
checkSubtype<Int?>(x)
y++
} while (x!! == y)
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun doWhileWithBreak(x: Int?, y0: Int) {
var y = y0
do {
x : Int?
checkSubtype<Int?>(x)
y++
if (y > 0) break
} while (x!! == y)
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
@@ -1,6 +1,8 @@
// !CHECK_TYPE
fun foo(arr: Array<Int>?) {
for (x in arr!!) {
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
}
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
}
@@ -1,29 +1,31 @@
// !CHECK_TYPE
fun ifThen(x: Int?) {
if (x!! == 0) {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun ifElse(x: Int?) {
if (x!! == 0) else {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun ifThenElse(x: Int?) {
if (x!! == 0) {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
} else {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun ifIs(x: Int?, cond: Boolean) {
if ((x is Int) == cond) {
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
@@ -1,6 +1,8 @@
// !CHECK_TYPE
fun foo(x: Number) {
if ((x as Int) is Int) {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
fun noUselessDataFlowInfoCreation(x: Number) {
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
@@ -14,7 +16,7 @@ fun dataFlowInfoAnd(a: Array<Number>) {
if (a[15] is Int) { if (a[16] is Int) { if (a[17] is Int) { if (a[18] is Int) { if (a[19] is Int) {
if (a[20] is Int) { if (a[21] is Int) { if (a[22] is Int) { if (a[23] is Int) { if (a[24] is Int) {
if (a[25] is Int) { if (a[26] is Int) { if (a[27] is Int) { if (a[28] is Int) { if (a[29] is Int) {
<!TYPE_MISMATCH!>a[0]<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>a[0]<!>)
} } } } } } } } } } } } } } } } } } } } } } } } } } } } } }
}
@@ -25,6 +27,6 @@ fun dataFlowInfoOr(a: Array<Number>) {
a[30] is Int || a[31] is Int || a[32] is Int || a[33] is Int || a[34] is Int || a[35] is Int || a[36] is Int || a[37] is Int || a[38] is Int || a[39] is Int ||
a[40] is Int || a[41] is Int || a[42] is Int || a[43] is Int || a[44] is Int || a[45] is Int || a[46] is Int || a[47] is Int || a[48] is Int || a[49] is Int ||
a[50] is Int || a[51] is Int || a[52] is Int || a[53] is Int || a[54] is Int || a[55] is Int || a[56] is Int || a[57] is Int || a[58] is Int || a[59] is Int) {
<!TYPE_MISMATCH!>a[0]<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>a[0]<!>)
}
}
@@ -1,7 +1,9 @@
// !CHECK_TYPE
fun Int.component1() = "a"
fun foo(a: Number) {
val (x) = a as Int
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
x : String
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
checkSubtype<String>(x)
}
@@ -1,6 +1,8 @@
// !CHECK_TYPE
fun foo(x: Number, y: String?): String {
val result = "abcde $x ${x as Int} ${y!!} $x $y"
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
<!DEBUG_INFO_SMARTCAST!>y<!> : String
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>y<!>)
return result
}
@@ -1,9 +1,11 @@
// !CHECK_TYPE
fun tryFinally(x: Int?) {
try {
} finally {
x!!
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun tryCatchFinally(x: Int?) {
@@ -12,8 +14,8 @@ fun tryCatchFinally(x: Int?) {
} catch (e: Exception) {
x!!
} finally {
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
x!!
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,24 +1,26 @@
// !CHECK_TYPE
fun foo(x: Number, y: Int) {
when (x) {
x as Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
x as Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
y -> {}
else -> {}
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun bar(x: Number) {
when (x) {
x as Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
x as Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
else -> {}
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun whenWithoutSubject(x: Number) {
when {
(x as Int) == 42 -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
(x as Int) == 42 -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
else -> {}
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,24 +1,26 @@
// !CHECK_TYPE
fun foo(x: Number, y: Int) {
when (x) {
is Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
is Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
y -> {}
else -> {}
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
fun bar(x: Number) {
when (x) {
is Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
is Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
else -> {}
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
fun whenWithoutSubject(x: Number) {
when {
(x is Int) -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
(x is Int) -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
else -> {}
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}
@@ -1,13 +1,15 @@
// !CHECK_TYPE
fun foo(x: Int, list: List<Int>?) {
when (x) {
in list!! -> <!DEBUG_INFO_SMARTCAST!>list<!> : List<Int>
in list!! -> checkSubtype<List<Int>>(<!DEBUG_INFO_SMARTCAST!>list<!>)
else -> {}
}
}
fun whenWithoutSubject(x: Int, list: List<Int>?) {
when {
x in list!! -> <!DEBUG_INFO_SMARTCAST!>list<!> : List<Int>
x in list!! -> checkSubtype<List<Int>>(<!DEBUG_INFO_SMARTCAST!>list<!>)
else -> {}
}
}
@@ -1,6 +1,8 @@
// !CHECK_TYPE
fun foo(x: Number) {
when (x as Int) {
else -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
else -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
@@ -1,24 +1,26 @@
// !CHECK_TYPE
fun simpleWhile(x: Int?, y0: Int) {
var y = y0
while (x!! == y) {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
y++
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun whileWithBreak(x: Int?, y0: Int) {
var y = y0
while (x!! == y) {
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
break
}
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
fun whileWithNoCondition(x: Int?) {
while (<!SYNTAX!><!>) {
x!!
}
<!TYPE_MISMATCH!>x<!> : Int
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
}