deprecating types after colon
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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">{
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Remove static type assertion" "true"
|
||||
fun foo(a: String) {
|
||||
val b = a
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// "Replace a cast with a static assert" "true"
|
||||
fun foo(a: String) {
|
||||
val b = a : Any
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Remove static type assertion" "true"
|
||||
fun foo(a: String) {
|
||||
val b = a <caret>: Any
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// "Replace a cast with a static assert" "true"
|
||||
fun foo(a: String) {
|
||||
val b = a <caret>as Any
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// "Cast expression 'x' to 'String'" "false"
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.String</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
|
||||
fun foo(x: Int) {
|
||||
x<caret>: String
|
||||
}
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
// "Change parameter 'z' type of function 'foo' to '(Int) -> String'" "false"
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
|
||||
|
||||
// ACTION: Disable 'Move Lambda Function Into Parentheses'
|
||||
// ACTION: Edit intention settings
|
||||
@@ -7,7 +6,7 @@
|
||||
|
||||
fun foo(y: Int = 0, z: (Int) -> String = {""}) {
|
||||
foo {
|
||||
""<caret>: Int
|
||||
""<caret> as Int
|
||||
""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user