Type checking for basic patterns

This commit is contained in:
Andrey Breslav
2011-05-19 23:34:27 +04:00
parent 298407210e
commit 5ad5a0e5e9
2 changed files with 90 additions and 44 deletions
+24 -1
View File
@@ -21,4 +21,27 @@ fun foo() {
}
}
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
fun test() {
val x = 1;
val s = "";
when (x) {
<error>s</error> => 1
is <error>""</error> => 1
x => 1
is 1 => 1
is <error>(1, 1)</error> => 1
}
val z = (1, 1)
when (z) {
is (*, *) => 1
is (*, 1) => 1
is (1, 1) => 1
is (1, <error>"1"</error>) => 1
is <error>(1, "1", *)</error> => 1
}
}