Skip to content

Commit 446580a

Browse files
authored
Merge pull request swiftlang#37713 from hamishknight/im-walkin-here
2 parents b8900de + 4197bc2 commit 446580a

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

include/swift/IDE/SourceEntityWalker.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "swift/Basic/LLVM.h"
1919
#include "swift/Basic/SourceLoc.h"
2020
#include "llvm/ADT/PointerUnion.h"
21+
#include "llvm/Support/SaveAndRestore.h"
2122

2223
namespace clang {
2324
class Module;
@@ -189,10 +190,7 @@ class SourceEntityWalker {
189190

190191
/// Utility that lets us keep track of an ASTWalker when walking.
191192
bool performWalk(ASTWalker &W, llvm::function_ref<bool(void)> DoWalk) {
192-
Walker = &W;
193-
SWIFT_DEFER {
194-
Walker = nullptr;
195-
};
193+
llvm::SaveAndRestore<ASTWalker *> SV(Walker, &W);
196194
return DoWalk();
197195
}
198196
};

test/refactoring/ConvertAsync/convert_function.swift

+20
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,23 @@ func testReturnHandling3(_ completion: (String?, Error?) -> Void) {
289289
// RETURN-HANDLING3: func testReturnHandling3() async throws -> String {
290290
// RETURN-HANDLING3-NEXT: {{^}} return (<#completion#>("", nil)){{$}}
291291
// RETURN-HANDLING3-NEXT: }
292+
293+
// RUN: %refactor -convert-to-async -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=RDAR78693050 %s
294+
func rdar78693050(_ completion: () -> Void) {
295+
simple { str in
296+
print(str)
297+
}
298+
if .random() {
299+
return completion()
300+
}
301+
completion()
302+
}
303+
304+
// RDAR78693050: func rdar78693050() async {
305+
// RDAR78693050-NEXT: let str = await simple()
306+
// RDAR78693050-NEXT: print(str)
307+
// RDAR78693050-NEXT: if .random() {
308+
// RDAR78693050-NEXT: return
309+
// RDAR78693050-NEXT: }
310+
// RDAR78693050-NEXT: return
311+
// RDAR78693050-NEXT: }

0 commit comments

Comments
 (0)