bug with automatically casting mutable variables (KT-228) fixed

This commit is contained in:
svtk
2011-08-23 11:44:56 +04:00
parent 3f4f0c8737
commit 847c727ad0
9 changed files with 64 additions and 22 deletions
+20 -1
View File
@@ -229,6 +229,25 @@ fun mergeAutocasts(a: Any?) {
is String, is Any => a.<error>compareTo</error>("")
}
if (a is String && a is Any) {
val i: Int = <info descr="Automatically cast to String">a</info>.length
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
}
}
//mutability
fun f(): String {
var a: Any = 11
if (a is String) {
val i: String = <error>a</error>
<error>a</error>.compareTo("f")
val f: Function0<String> = { <error>a</error> }
return <error>a</error>
}
return ""
}
fun foo(var a: Any): Int {
if (a is Int) {
return <error>a</error>
}
return 1
}