@@ -1557,11 +1557,11 @@ class DestructureInputs {
1557
1557
unsigned numEltTypes = params.size ();
1558
1558
1559
1559
bool hasSelf =
1560
- (extInfoBuilder.hasSelfParam () || Foreign.Self .isImportAsMember ());
1560
+ (extInfoBuilder.hasSelfParam () || Foreign.self .isImportAsMember ());
1561
1561
unsigned numNonSelfParams = (hasSelf ? numEltTypes - 1 : numEltTypes);
1562
1562
TopLevelOrigType = origType;
1563
1563
// If we have a foreign-self, install handleSelf as the handler.
1564
- if (Foreign.Self .isInstance ()) {
1564
+ if (Foreign.self .isInstance ()) {
1565
1565
assert (hasSelf && numEltTypes > 0 );
1566
1566
ForeignSelf = ForeignSelfInfo{origType.getFunctionParamType (numNonSelfParams),
1567
1567
params[numNonSelfParams]};
@@ -1582,7 +1582,7 @@ class DestructureInputs {
1582
1582
1583
1583
// Process the self parameter. Note that we implicitly drop self
1584
1584
// if this is a static foreign-self import.
1585
- if (hasSelf && !Foreign.Self .isImportAsMember ()) {
1585
+ if (hasSelf && !Foreign.self .isImportAsMember ()) {
1586
1586
auto selfParam = params[numNonSelfParams];
1587
1587
auto ty = selfParam.getParameterType ();
1588
1588
auto eltPattern = origType.getFunctionParamType (numNonSelfParams);
@@ -1670,12 +1670,13 @@ class DestructureInputs {
1670
1670
}
1671
1671
1672
1672
bool maybeAddForeignAsyncParameter () {
1673
- if (!Foreign.Async
1674
- || NextOrigParamIndex != Foreign.Async ->completionHandlerParamIndex ())
1673
+ if (!Foreign.async ||
1674
+ NextOrigParamIndex != Foreign.async ->completionHandlerParamIndex ())
1675
1675
return false ;
1676
-
1677
- CanType foreignCHTy = TopLevelOrigType
1678
- .getObjCMethodAsyncCompletionHandlerForeignType (Foreign.Async .getValue (), TC);
1676
+
1677
+ CanType foreignCHTy =
1678
+ TopLevelOrigType.getObjCMethodAsyncCompletionHandlerForeignType (
1679
+ Foreign.async .getValue (), TC);
1679
1680
auto completionHandlerOrigTy = TopLevelOrigType.getObjCMethodAsyncCompletionHandlerType (foreignCHTy);
1680
1681
auto completionHandlerTy = TC.getLoweredType (completionHandlerOrigTy,
1681
1682
foreignCHTy, expansion)
@@ -1689,15 +1690,15 @@ class DestructureInputs {
1689
1690
bool maybeAddForeignErrorParameter () {
1690
1691
// A foreign async convention absorbs any error parameter, making it into
1691
1692
// an argument to the callback.
1692
- if (Foreign.Async )
1693
+ if (Foreign.async )
1693
1694
return false ;
1694
-
1695
- if (!Foreign.Error ||
1696
- NextOrigParamIndex != Foreign.Error ->getErrorParameterIndex ())
1695
+
1696
+ if (!Foreign.error ||
1697
+ NextOrigParamIndex != Foreign.error ->getErrorParameterIndex ())
1697
1698
return false ;
1698
1699
1699
1700
auto foreignErrorTy = TC.getLoweredRValueType (
1700
- expansion, Foreign.Error ->getErrorParameterType ());
1701
+ expansion, Foreign.error ->getErrorParameterType ());
1701
1702
1702
1703
// Assume the error parameter doesn't have interesting lowering.
1703
1704
Inputs.push_back (SILParameterInfo (foreignErrorTy,
@@ -1707,8 +1708,8 @@ class DestructureInputs {
1707
1708
}
1708
1709
1709
1710
bool maybeAddForeignSelfParameter () {
1710
- if (!Foreign.Self .isInstance () ||
1711
- NextOrigParamIndex != Foreign.Self .getSelfIndex ())
1711
+ if (!Foreign.self .isInstance () ||
1712
+ NextOrigParamIndex != Foreign.self .getSelfIndex ())
1712
1713
return false ;
1713
1714
1714
1715
if (ForeignSelf) {
@@ -1759,22 +1760,22 @@ void updateResultTypeForForeignInfo(
1759
1760
const ForeignInfo &foreignInfo, CanGenericSignature genericSig,
1760
1761
AbstractionPattern &origResultType, CanType &substFormalResultType) {
1761
1762
// If there's no error or async convention, the return type is unchanged.
1762
- if (!foreignInfo.Async && !foreignInfo.Error ) {
1763
+ if (!foreignInfo.async && !foreignInfo.error ) {
1763
1764
return ;
1764
1765
}
1765
-
1766
+
1766
1767
// A foreign async convention means our lowered return type is Void, since
1767
1768
// the imported semantic return and/or error type map to the completion
1768
1769
// callback's argument(s).
1769
1770
auto &C = substFormalResultType->getASTContext ();
1770
- if (auto async = foreignInfo.Async ) {
1771
+ if (auto async = foreignInfo.async ) {
1771
1772
substFormalResultType = TupleType::getEmpty (C);
1772
1773
origResultType = AbstractionPattern (genericSig, substFormalResultType);
1773
1774
return ;
1774
1775
}
1775
-
1776
+
1776
1777
// Otherwise, adjust the return type to match the foreign error convention.
1777
- auto convention = *foreignInfo.Error ;
1778
+ auto convention = *foreignInfo.error ;
1778
1779
switch (convention.getKind ()) {
1779
1780
// These conventions replace the result type.
1780
1781
case ForeignErrorConvention::ZeroResult:
@@ -2086,27 +2087,25 @@ static CanSILFunctionType getSILFunctionType(
2086
2087
2087
2088
Optional<SILResultInfo> errorResult;
2088
2089
assert (
2089
- (!foreignInfo.Error || substFnInterfaceType->getExtInfo ().isThrowing ())
2090
- && " foreignError was set but function type does not throw?" );
2091
- assert (
2092
- (!foreignInfo.Async || substFnInterfaceType->getExtInfo ().isAsync ())
2093
- && " foreignAsync was set but function type is not async?" );
2090
+ (!foreignInfo.error || substFnInterfaceType->getExtInfo ().isThrowing ()) &&
2091
+ " foreignError was set but function type does not throw?" );
2092
+ assert ((!foreignInfo.async || substFnInterfaceType->getExtInfo ().isAsync ()) &&
2093
+ " foreignAsync was set but function type is not async?" );
2094
2094
2095
2095
// Map '@Sendable' to the appropriate `@Sendable` modifier.
2096
2096
bool isSendable = substFnInterfaceType->getExtInfo ().isSendable ();
2097
2097
2098
2098
// Map 'async' to the appropriate `@async` modifier.
2099
2099
bool isAsync = false ;
2100
- if (substFnInterfaceType->getExtInfo ().isAsync () && !foreignInfo.Async ) {
2100
+ if (substFnInterfaceType->getExtInfo ().isAsync () && !foreignInfo.async ) {
2101
2101
assert (!origType.isForeign ()
2102
2102
&& " using native Swift async for foreign type!" );
2103
2103
isAsync = true ;
2104
2104
}
2105
-
2105
+
2106
2106
// Map 'throws' to the appropriate error convention.
2107
- if (substFnInterfaceType->getExtInfo ().isThrowing ()
2108
- && !foreignInfo.Error
2109
- && !foreignInfo.Async ) {
2107
+ if (substFnInterfaceType->getExtInfo ().isThrowing () && !foreignInfo.error &&
2108
+ !foreignInfo.async ) {
2110
2109
assert (!origType.isForeign ()
2111
2110
&& " using native Swift error convention for foreign type!" );
2112
2111
SILType exnType = SILType::getExceptionType (TC.Context );
@@ -2892,20 +2891,21 @@ static CanSILFunctionType getSILFunctionTypeForClangDecl(
2892
2891
SILExtInfoBuilder extInfoBuilder, const ForeignInfo &foreignInfo,
2893
2892
Optional<SILDeclRef> constant) {
2894
2893
if (auto method = dyn_cast<clang::ObjCMethodDecl>(clangDecl)) {
2895
- auto origPattern =
2896
- AbstractionPattern::getObjCMethod (origType, method,
2897
- foreignInfo.Error ,
2898
- foreignInfo.Async );
2894
+ auto origPattern = AbstractionPattern::getObjCMethod (
2895
+ origType, method, foreignInfo.error , foreignInfo.async );
2899
2896
return getSILFunctionType (
2900
2897
TC, TypeExpansionContext::minimal (), origPattern, substInterfaceType,
2901
2898
extInfoBuilder, ObjCMethodConventions (method), foreignInfo, constant,
2902
2899
constant, None, ProtocolConformanceRef ());
2903
2900
}
2904
2901
2905
2902
if (auto method = dyn_cast<clang::CXXMethodDecl>(clangDecl)) {
2906
- AbstractionPattern origPattern = method->isOverloadedOperator () ?
2907
- AbstractionPattern::getCXXOperatorMethod (origType, method, foreignInfo.Self ):
2908
- AbstractionPattern::getCXXMethod (origType, method, foreignInfo.Self );
2903
+ AbstractionPattern origPattern =
2904
+ method->isOverloadedOperator ()
2905
+ ? AbstractionPattern::getCXXOperatorMethod (origType, method,
2906
+ foreignInfo.self )
2907
+ : AbstractionPattern::getCXXMethod (origType, method,
2908
+ foreignInfo.self );
2909
2909
bool isMutating =
2910
2910
TC.Context .getClangModuleLoader ()->isCXXMethodMutating (method);
2911
2911
auto conventions = CXXMethodConventions (method, isMutating);
@@ -2918,10 +2918,10 @@ static CanSILFunctionType getSILFunctionTypeForClangDecl(
2918
2918
if (auto func = dyn_cast<clang::FunctionDecl>(clangDecl)) {
2919
2919
auto clangType = func->getType ().getTypePtr ();
2920
2920
AbstractionPattern origPattern =
2921
- foreignInfo.Self .isImportAsMember ()
2922
- ? AbstractionPattern::getCFunctionAsMethod (origType, clangType,
2923
- foreignInfo.Self )
2924
- : AbstractionPattern (origType, clangType);
2921
+ foreignInfo.self .isImportAsMember ()
2922
+ ? AbstractionPattern::getCFunctionAsMethod (origType, clangType,
2923
+ foreignInfo.self )
2924
+ : AbstractionPattern (origType, clangType);
2925
2925
return getSILFunctionType (TC, TypeExpansionContext::minimal (), origPattern,
2926
2926
substInterfaceType, extInfoBuilder,
2927
2927
CFunctionConventions (func), foreignInfo, constant,
@@ -3214,10 +3214,10 @@ static CanSILFunctionType getUncachedSILFunctionTypeForConstant(
3214
3214
// import-as-member but do involve the same gymnastics with the
3215
3215
// formal type. That's all that SILFunctionType cares about, so
3216
3216
// pretend that it's import-as-member.
3217
- if (!foreignInfo.Self .isImportAsMember () &&
3217
+ if (!foreignInfo.self .isImportAsMember () &&
3218
3218
isImporterGeneratedAccessor (clangDecl, constant)) {
3219
3219
unsigned selfIndex = cast<AccessorDecl>(decl)->isSetter () ? 1 : 0 ;
3220
- foreignInfo.Self .setSelfIndex (selfIndex);
3220
+ foreignInfo.self .setSelfIndex (selfIndex);
3221
3221
}
3222
3222
3223
3223
return getSILFunctionTypeForClangDecl (
0 commit comments