KT-2643 Support multi-declarations in Data-Flow analysis

#KT-2643 fixed
This commit is contained in:
Svetlana Isakova
2012-08-20 18:48:09 +04:00
parent f817eba7aa
commit 8860bab9f1
17 changed files with 126 additions and 24 deletions
@@ -3,6 +3,6 @@ class A {
fun component2() : Int = 2
}
fun a(<!UNUSED_PARAMETER!>aa<!> : A) {
val (a: String, b1: String) = <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>aa<!>
fun a(aa : A) {
val (<!UNUSED_VARIABLE!>a<!>: String, <!UNUSED_VARIABLE!>b1<!>: String) = <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>aa<!>
}
@@ -5,10 +5,10 @@ class A {
fun a(aa : A?, b : Any) {
if (aa != null) {
val (a1, b1) = aa;
val (<!UNUSED_VARIABLE!>a1<!>, <!UNUSED_VARIABLE!>b1<!>) = aa;
}
if (b is A) {
val (a1, b1) = b;
val (<!UNUSED_VARIABLE!>a1<!>, <!UNUSED_VARIABLE!>b1<!>) = b;
}
}
}
@@ -9,7 +9,7 @@ class MyClass2 {}
<!CONFLICTING_OVERLOADS!>fun MyClass2.component1()<!> = 1.2
<!CONFLICTING_OVERLOADS!>fun MyClass2.component1()<!> = 1.3
fun test(<!UNUSED_PARAMETER!>mc1<!>: MyClass, <!UNUSED_PARAMETER!>mc2<!>: MyClass2) {
fun test(mc1: MyClass, mc2: MyClass2) {
val (a, b) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>mc1<!>
val (c) = <!COMPONENT_FUNCTION_AMBIGUITY!>mc2<!>
@@ -4,11 +4,11 @@ class A {
}
fun a() {
val (<!REDECLARATION!>a<!>, <!REDECLARATION!>a<!>) = A()
val (x, <!REDECLARATION!>y<!>) = A();
val (<!REDECLARATION, UNUSED_VARIABLE!>a<!>, <!REDECLARATION, UNUSED_VARIABLE!>a<!>) = A()
val (<!UNUSED_VARIABLE!>x<!>, <!REDECLARATION, UNUSED_VARIABLE!>y<!>) = A();
val <!REDECLARATION!>b<!> = 1
use(b)
val (<!REDECLARATION!>b<!>, <!REDECLARATION!>y<!>) = A();
val (<!REDECLARATION, UNUSED_VARIABLE!>b<!>, <!REDECLARATION, UNUSED_VARIABLE!>y<!>) = A();
}
@@ -10,7 +10,7 @@ class MyClass2 {}
fun MyClass2.component1() = 1.2
fun test(<!UNUSED_PARAMETER!>mc1<!>: MyClass, <!UNUSED_PARAMETER!>mc2<!>: MyClass2) {
fun test(mc1: MyClass, mc2: MyClass2) {
val (a, b) = mc1
a : Int
b : String
@@ -0,0 +1,27 @@
//KT-2643 Support multi-declarations in Data-Flow analysis
package n
class C {
fun component1() = 1
fun component2() = 2
}
fun test1(c: C) {
val (<!UNUSED_VARIABLE!>a<!>, <!UNUSED_VARIABLE!>b<!>) = c
}
fun test2(c: C) {
val (a, <!UNUSED_VARIABLE!>b<!>) = c
a + 3
}
fun test3(c: C) {
var (<!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>a<!>, <!UNUSED_VARIABLE!>b<!>) = c
a = <!UNUSED_VALUE!>3<!>
}
fun test4(c: C) {
var (<!VARIABLE_WITH_REDUNDANT_INITIALIZER!>a<!>, <!UNUSED_VARIABLE!>b<!>) = c
a = 3
a + 1
}