Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342825 - [Xtend] warnings for type guards in switch
Summary: [Xtend] warnings for type guards in switch
Status: RESOLVED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: v2.13
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-14 07:57 EDT by Sven Efftinge CLA
Modified: 2017-09-28 05:29 EDT (History)
1 user (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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