Files
sdk/pkg/front_end/parser_testcases/patterns/issue_51169.dart
T
Jens Johansen 284296f862 [parser] Support nullable record types in patterns
Not fixed for nullable record types in
https://dart-review.googlesource.com/c/sdk/+/280106.

Fixes: https://dartbug.com/52439
Closes: https://dartbug.com/52462

Change-Id: I52f42406f2e1c6b7c874a9828ef7f1de397b3c83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304642
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-05-25 10:28:05 +00:00

27 lines
503 B
Dart

class Class {
dynamic field;
Class(this.field);
}
test(a) {
switch (a) {
case (foo: int b) when b != 2:
print(b);
case (foo: (int, int) b) when b != (2, 3):
print(b);
case Class(field: int b) when b != 2:
print(b);
case Class(field: (int, int) b) when b != (2, 3):
print(b);
}
}
testNullable(a) {
switch (a) {
case (foo: (int, int)? b) when b != (2, 3):
print(b);
case Class(field: (int, int)? b) when b != (2, 3):
print(b);
}
}