@@ -4122,32 +4122,15 @@ bool ClangImporter::Implementation::lookupValue(SwiftLookupTable &table,
4122
4122
bool declFound = false ;
4123
4123
4124
4124
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
- }
4140
4125
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) {
4144
4127
for (auto entry : table.lookupMemberOperators (declBaseName)) {
4145
4128
if (isVisibleClangEntry (entry)) {
4146
4129
if (auto decl = dyn_cast_or_null<ValueDecl>(
4147
4130
importDeclReal (entry->getMostRecentDecl (), CurrentVersion))) {
4148
4131
consumer.foundDecl (decl, DeclVisibilityKind::VisibleAtTopLevel);
4149
4132
declFound = true ;
4150
- for (auto alternate: getAlternateDecls (decl)) {
4133
+ for (auto alternate : getAlternateDecls (decl)) {
4151
4134
if (alternate->getName ().matchesRef (name)) {
4152
4135
consumer.foundDecl (alternate, DeclVisibilityKind::DynamicLookup,
4153
4136
DynamicLookupInfo::AnyObject);
@@ -4156,6 +4139,15 @@ bool ClangImporter::Implementation::lookupValue(SwiftLookupTable &table,
4156
4139
}
4157
4140
}
4158
4141
}
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);
4159
4151
}
4160
4152
}
4161
4153
0 commit comments