Skip to content

Commit c4c5e9b

Browse files
authored
Merge pull request #37918 from ahoppen/pr-5.5/case-let-refactoring
[5.5][Refactoring] Support refactoring for `case let` patterns
2 parents 0887614 + de925d1 commit c4c5e9b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4580,7 +4580,8 @@ struct CallbackCondition {
45804580
/// }
45814581
/// ```
45824582
CallbackCondition(const Decl *Subject, const CaseLabelItem *CaseItem) {
4583-
if (auto *EEP = dyn_cast<EnumElementPattern>(CaseItem->getPattern())) {
4583+
if (auto *EEP = dyn_cast<EnumElementPattern>(
4584+
CaseItem->getPattern()->getSemanticsProvidingPattern())) {
45844585
// `case .<func>(let <bind>)`
45854586
initFromEnumPattern(Subject, EEP);
45864587
}

test/refactoring/ConvertAsync/convert_pattern.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ func testPatterns() async throws {
265265
// STRING-TUPLE-RESULT-NEXT: print("oh no")
266266
// STRING-TUPLE-RESULT-NEXT: }
267267

268+
// RUN: %refactor-check-compiles -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):3 | %FileCheck -check-prefix=STRING-TUPLE-RESULT %s
269+
stringTupleResult { res in
270+
switch res {
271+
case let .success((x, y)):
272+
print(x, y)
273+
case .failure:
274+
print("oh no")
275+
}
276+
}
277+
268278
// RUN: %refactor-check-compiles -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):3 | %FileCheck -check-prefix=MIXED-TUPLE-RESULT %s
269279
mixedTupleResult { res in
270280
if case .failure(let err) = res {

0 commit comments

Comments
 (0)