You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch teaches the compiler to emit a fix-it to automatically wrap
everything in the function in a Task and remove the effects from the
function declaration.
// expected-error@-1 {{@IBAction instance method cannot be async}}
49
-
// expected-note@-2 {{remove 'async' and wrap in 'Task' to use concurrency in 'asyncIBAction'}}
49
+
// expected-note@-2 {{remove 'async' and wrap in 'Task' to use concurrency in 'asyncIBActionNoSpace'}}{{45:3-47:57=@available(SwiftStdlib 5.5, *)\n @IBAction\n func asyncIBActionNoSpace(_: AnyObject) -> () {\nTask { @MainActor in \}\n\}}}
50
+
51
+
@available(SwiftStdlib 5.5,*)
52
+
@IBAction
53
+
func asyncIBActionWithFullBody(_:AnyObject)async{
54
+
print("Hello World")
55
+
}
56
+
// expected-error@-3 {{@IBAction instance method cannot be async}}
57
+
// expected-note@-4 {{remove 'async' and wrap in 'Task' to use concurrency in 'asyncIBActionWithFullBody'}}{{51:3-55:4=@available(SwiftStdlib 5.5, *)\n @IBAction\n func asyncIBActionWithFullBody(_: AnyObject) {\nTask { @MainActor in\n print("Hello World")\n \}\n\}}}
// expected-error@-1 {{expected '{' in body of function declaration}}
61
+
// expected-error@-2 {{@IBAction instance method cannot be asynchronous}}
62
+
// expected-note@-3 {{remove 'async' and wrap in 'Task' to use concurrency in 'asyncIBActionNoBody}}{{3-88=@available(SwiftStdlib 5.5, *) @IBAction func asyncIBActionNoBody(_: AnyObject)}}
// expected-error@-1 {{@IBSegueAction instance method cannot be asynchronous}}
52
+
// expected-note@-2 {{remove 'async' and wrap in 'Task' to use concurrency in 'process'}}{{49:3-50:80=@available(SwiftStdlib 5.5, *) @IBSegueAction\n func process(_: AnyObject, _: AnyObject, _: AnyObject) -> AnyObject {\nTask { @MainActor in \}\n\}}}
0 commit comments