Files
sdk/pkg/front_end/testcases/patterns/irrefutable_infix.dart
T
Johnni Winther c6347389d2 [cfe] Move irrefutable tails into the case body
This moves pattern variable assignments of fully matched expressions into the case body. This will help backends (dart2js in particular) to reason about the code flow.

Closes #54115

Change-Id: I598a384a829f16e91ab2d6a309499cf20b9cc121
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339122
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-12-07 11:13:30 +00:00

29 lines
553 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.
abstract class Foo {
int get a;
num get b;
num get c;
}
method1(o) {
if (o case Foo(:var a, :int b)) {
print(a + b);
}
}
method2(o) {
if (o case Foo(:var a, :var b, :int c)) {
print(a + b + c);
}
}
method3(o) {
if (o case Foo(:var a, b: int(:var isEven), :int c)) {
print(a + c);
print(isEven);
}
}