Typing for When-expressions

This commit is contained in:
Andrey Breslav
2011-02-03 15:10:07 +03:00
parent 253f5b2d06
commit 2e2c31ea00
6 changed files with 109 additions and 3 deletions
@@ -89,6 +89,16 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("if (true) 1 else '1'", "Any");
}
public void testWhen() throws Exception {
assertType("when (1) { is 1 => 2; } ", "Int");
assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else continue} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 when(e) {is 1 => null}} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(e) {is 1 => null}} ", "Any?");
}
public void testCommonSupertypes() throws Exception {
assertCommonSupertype("Int", "Int", "Int");