File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -3353,6 +3353,13 @@ ActorIsolation ActorIsolationRequest::evaluate(
33533353 return inferredIsolation (isolation);
33543354 }
33553355
3356+ // If this is a dynamic replacement for another function, use the
3357+ // actor isolation of the function it replaces.
3358+ if (auto replacedDecl = value->getDynamicallyReplacedDecl ()) {
3359+ if (auto isolation = getActorIsolation (replacedDecl))
3360+ return inferredIsolation (isolation);
3361+ }
3362+
33563363 if (shouldInferAttributeInContext (value->getDeclContext ())) {
33573364 // If the declaration witnesses a protocol requirement that is isolated,
33583365 // use that.
Original file line number Diff line number Diff line change 1+ @MainActor
2+ public dynamic func dynamicOnMainActor( ) { }
Original file line number Diff line number Diff line change 1- // RUN: %target-typecheck-verify-swift -disable-availability-checking
1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend -emit-module -emit-module-path %t/dynamically_replaceable.swiftmodule -module-name dynamically_replaceable -warn-concurrency %S/Inputs/dynamically_replaceable.swift
3+ // RUN: %target-typecheck-verify-swift -I %t -disable-availability-checking
24// REQUIRES: concurrency
5+ import dynamically_replaceable
36
47actor SomeActor { }
58
@@ -552,3 +555,11 @@ func useFooInADefer() -> String {
552555
553556 return " hello "
554557}
558+
559+ // ----------------------------------------------------------------------
560+ // Dynamic replacement
561+ // ----------------------------------------------------------------------
562+ @_dynamicReplacement ( for: dynamicOnMainActor)
563+ func replacesDynamicOnMainActor( ) {
564+ onlyOnMainActor ( )
565+ }
You can’t perform that action at this time.
0 commit comments