diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index 19a5a3a5e59..04c5cc8f4cf 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -181,7 +181,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con typeOfExpression.init(m_document, m_snapshot); typeOfExpression.setExpandTemplates(true); const QList 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) { diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 5b7bf1655da..bfda3165381 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -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(0)->$@virt(); }\n") + << (OverrideItemList() + << OverrideItem(QLatin1String("Base::virt"), 1) + << OverrideItem(QLatin1String("Derived::virt"), 2)); } void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()