diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index a15c0cc332b..0e4c26ef362 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -596,6 +596,32 @@ void CppEditorPlugin::test_quickfix_data() "" ); + // Checks: complete switch statement where enum is goes via a template type parameter + QTest::newRow("CompleteSwitchCaseStatement_QTCREATORBUG-24752") + << CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _( + "enum E {EA, EB};\n" + "template struct S {\n" + " static T theType() { return T(); }\n" + "};\n" + "int main() {\n" + " @switch (S::theType()) {\n" + " }\n" + "}\n" + ) << _( + "enum E {EA, EB};\n" + "template struct S {\n" + " static T theType() { return T(); }\n" + "};\n" + "int main() {\n" + " switch (S::theType()) {\n" + " case EA:\n" + " break;\n" + " case EB:\n" + " break;\n" + " }\n" + "}\n" + ); + // Checks: // 1. If the name does not start with ("m_" or "_") and does not // end with "_", we are forced to prefix the getter with "get". diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 931d7835236..b5f930efdbf 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -2744,6 +2744,7 @@ Enum *conditionEnum(const CppQuickFixInterface &interface, SwitchStatementAST *s Block *block = statement->symbol; Scope *scope = interface.semanticInfo().doc->scopeAt(block->line(), block->column()); TypeOfExpression typeOfExpression; + typeOfExpression.setExpandTemplates(true); typeOfExpression.init(interface.semanticInfo().doc, interface.snapshot()); const QList results = typeOfExpression(statement->condition, interface.semanticInfo().doc,