[concurrency] global actors in reslient modules need thick metatype.

Resolves rdar://72604101
This commit is contained in:
Kavon Farvardin
2020-12-23 13:35:07 -08:00
parent fabd45e7c3
commit f76645dab1
3 changed files with 33 additions and 1 deletions

View File

@@ -514,10 +514,15 @@ SILValue SILGenFunction::emitLoadGlobalActorExecutor(Type globalActor) {
Type instanceType =
actorType->getTypeOfMember(SGM.SwiftModule, sharedInstanceDecl);
auto metaRepr =
nominal->isResilient(SGM.SwiftModule, ResilienceExpansion::Maximal)
? MetatypeRepresentation::Thick
: MetatypeRepresentation::Thin;
ManagedValue actorMetaType =
ManagedValue::forUnmanaged(B.createMetatype(loc,
SILType::getPrimitiveObjectType(
CanMetatypeType::get(actorType, MetatypeRepresentation::Thin))));
CanMetatypeType::get(actorType, metaRepr))));
RValue actorInstanceRV = emitRValueForStorageLoad(loc, actorMetaType,
actorType, /*isSuper*/ false, sharedInstanceDecl, PreparedArguments(),

View File

@@ -0,0 +1,10 @@
@globalActor public final class MeowActor {
public static let shared = _Impl()
public actor class _Impl {
@actorIndependent
public func enqueue(partialTask: PartialAsyncTask) {
// DOES NOTHING! :)
}
}
}

View File

@@ -0,0 +1,17 @@
// RUN: %empty-directory(%t)
import MeowActor
@MeowActor func doMeow() {}
// RUN: %target-swift-frontend -enable-experimental-concurrency -enable-library-evolution -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-RESILIENT %s
// CHECK-RESILIENT: metatype $@thick MeowActor.Type
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-FRAGILE %s
// CHECK-FRAGILE: metatype $@thin MeowActor.Type
func someFunc() async {
await doMeow()
}