mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:39:48 +00:00
Issue 52130. Fix 'Inline Local' refactoring inside SwitchPatternCase.
Bug: https://github.com/dart-lang/sdk/issues/52130 Change-Id: Ic84e4781e12dece3775fc0462b727a6a9b9c9906 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306125 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
4d21b9e5aa
commit
faa16fc565
|
@ -203,7 +203,9 @@ class InlineLocalRefactoringImpl extends RefactoringImpl
|
|||
var statement = declarationList.parent;
|
||||
if (statement is VariableDeclarationStatement) {
|
||||
var parent = statement.parent;
|
||||
if (parent is Block || parent is SwitchCase) {
|
||||
if (parent is Block ||
|
||||
parent is SwitchCase ||
|
||||
parent is SwitchPatternCase) {
|
||||
return statement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,31 +154,6 @@ void f() {
|
|||
''');
|
||||
}
|
||||
|
||||
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/49759')
|
||||
Future<void> test_OK_inSwitchCase() async {
|
||||
await indexTestUnit('''
|
||||
void f(int p) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
int test = 42;
|
||||
print(test);
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
_createRefactoring('test =');
|
||||
// validate change
|
||||
return assertSuccessfulRefactoring('''
|
||||
void f(int p) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
print(42);
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_OK_inSwitchCase_language219() async {
|
||||
await indexTestUnit('''
|
||||
// @dart=2.19
|
||||
|
@ -205,6 +180,28 @@ void f(int p) {
|
|||
''');
|
||||
}
|
||||
|
||||
Future<void> test_OK_inSwitchPatternCase() async {
|
||||
await indexTestUnit('''
|
||||
void f(Object? x) {
|
||||
switch (x) {
|
||||
case _?:
|
||||
var test = 42;
|
||||
print(test);
|
||||
}
|
||||
}
|
||||
''');
|
||||
_createRefactoring('test =');
|
||||
// validate change
|
||||
return assertSuccessfulRefactoring('''
|
||||
void f(Object? x) {
|
||||
switch (x) {
|
||||
case _?:
|
||||
print(42);
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_OK_intoStringInterpolation_binaryExpression() async {
|
||||
await indexTestUnit(r'''
|
||||
void f() {
|
||||
|
|
Loading…
Reference in a new issue