Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342577 - [Xtend/Xbase] Compiler breaks specification of boolean operator &&
Summary: [Xtend/Xbase] Compiler breaks specification of boolean operator &&
Status: CLOSED DUPLICATE of bug 342424
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-12 10:40 EDT by Robert von Massow CLA
Modified: 2011-04-13 04:52 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert von Massow CLA 2011-04-12 10:40:43 EDT
Build Identifier: 

The following expression is not compiled correctly:

cb.contents.size == 1 && !cb.contents.head.toString.contains("\n")

the compiled Java code looks like this:

    EList<EObject> _contents = cb.getContents();
    int _size = _contents.size();
    boolean _operator_equals = ObjectExtensions.operator_equals(((Object)_size), 1);
    EList<EObject> _contents_1 = cb.getContents();
    EObject _head = IterableExtensions.<EObject>head(_contents_1);
    String _string = _head.toString();
    boolean _contains = _string.contains("\n");
    boolean _operator_not = BooleanExtensions.operator_not(_contains);
    boolean _operator_and = BooleanExtensions.operator_and(_operator_equals, _operator_not);

According to the Xbase specification the right hand side of the operator && is not evaluated if the left hand side is already false. This is not achieved in this case, thus an exception is thrown if cb.contents is empty anthough it has been checked to be non-empty.

Reproducible: Always
Comment 1 Sven Efftinge CLA 2011-04-13 04:52:00 EDT

*** This bug has been marked as a duplicate of bug 342424 ***