| Summary: | ClassTypeHelper methods aren't aware of covariant return types | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Tomasz Wesolowski <kosashi> | ||||||
| Component: | cdt-parser | Assignee: | Markus Schorn <mschorn.eclipse> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Mike Kucera <mikekucera> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | yevshif | ||||||
| Version: | 7.0.1 | Keywords: | contributed | ||||||
| Target Milestone: | 7.0.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Tomasz Wesolowski
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 |