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
+12 -10
View File
@@ -1,16 +1,18 @@
fun <T> checkSubtype(t: T) = t
fun test() : Unit {
var x : Int? = 0
var y : Int = 0
x : Int?
y : Int
x as Int : Int
y <warning>as Int</warning> : Int
x <warning>as Int?</warning> : Int?
y <warning>as Int?</warning> : Int?
x <warning>as Int?</warning> : Int?
y <warning>as? Int</warning> : Int?
x <warning>as? Int?</warning> : Int?
y <warning>as? Int?</warning> : Int?
checkSubtype<Int?>(x)
checkSubtype<Int>(y)
checkSubtype<Int>(x as Int)
checkSubtype<Int>(y <warning>as Int</warning>)
checkSubtype<Int?>(x <warning>as Int?</warning>)
checkSubtype<Int?>(y <warning>as Int?</warning>)
checkSubtype<Int?>(x <warning>as Int?</warning>)
checkSubtype<Int?>(y <warning>as? Int</warning>)
checkSubtype<Int?>(x <warning>as? Int?</warning>)
checkSubtype<Int?>(y <warning>as? Int?</warning>)
Unit
}
+5 -3
View File
@@ -1,7 +1,9 @@
fun <T> checkSubtype(t: T) = t
fun test() {
1 : Byte
1 : Int
<error>1</error> : Double
checkSubtype<Byte>(1)
checkSubtype<Int>(1)
checkSubtype<Double>(<error>1</error>)
1 <warning>as</warning> Byte
1 <warning>as Int</warning>
1 <warning>as</warning> Double
+3 -1
View File
@@ -1,5 +1,7 @@
import java.util.*;
fun <T> checkSubtype(t: T) = t
class NotRange1() {
}
@@ -76,6 +78,6 @@ fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRa
for (i in range0);
for (i in range1);
for (i in (ArrayList<Int>() : List<Int>));
for (i in (checkSubtype<List<Int>>(ArrayList<Int>())));
}
@@ -1,16 +1,18 @@
class A(val a:Int) {
fun <T> checkSubtype(t: T) = t
class A(val a:Int) {
inner class B() {
val x = this@B : B
val y = this@A : A
val z = this : B
val Int.xx : Int get() = this : Int
val x = checkSubtype<B>(this@B)
val y = checkSubtype<A>(this@A)
val z = checkSubtype<B>(this)
val Int.xx : Int get() = checkSubtype<Int>(this)
fun Char.xx() : Double.() -> Unit {
this : Char
val <warning>a</warning>: Double.() -> Unit = { this : Double + this@xx : Char}
val <warning>b</warning>: Double.() -> Unit = a@{this@a : Double + this@xx : Char}
val <warning>c</warning> = a@{<error>this@a</error> <error>+</error> this@xx : Char}
return (a@{this@a : Double + this@xx : Char})
checkSubtype<Char>(this)
val <warning>a</warning>: Double.() -> Unit = { checkSubtype<Double>(this) + checkSubtype<Char>(this@xx) }
val <warning>b</warning>: Double.() -> Unit = a@{checkSubtype<Double>(this@a) + checkSubtype<Char>(this@xx) }
val <warning>c</warning> = a@{<error>this@a</error> <error>+</error> checkSubtype<Char>(this@xx) }
return (a@{checkSubtype<Double>(this@a) + checkSubtype<Char>(this@xx) })
}
}
}
+4 -2
View File
@@ -6,6 +6,8 @@ import <error>utils</error>.*
import java.io.PrintStream
import <warning>java.lang.Comparable</warning> as Com
fun <T> checkSubtype(t: T) = t
val l : MutableList<in Int> = ArrayList<Int>()
fun test(<warning>l</warning> : List<Int>) {
@@ -22,7 +24,7 @@ fun test(<warning>l</warning> : List<Int>) {
Collections.emptyList<Int>()
Collections.<error>emptyList</error>()
Collections.singleton<Int>(1) : Set<Int>?
checkSubtype<Set<Int>?>(Collections.singleton<Int>(1))
Collections.singleton<Int>(<error>1.0</error>)
<error>List</error><Int>
@@ -41,7 +43,7 @@ fun test(<warning>l</warning> : List<Int>) {
val c : <warning>Com<Int></warning>? = null
c : <warning>java.lang.Comparable<Int></warning>?
checkSubtype<<warning>java.lang.Comparable<Int></warning>?>(c)
// Collections.sort<Integer>(ArrayList<Integer>())
}
-1
View File
@@ -1,7 +1,6 @@
fun test(<warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">unusedParam</warning>: Int) { // UNUSED_PARAMETER
val str = ":)"
str <warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">as String</warning> // USELESS_CAST
str <warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">as Any</warning> // USELESS_CAST_STATIC_ASSERT_IS_FINE
// UNUSED_FUNCTION_LITERAL
<warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">{
+3 -1
View File
@@ -1,3 +1,5 @@
import java.util.Collections
val ab = Collections.emptyList<Int>() : List<Int>?
fun <T> checkSubtype(t: T) = t
val ab = checkSubtype<List<Int>?>(Collections.emptyList<Int>())
@@ -1,18 +1,20 @@
class Foo(var bar : Int, var barr : Int, var barrr : Int) {
init {
bar = 1
barr = 1
barrr = 1
1 : Int
this : Foo
}
fun <T> checkSubtype(t: T) = t
init {
bar = 1
this.bar
1 : Int
val <warning>a</warning> : Int =1
this : Foo
}
class Foo(var bar : Int, var barr : Int, var barrr : Int) {
init {
bar = 1
barr = 1
barrr = 1
checkSubtype<Int>(1)
checkSubtype<Foo>(this)
}
init {
bar = 1
this.bar
checkSubtype<Int>(1)
val <warning>a</warning> : Int =1
checkSubtype<Foo>(this)
}
}