@@ -1424,51 +1424,44 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
1424
1424
1425
1425
B.setInsertionPoint (entryBlock);
1426
1426
1427
- // If we're using a new enough deployment target, call swift_createExecutors()
1428
- if (ctx.LangOpts .ExecutorFactory ) {
1429
- if (!isCreateExecutorsFunctionAvailable (SGM)) {
1430
- ctx.Diags .diagnose (SourceLoc (), diag::executor_factory_not_supported);
1431
- } else {
1432
- CanType factoryTy = SGM.getConfiguredExecutorFactory ()->getCanonicalType ();
1427
+ // If we're using a new enough deployment target, and we can find a
1428
+ // DefaultExecutorFactory type, call swift_createExecutors()
1429
+ Type factoryNonCanTy = SGM.getConfiguredExecutorFactory ();
1433
1430
1434
- if (!factoryTy) {
1435
- ctx.Diags .diagnose (SourceLoc (), diag::cannot_find_executor_factory_type,
1436
- *ctx.LangOpts .ExecutorFactory );
1437
- }
1431
+ if (isCreateExecutorsFunctionAvailable (SGM) && factoryNonCanTy) {
1432
+ CanType factoryTy = factoryNonCanTy->getCanonicalType ();
1438
1433
1439
- ProtocolDecl *executorFactoryProtocol
1440
- = ctx.getProtocol (KnownProtocolKind::ExecutorFactory);
1441
- auto conformance = lookupConformance (factoryTy, executorFactoryProtocol);
1434
+ ProtocolDecl *executorFactoryProtocol
1435
+ = ctx.getProtocol (KnownProtocolKind::ExecutorFactory);
1436
+ auto conformance = lookupConformance (factoryTy, executorFactoryProtocol);
1442
1437
1443
- if (conformance.isInvalid ()) {
1444
- // If this type doesn't conform, ignore it and use the default factory
1445
- SourceLoc loc = extractNearestSourceLoc (factoryTy);
1438
+ if (conformance.isInvalid ()) {
1439
+ // If this type doesn't conform, ignore it and use the default factory
1440
+ SourceLoc loc = extractNearestSourceLoc (factoryTy);
1446
1441
1447
- ctx.Diags .diagnose (loc, diag::executor_factory_must_conform,
1448
- *ctx.LangOpts .ExecutorFactory );
1442
+ ctx.Diags .diagnose (loc, diag::executor_factory_must_conform);
1449
1443
1450
- factoryTy = SGM.getDefaultExecutorFactory ()->getCanonicalType ();
1451
- conformance = lookupConformance (factoryTy, executorFactoryProtocol);
1444
+ factoryTy = SGM.getDefaultExecutorFactory ()->getCanonicalType ();
1445
+ conformance = lookupConformance (factoryTy, executorFactoryProtocol);
1452
1446
1453
- assert (!conformance.isInvalid ());
1454
- }
1447
+ assert (!conformance.isInvalid ());
1448
+ }
1455
1449
1456
- FuncDecl *createExecutorsFuncDecl = SGM.getCreateExecutors ();
1457
- assert (createExecutorsFuncDecl
1458
- && " Failed to find swift_createExecutors function decl" );
1459
- SILFunction *createExecutorsSILFunc =
1460
- SGM.getFunction (SILDeclRef (createExecutorsFuncDecl, SILDeclRef::Kind::Func),
1450
+ FuncDecl *createExecutorsFuncDecl = SGM.getCreateExecutors ();
1451
+ assert (createExecutorsFuncDecl
1452
+ && " Failed to find swift_createExecutors function decl" );
1453
+ SILFunction *createExecutorsSILFunc =
1454
+ SGM.getFunction (SILDeclRef (createExecutorsFuncDecl, SILDeclRef::Kind::Func),
1461
1455
NotForDefinition);
1462
- SILValue createExecutorsFunc =
1463
- B.createFunctionRefFor (moduleLoc, createExecutorsSILFunc);
1464
- MetatypeType *factoryThickMetaTy
1465
- = MetatypeType::get (factoryTy, MetatypeRepresentation::Thick);
1466
- SILValue factorySILMetaTy
1467
- = B.createMetatype (moduleLoc, getLoweredType (factoryThickMetaTy));
1468
- auto ceSubs = SubstitutionMap::getProtocolSubstitutions (
1469
- conformance.getProtocol (), factoryTy, conformance);
1470
- B.createApply (moduleLoc, createExecutorsFunc, ceSubs, { factorySILMetaTy });
1471
- }
1456
+ SILValue createExecutorsFunc =
1457
+ B.createFunctionRefFor (moduleLoc, createExecutorsSILFunc);
1458
+ MetatypeType *factoryThickMetaTy
1459
+ = MetatypeType::get (factoryTy, MetatypeRepresentation::Thick);
1460
+ SILValue factorySILMetaTy
1461
+ = B.createMetatype (moduleLoc, getLoweredType (factoryThickMetaTy));
1462
+ auto ceSubs = SubstitutionMap::getProtocolSubstitutions (
1463
+ conformance.getProtocol (), factoryTy, conformance);
1464
+ B.createApply (moduleLoc, createExecutorsFunc, ceSubs, { factorySILMetaTy });
1472
1465
}
1473
1466
1474
1467
auto wrapCallArgs = [this , &moduleLoc](SILValue originalValue, FuncDecl *fd,
0 commit comments