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