@@ -4122,32 +4122,15 @@ bool ClangImporter::Implementation::lookupValue(SwiftLookupTable &table,
41224122 bool declFound = false ;
41234123
41244124 if (name.isOperator ()) {
4125- for (auto entry : table.lookupMemberOperators (name.getBaseName ())) {
4126- if (isVisibleClangEntry (entry)) {
4127- if (auto decl = dyn_cast_or_null<ValueDecl>(
4128- importDeclReal (entry->getMostRecentDecl (), CurrentVersion))) {
4129- consumer.foundDecl (decl, DeclVisibilityKind::VisibleAtTopLevel);
4130- declFound = true ;
4131- for (auto alternate : getAlternateDecls (decl)) {
4132- if (alternate->getName ().matchesRef (name)) {
4133- consumer.foundDecl (alternate, DeclVisibilityKind::DynamicLookup,
4134- DynamicLookupInfo::AnyObject);
4135- }
4136- }
4137- }
4138- }
4139- }
41404125
4141- // If CXXInterop is enabled we need to check the modified operator name as well
4142- if (SwiftContext.LangOpts .EnableCXXInterop ) {
4143- auto declBaseName = DeclBaseName (SwiftContext.getIdentifier (" __operator" + getOperatorNameForToken (name.getBaseName ().getIdentifier ().str ().str ())));
4126+ auto findAndConsumeBaseNameFromTable = [this , &table, &consumer, &declFound, &name](DeclBaseName declBaseName) {
41444127 for (auto entry : table.lookupMemberOperators (declBaseName)) {
41454128 if (isVisibleClangEntry (entry)) {
41464129 if (auto decl = dyn_cast_or_null<ValueDecl>(
41474130 importDeclReal (entry->getMostRecentDecl (), CurrentVersion))) {
41484131 consumer.foundDecl (decl, DeclVisibilityKind::VisibleAtTopLevel);
41494132 declFound = true ;
4150- for (auto alternate: getAlternateDecls (decl)) {
4133+ for (auto alternate : getAlternateDecls (decl)) {
41514134 if (alternate->getName ().matchesRef (name)) {
41524135 consumer.foundDecl (alternate, DeclVisibilityKind::DynamicLookup,
41534136 DynamicLookupInfo::AnyObject);
@@ -4156,6 +4139,15 @@ bool ClangImporter::Implementation::lookupValue(SwiftLookupTable &table,
41564139 }
41574140 }
41584141 }
4142+ };
4143+
4144+ findAndConsumeBaseNameFromTable (name.getBaseName ());
4145+
4146+ // If CXXInterop is enabled we need to check the modified operator name as well
4147+ if (SwiftContext.LangOpts .EnableCXXInterop ) {
4148+ auto declBaseName = DeclBaseName (SwiftContext.getIdentifier (
4149+ " __operator" + getOperatorNameForToken (name.getBaseName ().getIdentifier ().str ().str ())));
4150+ findAndConsumeBaseNameFromTable (declBaseName);
41594151 }
41604152 }
41614153
0 commit comments