-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SE-0338 changed the execution of non-actor async functions so that they always hop to the generic executor, but some functions need a way to suppress this so that they inherit the caller's executor. The right way to implement this is to have the caller pass down the target executor in some reliable way and then switch to it in all the appropriate places in the caller. We might reasonably be able to build this on top of isolated parameters, using some sort of default argument, or we might need a wholly novel mechanism. But those things are all ABI-breaking absent some sort of guarantee about switching that we probably don't want to make, and unfortunately we have functions in the library which we need to export that need to inherit executors. So in the short term, we need some unsafe way of getting back to the previous behavior.
- Loading branch information
Showing
13 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking %s | ||
|
||
// expected-error @+1 {{non-async functions cannot inherit an executor}} | ||
@_unsafeInheritExecutor | ||
func testNonAsync() {} | ||
|
||
@_unsafeInheritExecutor | ||
func testAsync() async {} | ||
|
||
struct A { | ||
// expected-error @+1 {{@_unsafeInheritExecutor may only be used on 'func' declarations}} | ||
@_unsafeInheritExecutor | ||
init() async {} | ||
|
||
// expected-error @+1 {{non-async functions cannot inherit an executor}} | ||
@_unsafeInheritExecutor | ||
func testNonAsync() {} | ||
|
||
@_unsafeInheritExecutor | ||
func testAsync() async {} | ||
} | ||
|
||
|
||
class NonSendableObject { | ||
var property = 0 | ||
} | ||
|
||
@_unsafeInheritExecutor | ||
func useNonSendable(object: NonSendableObject) async {} | ||
|
||
actor MyActor { | ||
var object = NonSendableObject() | ||
func foo() async { | ||
// This should not be diagnosed when we implement SE-0338 checking. | ||
await useNonSendable(object: self.object) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters