Skip to content

Commit f76645d

Browse files
committed
[concurrency] global actors in reslient modules need thick metatype.
Resolves rdar://72604101
1 parent fabd45e commit f76645d

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,15 @@ SILValue SILGenFunction::emitLoadGlobalActorExecutor(Type globalActor) {
514514
Type instanceType =
515515
actorType->getTypeOfMember(SGM.SwiftModule, sharedInstanceDecl);
516516

517+
auto metaRepr =
518+
nominal->isResilient(SGM.SwiftModule, ResilienceExpansion::Maximal)
519+
? MetatypeRepresentation::Thick
520+
: MetatypeRepresentation::Thin;
521+
517522
ManagedValue actorMetaType =
518523
ManagedValue::forUnmanaged(B.createMetatype(loc,
519524
SILType::getPrimitiveObjectType(
520-
CanMetatypeType::get(actorType, MetatypeRepresentation::Thin))));
525+
CanMetatypeType::get(actorType, metaRepr))));
521526

522527
RValue actorInstanceRV = emitRValueForStorageLoad(loc, actorMetaType,
523528
actorType, /*isSuper*/ false, sharedInstanceDecl, PreparedArguments(),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@globalActor public final class MeowActor {
2+
public static let shared = _Impl()
3+
4+
public actor class _Impl {
5+
@actorIndependent
6+
public func enqueue(partialTask: PartialAsyncTask) {
7+
// DOES NOTHING! :)
8+
}
9+
}
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %empty-directory(%t)
2+
3+
import MeowActor
4+
5+
@MeowActor func doMeow() {}
6+
7+
// RUN: %target-swift-frontend -enable-experimental-concurrency -enable-library-evolution -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
8+
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-RESILIENT %s
9+
// CHECK-RESILIENT: metatype $@thick MeowActor.Type
10+
11+
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
12+
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-FRAGILE %s
13+
// CHECK-FRAGILE: metatype $@thin MeowActor.Type
14+
15+
func someFunc() async {
16+
await doMeow()
17+
}

0 commit comments

Comments
 (0)