[concurrency] initial declaration of MainActor

Implementation is left as a TODO for now.

Resolves rdar://72161578
Partially resolves rdar://72105129
This commit is contained in:
Kavon Farvardin
2020-12-08 14:20:38 -08:00
parent f76645dab1
commit a2c57d13c3
4 changed files with 84 additions and 0 deletions

View File

@@ -414,6 +414,11 @@ public:
if (!printOptions.shouldPrint(nominal))
return;
/// is this nominal specifically an 'actor class'?
bool actorClass = false;
if (auto klass = dyn_cast<ClassDecl>(nominal))
actorClass = klass->isActor();
SmallPtrSet<ProtocolDecl *, 16> handledProtocols;
// First record all protocols that have already been handled.
@@ -438,6 +443,15 @@ public:
if (!handledProtocols.insert(inherited).second)
return TypeWalker::Action::SkipChildren;
// If 'nominal' is an 'actor class', we do not synthesize its
// conformance to the Actor protocol through a dummy extension.
// There is a special restriction on the Actor protocol in that
// it is only valid to conform to Actor on an 'actor class' decl,
// not extensions of that 'actor class'.
if (actorClass &&
inherited->isSpecificProtocol(KnownProtocolKind::Actor))
return TypeWalker::Action::Continue;
if (isPublicOrUsableFromInline(inherited) &&
conformanceDeclaredInModule(M, nominal, inherited)) {
protocolsToPrint.push_back({inherited, protoAndAvailability.second});