blob: 3ee7e894816ac87862dc35c3df3e3553af704e0c [file]
// Copyright (c) 2026, 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.
patternVariableAssignment((int, String) r) {
var (x, s) = r;
return () => x;
}
joinedVariableMultipleHeads(dynamic x) {
switch (x) {
case int y:
case String(length: int y):
return () => y;
default:
return () => 0;
}
}
joinedVariableSingleHead(dynamic x) {
switch (x) {
case int y || String(length: int y):
return () => y;
default:
return () => 0;
}
}
joinedVariableMixed(dynamic x) {
switch (x) {
case int y || String(length: int y):
case Object(hashCode: int y):
return () => y;
default:
return () => 0;
}
}
joinedVariableSwitchExpression(dynamic x) {
return switch (x) {
int y || String(length: int y) => () => y,
_ => () => 0,
};
}
joinedVariableIfCaseStatement(dynamic x) {
if (x case int y || String(length: int y)) {
return () => y;
} else {
return () => 0;
}
}
joinedVariableIfCaseElement(dynamic x) {
return [if (x case int y || String(length: int y)) () => y else () => 0];
}
// In the following test a variable pattern goes immediately after the pattern
// switch statement, testing that the stale pattern switch builder objects were
// released before the variable pattern was analyzed.
staleSwitchCaseBuilderTest(dynamic x, (String, int) r) {
switch (x) {
case int y:
return () => y;
default:
return null;
}
var (s, n) = r;
return () => s;
}
mergingJoinedVariableScopeAndLocalCaseScopeTest(dynamic x) {
switch (x) {
case int y:
case String(length: int y):
int a = 0;
return () => [a, y];
default:
return null;
}
}