Community
Participate
Working Groups
In code like if (v instanceof C) v.someMethodOfC(...) the Xtend 2.5 type checker propagates the information that v is an instance of C into the "then" clause of the "if" statement. It would be nice if this information were propagated in more cases: * if (someCondition && v instanceof C && someOtherCondition) v.someMethodOfC(...) * v instanceof C && v.someBooleanPropertyOfC * if (!v instanceof C) someExpression else someCodeExpectingC(v) * if (!v instanceof C) throw someException // or return; someCodeExpectingC(v) * if (!(v instanceof C) || v.someBooleanPropertyOfC || !(w instanceof D)) throw someException someCodeExpectingCandD(v, w) * if (v instanceof C && v instanceof D) { someCodeExpectingC(v) someCodeExpectingD(v) } So how far should this go? I could imagine that the type information may be propagated along the same lines as truth and reachability are propagated by JDT's reachability checker (see also bug #429188), which is stronger than the notion of reachability defined in the Java language spec.
See also https://github.com/eclipse/xtext-xtend/issues/477