Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/swift/IDE/SourceEntityWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "swift/Basic/LLVM.h"
#include "swift/Basic/SourceLoc.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/Support/SaveAndRestore.h"

namespace clang {
class Module;
Expand Down Expand Up @@ -189,10 +190,7 @@ class SourceEntityWalker {

/// Utility that lets us keep track of an ASTWalker when walking.
bool performWalk(ASTWalker &W, llvm::function_ref<bool(void)> DoWalk) {
Walker = &W;
SWIFT_DEFER {
Walker = nullptr;
};
llvm::SaveAndRestore<ASTWalker *> SV(Walker, &W);
return DoWalk();
}
};
Expand Down
20 changes: 20 additions & 0 deletions test/refactoring/ConvertAsync/convert_function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,23 @@ func testReturnHandling3(_ completion: (String?, Error?) -> Void) {
// RETURN-HANDLING3: func testReturnHandling3() async throws -> String {
// RETURN-HANDLING3-NEXT: {{^}} return (<#completion#>("", nil)){{$}}
// RETURN-HANDLING3-NEXT: }

// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=RDAR78693050 %s
func rdar78693050(_ completion: () -> Void) {
simple { str in
print(str)
}
if .random() {
return completion()
}
completion()
}

// RDAR78693050: func rdar78693050() async {
// RDAR78693050-NEXT: let str = await simple()
// RDAR78693050-NEXT: print(str)
// RDAR78693050-NEXT: if .random() {
// RDAR78693050-NEXT: return
// RDAR78693050-NEXT: }
// RDAR78693050-NEXT: return
// RDAR78693050-NEXT: }