forked from qt-creator/qt-creator
C++: fix dereferencing of nested type and operator '->'
Fixed case: template<class T> struct List { struct iterator { T *operator->() { return &t; } T t; }; iterator begin() { return iterator(); } }; struct Foo { int bar; }; void func() { List<Foo> list; list.begin()->; // code completion doesn't work } Task-number: QTCREATORBUG-13799 Change-Id: I65e8d3092bbc9b01a5dbee241c24d95dd03fc670 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
209078e57e
commit
1a239bd3e9
@@ -1078,8 +1078,9 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
|
|||||||
ClassOrNamespace *binding
|
ClassOrNamespace *binding
|
||||||
= findClassForTemplateParameterInExpressionScope(r.binding(),
|
= findClassForTemplateParameterInExpressionScope(r.binding(),
|
||||||
ty);
|
ty);
|
||||||
|
|
||||||
if (! binding)
|
if (! binding)
|
||||||
binding = findClass(ty, scope);
|
binding = findClass(ty, scope, r.binding());
|
||||||
|
|
||||||
if (binding){
|
if (binding){
|
||||||
// lookup for overloads of operator->
|
// lookup for overloads of operator->
|
||||||
|
@@ -2533,6 +2533,26 @@ void CppToolsPlugin::test_completion_data()
|
|||||||
) << _("(*list.begin()).") << (QStringList()
|
) << _("(*list.begin()).") << (QStringList()
|
||||||
<< QLatin1String("Foo")
|
<< QLatin1String("Foo")
|
||||||
<< QLatin1String("bar"));
|
<< QLatin1String("bar"));
|
||||||
|
|
||||||
|
QTest::newRow("dereference_of_nested_type_opertor_->") << _(
|
||||||
|
"template<typename T>\n"
|
||||||
|
"struct QList\n"
|
||||||
|
"{\n"
|
||||||
|
" struct iterator\n"
|
||||||
|
" {\n"
|
||||||
|
" T *operator->() { return &t; }\n"
|
||||||
|
" T t;\n"
|
||||||
|
" };\n"
|
||||||
|
" iterator begin() { return iterator(); }\n"
|
||||||
|
"};\n"
|
||||||
|
"struct Foo { int bar; };\n"
|
||||||
|
"void fun() {\n"
|
||||||
|
" QList<Foo> list;\n"
|
||||||
|
" @\n"
|
||||||
|
"}\n"
|
||||||
|
) << _("list.begin()->") << (QStringList()
|
||||||
|
<< QLatin1String("Foo")
|
||||||
|
<< QLatin1String("bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_completion_member_access_operator()
|
void CppToolsPlugin::test_completion_member_access_operator()
|
||||||
|
Reference in New Issue
Block a user