Commit b5f6a9e6 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

C++: Fix decltype resolving for nested instantiated class



The enclosingScope of a cloned nested class is not the
original class but the cloned parent.

Use-case:
template <typename T>
struct Temp
{
    struct Nested
    {
        static T f();
        typedef decltype(f()) type;
    };
};

struct Foo { int bar; };

void fun()
{
    Temp<Foo>::Nested::type s;
    s.bar; // bar not highlighted
}

Task-number: QTCREATORBUG-14483
Change-Id: I3e15399a78a7492f740db8d0c7d5c84adf77d1d0
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 04c4043e
......@@ -188,10 +188,8 @@ Symbol *CloneSymbol::cloneSymbol(Symbol *symbol, Subst *subst)
SymbolSubstPair symbolSubstPair = std::make_pair(symbol, subst);
auto it = _cache.find(symbolSubstPair);
if (it != _cache.end()) {
if (it->second->enclosingScope() == symbol->enclosingScope())
return it->second;
}
if (it != _cache.end())
return it->second;
Symbol *r = 0;
std::swap(_subst, subst);
......
......@@ -2962,6 +2962,28 @@ void CppToolsPlugin::test_completion_data()
) << _("s.") << (QStringList()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
QTest::newRow("nested_instantiation_typedefed_decltype_declaration") << _(
"template <typename T>\n"
"struct Temp\n"
"{\n"
" struct Nested\n"
" {\n"
" static T f();\n"
" typedef decltype(f()) type;\n"
" };\n"
"};\n"
"\n"
"struct Foo { int bar; };\n"
"\n"
"void fun()\n"
"{\n"
" Temp<Foo>::Nested::type s;\n"
" @\n"
"}\n"
) << _("s.") << (QStringList()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
}
void CppToolsPlugin::test_completion_member_access_operator()
......
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