273594fe8a
When the `switch` expression's type is dynamic, call the equality method of the `case` expressions. Fixes #56321. Change-Id: I25338ffebaf9130c39ce3aa66e7b4a7eb20aac71 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377921 Commit-Queue: Ömer Ağacan <omersa@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
24 lines
555 B
Dart
24 lines
555 B
Dart
// Copyright (c) 2024, 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.
|
|
|
|
// Regression test for dart2wasm: #56321. Switching on a dynamic value should
|
|
// use object equality for the test.
|
|
|
|
void main() {
|
|
dynamic x = 3.0;
|
|
|
|
switch (x) {
|
|
case 0:
|
|
throw 'Test failed';
|
|
case 1:
|
|
throw 'Test failed';
|
|
case 2:
|
|
throw 'Test failed';
|
|
case 3:
|
|
return;
|
|
}
|
|
|
|
throw 'Test failed';
|
|
}
|