File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
test/refactoring/ConvertAsync Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -4680,6 +4680,7 @@ struct CallbackClassifier {
4680
4680
void classifySwitch (SwitchStmt *SS) {
4681
4681
if (!IsResultParam || singleSwitchSubject (SS) != ErrParam) {
4682
4682
CurrentBlock->addNode (SS);
4683
+ return ;
4683
4684
}
4684
4685
4685
4686
for (auto *CS : SS->getCases ()) {
Original file line number Diff line number Diff line change @@ -322,3 +322,25 @@ voidAndErrorResult { res in
322
322
}
323
323
// VOID-AND-ERROR-RESULT-CALL: {{^}}try await voidAndErrorResult()
324
324
// VOID-AND-ERROR-RESULT-CALL: {{^}}print(<#res#>)
325
+
326
+ // Make sure we ignore an unrelated switch.
327
+ // RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=IGNORE-UNRELATED %s
328
+ simple { res in
329
+ print ( " before " )
330
+ switch Bool . random ( ) {
331
+ case true :
332
+ break
333
+ case false :
334
+ break
335
+ }
336
+ print ( " after " )
337
+ }
338
+ // IGNORE-UNRELATED: let res = try await simple()
339
+ // IGNORE-UNRELATED-NEXT: print("before")
340
+ // IGNORE-UNRELATED-NEXT: switch Bool.random() {
341
+ // IGNORE-UNRELATED-NEXT: case true:
342
+ // IGNORE-UNRELATED-NEXT: {{^}} break{{$}}
343
+ // IGNORE-UNRELATED-NEXT: case false:
344
+ // IGNORE-UNRELATED-NEXT: {{^}} break{{$}}
345
+ // IGNORE-UNRELATED-NEXT: }
346
+ // IGNORE-UNRELATED-NEXT: print("after")
You can’t perform that action at this time.
0 commit comments