Typing for When-expressions
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user