Skip to content

Commit 68b95f8

Browse files
authored
Merge pull request #80382 from hborla/isolation-crash
[Concurrency] When expanding `#isolation` create a type-checked type expr for global actors.
2 parents 42fe7d9 + 9c1f7e3 commit 68b95f8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,8 +4192,7 @@ namespace {
41924192
// Form a <global actor type>.shared reference.
41934193
Type globalActorType = getDeclContext()->mapTypeIntoContext(
41944194
isolation.getGlobalActor());
4195-
auto typeExpr = TypeExpr::createForDecl(
4196-
DeclNameLoc(loc), globalActorType->getAnyNominal(), dc);
4195+
auto typeExpr = TypeExpr::createImplicit(globalActorType, ctx);
41974196
actorExpr = new (ctx) UnresolvedDotExpr(
41984197
typeExpr, loc, DeclNameRef(ctx.Id_shared), DeclNameLoc(loc),
41994198
/*implicit=*/false);

test/Concurrency/isolation_macro.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func mainActorIsolated() {
6363
// CHECK-NEXT: inject_into_optional
6464
// CHECK-NEXT: erasure_expr
6565
// CHECK: member_ref_expr type="MainActor" location=@__swiftmacro_{{.*}} decl="_Concurrency.(file).MainActor.shared"
66-
// CHECK-NEXT: type_expr type="MainActor.Type"
66+
// CHECK-NEXT: type_expr implicit type="MainActor.Type"
6767
_ = #isolation
6868
}
6969

@@ -126,3 +126,19 @@ func testContextualType() {
126126
await concreteActorIsolation()
127127
}
128128
#endif
129+
130+
func isolationMacroDefault(
131+
isolation: isolated (any Actor)? = #isolation,
132+
) async -> Void {}
133+
134+
class C {
135+
@globalActor
136+
actor NestedActor {
137+
static let shared = NestedActor()
138+
}
139+
140+
@NestedActor
141+
func expandIsolation() async {
142+
await isolationMacroDefault()
143+
}
144+
}

0 commit comments

Comments
 (0)