File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -3986,7 +3986,7 @@ namespace {
3986
3986
// do not cause implicit 'self' capture diagnostics, etc.
3987
3987
3988
3988
Expr *actorExpr = nullptr ;
3989
- Type optionalAnyActorType = isolationExpr->getType ();
3989
+ Type isolationType = isolationExpr->getType ();
3990
3990
switch (isolation) {
3991
3991
case ActorIsolation::ActorInstance: {
3992
3992
if (auto *instance = isolation.getActorInstanceExpr ()) {
@@ -4040,10 +4040,16 @@ namespace {
4040
4040
4041
4041
4042
4042
// Convert the actor argument to the appropriate type.
4043
- ( void ) TypeChecker::typeCheckExpression (
4043
+ auto result = TypeChecker::typeCheckExpression (
4044
4044
actorExpr, dc,
4045
4045
constraints::ContextualTypeInfo (
4046
- optionalAnyActorType, CTP_CallArgument));
4046
+ isolationType, CTP_CallArgument));
4047
+
4048
+ // Don't set the actor if there's a type mismatch. The isolation
4049
+ // checker will treat calls using this #isolation value for an
4050
+ // isolated argument as crossing an isolation boundary.
4051
+ if (!result)
4052
+ return ;
4047
4053
4048
4054
isolationExpr->setActor (actorExpr);
4049
4055
}
Original file line number Diff line number Diff line change @@ -100,6 +100,14 @@ extension A {
100
100
}
101
101
102
102
#if TEST_DIAGNOSTICS
103
+ @available ( SwiftStdlib 5 . 1 , * )
104
+ actor ConcreteActor { }
105
+
106
+ @available ( SwiftStdlib 5 . 1 , * )
107
+ func concreteActorIsolation(
108
+ actor : isolated ConcreteActor = #isolation
109
+ ) async { }
110
+
103
111
@available ( SwiftStdlib 5 . 1 , * )
104
112
@MainActor
105
113
func testContextualType( ) {
@@ -111,5 +119,10 @@ func testContextualType() {
111
119
// CHECK-DIAGS: note: in expansion of macro 'isolation' here
112
120
// CHECK-DIAGS: let _: Int = #isolation
113
121
let _: Int = #isolation
122
+
123
+ // CHECK-DIAGS: error: cannot convert value of type 'MainActor' to expected argument type 'ConcreteActor'
124
+ // CHECK-DIAGS: note: in expansion of macro 'isolation' here
125
+ // CHECK-DIAGS: await concreteActorIsolation()
126
+ await concreteActorIsolation ( )
114
127
}
115
128
#endif
You can’t perform that action at this time.
0 commit comments