File: handler_position.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (43 lines) | stat: -rw-r--r-- 2,717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// REQUIRES: concurrency

// RUN: %empty-directory(%t)

// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1 | %FileCheck -check-prefix=FIRST-ARG %s
// RUN: %refactor-check-compiles -add-async-wrapper -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=FIRST-ARG-WRAPPER %s
func completionFirst(/*c1s*/ completion: @escaping (String) -> Void /*c1e*/, /*c2s*/ arg: Int /*c2e*/) { }

// FIRST-ARG:      @available(*, renamed: "completionFirst(arg:)")
// FIRST-ARG:      Task {
// FIRST-ARG-NEXT:   let result = await completionFirst(arg: arg)
// FIRST-ARG-NEXT:   completion(result)
// FIRST-ARG-NEXT: }
// FIRST-ARG:      func completionFirst(/*c2s*/ arg: Int /*c2e*/) async -> String { }

// FIRST-ARG-WRAPPER:      @available(*, renamed: "completionFirst(arg:)")
// FIRST-ARG-WRAPPER:      func completionFirst(/*c2s*/ arg: Int /*c2e*/) async -> String {
// FIRST-ARG-WRAPPER-NEXT:   return await withCheckedContinuation { continuation in
// FIRST-ARG-WRAPPER-NEXT:     completionFirst(completion: { result in
// FIRST-ARG-WRAPPER-NEXT:       continuation.resume(returning: result)
// FIRST-ARG-WRAPPER-NEXT:     }, arg: arg)
// FIRST-ARG-WRAPPER-NEXT:   }
// FIRST-ARG-WRAPPER-NEXT: }

// RUN: %refactor-check-compiles -add-async-alternative -dump-text -source-filename %s -pos=%(line+2):1 | %FileCheck -check-prefix MIDDLE-ARG %s
// RUN: %refactor-check-compiles -add-async-wrapper -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=MIDDLE-ARG-WRAPPER %s
func completionMiddle(/*c1s*/ arg1: Int /*c1e*/, /*c2s*/ _ arg2: Int /*c2e*/, /*c3s*/ completion: @escaping (String) -> Void /*c3e*/, /*c4s*/ arg3: Int /*c4e*/) { }

// MIDDLE-ARG:      @available(*, renamed: "completionMiddle(arg1:_:arg3:)")
// MIDDLE-ARG:      Task {
// MIDDLE-ARG-NEXT:   let result = await completionMiddle(arg1: arg1, arg2, arg3: arg3)
// MIDDLE-ARG-NEXT:   completion(result)
// MIDDLE-ARG-NEXT: }
// MIDDLE-ARG:      func completionMiddle(/*c1s*/ arg1: Int /*c1e*/, /*c2s*/ _ arg2: Int /*c2e*/, /*c4s*/ arg3: Int /*c4e*/) async -> String { }

// MIDDLE-ARG-WRAPPER:      @available(*, renamed: "completionMiddle(arg1:_:arg3:)")
// MIDDLE-ARG-WRAPPER:      func completionMiddle(/*c1s*/ arg1: Int /*c1e*/, /*c2s*/ _ arg2: Int /*c2e*/, /*c4s*/ arg3: Int /*c4e*/) async -> String {
// MIDDLE-ARG-WRAPPER-NEXT:   return await withCheckedContinuation { continuation in
// MIDDLE-ARG-WRAPPER-NEXT:     completionMiddle(arg1: arg1, arg2, completion: { result in
// MIDDLE-ARG-WRAPPER-NEXT:       continuation.resume(returning: result)
// MIDDLE-ARG-WRAPPER-NEXT:     }, arg3: arg3)
// MIDDLE-ARG-WRAPPER-NEXT:   }
// MIDDLE-ARG-WRAPPER-NEXT: }