@@ -804,7 +804,7 @@ static bool omitNeedlessWordsInFunctionName(
804804 ArrayRef<const clang::ParmVarDecl *> params, clang::QualType resultType,
805805 const clang::DeclContext *dc, const SmallBitVector &nonNullArgs,
806806 Optional<unsigned > errorParamIndex, bool returnsSelf, bool isInstanceMethod,
807- NameImporter &nameImporter) {
807+ Optional< unsigned > completionHandlerIndex, NameImporter &nameImporter) {
808808 clang::ASTContext &clangCtx = nameImporter.getClangContext ();
809809
810810 // Collect the parameter type names.
@@ -817,10 +817,6 @@ static bool omitNeedlessWordsInFunctionName(
817817 if (i == 0 )
818818 firstParamName = param->getName ();
819819
820- // Determine the number of parameters.
821- unsigned numParams = params.size ();
822- if (errorParamIndex) --numParams;
823-
824820 bool isLastParameter
825821 = (i == params.size () - 1 ) ||
826822 (i == params.size () - 2 &&
@@ -858,7 +854,8 @@ static bool omitNeedlessWordsInFunctionName(
858854 getClangTypeNameForOmission (clangCtx, resultType),
859855 getClangTypeNameForOmission (clangCtx, contextType),
860856 paramTypes, returnsSelf, /* isProperty=*/ false ,
861- allPropertyNames, nameImporter.getScratch ());
857+ allPropertyNames, completionHandlerIndex.hasValue (),
858+ nameImporter.getScratch ());
862859}
863860
864861// / Prepare global name for importing onto a swift_newtype.
@@ -1189,7 +1186,6 @@ Optional<ForeignAsyncConvention::Info>
11891186NameImporter::considerAsyncImport (
11901187 const clang::ObjCMethodDecl *clangDecl,
11911188 StringRef &baseName,
1192- SmallVectorImpl<char > &baseNameScratch,
11931189 SmallVectorImpl<StringRef> ¶mNames,
11941190 ArrayRef<const clang::ParmVarDecl *> params,
11951191 bool isInitializer, bool hasCustomName,
@@ -1225,17 +1221,6 @@ NameImporter::considerAsyncImport(
12251221 return None;
12261222 }
12271223
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-
12391224 // Used for returns once we've determined that the method cannot be
12401225 // imported as async, even though it has what looks like a completion handler
12411226 // parameter.
@@ -1473,7 +1458,6 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
14731458 }
14741459
14751460 // If we have a swift_name attribute, use that.
1476- SmallString<32 > asyncBaseNameScratch;
14771461 if (auto *nameAttr = findSwiftNameAttr (D, version)) {
14781462 bool skipCustomName = false ;
14791463
@@ -1552,9 +1536,9 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
15521536
15531537 if (version.supportsConcurrency ()) {
15541538 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 ())) {
15581542 result.info .hasAsyncInfo = true ;
15591543 result.info .asyncInfo = *asyncInfo;
15601544
@@ -1829,9 +1813,8 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
18291813 if (version.supportsConcurrency () &&
18301814 result.info .accessorKind == ImportedAccessorKind::None) {
18311815 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 ())) {
18351818 result.info .hasAsyncInfo = true ;
18361819 result.info .asyncInfo = *asyncInfo;
18371820 }
@@ -1971,7 +1954,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
19711954 (void )omitNeedlessWords (baseName, {}, " " , propertyTypeName,
19721955 contextTypeName, {}, /* returnsSelf=*/ false ,
19731956 /* isProperty=*/ true , allPropertyNames,
1974- scratch);
1957+ /* isAsync= */ false , scratch);
19751958 }
19761959 }
19771960
@@ -1983,7 +1966,12 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
19831966 result.getErrorInfo ()
19841967 ? Optional<unsigned >(result.getErrorInfo ()->ErrorParameterIndex )
19851968 : 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 );
19871975 }
19881976
19891977 // If the result is a value, lowercase it.
0 commit comments