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(
3353
3353
return inferredIsolation (isolation);
3354
3354
}
3355
3355
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
+
3356
3363
if (shouldInferAttributeInContext (value->getDeclContext ())) {
3357
3364
// If the declaration witnesses a protocol requirement that is isolated,
3358
3365
// 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
2
4
// REQUIRES: concurrency
5
+ import dynamically_replaceable
3
6
4
7
actor SomeActor { }
5
8
@@ -552,3 +555,11 @@ func useFooInADefer() -> String {
552
555
553
556
return " hello "
554
557
}
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