diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index c5d6dedc96c51f09d76f640161dbb8e2c1e7a610..2cd4dea274f473840c2f201f6614f1e0758395ee 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -304,7 +304,17 @@ ClassOrNamespace *ClassOrNamespace::globalNamespace() const
     return e;
 }
 
+QList<Symbol *> ClassOrNamespace::find(const Name *name)
+{
+    return lookup_helper(name, false);
+}
+
 QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
+{
+    return lookup_helper(name, true);
+}
+
+QList<Symbol *> ClassOrNamespace::lookup_helper(const Name *name, bool searchInEnclosingScope)
 {
     QList<Symbol *> result;
     if (! name)
@@ -317,7 +327,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
             binding = globalNamespace();
 
         if (q->nameCount() == 1)
-            return binding->lookup(q->unqualifiedNameId());
+            return binding->find(q->unqualifiedNameId());
 
         binding = binding->lookupClassOrNamespace(q->nameAt(0));
 
@@ -325,7 +335,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
             binding = binding->findClassOrNamespace(q->nameAt(index));
 
         if (binding)
-            result = binding->lookup(q->unqualifiedNameId());
+            result = binding->find(q->unqualifiedNameId());
 
         return result;
     }
@@ -335,7 +345,7 @@ QList<Symbol *> ClassOrNamespace::lookup(const Name *name)
     do {
         lookup_helper(name, binding, &result, &processed, /*templateId = */ 0);
         binding = binding->_parent;
-    } while (binding);
+    } while (searchInEnclosingScope && binding);
 
     return result;
 }
diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h
index 88e273bd63ba7cd75eff31fbfa6f8092902c8a74..4dff4c4cd361d82cfbb967a5627c3b9830f92645 100644
--- a/src/libs/cplusplus/LookupContext.h
+++ b/src/libs/cplusplus/LookupContext.h
@@ -56,6 +56,7 @@ public:
     ClassOrNamespace *globalNamespace() const;
 
     QList<Symbol *> lookup(const Name *name);
+    QList<Symbol *> find(const Name *name);
 
     ClassOrNamespace *lookupClassOrNamespace(const Name *name);
     ClassOrNamespace *findClassOrNamespace(const Name *name);
@@ -68,6 +69,8 @@ private:
     /// \internal
     ClassOrNamespace *findOrCreate(const Name *name);
 
+    QList<Symbol *> lookup_helper(const Name *name, bool searchInEnclosingScope);
+
     void addTodo(Symbol *symbol);
     void addSymbol(Symbol *symbol);
     void addEnum(Enum *e);
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index c32afc937bfdf78cf6070f4418956e9ebbcd1f28..753c69c8892c6f9332656b3f4dc548d94b8700ce 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -490,7 +490,7 @@ bool ResolveExpression::visit(CallAST *ast)
 
         if (NamedType *namedTy = ty->asNamedType()) {
             if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), lastVisibleSymbol)) {
-                foreach (Symbol *overload, b->lookup(functionCallOp)) {
+                foreach (Symbol *overload, b->find(functionCallOp)) {
                     if (Function *funTy = overload->type()->asFunctionType()) {
                         if (maybeValidPrototype(funTy, actualArgumentCount)) {
                             Function *proto = instantiate(namedTy->name(), funTy)->asFunctionType();
@@ -535,7 +535,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
 
         } else if (NamedType *namedTy = ty->asNamedType()) {
             if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), lastVisibleSymbol)) {
-                foreach (Symbol *overload, b->lookup(arrayAccessOp)) {
+                foreach (Symbol *overload, b->find(arrayAccessOp)) {
                     if (Function *funTy = overload->type()->asFunctionType()) {
                         Function *proto = instantiate(namedTy->name(), funTy)->asFunctionType();
                         // ### TODO: check the actual arguments
@@ -610,7 +610,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i
             }
 
             if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), result.lastVisibleSymbol())) {
-                foreach (Symbol *overload, b->lookup(arrowAccessOp)) {
+                foreach (Symbol *overload, b->find(arrowAccessOp)) {
                     if (Function *funTy = overload->type()->asFunctionType()) {
                         FullySpecifiedType f = instantiate(namedTy->name(), funTy);
                         FullySpecifiedType retTy = f->asFunctionType()->returnType().simplified();
@@ -687,7 +687,7 @@ ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults,
 
         else if (NamedType *namedTy = ty->asNamedType()) {
             if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), r.lastVisibleSymbol())) {
-                foreach (Symbol *c, b->lookup(memberName))
+                foreach (Symbol *c, b->find(memberName))
                     results.append(LookupItem(instantiate(namedTy->name(), c), c));
             }
         }