@@ -804,7 +804,7 @@ static bool omitNeedlessWordsInFunctionName(
804
804
ArrayRef<const clang::ParmVarDecl *> params, clang::QualType resultType,
805
805
const clang::DeclContext *dc, const SmallBitVector &nonNullArgs,
806
806
Optional<unsigned > errorParamIndex, bool returnsSelf, bool isInstanceMethod,
807
- NameImporter &nameImporter) {
807
+ Optional< unsigned > completionHandlerIndex, NameImporter &nameImporter) {
808
808
clang::ASTContext &clangCtx = nameImporter.getClangContext ();
809
809
810
810
// Collect the parameter type names.
@@ -817,10 +817,6 @@ static bool omitNeedlessWordsInFunctionName(
817
817
if (i == 0 )
818
818
firstParamName = param->getName ();
819
819
820
- // Determine the number of parameters.
821
- unsigned numParams = params.size ();
822
- if (errorParamIndex) --numParams;
823
-
824
820
bool isLastParameter
825
821
= (i == params.size () - 1 ) ||
826
822
(i == params.size () - 2 &&
@@ -858,7 +854,8 @@ static bool omitNeedlessWordsInFunctionName(
858
854
getClangTypeNameForOmission (clangCtx, resultType),
859
855
getClangTypeNameForOmission (clangCtx, contextType),
860
856
paramTypes, returnsSelf, /* isProperty=*/ false ,
861
- allPropertyNames, nameImporter.getScratch ());
857
+ allPropertyNames, completionHandlerIndex.hasValue (),
858
+ nameImporter.getScratch ());
862
859
}
863
860
864
861
// / Prepare global name for importing onto a swift_newtype.
@@ -1189,7 +1186,6 @@ Optional<ForeignAsyncConvention::Info>
1189
1186
NameImporter::considerAsyncImport (
1190
1187
const clang::ObjCMethodDecl *clangDecl,
1191
1188
StringRef &baseName,
1192
- SmallVectorImpl<char > &baseNameScratch,
1193
1189
SmallVectorImpl<StringRef> ¶mNames,
1194
1190
ArrayRef<const clang::ParmVarDecl *> params,
1195
1191
bool isInitializer, bool hasCustomName,
@@ -1225,17 +1221,6 @@ NameImporter::considerAsyncImport(
1225
1221
return None;
1226
1222
}
1227
1223
1228
- // If there's no custom name, and the base name starts with "get", drop the
1229
- // get.
1230
- if (!hasCustomName) {
1231
- StringRef currentBaseName = newBaseName ? *newBaseName : baseName;
1232
- if (currentBaseName.size () > 3 &&
1233
- camel_case::getFirstWord (currentBaseName) == " get" ) {
1234
- newBaseName = camel_case::toLowercaseInitialisms (
1235
- currentBaseName.substr (3 ), baseNameScratch);
1236
- }
1237
- }
1238
-
1239
1224
// Used for returns once we've determined that the method cannot be
1240
1225
// imported as async, even though it has what looks like a completion handler
1241
1226
// parameter.
@@ -1473,7 +1458,6 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1473
1458
}
1474
1459
1475
1460
// If we have a swift_name attribute, use that.
1476
- SmallString<32 > asyncBaseNameScratch;
1477
1461
if (auto *nameAttr = findSwiftNameAttr (D, version)) {
1478
1462
bool skipCustomName = false ;
1479
1463
@@ -1552,9 +1536,9 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1552
1536
1553
1537
if (version.supportsConcurrency ()) {
1554
1538
if (auto asyncInfo = considerAsyncImport (
1555
- method, parsedName.BaseName , asyncBaseNameScratch ,
1556
- parsedName. ArgumentLabels , params, isInitializer,
1557
- /* hasCustomName= */ true , result.getErrorInfo ())) {
1539
+ method, parsedName.BaseName , parsedName. ArgumentLabels ,
1540
+ params, isInitializer, /* hasCustomName= */ true ,
1541
+ result.getErrorInfo ())) {
1558
1542
result.info .hasAsyncInfo = true ;
1559
1543
result.info .asyncInfo = *asyncInfo;
1560
1544
@@ -1829,9 +1813,8 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1829
1813
if (version.supportsConcurrency () &&
1830
1814
result.info .accessorKind == ImportedAccessorKind::None) {
1831
1815
if (auto asyncInfo = considerAsyncImport (
1832
- objcMethod, baseName, asyncBaseNameScratch,
1833
- argumentNames, params, isInitializer, /* hasCustomName=*/ false ,
1834
- result.getErrorInfo ())) {
1816
+ objcMethod, baseName, argumentNames, params, isInitializer,
1817
+ /* hasCustomName=*/ false , result.getErrorInfo ())) {
1835
1818
result.info .hasAsyncInfo = true ;
1836
1819
result.info .asyncInfo = *asyncInfo;
1837
1820
}
@@ -1971,7 +1954,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1971
1954
(void )omitNeedlessWords (baseName, {}, " " , propertyTypeName,
1972
1955
contextTypeName, {}, /* returnsSelf=*/ false ,
1973
1956
/* isProperty=*/ true , allPropertyNames,
1974
- scratch);
1957
+ /* isAsync= */ false , scratch);
1975
1958
}
1976
1959
}
1977
1960
@@ -1983,7 +1966,12 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1983
1966
result.getErrorInfo ()
1984
1967
? Optional<unsigned >(result.getErrorInfo ()->ErrorParameterIndex )
1985
1968
: None,
1986
- method->hasRelatedResultType (), method->isInstanceMethod (), *this );
1969
+ method->hasRelatedResultType (), method->isInstanceMethod (),
1970
+ result.getAsyncInfo ().map (
1971
+ [](const ForeignAsyncConvention::Info &info) {
1972
+ return info.CompletionHandlerParamIndex ;
1973
+ }),
1974
+ *this );
1987
1975
}
1988
1976
1989
1977
// If the result is a value, lowercase it.
0 commit comments