Review fixes for mutable variable smart casting (mostly refactoring).

DataFlowValue.isPredictable() introduced instead of isStableIdentifier().
Parenthesized assignments are treated correctly.
This commit is contained in:
Mikhail Glukhikh
2015-04-16 20:05:46 +03:00
parent e97e792674
commit 109e0abb6d
17 changed files with 133 additions and 81 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ fun test() : Unit {
y <!USELESS_CAST!>as Int<!> : Int
x <!USELESS_CAST!>as Int?<!> : Int?
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as Int?<!> : Int?
x as? Int : Int?
x <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as? Int<!> : Int?
y <!USELESS_CAST!>as? Int<!> : Int?
x <!USELESS_CAST!>as? Int?<!> : Int?
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as? Int?<!> : Int?
@@ -68,7 +68,7 @@ class MyTest() {
}
else {
a = "ss"
doSmth(a as String)
doSmth(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
doSmth(a)
@@ -0,0 +1,13 @@
fun x(): Boolean { return true }
public fun foo(pp: String?): Int {
var p = pp
while(true) {
p!!.length()
if (x()) break
(((p))) = null
}
// Smart cast is NOT possible here
// (we could provide it but p = null makes it much harder)
return p<!UNSAFE_CALL!>.<!>length()
}
@@ -0,0 +1,4 @@
package
public fun foo(/*0*/ pp: kotlin.String?): kotlin.Int
internal fun x(): kotlin.Boolean
@@ -0,0 +1,13 @@
fun x(): Boolean { return true }
public fun foo(pp: String?): Int {
var p = pp
while(true) {
p!!.length()
if (x()) break
(p) = null
}
// Smart cast is NOT possible here
// (we could provide it but p = null makes it much harder)
return p<!UNSAFE_CALL!>.<!>length()
}
@@ -0,0 +1,4 @@
package
public fun foo(/*0*/ pp: kotlin.String?): kotlin.Int
internal fun x(): kotlin.Boolean