@@ -2400,6 +2400,12 @@ static CanSILFunctionType getNativeSILFunctionType(
24002400 Optional<SubstitutionMap> reqtSubs,
24012401 ProtocolConformanceRef witnessMethodConformance) {
24022402 assert (bool (origConstant) == bool (constant));
2403+ auto getSILFunctionTypeForConventions =
2404+ [&](const Conventions &convs) -> CanSILFunctionType {
2405+ return getSILFunctionType (TC, context, origType, substInterfaceType,
2406+ extInfo, convs, ForeignInfo (), origConstant,
2407+ constant, reqtSubs, witnessMethodConformance);
2408+ };
24032409 switch (extInfo.getSILRepresentation ()) {
24042410 case SILFunctionType::Representation::Block:
24052411 case SILFunctionType::Representation::CFunctionPointer:
@@ -2416,42 +2422,29 @@ static CanSILFunctionType getNativeSILFunctionType(
24162422 switch (constant ? constant->kind : SILDeclRef::Kind::Func) {
24172423 case SILDeclRef::Kind::Initializer:
24182424 case SILDeclRef::Kind::EnumElement:
2419- return getSILFunctionType (TC, context, origType, substInterfaceType,
2420- extInfo, DefaultInitializerConventions (),
2421- ForeignInfo (), origConstant, constant, reqtSubs,
2422- witnessMethodConformance);
2425+ return getSILFunctionTypeForConventions (DefaultInitializerConventions ());
24232426 case SILDeclRef::Kind::Allocator:
2424- return getSILFunctionType (TC, context, origType, substInterfaceType,
2425- extInfo, DefaultAllocatorConventions (),
2426- ForeignInfo (), origConstant, constant, reqtSubs,
2427- witnessMethodConformance);
2428- case SILDeclRef::Kind::Func:
2427+ return getSILFunctionTypeForConventions (DefaultAllocatorConventions ());
2428+ case SILDeclRef::Kind::Func: {
24292429 // If we have a setter, use the special setter convention. This ensures
24302430 // that we take normal parameters at +1.
24312431 if (constant && constant->isSetter ()) {
2432- return getSILFunctionType (TC, context, origType, substInterfaceType,
2433- extInfo, DefaultSetterConventions (),
2434- ForeignInfo (), origConstant, constant,
2435- reqtSubs, witnessMethodConformance);
2432+ return getSILFunctionTypeForConventions (DefaultSetterConventions ());
24362433 }
2437- LLVM_FALLTHROUGH;
2434+ return getSILFunctionTypeForConventions (
2435+ DefaultConventions (NormalParameterConvention::Guaranteed));
2436+ }
24382437 case SILDeclRef::Kind::Destroyer:
24392438 case SILDeclRef::Kind::GlobalAccessor:
24402439 case SILDeclRef::Kind::DefaultArgGenerator:
24412440 case SILDeclRef::Kind::StoredPropertyInitializer:
24422441 case SILDeclRef::Kind::PropertyWrapperBackingInitializer:
24432442 case SILDeclRef::Kind::IVarInitializer:
2444- case SILDeclRef::Kind::IVarDestroyer: {
2445- auto conv = DefaultConventions (NormalParameterConvention::Guaranteed);
2446- return getSILFunctionType (TC, context, origType, substInterfaceType,
2447- extInfo, conv, ForeignInfo (), origConstant,
2448- constant, reqtSubs, witnessMethodConformance);
2449- }
2443+ case SILDeclRef::Kind::IVarDestroyer:
2444+ return getSILFunctionTypeForConventions (
2445+ DefaultConventions (NormalParameterConvention::Guaranteed));
24502446 case SILDeclRef::Kind::Deallocator:
2451- return getSILFunctionType (TC, context, origType, substInterfaceType,
2452- extInfo, DeallocatorConventions (),
2453- ForeignInfo (), origConstant, constant, reqtSubs,
2454- witnessMethodConformance);
2447+ return getSILFunctionTypeForConventions (DeallocatorConventions ());
24552448 }
24562449 }
24572450 }
0 commit comments