Skip to content

Commit 139b943

Browse files
authored
Merge pull request #35932 from DougGregor/no-objc-infer-asynchandler
[Clang importer] Remove @asyncHandler inference for Objective-C methods
2 parents 0651352 + abb5fbf commit 139b943

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7823,32 +7823,6 @@ static bool hasAnyUnsafePointerParameters(FuncDecl *func) {
78237823
return false;
78247824
}
78257825

7826-
/// Determine whether the given Objective-C method is likely to be an
7827-
/// asynchronous handler based on its name.
7828-
static bool isObjCMethodLikelyAsyncHandler(
7829-
const clang::ObjCMethodDecl *method) {
7830-
auto selector = method->getSelector();
7831-
7832-
for (unsigned argIdx : range(std::max(selector.getNumArgs(), 1u))) {
7833-
auto selectorPiece = selector.getNameForSlot(argIdx);
7834-
// For the first selector piece, look for the word "did" anywhere.
7835-
if (argIdx == 0) {
7836-
for (auto word : camel_case::getWords(selectorPiece)) {
7837-
if (word == "did" || word == "Did")
7838-
return true;
7839-
}
7840-
7841-
continue;
7842-
}
7843-
7844-
// Otherwise, check whether any subsequent selector piece starts with "did".
7845-
if (camel_case::getFirstWord(selectorPiece) == "did")
7846-
return true;
7847-
}
7848-
7849-
return false;
7850-
}
7851-
78527826
Type ClangImporter::Implementation::getMainActorType() {
78537827
if (MainActorType)
78547828
return *MainActorType;
@@ -8203,24 +8177,6 @@ void ClangImporter::Implementation::importAttributes(
82038177
if (ClangDecl->hasAttr<clang::PureAttr>()) {
82048178
MappedDecl->getAttrs().add(new (C) EffectsAttr(EffectsKind::ReadOnly));
82058179
}
8206-
8207-
// Infer @asyncHandler on imported protocol methods that meet the semantic
8208-
// requirements.
8209-
if (SwiftContext.LangOpts.EnableExperimentalConcurrency) {
8210-
if (auto func = dyn_cast<FuncDecl>(MappedDecl)) {
8211-
if (auto proto = dyn_cast<ProtocolDecl>(func->getDeclContext())) {
8212-
if (proto->isObjC() && isa<clang::ObjCMethodDecl>(ClangDecl) &&
8213-
func->isInstanceMember() && !isa<AccessorDecl>(func) &&
8214-
isObjCMethodLikelyAsyncHandler(
8215-
cast<clang::ObjCMethodDecl>(ClangDecl)) &&
8216-
func->canBeAsyncHandler() &&
8217-
!hasAnyUnsafePointerParameters(func)) {
8218-
MappedDecl->getAttrs().add(
8219-
new (C) AsyncHandlerAttr(/*IsImplicit=*/false));
8220-
}
8221-
}
8222-
}
8223-
}
82248180
}
82258181

82268182
Decl *

test/IDE/print_clang_objc_async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import _Concurrency
2929
// CHECK: {{^[}]$}}
3030

3131
// CHECK-LABEL: protocol RefrigeratorDelegate
32-
// CHECK-NEXT: @asyncHandler func someoneDidOpenRefrigerator(_ fridge: Any)
33-
// CHECK-NEXT: @asyncHandler func refrigerator(_ fridge: Any, didGetFilledWithItems items: [Any])
32+
// CHECK-NEXT: func someoneDidOpenRefrigerator(_ fridge: Any)
33+
// CHECK-NEXT: func refrigerator(_ fridge: Any, didGetFilledWithItems items: [Any])
3434
// CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, didGetFilledWithIntegers items: UnsafeMutablePointer<Int>, count: Int)
3535
// CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, willAddItem item: Any)
3636
// CHECK-NEXT: {{^}} func refrigerator(_ fridge: Any, didRemoveItem item: Any) -> Bool

0 commit comments

Comments
 (0)