diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 71e7bab691c46a09e49fb0b8a134eb3c78444f28..970a8d128ce22a909fb7289220c50541785f27a0 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -345,7 +345,22 @@ struct CanonicalSymbol { const QList<LookupItem> results = typeOfExpression(code, scope, TypeOfExpression::Preprocess); - for (int i = 0; i < results.size(); ++i) { // ### TODO virtual methods and classes. + for (int i = results.size() - 1; i != -1; --i) { + const LookupItem &r = results.at(i); + + if (! r.declaration()) + break; + else if (! r.declaration()->scope()) + break; + else if (! r.declaration()->scope()->isClassScope()) + break; + + if (Function *funTy = r.declaration()->type()->asFunctionType()) + if (funTy->isVirtual()) + return r.declaration(); + } + + for (int i = 0; i < results.size(); ++i) { const LookupItem &r = results.at(i); if (r.declaration())