| Summary: | error in generated code for two level override, if return type changes | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Philipp W. Kutter <kutter> | ||||||||||
| Component: | Tools | Assignee: | Dave Steinberg <davidms> | ||||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | Ed.Merks | ||||||||||
| Version: | 2.4.0 | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows XP | ||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Philipp W. Kutter
Created attachment 83992 [details]
Example Screenshot
Created attachment 85836 [details]
Patches to address the issue.
The idea is to check before discarding a method if the return type is different. Unfortunately we can't in general know how to deal with proper subtype checking because with EDataTypes we're just dealing with class names. So I could imagine complex situations where we ought to be finding the "overload" is the most specific type.
Created attachment 85838 [details]
I'll mark it as a patch this type.
Dave, Does this look okay? It seems fine as a minimal solution. Of course, this still allows invalid code to be generated in the case where it's not type compatible. It would be nice to (you guessed it!) have a constraint that does the type analysis for classes and perhaps issues a warning for differing data types, since they could possibly result in generating invalid code. Also, the bug report quoted you suggesting a pattern that calls super and casts, but I don't see that in the patch. Did you intend to add it? No, I'm too lazy to take the approach of trying to generate a method body in some fancy way. It's not clear that such a result will always be exactly what's intended so a TODO seems reasonable. The constraint on the type is difficult to enforce because in general I can't know the relationship between two different EDataTypes. There are quite few possible Java types of problems, such of overloaded signatures that are actually collisions rather than proper overloads that I just can't do in general... 1. Cool, and I agree. I was just checking to make sure you had done what you intended, since your previous comment suggested otherwise. 2. My suggestion was to only enforce the constraint in the case of classes, and just to issue a warning any time data types do not match exactly. My motivation is that some people might have invalid cases in their models already, which were just being ignored by the generator previously and will now generate code with errors. It might help them figure out what's wrong if we present an error (for classes) or warning (for data types). Again, it's just a suggestion; this definitely seems a corner case. The changes are committed to CVS for 2.4. Fixed in I200801090807. Move to verified as per bug 206558. |