Bindings are propagated over control flow, scope intersections are not supported yet

This commit is contained in:
Andrey Breslav
2011-06-13 16:12:32 +04:00
parent 3cacb512a3
commit 79d3f318b9
2 changed files with 124 additions and 34 deletions
+57
View File
@@ -86,3 +86,60 @@ fun f12(a : A?) {
<info descr="Automatically cast to B">b</info>.bar()
}
}
fun f13(a : A?) {
if (a is val c is B) {
c.foo()
<info descr="Automatically cast to B">c</info>.bar()
}
else {
a?.foo()
<error>c</error>.bar()
}
a?.foo()
if (!(a is val c is B)) {
a?.foo()
<error>c</error>.bar()
}
else {
a.foo()
<info descr="Automatically cast to B">c</info>.bar()
}
a?.foo()
if (a is val c is B && a.foo() == () && <info descr="Automatically cast to B">c</info>.bar() == ()) {
c.foo()
<info descr="Automatically cast to B">c</info>.bar()
}
else {
a?.foo()
<error>c</error>.bar()
}
// a?.foo()
// if ((a is val c is B) || (a is val c is A)) {
// c.foo()
// c.bar()
// }
// else {
// a?.foo()
// c.bar()
// }
if (!(a is val c is B)) return
<info descr="Automatically cast to B">a</info>.bar()
c.foo()
<info descr="Automatically cast to B">c</info>.bar()
}
fun f14(a : A?) {
while (!(a is val c is B)) {
}
<info descr="Automatically cast to B">c</info>.bar()
}
fun f15(a : A?) {
do {
} while (!(a is val c is B))
<info descr="Automatically cast to B">c</info>.bar()
}