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

C++: Fix resolving of templated partial specialization

Use-case:
template<class T> struct t {};

template<class> struct s { float f; };
template<class X> struct s<t<X>> { int i; };

void f()
{
    s<t<char>> var;
    var.i; // i not highlighted
}

Task-number: QTCREATORBUG-14034
Change-Id: I5d00bc3247352fca4af4c41a47c208ec3e193c8e
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 2070431d
......@@ -1215,6 +1215,13 @@ LookupScopePrivate *LookupScopePrivate::findSpecialization(
if (specializationTemplateArgument == initializationTemplateArgument)
return cit->second;
if (const NamedType *specName = specializationTemplateArgument->asNamedType()) {
if (const NamedType *initName = initializationTemplateArgument->asNamedType()) {
if (specName->name()->identifier() == initName->name()->identifier())
return cit->second;
}
}
}
}
}
......
......@@ -2637,6 +2637,21 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("i")
<< QLatin1String("s"));
QTest::newRow("partial_specialization_templated_argument") << _(
"template<class T> struct t {};\n"
"\n"
"template<class> struct s { float f; };\n"
"template<class X> struct s<t<X>> { int i; };\n"
"\n"
"void f()\n"
"{\n"
" s<t<char>> var;\n"
" @\n"
"}\n"
) << _("var.") << (QStringList()
<< QLatin1String("i")
<< QLatin1String("s"));
QTest::newRow("auto_declaration_in_if_condition") << _(
"struct Foo { int bar; };\n"
"void fun() {\n"
......
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