KT-609 Analyze not only local variables, but function parameters as well in 'unused values' analysis
This commit is contained in:
@@ -31,8 +31,10 @@ fun f(a : Boolean) : Unit {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[r(1)] PREV:[]
|
||||
r(1) NEXT:[r(a)] PREV:[<START>]
|
||||
<START> NEXT:[v(a : Boolean)] PREV:[]
|
||||
v(a : Boolean) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[r(1)] PREV:[v(a : Boolean)]
|
||||
r(1) NEXT:[r(a)] PREV:[w(a)]
|
||||
r(a) NEXT:[r(2)] PREV:[r(1)]
|
||||
r(2) NEXT:[r(lng)] PREV:[r(a)]
|
||||
r(lng) NEXT:[r(2.lng)] PREV:[r(2)]
|
||||
@@ -92,14 +94,18 @@ sink:
|
||||
fun foo(a : Boolean, b : Int) : Unit {}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(a : Boolean)] PREV:[]
|
||||
v(a : Boolean) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[v(b : Int)] PREV:[v(a : Boolean)]
|
||||
v(b : Int) NEXT:[w(b)] PREV:[w(a)]
|
||||
w(b) NEXT:[read (Unit)] PREV:[v(b : Int)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(b)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
=====================
|
||||
== genfun ==
|
||||
fun genfun<T>() : Unit {}
|
||||
@@ -118,12 +124,14 @@ sink:
|
||||
fun flfun(f : fun () : Any) : Unit {}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(f : fun () : Any)] PREV:[]
|
||||
v(f : fun () : Any) NEXT:[w(f)] PREV:[<START>]
|
||||
w(f) NEXT:[read (Unit)] PREV:[v(f : fun () : Any)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(f)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
=====================
|
||||
|
||||
@@ -388,8 +388,10 @@ fun t8(a : Int) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[r(1)] PREV:[]
|
||||
r(1) NEXT:[r(a)] PREV:[<START>]
|
||||
<START> NEXT:[v(a : Int)] PREV:[]
|
||||
v(a : Int) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[r(1)] PREV:[v(a : Int)]
|
||||
r(1) NEXT:[r(a)] PREV:[w(a)]
|
||||
r(a) NEXT:[r(..)] PREV:[r(1)]
|
||||
r(..) NEXT:[r(1..a)] PREV:[r(a)]
|
||||
r(1..a) NEXT:[v(i)] PREV:[r(..)]
|
||||
@@ -439,8 +441,10 @@ fun t9(a : Int) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[r(1)] PREV:[]
|
||||
r(1) NEXT:[r(a)] PREV:[<START>]
|
||||
<START> NEXT:[v(a : Int)] PREV:[]
|
||||
v(a : Int) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[r(1)] PREV:[v(a : Int)]
|
||||
r(1) NEXT:[r(a)] PREV:[w(a)]
|
||||
r(a) NEXT:[r(..)] PREV:[r(1)]
|
||||
r(..) NEXT:[r(1..a)] PREV:[r(a)]
|
||||
r(1..a) NEXT:[v(i)] PREV:[r(..)]
|
||||
@@ -489,8 +493,10 @@ fun t10(a : Int) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[r(1)] PREV:[]
|
||||
r(1) NEXT:[r(a)] PREV:[<START>]
|
||||
<START> NEXT:[v(a : Int)] PREV:[]
|
||||
v(a : Int) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[r(1)] PREV:[v(a : Int)]
|
||||
r(1) NEXT:[r(a)] PREV:[w(a)]
|
||||
r(a) NEXT:[r(..)] PREV:[r(1)]
|
||||
r(..) NEXT:[r(1..a)] PREV:[r(a)]
|
||||
r(1..a) NEXT:[v(i)] PREV:[r(..)]
|
||||
@@ -747,8 +753,10 @@ fun doSmth(i: Int) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(i: Int)] PREV:[]
|
||||
v(i: Int) NEXT:[w(i)] PREV:[<START>]
|
||||
w(i) NEXT:[read (Unit)] PREV:[v(i: Int)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(i)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
|
||||
@@ -34,8 +34,10 @@ sink:
|
||||
fun doSmth(i: Int) {}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(i: Int)] PREV:[]
|
||||
v(i: Int) NEXT:[w(i)] PREV:[<START>]
|
||||
w(i) NEXT:[read (Unit)] PREV:[v(i: Int)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(i)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
|
||||
@@ -17,8 +17,10 @@ fun t1(b: Boolean) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[v(var u: String)] PREV:[]
|
||||
v(var u: String) NEXT:[r(b)] PREV:[<START>]
|
||||
<START> NEXT:[v(b: Boolean)] PREV:[]
|
||||
v(b: Boolean) NEXT:[w(b)] PREV:[<START>]
|
||||
w(b) NEXT:[v(var u: String)] PREV:[v(b: Boolean)]
|
||||
v(var u: String) NEXT:[r(b)] PREV:[w(b)]
|
||||
r(b) NEXT:[jf(l2)] PREV:[v(var u: String)]
|
||||
jf(l2) NEXT:[read (Unit), r("s")] PREV:[r(b)]
|
||||
r("s") NEXT:[w(u)] PREV:[jf(l2)]
|
||||
@@ -63,45 +65,49 @@ fun t2(b: Boolean) {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[v(val i = 3)] PREV:[]
|
||||
v(val i = 3) NEXT:[r(3)] PREV:[<START>]
|
||||
r(3) NEXT:[w(i)] PREV:[v(val i = 3)]
|
||||
w(i) NEXT:[r(b)] PREV:[r(3)]
|
||||
r(b) NEXT:[jf(l2)] PREV:[w(i)]
|
||||
jf(l2) NEXT:[read (Unit), ret l1] PREV:[r(b)]
|
||||
ret l1 NEXT:[<END>] PREV:[jf(l2)]
|
||||
* jmp(l3) NEXT:[r(i)] PREV:[]
|
||||
<START> NEXT:[v(b: Boolean)] PREV:[]
|
||||
v(b: Boolean) NEXT:[w(b)] PREV:[<START>]
|
||||
w(b) NEXT:[v(val i = 3)] PREV:[v(b: Boolean)]
|
||||
v(val i = 3) NEXT:[r(3)] PREV:[w(b)]
|
||||
r(3) NEXT:[w(i)] PREV:[v(val i = 3)]
|
||||
w(i) NEXT:[r(b)] PREV:[r(3)]
|
||||
r(b) NEXT:[jf(l2)] PREV:[w(i)]
|
||||
jf(l2) NEXT:[read (Unit), ret l1] PREV:[r(b)]
|
||||
ret l1 NEXT:[<END>] PREV:[jf(l2)]
|
||||
* jmp(l3) NEXT:[r(i)] PREV:[]
|
||||
l2:
|
||||
read (Unit) NEXT:[r(i)] PREV:[jf(l2)]
|
||||
read (Unit) NEXT:[r(i)] PREV:[jf(l2)]
|
||||
l3:
|
||||
r(i) NEXT:[r(doSmth)] PREV:[read (Unit)]
|
||||
r(doSmth) NEXT:[r(doSmth(i))] PREV:[r(i)]
|
||||
r(doSmth(i)) NEXT:[r(i)] PREV:[r(doSmth)]
|
||||
r(i) NEXT:[r(i is Int)] PREV:[r(doSmth(i))]
|
||||
r(i is Int) NEXT:[jf(l4)] PREV:[r(i)]
|
||||
jf(l4) NEXT:[read (Unit), ret l1] PREV:[r(i is Int)]
|
||||
ret l1 NEXT:[<END>] PREV:[jf(l4)]
|
||||
* jmp(l5) NEXT:[<END>] PREV:[]
|
||||
r(i) NEXT:[r(doSmth)] PREV:[read (Unit)]
|
||||
r(doSmth) NEXT:[r(doSmth(i))] PREV:[r(i)]
|
||||
r(doSmth(i)) NEXT:[r(i)] PREV:[r(doSmth)]
|
||||
r(i) NEXT:[r(i is Int)] PREV:[r(doSmth(i))]
|
||||
r(i is Int) NEXT:[jf(l4)] PREV:[r(i)]
|
||||
jf(l4) NEXT:[read (Unit), ret l1] PREV:[r(i is Int)]
|
||||
ret l1 NEXT:[<END>] PREV:[jf(l4)]
|
||||
* jmp(l5) NEXT:[<END>] PREV:[]
|
||||
l4:
|
||||
read (Unit) NEXT:[<END>] PREV:[jf(l4)]
|
||||
read (Unit) NEXT:[<END>] PREV:[jf(l4)]
|
||||
l1:
|
||||
l5:
|
||||
<END> NEXT:[<SINK>] PREV:[ret l1, ret l1, read (Unit)]
|
||||
<END> NEXT:[<SINK>] PREV:[ret l1, ret l1, read (Unit)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
=====================
|
||||
== doSmth ==
|
||||
fun doSmth(s: String) {}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(s: String)] PREV:[]
|
||||
v(s: String) NEXT:[w(s)] PREV:[<START>]
|
||||
w(s) NEXT:[read (Unit)] PREV:[v(s: String)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(s)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
=====================
|
||||
|
||||
@@ -18,57 +18,61 @@ fun lazyBooleans(a : Boolean, b : Boolean) : Unit {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[r(a)] PREV:[]
|
||||
r(a) NEXT:[jf(l2)] PREV:[<START>]
|
||||
jf(l2) NEXT:[r(2), r(1)] PREV:[r(a)]
|
||||
r(1) NEXT:[jmp(l3)] PREV:[jf(l2)]
|
||||
jmp(l3) NEXT:[r(3)] PREV:[r(1)]
|
||||
<START> NEXT:[v(a : Boolean)] PREV:[]
|
||||
v(a : Boolean) NEXT:[w(a)] PREV:[<START>]
|
||||
w(a) NEXT:[v(b : Boolean)] PREV:[v(a : Boolean)]
|
||||
v(b : Boolean) NEXT:[w(b)] PREV:[w(a)]
|
||||
w(b) NEXT:[r(a)] PREV:[v(b : Boolean)]
|
||||
r(a) NEXT:[jf(l2)] PREV:[w(b)]
|
||||
jf(l2) NEXT:[r(2), r(1)] PREV:[r(a)]
|
||||
r(1) NEXT:[jmp(l3)] PREV:[jf(l2)]
|
||||
jmp(l3) NEXT:[r(3)] PREV:[r(1)]
|
||||
l2:
|
||||
r(2) NEXT:[r(3)] PREV:[jf(l2)]
|
||||
r(2) NEXT:[r(3)] PREV:[jf(l2)]
|
||||
l3:
|
||||
r(3) NEXT:[r(a)] PREV:[jmp(l3), r(2)]
|
||||
r(a) NEXT:[jf(l4)] PREV:[r(3)]
|
||||
jf(l4) NEXT:[jf(l5), r(b)] PREV:[r(a)]
|
||||
r(b) NEXT:[jf(l5)] PREV:[jf(l4)]
|
||||
r(3) NEXT:[r(a)] PREV:[jmp(l3), r(2)]
|
||||
r(a) NEXT:[jf(l4)] PREV:[r(3)]
|
||||
jf(l4) NEXT:[jf(l5), r(b)] PREV:[r(a)]
|
||||
r(b) NEXT:[jf(l5)] PREV:[jf(l4)]
|
||||
l4:
|
||||
jf(l5) NEXT:[r(6), r(5)] PREV:[jf(l4), r(b)]
|
||||
r(5) NEXT:[jmp(l6)] PREV:[jf(l5)]
|
||||
jmp(l6) NEXT:[r(7)] PREV:[r(5)]
|
||||
jf(l5) NEXT:[r(6), r(5)] PREV:[jf(l4), r(b)]
|
||||
r(5) NEXT:[jmp(l6)] PREV:[jf(l5)]
|
||||
jmp(l6) NEXT:[r(7)] PREV:[r(5)]
|
||||
l5:
|
||||
r(6) NEXT:[r(7)] PREV:[jf(l5)]
|
||||
r(6) NEXT:[r(7)] PREV:[jf(l5)]
|
||||
l6:
|
||||
r(7) NEXT:[r(a)] PREV:[jmp(l6), r(6)]
|
||||
r(a) NEXT:[jt(l7)] PREV:[r(7)]
|
||||
jt(l7) NEXT:[r(b), jf(l8)] PREV:[r(a)]
|
||||
r(b) NEXT:[jf(l8)] PREV:[jt(l7)]
|
||||
r(7) NEXT:[r(a)] PREV:[jmp(l6), r(6)]
|
||||
r(a) NEXT:[jt(l7)] PREV:[r(7)]
|
||||
jt(l7) NEXT:[r(b), jf(l8)] PREV:[r(a)]
|
||||
r(b) NEXT:[jf(l8)] PREV:[jt(l7)]
|
||||
l7:
|
||||
jf(l8) NEXT:[r(9), r(8)] PREV:[jt(l7), r(b)]
|
||||
r(8) NEXT:[jmp(l9)] PREV:[jf(l8)]
|
||||
jmp(l9) NEXT:[r(10)] PREV:[r(8)]
|
||||
jf(l8) NEXT:[r(9), r(8)] PREV:[jt(l7), r(b)]
|
||||
r(8) NEXT:[jmp(l9)] PREV:[jf(l8)]
|
||||
jmp(l9) NEXT:[r(10)] PREV:[r(8)]
|
||||
l8:
|
||||
r(9) NEXT:[r(10)] PREV:[jf(l8)]
|
||||
r(9) NEXT:[r(10)] PREV:[jf(l8)]
|
||||
l9:
|
||||
r(10) NEXT:[r(a)] PREV:[jmp(l9), r(9)]
|
||||
r(a) NEXT:[jf(l10)] PREV:[r(10)]
|
||||
jf(l10) NEXT:[read (Unit), r(11)] PREV:[r(a)]
|
||||
r(11) NEXT:[jmp(l11)] PREV:[jf(l10)]
|
||||
jmp(l11) NEXT:[r(12)] PREV:[r(11)]
|
||||
r(10) NEXT:[r(a)] PREV:[jmp(l9), r(9)]
|
||||
r(a) NEXT:[jf(l10)] PREV:[r(10)]
|
||||
jf(l10) NEXT:[read (Unit), r(11)] PREV:[r(a)]
|
||||
r(11) NEXT:[jmp(l11)] PREV:[jf(l10)]
|
||||
jmp(l11) NEXT:[r(12)] PREV:[r(11)]
|
||||
l10:
|
||||
read (Unit) NEXT:[r(12)] PREV:[jf(l10)]
|
||||
read (Unit) NEXT:[r(12)] PREV:[jf(l10)]
|
||||
l11:
|
||||
r(12) NEXT:[r(a)] PREV:[jmp(l11), read (Unit)]
|
||||
r(a) NEXT:[jf(l12)] PREV:[r(12)]
|
||||
jf(l12) NEXT:[r(13), read (Unit)] PREV:[r(a)]
|
||||
read (Unit) NEXT:[jmp(l13)] PREV:[jf(l12)]
|
||||
jmp(l13) NEXT:[r(14)] PREV:[read (Unit)]
|
||||
r(12) NEXT:[r(a)] PREV:[jmp(l11), read (Unit)]
|
||||
r(a) NEXT:[jf(l12)] PREV:[r(12)]
|
||||
jf(l12) NEXT:[r(13), read (Unit)] PREV:[r(a)]
|
||||
read (Unit) NEXT:[jmp(l13)] PREV:[jf(l12)]
|
||||
jmp(l13) NEXT:[r(14)] PREV:[read (Unit)]
|
||||
l12:
|
||||
r(13) NEXT:[r(14)] PREV:[jf(l12)]
|
||||
r(13) NEXT:[r(14)] PREV:[jf(l12)]
|
||||
l13:
|
||||
r(14) NEXT:[<END>] PREV:[jmp(l13), r(13)]
|
||||
r(14) NEXT:[<END>] PREV:[jmp(l13), r(13)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[r(14)]
|
||||
<END> NEXT:[<SINK>] PREV:[r(14)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
<SINK> NEXT:[] PREV:[<END>]
|
||||
=====================
|
||||
|
||||
@@ -80,8 +80,10 @@ sink:
|
||||
fun doSmth(i: Int) {}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[read (Unit)] PREV:[]
|
||||
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||
<START> NEXT:[v(i: Int)] PREV:[]
|
||||
v(i: Int) NEXT:[w(i)] PREV:[<START>]
|
||||
w(i) NEXT:[read (Unit)] PREV:[v(i: Int)]
|
||||
read (Unit) NEXT:[<END>] PREV:[w(i)]
|
||||
l1:
|
||||
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||
error:
|
||||
|
||||
@@ -237,7 +237,7 @@ abstract class B3(i: Int) {
|
||||
this(): this(1)
|
||||
}
|
||||
|
||||
fun foo(c: B3) {
|
||||
fun foo(<!UNUSED_PARAMETER!>c<!>: B3) {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
|
||||
val <!UNUSED_VARIABLE!>b<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,18 @@ fun text() {
|
||||
bar2 <!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>it<!> => it}<!>
|
||||
}
|
||||
|
||||
fun bar(f : fun (Int, Int) : Int) {}
|
||||
fun bar1(f : fun (Int) : Int) {}
|
||||
fun bar2(f : fun () : Int) {}
|
||||
fun bar(<!UNUSED_PARAMETER!>f<!> : fun (Int, Int) : Int) {}
|
||||
fun bar1(<!UNUSED_PARAMETER!>f<!> : fun (Int) : Int) {}
|
||||
fun bar2(<!UNUSED_PARAMETER!>f<!> : fun () : Int) {}
|
||||
|
||||
fun String.to(dest : String) {
|
||||
fun String.to(<!UNUSED_PARAMETER!>dest<!> : String) {
|
||||
|
||||
}
|
||||
|
||||
fun String.on(predicate : fun (s : URI) : Boolean) : URI {
|
||||
fun String.on(<!UNUSED_PARAMETER!>predicate<!> : fun (s : URI) : Boolean) : URI {
|
||||
return URI(this)
|
||||
}
|
||||
|
||||
class URI(val body : Any) {
|
||||
fun to(dest : String) {}
|
||||
fun to(<!UNUSED_PARAMETER!>dest<!> : String) {}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class AClass() {
|
||||
|
||||
val x : Any? = 1
|
||||
|
||||
fun Any?.vars(a: Any?) : Int {
|
||||
fun Any?.vars(<!UNUSED_PARAMETER!>a<!>: Any?) : Int {
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>b<!>: Int = 0
|
||||
if (ns.y is Int) {
|
||||
b = <!UNUSED_VALUE!>ns.y<!>
|
||||
@@ -88,4 +88,4 @@ open class C {
|
||||
t = <!UNUSED_VALUE!>this@C<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
fun foo(<!UNUSED_PARAMETER!>u<!> : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class A() {
|
||||
fun equals(a : Any?) : Boolean = false
|
||||
fun equals(<!UNUSED_PARAMETER!>a<!> : Any?) : Boolean = false
|
||||
}
|
||||
|
||||
class B() {
|
||||
fun equals(a : Any?) : Boolean? = false
|
||||
fun equals(<!UNUSED_PARAMETER!>a<!> : Any?) : Boolean? = false
|
||||
}
|
||||
|
||||
class C() {
|
||||
fun equals(a : Any?) : Int = 0
|
||||
fun equals(<!UNUSED_PARAMETER!>a<!> : Any?) : Int = 0
|
||||
}
|
||||
|
||||
fun f(): Unit {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class C {
|
||||
|
||||
fun f (a : Boolean, b : Boolean) {
|
||||
fun f (<!UNUSED_PARAMETER!>a<!> : Boolean, <!UNUSED_PARAMETER!>b<!> : Boolean) {
|
||||
@b (while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
@@ -25,7 +25,7 @@ class C {
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
}
|
||||
|
||||
fun containsBreak(a: String?, b: String?) {
|
||||
fun containsBreak(a: String?, <!UNUSED_PARAMETER!>b<!>: String?) {
|
||||
while (a == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// http://youtrack.jetbrains.net/issue/KT-424
|
||||
|
||||
class A {
|
||||
<!CONFLICTING_OVERLOADS!>fun a(a: Int): Int<!> = 0
|
||||
<!CONFLICTING_OVERLOADS!>fun a(<!UNUSED_PARAMETER!>a<!>: Int): Int<!> = 0
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun a(a: Int)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun a(<!UNUSED_PARAMETER!>a<!>: Int)<!> {
|
||||
}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun b()<!> {
|
||||
@@ -14,17 +14,17 @@ class A {
|
||||
}
|
||||
|
||||
namespace deepSpace {
|
||||
<!CONFLICTING_OVERLOADS!>fun c(s: String)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun c(<!UNUSED_PARAMETER!>s<!>: String)<!> {
|
||||
}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun c(s: String)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun c(<!UNUSED_PARAMETER!>s<!>: String)<!> {
|
||||
}
|
||||
|
||||
class B {
|
||||
<!CONFLICTING_OVERLOADS!>fun d(s: String)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun d(<!UNUSED_PARAMETER!>s<!>: String)<!> {
|
||||
}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun d(s: String)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun d(<!UNUSED_PARAMETER!>s<!>: String)<!> {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,9 +49,9 @@ namespace ns3 {
|
||||
// check same rules apply for ext functions
|
||||
|
||||
namespace extensionFunctions {
|
||||
<!CONFLICTING_OVERLOADS!>fun Int.qwe(a: Float)<!> = 1
|
||||
<!CONFLICTING_OVERLOADS!>fun Int.qwe(<!UNUSED_PARAMETER!>a<!>: Float)<!> = 1
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun Int.qwe(a: Float)<!> = 2
|
||||
<!CONFLICTING_OVERLOADS!>fun Int.qwe(<!UNUSED_PARAMETER!>a<!>: Float)<!> = 2
|
||||
|
||||
fun Int.rty() = 3
|
||||
|
||||
@@ -94,5 +94,4 @@ namespace constructorVsFun {
|
||||
class ololo() { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
val x = ""
|
||||
|
||||
fun bar(x : Int = <!TYPE_MISMATCH!>""<!>, y : Int = <!TYPE_MISMATCH!>x<!>, z : String = <!UNRESOLVED_REFERENCE!>y<!>) {
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!> : Int = <!TYPE_MISMATCH!>""<!>, <!UNUSED_PARAMETER!>y<!> : Int = <!TYPE_MISMATCH!>x<!>, <!UNUSED_PARAMETER!>z<!> : String = <!UNRESOLVED_REFERENCE!>y<!>) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
fun <T, E> T.foo(x : E, y : A) : T {
|
||||
fun <T, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T {
|
||||
y.plus(1)
|
||||
y plus 1
|
||||
y + 1.0
|
||||
@@ -15,7 +15,7 @@ fun <T, E> T.foo(x : E, y : A) : T {
|
||||
|
||||
class A
|
||||
|
||||
fun A.plus(a : Any) {
|
||||
fun A.plus(<!UNUSED_PARAMETER!>a<!> : Any) {
|
||||
|
||||
1.foo()
|
||||
true.<!NONE_APPLICABLE!>foo<!>()
|
||||
@@ -23,11 +23,11 @@ fun A.plus(a : Any) {
|
||||
1
|
||||
}
|
||||
|
||||
fun A.plus(a : Int) {
|
||||
fun A.plus(<!UNUSED_PARAMETER!>a<!> : Int) {
|
||||
1
|
||||
}
|
||||
|
||||
fun <T> T.minus(t : T) : Int = 1
|
||||
fun <T> T.minus(<!UNUSED_PARAMETER!>t<!> : T) : Int = 1
|
||||
|
||||
fun test() {
|
||||
val <!UNUSED_VARIABLE!>y<!> = 1.abs
|
||||
@@ -41,15 +41,15 @@ fun Int.foo() = this
|
||||
|
||||
namespace null_safety {
|
||||
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
fun parse(<!UNUSED_PARAMETER!>cmd<!>: String): Command? { return null }
|
||||
class Command() {
|
||||
// fun equals(other : Any?) : Boolean
|
||||
val foo : Int = 0
|
||||
}
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any?.equals1(other : Any?) : Boolean = true
|
||||
fun Any.equals2(other : Any?) : Boolean = true
|
||||
fun Any.equals(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
fun Any?.equals1(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
fun Any.equals2(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
@@ -70,4 +70,4 @@ namespace null_safety {
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ fun main(args : Array<String>) {
|
||||
|
||||
fun f() : fun Int.() : Unit = {}
|
||||
|
||||
fun main1(args : Array<String>) {
|
||||
fun main1() {
|
||||
1.{Int.() => 1}();
|
||||
{1}()
|
||||
{(x : Int) => x}(1)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// A generic funciton is always less specific than a non-generic one
|
||||
fun foo<T>(t : T) : Unit {}
|
||||
fun foo(i : Int) : Int = 1
|
||||
fun foo<T>(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
||||
fun foo(<!UNUSED_PARAMETER!>i<!> : Int) : Int = 1
|
||||
|
||||
fun test() {
|
||||
foo(1) : Int
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
fun ff(a: String) = 1
|
||||
fun ff(<!UNUSED_PARAMETER!>a<!>: String) = 1
|
||||
|
||||
fun gg() {
|
||||
val a: String? = ""
|
||||
@@ -7,5 +6,4 @@ fun gg() {
|
||||
if (a != null) {
|
||||
ff(a)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ open class B() {
|
||||
|
||||
class C() : B() {
|
||||
var x = 4
|
||||
fun foo(c: C) {
|
||||
fun foo(<!UNUSED_PARAMETER!>c<!>: C) {
|
||||
this.x = 34
|
||||
this.b = 123
|
||||
super.b = 23
|
||||
@@ -17,7 +17,7 @@ class C() : B() {
|
||||
<!VARIABLE_EXPECTED!>getInt()<!> = 12
|
||||
}
|
||||
|
||||
fun foo1(c: C) {
|
||||
fun foo1(<!UNUSED_PARAMETER!>c<!>: C) {
|
||||
<!VAL_REASSIGNMENT!>super.c<!> = 34
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class D() {
|
||||
}
|
||||
}
|
||||
|
||||
fun cannotBe(var i: Int) {
|
||||
fun cannotBe(var <!UNUSED_PARAMETER!>i<!>: Int) {
|
||||
<!UNRESOLVED_REFERENCE!>z<!> = 30;
|
||||
<!VARIABLE_EXPECTED!>()<!> = ();
|
||||
|
||||
@@ -47,18 +47,18 @@ fun cannotBe(var i: Int) {
|
||||
}
|
||||
|
||||
fun canBe(var i: Int, val j: Int) {
|
||||
(i: Int) = 36
|
||||
(@label i) = 34
|
||||
(i: Int) = <!UNUSED_VALUE!>36<!>
|
||||
(@label i) = <!UNUSED_VALUE!>34<!>
|
||||
|
||||
(<!VAL_REASSIGNMENT!>j<!>: Int) = 36
|
||||
(@label j) = 34 //repeat for j
|
||||
(<!VAL_REASSIGNMENT!>j<!>: Int) = <!UNUSED_VALUE!>36<!>
|
||||
(@label j) = <!UNUSED_VALUE!>34<!> //repeat for j
|
||||
|
||||
val a = A()
|
||||
(@ a.a) = 3894
|
||||
}
|
||||
|
||||
fun canBe2(val j: Int) {
|
||||
(@label <!VAL_REASSIGNMENT!>j<!>) = 34
|
||||
(@label <!VAL_REASSIGNMENT!>j<!>) = <!UNUSED_VALUE!>34<!>
|
||||
}
|
||||
|
||||
class A() {
|
||||
@@ -140,4 +140,4 @@ fun Array<Int>.checkThis() {
|
||||
|
||||
abstract class Ab {
|
||||
abstract fun getArray() : Array<Int>
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
fun foo(a : Int = 1, b : String = "abc") {
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!> : Int = 1, <!UNUSED_PARAMETER!>b<!> : String = "abc") {
|
||||
}
|
||||
|
||||
fun bar(x : Int = 1, y : Int = 1, z : String) {
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!> : Int = 1, <!UNUSED_PARAMETER!>y<!> : Int = 1, <!UNUSED_PARAMETER!>z<!> : String) {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// +JDK
|
||||
|
||||
// Fixpoint generic in Java: Enum<T extends Enum<T>>
|
||||
fun test(a : annotation.RetentionPolicy) {
|
||||
fun test(<!UNUSED_PARAMETER!>a<!> : annotation.RetentionPolicy) {
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ fun test() {
|
||||
java.util.Collections.emptyList()
|
||||
}
|
||||
|
||||
fun test(a : java.lang.Comparable<Int>) {
|
||||
fun test(<!UNUSED_PARAMETER!>a<!> : java.lang.Comparable<Int>) {
|
||||
|
||||
}
|
||||
|
||||
fun test(a : java.util.ArrayList<Int>) {
|
||||
fun test(<!UNUSED_PARAMETER!>a<!> : java.util.ArrayList<Int>) {
|
||||
|
||||
}
|
||||
|
||||
fun test(a : java.lang.Class<Int>) {
|
||||
fun test(<!UNUSED_PARAMETER!>a<!> : java.lang.Class<Int>) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.lang.Comparable as Com
|
||||
|
||||
val l : List<in Int> = ArrayList<Int>()
|
||||
|
||||
fun test(l : java.util.List<Int>) {
|
||||
fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) {
|
||||
val <!UNUSED_VARIABLE!>x<!> : java.<!UNRESOLVED_REFERENCE!>List<!>
|
||||
val <!UNUSED_VARIABLE!>y<!> : java.util.List<Int>
|
||||
val <!UNUSED_VARIABLE!>b<!> : java.lang.Object
|
||||
@@ -51,4 +51,4 @@ fun test(l : java.util.List<Int>) {
|
||||
|
||||
namespace xxx {
|
||||
import java.lang.Class;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace example;
|
||||
|
||||
fun any(a : Any) {}
|
||||
fun any(<!UNUSED_PARAMETER!>a<!> : Any) {}
|
||||
|
||||
fun notAnExpression() {
|
||||
any(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) // not an expression
|
||||
|
||||
@@ -2,7 +2,7 @@ class C<T>() {
|
||||
fun foo() : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
}
|
||||
|
||||
fun foo(c: C<Int>) {}
|
||||
fun foo(<!UNUSED_PARAMETER!>c<!>: C<Int>) {}
|
||||
fun bar<T>() : C<T> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
namespace uninitialized_reassigned_variables
|
||||
|
||||
fun doSmth(s: String) {}
|
||||
fun doSmth(i: Int) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>s<!>: String) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
|
||||
// ------------------------------------------------
|
||||
// uninitialized variables
|
||||
@@ -54,9 +54,9 @@ fun t2() {
|
||||
class A() {}
|
||||
|
||||
fun t4(a: A, val b: A, var c: A) {
|
||||
<!VAL_REASSIGNMENT!>a<!> = A()
|
||||
<!VAL_REASSIGNMENT!>b<!> = A()
|
||||
c = A()
|
||||
<!VAL_REASSIGNMENT!>a<!> = <!UNUSED_VALUE!>A()<!>
|
||||
<!VAL_REASSIGNMENT!>b<!> = <!UNUSED_VALUE!>A()<!>
|
||||
c = <!UNUSED_VALUE!>A()<!>
|
||||
}
|
||||
|
||||
// ------------------------------------------------
|
||||
@@ -191,7 +191,7 @@ class AnonymousInitializers(var a: String, val b: String) {
|
||||
}
|
||||
|
||||
fun reassignFunParams(val a: Int) {
|
||||
<!VAL_REASSIGNMENT!>a<!> = 1
|
||||
<!VAL_REASSIGNMENT!>a<!> = <!UNUSED_VALUE!>1<!>
|
||||
}
|
||||
|
||||
open class Open(a: Int, w: Int) {}
|
||||
|
||||
@@ -47,7 +47,7 @@ fun t3() : Any {
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4(a : Boolean) : Int {
|
||||
fun t4(<!UNUSED_PARAMETER!>a<!> : Boolean) : Int {
|
||||
do {
|
||||
return 1
|
||||
}
|
||||
@@ -55,7 +55,7 @@ fun t4(a : Boolean) : Int {
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4break(a : Boolean) : Int {
|
||||
fun t4break(<!UNUSED_PARAMETER!>a<!> : Boolean) : Int {
|
||||
do {
|
||||
break
|
||||
}
|
||||
@@ -162,7 +162,7 @@ fun nullIsNotNothing() : Unit {
|
||||
fail()
|
||||
}
|
||||
|
||||
fun returnInWhile(a: Int) {
|
||||
fun returnInWhile(<!UNUSED_PARAMETER!>a<!>: Int) {
|
||||
do {return}
|
||||
while (<!UNREACHABLE_CODE!>1 > a<!>)
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,4 @@ fun testUnresolved() {
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(i: Int) {}
|
||||
fun foo1(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
@@ -86,8 +86,8 @@ class MyTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun doSmth(s: String) {}
|
||||
fun doSmth(a: Any) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>s<!>: String) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>a<!>: Any) {}
|
||||
}
|
||||
|
||||
fun testInnerFunctions() {
|
||||
@@ -139,4 +139,4 @@ fun testBackingFieldsNotMarked() {
|
||||
}
|
||||
}
|
||||
|
||||
fun doSmth(i : Int) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>i<!> : Int) {}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun v(x : Int, y : String, vararg f : Long) {}
|
||||
fun v1(vararg f : fun (Int) : Unit) {}
|
||||
fun v(<!UNUSED_PARAMETER!>x<!> : Int, <!UNUSED_PARAMETER!>y<!> : String, vararg <!UNUSED_PARAMETER!>f<!> : Long) {}
|
||||
fun v1(vararg <!UNUSED_PARAMETER!>f<!> : fun (Int) : Unit) {}
|
||||
|
||||
fun test() {
|
||||
v(1, "")
|
||||
@@ -14,4 +14,4 @@ fun test() {
|
||||
v1({}, {}, {it})
|
||||
v1({}) <!VARARG_OUTSIDE_PARENTHESES!>{}<!>
|
||||
v1 <!VARARG_OUTSIDE_PARENTHESES!>{}<!>
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,17 @@ fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int, val t : T) {
|
||||
fun get(index : Int) : T { return t }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
fun get(<!UNUSED_PARAMETER!>index<!> : Int) : T { return t }
|
||||
fun set(<!UNUSED_PARAMETER!>index<!> : Int, <!UNUSED_PARAMETER!>value<!> : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(from : Array<Any>, to : Array<Any>) {}
|
||||
fun copy1(<!UNUSED_PARAMETER!>from<!> : Array<Any>, <!UNUSED_PARAMETER!>to<!> : Array<Any>) {}
|
||||
|
||||
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
|
||||
fun copy2(<!UNUSED_PARAMETER!>from<!> : Array<out Any>, <!UNUSED_PARAMETER!>to<!> : Array<in Any>) {}
|
||||
|
||||
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
||||
fun <T> copy3(<!UNUSED_PARAMETER!>from<!> : Array<out T>, <!UNUSED_PARAMETER!>to<!> : Array<in T>) {}
|
||||
|
||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||
fun copy4(<!UNUSED_PARAMETER!>from<!> : Array<out Number>, <!UNUSED_PARAMETER!>to<!> : Array<in Int>) {}
|
||||
|
||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||
copy1(<!TYPE_MISMATCH!>ints<!>, any)
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
class A() {
|
||||
fun plus(i : Int) {}
|
||||
fun plus(<!UNUSED_PARAMETER!>i<!> : Int) {}
|
||||
fun minus() {}
|
||||
fun contains(a : Any?) : Boolean = true
|
||||
fun contains(<!UNUSED_PARAMETER!>a<!> : Any?) : Boolean = true
|
||||
}
|
||||
|
||||
fun A.div(i : Int) {}
|
||||
fun A?.times(i : Int) {}
|
||||
fun A.div(<!UNUSED_PARAMETER!>i<!> : Int) {}
|
||||
fun A?.times(<!UNUSED_PARAMETER!>i<!> : Int) {}
|
||||
|
||||
fun test(x : Int?, a : A?) {
|
||||
x<!UNSAFE_CALL!>.<!>plus(1)
|
||||
@@ -38,4 +38,4 @@ fun test(x : Int?, a : A?) {
|
||||
a <!UNSAFE_INFIX_CALL!>contains<!> 1
|
||||
a<!UNSAFE_CALL!>.<!>contains(1)
|
||||
a?.contains(1)
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -7,6 +7,6 @@ val b : Foo = Foo()
|
||||
val a1 = b.compareTo(2)
|
||||
|
||||
class Foo() {
|
||||
fun compareTo(other : Byte) : Int = 0
|
||||
fun compareTo(other : Char) : Int = 0
|
||||
}
|
||||
fun compareTo(<!UNUSED_PARAMETER!>other<!> : Byte) : Int = 0
|
||||
fun compareTo(<!UNUSED_PARAMETER!>other<!> : Char) : Int = 0
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
fun foo(<!UNUSED_PARAMETER!>u<!> : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun foo(a : Any) {}
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!> : Any) {}
|
||||
|
||||
fun test() {
|
||||
foo(object {});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun foo1() : fun (Int) : Int = { (x: Int) => x }
|
||||
|
||||
fun foo() {
|
||||
val <!UNUSED_VARIABLE!>h<!> : fun (Int) : Int = foo1();
|
||||
val h : fun (Int) : Int = foo1();
|
||||
h(1)
|
||||
val <!UNUSED_VARIABLE!>m<!> : fun (Int) : Int = {(a : Int) => 1}//foo1()
|
||||
val m : fun (Int) : Int = {(a : Int) => 1}//foo1()
|
||||
m(1)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
fun set(key : String, value : String) {
|
||||
fun set(<!UNUSED_PARAMETER!>key<!> : String, <!UNUSED_PARAMETER!>value<!> : String) {
|
||||
val a : String? = ""
|
||||
when (a) {
|
||||
"" => a<!UNSAFE_CALL!>.<!>get(0)
|
||||
is String, is Any => a.compareTo("")
|
||||
else => a.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
class Command() {}
|
||||
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
fun parse(<!UNUSED_PARAMETER!>cmd<!>: String): Command? { return null }
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = this === other
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val command = parse("")
|
||||
if (command == null) 1 // error on this line, but must be OK
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ class Point() {
|
||||
|
||||
class G<T>() {}
|
||||
|
||||
fun f<T>(expression : T) : G<out T> = G<T>
|
||||
fun f<T>(<!UNUSED_PARAMETER!>expression<!> : T) : G<out T> = G<T>
|
||||
|
||||
|
||||
fun foo() : G<Point> {
|
||||
@@ -13,7 +13,7 @@ fun foo() : G<Point> {
|
||||
|
||||
class Out<out T>() {}
|
||||
|
||||
fun fout<T>(expression : T) : Out<out T> = Out<T>
|
||||
fun fout<T>(<!UNUSED_PARAMETER!>expression<!> : T) : Out<out T> = Out<T>
|
||||
|
||||
fun fooout() : Out<Point> {
|
||||
val p = Point();
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ class Foo(var bar : Int, var barr : Int, var barrr : Int) {
|
||||
}
|
||||
|
||||
this(var bar : Int) : this(1, 1, 1) {
|
||||
bar = 1
|
||||
bar = <!UNUSED_VALUE!>1<!>
|
||||
this.bar
|
||||
1 : Int
|
||||
val <!UNUSED_VARIABLE!>a<!> : Int =1
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any.equals(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
open class Foo {}
|
||||
open class Bar {}
|
||||
|
||||
fun <T : Bar, T1> foo(x : Int) {}
|
||||
fun <T1, T : Foo> foo(x : Long) {}
|
||||
fun <T : Bar, T1> foo(<!UNUSED_PARAMETER!>x<!> : Int) {}
|
||||
fun <T1, T : Foo> foo(<!UNUSED_PARAMETER!>x<!> : Long) {}
|
||||
|
||||
fun f(): Unit {
|
||||
foo<<!UPPER_BOUND_VIOLATED!>Int<!>, Int>(1)
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//KT-609 Analyze not only local variables, but function parameters as well in 'unused values' analysis
|
||||
|
||||
namespace kt609
|
||||
|
||||
fun test(var a: Int) {
|
||||
a = <!UNUSED_VALUE!>324<!> //should be an 'unused value' warning here
|
||||
}
|
||||
|
||||
class C() {
|
||||
fun foo(<!UNUSED_PARAMETER!>s<!>: String) {} //should be an 'unused variable' warning
|
||||
}
|
||||
|
||||
open class A() {
|
||||
open fun foo(s : String) {} //should not be a warning
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
final override fun foo(s : String) {} //should not be a warning
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class Foo() {}
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any?.equals1(other : Any?) : Boolean = true
|
||||
fun Any.equals(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
fun Any?.equals1(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
@@ -15,4 +15,4 @@ fun main(args: Array<String>) {
|
||||
// ?.equals(null) => 1 // same here
|
||||
// }
|
||||
command.equals(null)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// KT-128 Support passing only the last closure if all the other parameters have default values
|
||||
|
||||
fun div(c : String = "", f : fun()) {}
|
||||
fun div(<!UNUSED_PARAMETER!>c<!> : String = "", <!UNUSED_PARAMETER!>f<!> : fun()) {}
|
||||
fun f() {
|
||||
div { // Nothing passed, but could have been...
|
||||
// ...
|
||||
|
||||
@@ -36,15 +36,15 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
class MyArray() {
|
||||
fun get(i: Int): Int = 1
|
||||
fun set(i: Int, value: Int): Int = 1
|
||||
fun get(<!UNUSED_PARAMETER!>i<!>: Int): Int = 1
|
||||
fun set(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>value<!>: Int): Int = 1
|
||||
}
|
||||
|
||||
class MyArray1() {
|
||||
fun get(i: Int): Int = 1
|
||||
fun set(i: Int, value: Int) {}
|
||||
fun get(<!UNUSED_PARAMETER!>i<!>: Int): Int = 1
|
||||
fun set(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>value<!>: Int) {}
|
||||
}
|
||||
|
||||
class MyNumber() {
|
||||
fun inc(): MyNumber = MyNumber()
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@ fun test() {
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
fun <K, V> java.util.Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
|
||||
@@ -1,12 +1,12 @@
|
||||
// KT-282 Nullability in extension functions and in binary calls
|
||||
|
||||
class Set {
|
||||
fun contains(x : Int) : Boolean = true
|
||||
fun contains(<!UNUSED_PARAMETER!>x<!> : Int) : Boolean = true
|
||||
}
|
||||
|
||||
fun Set?.plus(x : Int) : Int = 1
|
||||
fun Set?.plus(<!UNUSED_PARAMETER!>x<!> : Int) : Int = 1
|
||||
|
||||
fun Int?.contains(x : Int) : Boolean = false
|
||||
fun Int?.contains(<!UNUSED_PARAMETER!>x<!> : Int) : Boolean = false
|
||||
|
||||
fun f(): Unit {
|
||||
var set : Set? = null
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.util.*
|
||||
fun attributes() : Map<String, String> = HashMap() // Should be inferred;
|
||||
val attributes : Map<String, String> = HashMap() // Should be inferred;
|
||||
|
||||
fun foo(m : Map<String, String>) {}
|
||||
fun foo(<!UNUSED_PARAMETER!>m<!> : Map<String, String>) {}
|
||||
|
||||
fun test() {
|
||||
foo(HashMap())
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ fun <T : java.lang.Comparable<T>> List<T>.sort() {
|
||||
Collections.sort(this) // Error here
|
||||
}
|
||||
|
||||
fun <T> List<T>.plus(other : List<T>) : List<T> {
|
||||
fun <T> List<T>.plus(<!UNUSED_PARAMETER!>other<!> : List<T>) : List<T> {
|
||||
val result = ArrayList(this)
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ val g : fun() : Unit = <!TYPE_MISMATCH!>{ (): Int => 42 }<!>
|
||||
val h : fun() : Unit = { doSmth() }
|
||||
|
||||
fun doSmth(): Int = 42
|
||||
fun doSmth(a: String) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>a<!>: String) {}
|
||||
|
||||
val testIt : fun(Any) : Unit = {
|
||||
if (it is String) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// KT-399 Type argument inference not implemented for CALL_EXPRESSION
|
||||
|
||||
fun <T> getSameTypeChecker(obj: T) : Function1<Any,Boolean> {
|
||||
fun <T> getSameTypeChecker(<!UNUSED_PARAMETER!>obj<!>: T) : Function1<Any,Boolean> {
|
||||
return { (a : Any) => a is T }
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fun f() {
|
||||
}
|
||||
)
|
||||
}
|
||||
fun invoker(gen : fun() : Int) : Int = 0
|
||||
fun invoker(<!UNUSED_PARAMETER!>gen<!> : fun() : Int) : Int = 0
|
||||
|
||||
//more tests
|
||||
fun t1() {
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
inline fun run1<T>(body : fun() : T) : T = body()
|
||||
|
||||
fun main1(args : Array<String>) {
|
||||
fun main1(<!UNUSED_PARAMETER!>args<!> : Array<String>) {
|
||||
run1 @l{ 1 } // should not be an error
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ fun testFunny() {
|
||||
val <!UNUSED_VARIABLE!>a<!> : Int = funny {1}
|
||||
}
|
||||
|
||||
fun <T> funny2(f : fun(t : T) : T) : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
fun <T> funny2(<!UNUSED_PARAMETER!>f<!> : fun(t : T) : T) : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
|
||||
fun testFunny2() {
|
||||
val <!UNUSED_VARIABLE!>a<!> : Int = funny2 {it}
|
||||
|
||||
@@ -7,4 +7,4 @@ fun foo() {
|
||||
doSmth(<!UNINITIALIZED_VARIABLE!>a<!>) //error
|
||||
doSmth(a) //no repeat error
|
||||
}
|
||||
fun doSmth(i: Int) {}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
@@ -6,4 +6,4 @@ fun test() {
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
fun <K, V> java.util.Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
|
||||
@@ -88,5 +88,5 @@ fun t7() : Int {
|
||||
}
|
||||
}
|
||||
|
||||
fun doSmth(i: Int) {
|
||||
}
|
||||
fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
namespace lol
|
||||
|
||||
class B() {
|
||||
fun plusAssign(other : B) : String {
|
||||
fun plusAssign(<!UNUSED_PARAMETER!>other<!> : B) : String {
|
||||
return "s"
|
||||
}
|
||||
fun minusAssign(other : B) : String {
|
||||
fun minusAssign(<!UNUSED_PARAMETER!>other<!> : B) : String {
|
||||
return "s"
|
||||
}
|
||||
fun modAssign(other : B) : String {
|
||||
fun modAssign(<!UNUSED_PARAMETER!>other<!> : B) : String {
|
||||
return "s"
|
||||
}
|
||||
fun divAssign(other : B) : String {
|
||||
fun divAssign(<!UNUSED_PARAMETER!>other<!> : B) : String {
|
||||
return "s"
|
||||
}
|
||||
fun timesAssign(other : B) : String {
|
||||
fun timesAssign(<!UNUSED_PARAMETER!>other<!> : B) : String {
|
||||
return "s"
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,4 @@ fun main(args : Array<String>) {
|
||||
<!TYPE_MISMATCH!>c /= B()<!>
|
||||
<!TYPE_MISMATCH!>c -= B()<!>
|
||||
<!TYPE_MISMATCH!>c %= B()<!>
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace kt629
|
||||
|
||||
class A() {
|
||||
var p = "yeah"
|
||||
fun mod(other : A) : A {
|
||||
fun mod(<!UNUSED_PARAMETER!>other<!> : A) : A {
|
||||
return A();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,5 +1,4 @@
|
||||
|
||||
fun f(p: Int): Int {
|
||||
fun f(<!UNUSED_PARAMETER!>p<!>: Int): Int {
|
||||
val <!NAME_SHADOWING!>p<!> = 2
|
||||
return p
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
fun f(i: Int) {
|
||||
fun f(<!UNUSED_PARAMETER!>i<!>: Int) {
|
||||
for (j in 1..100) {
|
||||
{
|
||||
var <!NAME_SHADOWING!>i<!> = 12
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user