Commit fe9bb880 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppEditor: Fix override lookup for double call and casting

Possibly fixes other use-cases

Task-number: QTCREATORBUG-11159
Task-number: QTCREATORBUG-11165

Change-Id: I375143c9658c581267c7c8d61ce03c27858f2de5
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 3d481b2b
......@@ -181,7 +181,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
typeOfExpression.init(m_document, m_snapshot);
typeOfExpression.setExpandTemplates(true);
const QList<LookupItem> items = typeOfExpression(memberAccessAST->base_expression,
m_document, m_scope);
m_expressionDocument, m_scope);
ResolveExpression resolveExpression(typeOfExpression.context());
ClassOrNamespace *binding = resolveExpression.baseExpression(items, m_accessTokenKind);
if (binding) {
......
......@@ -1364,6 +1364,35 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
<< (OverrideItemList()
<< OverrideItem(QLatin1String("Base::virt"), 1)
<< OverrideItem(QLatin1String("Derived::virt"), 2));
QTest::newRow("static_call") << _(
"struct Base { virtual void virt() {} };\n"
"struct Derived : Base { void virt() {} };\n"
"struct Foo {\n"
" static Base *base();\n"
"};\n"
"void client() { Foo::base()->$@virt(); }\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("Base::virt"), 1)
<< OverrideItem(QLatin1String("Derived::virt"), 2));
QTest::newRow("double_call") << _(
"struct Base { virtual void virt() {} };\n"
"struct Derived : Base { void virt() {} };\n"
"struct Foo { Base *base(); };\n"
"Foo *instance();\n"
"void client() { instance()->base()->$@virt(); }\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("Base::virt"), 1)
<< OverrideItem(QLatin1String("Derived::virt"), 2));
QTest::newRow("casting") << _(
"struct Base { virtual void virt() {} };\n"
"struct Derived : Base { void virt() {} };\n"
"void client() { static_cast<Base *>(0)->$@virt(); }\n")
<< (OverrideItemList()
<< OverrideItem(QLatin1String("Base::virt"), 1)
<< OverrideItem(QLatin1String("Derived::virt"), 2));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment