Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341873

Summary: ->filter(MyType) seems to change the order of the list it is applied to
Product: [Modeling] Acceleo Reporter: Laurent Delaigue <laurent.delaigue>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: laurent.goubet, stephane.begaudeau
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

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.