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

Bug 342825

Summary: [Xtend] warnings for type guards in switch
Product: [Tools] Xtend Reporter: Sven Efftinge <sven.efftinge>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: christian.dietrich.opensource
Version: 2.2.0Flags: sven.efftinge: indigo+
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: v2.13

Description Sven Efftinge CLA 2011-04-14 07:57:32 EDT
There should be a warning if use generified types in type guards where the type erasured version is the same.

val Object x = ...
switch x {
   case List<String> : ...
   case List<Object> : ...
} 

We should also apply all casting warnings here (i.e. the upper example would be at least an unsafe cast).

Maybe we could generalize the rule such that if any type guard fetches all members of a subsequent type guard there should be an error/warning (because it is dead code).
I.e. :

val Object x = ...
switch x {
   CharSequence : ....
   String : ... // error because all members are also of type CharSequence
}

If there is a regular guard this rule cannot be applied because we don't want to go into deep control flow analysis now (maybe later).
Comment 1 Christian Dietrich CLA 2017-09-22 04:02:09 EDT
https://github.com/eclipse/xtext-xtend/issues/268
Comment 2 Christian Dietrich CLA 2017-09-28 05:29:17 EDT
fixed in 2.13