Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341873 - ->filter(MyType) seems to change the order of the list it is applied to
Summary: ->filter(MyType) seems to change the order of the list it is applied to
Status: CLOSED FIXED
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-05 04:55 EDT by Laurent Delaigue CLA
Modified: 2011-04-05 05:27 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Delaigue CLA 2011-04-05 04:55:22 EDT
Build Identifier: S201103231016

I generate code from a GenModel model.
I use the following code :

myEnum.getGenEnumLiterals()->filter(GenEnumLiteral)

The problem seems to be due to the type EList, which is not handled properly by the filter operation.

Reproducible: Always
Comment 1 Laurent Goubet CLA 2011-04-05 05:02:05 EDT
This is due to us expecting "OCL" typing and infering the return type of some operation from those. In particular, this snippet

-----8<-----
if (xxx instanceof ArrayList) {
    result = OCL.createSequence();
} else if (xxx instanceof LinkedHashSet) {
    result = OCL.createOrderedSet();
} else if (xxx instanceof Set) {
    result = OCL.createSet();
} else {
    result = OCL.createBag();
}
----->8-----

must be replaced everywhere by a code that reduce the number of "unordered" collections we can create (users usually want ordered collections, even when they think they want unordered ones :p) :

-----8<-----
if (xxx instanceof Bag) {
    result = OCL.createBag();
} else if (xxx instanceof HashSet && !(xxx instanceof LinkedHashSet)) {
    result = OCL.createSet();
} else if (xxx instanceof Set) {
    result = OCL.createOrderedSet();
} else {
    result = OCL.createSequence();
}
----->8-----
Comment 2 Stephane Begaudeau CLA 2011-04-05 05:27:14 EDT
The fix has been contributed on HEAD. It will be available in Acceleo 3.1.0 M7.