Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362981 - Warning: Statement unnecessarily nested within else clause
Summary: Warning: Statement unnecessarily nested within else clause
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: 2.8.0   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 370091 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-11-06 03:51 EST by Eike Stepper CLA
Modified: 2013-07-10 11:26 EDT (History)
0 users

See Also:


Attachments
Fix (1.35 KB, patch)
2011-11-06 03:51 EST, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Stepper CLA 2011-11-06 03:51:29 EST
Created attachment 206495 [details]
Fix

The generator produces warnings in the generated switch classes:

  protected T doSwitch(EClass theEClass, EObject theEObject)
  {
    if (theEClass.eContainer() == modelPackage)
    {
      return doSwitch(theEClass.getClassifierID(), theEObject);
    }
    else // HERE!!!
    {
      List<EClass> eSuperTypes = theEClass.getESuperTypes();
      return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
    }
  }

The attached patch should fix that.
Comment 1 Eike Stepper CLA 2012-01-30 03:01:35 EST
Please consult the project settings (falling back to the workspace preferences) to determine what compiler setting is used to create problem markers for unnecessary else clauses.
Comment 2 Eike Stepper CLA 2012-01-30 03:02:06 EST
*** Bug 370091 has been marked as a duplicate of this bug. ***
Comment 3 Ed Merks CLA 2013-01-10 08:23:40 EST
The enhancement is committed to master:

http://git.eclipse.org/c/emf/org.eclipse.emf.git/commit/?id=ca5d1a30b0c5828a1df2f948771e2710d3541592
Comment 4 Ed Merks CLA 2013-07-10 11:26:09 EDT
The changes are available in Kepler.