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 {
46804680 void classifySwitch (SwitchStmt *SS) {
46814681 if (!IsResultParam || singleSwitchSubject (SS) != ErrParam) {
46824682 CurrentBlock->addNode (SS);
4683+ return ;
46834684 }
46844685
46854686 for (auto *CS : SS->getCases ()) {
Original file line number Diff line number Diff line change @@ -322,3 +322,25 @@ voidAndErrorResult { res in
322322}
323323// VOID-AND-ERROR-RESULT-CALL: {{^}}try await voidAndErrorResult()
324324// 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