mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Adapt the `ThrowingEntityAnalyzer` to pick up any `await` keywords and add an `async` to the extracted function if necessary along with an `await` for its call. rdar://72199949
19 lines
992 B
Swift
19 lines
992 B
Swift
func longLongLongJourney() async -> Int { 0 }
|
|
func longLongLongAwryJourney() async throws -> Int { 0 }
|
|
func consumesAsync(_ fn: () async throws -> Void) rethrows {}
|
|
|
|
func testThrowingClosure() async throws -> Int {
|
|
let x = await longLongLongJourney()
|
|
let y = try await longLongLongAwryJourney() + 1
|
|
try consumesAsync { try await longLongLongAwryJourney() }
|
|
return x + y
|
|
}
|
|
|
|
// RUN: %empty-directory(%t.result)
|
|
// RUN: %refactor -extract-function -source-filename %s -pos=6:11 -end-pos=6:38 >> %t.result/async1.swift
|
|
// RUN: diff -u %S/Outputs/await/async1.swift.expected %t.result/async1.swift
|
|
// RUN: %refactor -extract-function -source-filename %s -pos=7:11 -end-pos=7:50 >> %t.result/async2.swift
|
|
// RUN: diff -u %S/Outputs/await/async2.swift.expected %t.result/async2.swift
|
|
// RUN: %refactor -extract-function -source-filename %s -pos=8:1 -end-pos=8:60 >> %t.result/consumes_async.swift
|
|
// RUN: diff -u %S/Outputs/await/consumes_async.swift.expected %t.result/consumes_async.swift
|