03700211b2
This updates the toString on Witness to produce pattern code. The created pattern is directly derived from the predicates of the witness and there contain some needless precision, for instance `[...[...]]` instead of `[...]`. It is the plan to address this in a follow-up. Change-Id: Ied7930f36b1e1818540b8c635b18ff92f28e113b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290720 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
35 lines
783 B
Dart
35 lines
783 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.
|
|
|
|
class A {
|
|
int field1;
|
|
num field2;
|
|
|
|
A(this.field1, this.field2);
|
|
}
|
|
|
|
exhaustiveDirect(A a) => switch (a) {
|
|
A() => 0,
|
|
};
|
|
|
|
exhaustiveWithWildcards(A a) => switch (a) {
|
|
A(field1: _, field2: _) => 0,
|
|
};
|
|
|
|
exhaustiveWithFields(A a) => switch (a) {
|
|
A(:var field1, :var field2) => 0,
|
|
};
|
|
|
|
exhaustiveWithTypedFields(A a) => switch (a) {
|
|
A(:int field1, :num field2) => 0,
|
|
};
|
|
|
|
nonExhaustiveFixedField(A a) => switch (a) {
|
|
A(field1: 5) => 0,
|
|
};
|
|
|
|
nonExhaustiveTypedField(A a) => switch (a) {
|
|
A(:int field2) => 0,
|
|
};
|