diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 99db8cef9df..f59dcdac427 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -910,7 +910,7 @@ bool ResolveExpression::visit(CallAST *ast) if (Symbol *declaration = templateTy->declaration()) { if (Function *funTy = declaration->asFunction()) { if (maybeValidPrototype(funTy, actualArgumentCount)) - addResult(funTy->returnType().simplified(), scope); + addResult(funTy->returnType().simplified(), _scope); } } } diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index 1190edb18d0..ab0bdf4d34f 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -907,6 +907,34 @@ void CppEditorPlugin::test_quickfix_data() "}\n" ); + // Checks: Complete switch statement where enum is return type of a template function + // which is outside the scope of the return value. + // TODO: Type minimization. + QTest::newRow("CompleteSwitchCaseStatement_QTCREATORBUG-25998") + << CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _( + "template T enumCast(int value) { return static_cast(value); }\n" + "class Test {\n" + " enum class E { V1, V2 };" + " void func(int i) {\n" + " @switch (enumCast(i)) {\n" + " }\n" + " }\n" + "};\n" + ) << _( + "template T enumCast(int value) { return static_cast(value); }\n" + "class Test {\n" + " enum class E { V1, V2 };" + " void func(int i) {\n" + " switch (enumCast(i)) {\n" + " case Test::E::V1:\n" + " break;\n" + " case Test::E::V2:\n" + " break;\n" + " }\n" + " }\n" + "};\n" + ); + // Checks: No special treatment for reference to non const. // Check: Quick fix is not triggered on a member function.