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