@@ -818,11 +818,35 @@ TBD
818
818
819
819
## ABI compatibility
820
820
821
- TBD: I'm still figuring out whether this change can be staged in while
822
- preserving ABI for existing nonisolated async functions. A number of APIs
823
- in the concurrency library have transitioned to inheriting the isolation of
824
- the caller using isolated parameters and ` #isolation ` , and it may be possible
825
- to do this transformation automatically.
821
+ ** Open question.** I'm still figuring out whether this change can be staged in
822
+ while preserving ABI for existing nonisolated async functions while also
823
+ preserving source compatibility. A number of APIs in the concurrency library
824
+ have transitioned to inheriting the isolation of the caller using isolated
825
+ parameters and ` #isolation ` , and it may be possible to do this transformation
826
+ automatically for resilient libraries.
827
+
828
+ For example, if a nonisolated async function is ABI-public and is available
829
+ earlier than a version of the Swift runtime that includes this change, the
830
+ compiler could emit two separate entry points for the function:
831
+
832
+ ``` swift
833
+ @_alwaysEmitIntoClient
834
+ public func myAsyncFunc () async {
835
+ // original implementation
836
+ }
837
+
838
+ @concurrent
839
+ @_silgen_name (... ) // to preserve the original symbol name
840
+ @usableFromInline
841
+ internal func abi_myAsyncFunc () async {
842
+ // existing compiled code will continue to always run calls to this function
843
+ // on the generic executor.
844
+ await myAsyncFunc ()
845
+ }
846
+ ```
847
+
848
+ However, this transformation only works if the original function implementation
849
+ can be made inlinable.
826
850
827
851
## Implications on adoption
828
852
0 commit comments