@@ -6580,6 +6580,35 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
6580
6580
" transferring result means all results are transferring" );
6581
6581
6582
6582
// We should only ever have a single sil_isolated parameter.
6583
+ bool foundIsolatedParameter = false ;
6584
+ for (const auto ¶meterInfo : FTy->getParameters ()) {
6585
+ if (parameterInfo.hasOption (SILParameterInfo::Isolated)) {
6586
+ auto argType = parameterInfo.getArgumentType (F.getModule (),
6587
+ FTy,
6588
+ F.getTypeExpansionContext ());
6589
+ if (argType->isOptional ())
6590
+ argType = argType->lookThroughAllOptionalTypes ()->getCanonicalType ();
6591
+
6592
+ auto genericSig = FTy->getInvocationGenericSignature ();
6593
+ auto &ctx = F.getASTContext ();
6594
+ auto *actorProtocol = ctx.getProtocol (KnownProtocolKind::Actor);
6595
+ auto *anyActorProtocol = ctx.getProtocol (KnownProtocolKind::AnyActor);
6596
+ bool genericTypeWithActorRequirement = llvm::any_of (
6597
+ genericSig.getRequirements (), [&](const Requirement &other) {
6598
+ if (other.getKind () != RequirementKind::Conformance)
6599
+ return false ;
6600
+ if (other.getFirstType ()->getCanonicalType () != argType)
6601
+ return false ;
6602
+ auto *otherProtocol = other.getProtocolDecl ();
6603
+ return otherProtocol->inheritsFrom (actorProtocol) ||
6604
+ otherProtocol->inheritsFrom (anyActorProtocol);
6605
+ });
6606
+ require (argType->isAnyActorType () || genericTypeWithActorRequirement,
6607
+ " Only any actor types can be isolated" );
6608
+ require (!foundIsolatedParameter, " Two isolated parameters" );
6609
+ foundIsolatedParameter = true ;
6610
+ }
6611
+ }
6583
6612
require (1 >= std::count_if (FTy->getParameters ().begin (), FTy->getParameters ().end (),
6584
6613
[](const SILParameterInfo ¶meterInfo) {
6585
6614
return parameterInfo.hasOption (SILParameterInfo::Isolated);
0 commit comments