Community
Participate
Working Groups
Some methods assume that an overriding function will have same function type as the overridden function, which isn't the case when covariant return types are used. Thus some cases are not detected in isVirtual, isOverrider, findOverridden nad findOverrides.
Created attachment 175788 [details] test case
Created attachment 175791 [details] proposed fix My proposed solution is to ignore the returned type when comparing function types. Note that when everything besides return type matches in the functions, then it's known that the method is _intended_ to be the override, and not i.e. another overload. After that, comparing the actual covariance of return types could be done alongside with comparing the strictness of throw() declaration to check if the code would actually compile, but both of those are more expensive checks. Neither of those is necessary to answer isOverride() and others. We might want to have that as a codan checker.
(In reply to comment #2) > Created an attachment (id=175791) [details] > proposed fix > My proposed solution is to ignore the returned type when comparing function > types. > Note that when everything besides return type matches in the functions, then > it's known that the method is _intended_ to be the override, and not i.e. > another overload. > After that, comparing the actual covariance of return types could be done > alongside with comparing the strictness of throw() declaration to check if the > code would actually compile, but both of those are more expensive checks. > Neither of those is necessary to answer isOverride() and others. > We might want to have that as a codan checker. Perfect, that's the right choice.
Thanks for the patches, fixed in 7.0.1 and 8.0 > 20100804.
*** cdt cvs genie on behalf of mschorn *** Bug 321617: Virtual overriders and covariant types. [*] AST2CPPTests.java 1.348 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java?root=Tools_Project&r1=1.347&r2=1.348 [*] ClassTypeHelper.java 1.14 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java?root=Tools_Project&r1=1.13&r2=1.14 [*] ClassTypeHelper.java 1.13.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java?root=Tools_Project&r1=1.13&r2=1.13.2.1 [*] AST2CPPTests.java 1.345.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java?root=Tools_Project&r1=1.345&r2=1.345.2.1