Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 265365

Summary: Generated switch statements can be incorrectly ordered.
Product: [Modeling] EMF Reporter: James Bruck <bruck.james>
Component: ToolsAssignee: Dave Steinberg <davidms>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: davidms, Ed.Merks
Version: 2.5.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 265703    
Attachments:
Description Flags
Fix for switch class ordering none

Description James Bruck CLA 2009-02-18 15:39:04 EST
Consider an example where we have:
Class A that extends B and C.
B extends  Z.
C extends Y.
Y extends Z.

The generated switch for A would be:   B, C, Z, Y.  But the more appropriate order would be B, C, Y, Z since Z is more general than Y.

The algorithm that determines the switch order seems to be breadth first as opposed to considering inheritance depth.

This is a particular problem for the UMLSwitch casePort for example.
Comment 1 Dave Steinberg CLA 2009-02-18 15:45:36 EST
Breadth first *does* of course consider inheritance depth. It just considers depth of the first encountered inheritance path, not the *longest* path. I'm working on a patch.
Comment 2 Dave Steinberg CLA 2009-02-18 18:03:08 EST
Created attachment 126091 [details]
Fix for switch class ordering

Here's a patch that should fix the ordering of supertype cases.
Comment 3 Ed Merks CLA 2009-02-20 12:16:22 EST
Looks good.
Comment 4 Dave Steinberg CLA 2009-02-20 13:01:35 EST
The fix is in CVS for EMF 2.5.
Comment 5 Dave Steinberg CLA 2009-03-17 15:40:47 EDT
Fix available in HEAD: 2.5.0.I200902241800.
Comment 6 Dave Steinberg CLA 2009-06-25 02:51:24 EDT
Fix available in HEAD: 2.5.0 (R200906151043).