Files
sdk/pkg/front_end/testcases/patterns/issue50871.dart
T
Johnni Winther 404fbe553b [cfe] Always create PatternSwitchStatement when patterns are enabled
This ensures that an otherwise regular switch statement has the new
switch statements semantics; using == calls and allowing user defined
== implementations.

Closes #50871

Change-Id: I0908b3a0adce959fe65ca61c5e94cf2a5e3f7e65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280109
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-02-01 19:08:54 +00:00

24 lines
546 B
Dart

// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
String test(Symbol value) {
switch (value) {
case #foo:
return "foo";
default:
return "default";
}
}
main() {
expect("foo", test(Symbol("foo")));
expect("foo", test(const Symbol("foo")));
}
expect(expected, actual) {
if (expected != actual) {
throw 'Expected $expected, actual $actual';
}
}