@@ -1189,6 +1189,7 @@ Optional<ForeignAsyncConvention::Info>
1189
1189
NameImporter::considerAsyncImport (
1190
1190
const clang::ObjCMethodDecl *clangDecl,
1191
1191
StringRef &baseName,
1192
+ SmallVectorImpl<char > &baseNameScratch,
1192
1193
SmallVectorImpl<StringRef> ¶mNames,
1193
1194
ArrayRef<const clang::ParmVarDecl *> params,
1194
1195
bool isInitializer, bool hasCustomName,
@@ -1224,6 +1225,17 @@ NameImporter::considerAsyncImport(
1224
1225
return None;
1225
1226
}
1226
1227
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
+
1227
1239
// Used for returns once we've determined that the method cannot be
1228
1240
// imported as async, even though it has what looks like a completion handler
1229
1241
// parameter.
@@ -1461,6 +1473,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1461
1473
}
1462
1474
1463
1475
// If we have a swift_name attribute, use that.
1476
+ SmallString<32 > asyncBaseNameScratch;
1464
1477
if (auto *nameAttr = findSwiftNameAttr (D, version)) {
1465
1478
bool skipCustomName = false ;
1466
1479
@@ -1539,9 +1552,9 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1539
1552
1540
1553
if (version.supportsConcurrency ()) {
1541
1554
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 ())) {
1545
1558
result.info .hasAsyncInfo = true ;
1546
1559
result.info .asyncInfo = *asyncInfo;
1547
1560
@@ -1816,8 +1829,8 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
1816
1829
if (version.supportsConcurrency () &&
1817
1830
result.info .accessorKind == ImportedAccessorKind::None) {
1818
1831
if (auto asyncInfo = considerAsyncImport (
1819
- objcMethod, baseName, argumentNames, params, isInitializer ,
1820
- /* hasCustomName=*/ false ,
1832
+ objcMethod, baseName, asyncBaseNameScratch ,
1833
+ argumentNames, params, isInitializer, /* hasCustomName=*/ false ,
1821
1834
result.getErrorInfo ())) {
1822
1835
result.info .hasAsyncInfo = true ;
1823
1836
result.info .asyncInfo = *asyncInfo;
0 commit comments