@@ -1189,6 +1189,7 @@ Optional<ForeignAsyncConvention::Info>
11891189NameImporter::considerAsyncImport (
11901190 const clang::ObjCMethodDecl *clangDecl,
11911191 StringRef &baseName,
1192+ SmallVectorImpl<char > &baseNameScratch,
11921193 SmallVectorImpl<StringRef> ¶mNames,
11931194 ArrayRef<const clang::ParmVarDecl *> params,
11941195 bool isInitializer, bool hasCustomName,
@@ -1224,6 +1225,17 @@ NameImporter::considerAsyncImport(
12241225 return None;
12251226 }
12261227
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+
12271239 // Used for returns once we've determined that the method cannot be
12281240 // imported as async, even though it has what looks like a completion handler
12291241 // parameter.
@@ -1461,6 +1473,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
14611473 }
14621474
14631475 // If we have a swift_name attribute, use that.
1476+ SmallString<32 > asyncBaseNameScratch;
14641477 if (auto *nameAttr = findSwiftNameAttr (D, version)) {
14651478 bool skipCustomName = false ;
14661479
@@ -1539,9 +1552,9 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
15391552
15401553 if (version.supportsConcurrency ()) {
15411554 if (auto asyncInfo = considerAsyncImport (
1542- method, parsedName.BaseName , parsedName. ArgumentLabels ,
1543- params, isInitializer, /* hasCustomName= */ true ,
1544- result.getErrorInfo ())) {
1555+ method, parsedName.BaseName , asyncBaseNameScratch ,
1556+ parsedName. ArgumentLabels , params, isInitializer ,
1557+ /* hasCustomName= */ true , result.getErrorInfo ())) {
15451558 result.info .hasAsyncInfo = true ;
15461559 result.info .asyncInfo = *asyncInfo;
15471560
@@ -1816,8 +1829,8 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
18161829 if (version.supportsConcurrency () &&
18171830 result.info .accessorKind == ImportedAccessorKind::None) {
18181831 if (auto asyncInfo = considerAsyncImport (
1819- objcMethod, baseName, argumentNames, params, isInitializer ,
1820- /* hasCustomName=*/ false ,
1832+ objcMethod, baseName, asyncBaseNameScratch ,
1833+ argumentNames, params, isInitializer, /* hasCustomName=*/ false ,
18211834 result.getErrorInfo ())) {
18221835 result.info .hasAsyncInfo = true ;
18231836 result.info .asyncInfo = *asyncInfo;
0 commit comments