36
36
#include " swift/Basic/Statistic.h"
37
37
#include " swift/ClangImporter/ClangImporterRequests.h"
38
38
#include " swift/Parse/Lexer.h"
39
- #include " swift/Strings.h"
40
39
#include " clang/AST/DeclObjC.h"
41
40
#include " clang/Basic/Specifiers.h"
42
41
#include " llvm/ADT/DenseMap.h"
@@ -1311,24 +1310,7 @@ class swift::ObjCMethodLookupTable
1311
1310
: public llvm::DenseMap<std::pair<ObjCSelector, char >,
1312
1311
StoredObjCMethods>,
1313
1312
public ASTAllocated<ObjCMethodLookupTable>
1314
- {
1315
- SWIFT_DEBUG_DUMP {
1316
- llvm::errs () << " ObjCMethodLookupTable:\n " ;
1317
- for (auto pair : *this ) {
1318
- auto selector = pair.getFirst ().first ;
1319
- auto isInstanceMethod = pair.getFirst ().second ;
1320
- auto &methods = pair.getSecond ();
1321
-
1322
- llvm::errs () << " \" " << (isInstanceMethod ? " -" : " +" ) << selector
1323
- << " \" :\n " ;
1324
- for (auto method : methods.Methods ) {
1325
- llvm::errs () << " - \" " ;
1326
- method->dumpRef (llvm::errs ());
1327
- llvm::errs () << " \"\n " ;
1328
- }
1329
- }
1330
- }
1331
- };
1313
+ {};
1332
1314
1333
1315
MemberLookupTable::MemberLookupTable (ASTContext &ctx) {
1334
1316
// Register a cleanup with the ASTContext to call the lookup table
@@ -1686,7 +1668,7 @@ bool NominalTypeDecl::createObjCMethodLookup() {
1686
1668
assert (!ObjCMethodLookup && " Already have an Objective-C member table" );
1687
1669
1688
1670
// Most types cannot have ObjC methods.
1689
- if (!(isa<ClassDecl>(this ) || isa<ProtocolDecl>( this ) ))
1671
+ if (!(isa<ClassDecl>(this )))
1690
1672
return false ;
1691
1673
1692
1674
auto &ctx = getASTContext ();
@@ -1717,36 +1699,6 @@ NominalTypeDecl::lookupDirect(ObjCSelector selector, bool isInstance) {
1717
1699
return stored.Methods ;
1718
1700
}
1719
1701
1720
- // / If there is an apparent conflict between \p newDecl and one of the methods
1721
- // / in \p vec, should we diagnose it?
1722
- static bool
1723
- shouldDiagnoseConflict (NominalTypeDecl *ty, AbstractFunctionDecl *newDecl,
1724
- llvm::TinyPtrVector<AbstractFunctionDecl *> &vec) {
1725
- // Are all conflicting methods imported from ObjC and in our ObjC half or a
1726
- // bridging header? Some code bases implement ObjC methods in Swift even
1727
- // though it's not exactly supported.
1728
- auto newDeclModuleName = newDecl->getModuleContext ()->getName ();
1729
- if (llvm::all_of (vec, [&](AbstractFunctionDecl *oldDecl) {
1730
- if (!oldDecl->hasClangNode ())
1731
- return false ;
1732
- auto oldDeclModuleName = oldDecl->getModuleContext ()->getName ();
1733
- return oldDeclModuleName == newDeclModuleName
1734
- || oldDeclModuleName.str () == CLANG_HEADER_MODULE_NAME;
1735
- }))
1736
- return false ;
1737
-
1738
- // If we're looking at protocol requirements, is the new method an async
1739
- // alternative of any existing method, or vice versa?
1740
- if (isa<ProtocolDecl>(ty) &&
1741
- llvm::any_of (vec, [&](AbstractFunctionDecl *oldDecl) {
1742
- return newDecl->getAsyncAlternative (/* isKnownObjC=*/ true ) == oldDecl
1743
- || oldDecl->getAsyncAlternative (/* isKnownObjC=*/ true ) == newDecl;
1744
- }))
1745
- return false ;
1746
-
1747
- return true ;
1748
- }
1749
-
1750
1702
void NominalTypeDecl::recordObjCMethod (AbstractFunctionDecl *method,
1751
1703
ObjCSelector selector) {
1752
1704
if (!ObjCMethodLookup && !createObjCMethodLookup ())
@@ -1762,11 +1714,12 @@ void NominalTypeDecl::recordObjCMethod(AbstractFunctionDecl *method,
1762
1714
return ;
1763
1715
1764
1716
if (auto *sf = method->getParentSourceFile ()) {
1765
- if (vec.empty ()) {
1766
- sf->ObjCMethodList .push_back (method);
1767
- } else if (shouldDiagnoseConflict (this , method, vec)) {
1717
+ if (vec.size () == 1 ) {
1768
1718
// We have a conflict.
1769
- sf->ObjCMethodConflicts .insert ({ this , selector, isInstanceMethod });
1719
+ sf->ObjCMethodConflicts .push_back (std::make_tuple (this , selector,
1720
+ isInstanceMethod));
1721
+ } if (vec.empty ()) {
1722
+ sf->ObjCMethodList .push_back (method);
1770
1723
}
1771
1724
}
1772
1725
0 commit comments