Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321011 - Unexpecter filter signature
Summary: Unexpecter filter signature
Status: CLOSED FIXED
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-27 09:32 EDT by Ed Willink CLA
Modified: 2011-08-18 04:22 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 Ed Willink CLA 2010-07-27 09:32:58 EDT
Surely filter just selects collection elements, so it does not change the collection kind, therefore Bag::filter => Bag.

This is particularly tricky given the lack of let diagnosis so

[let aFilteredBag : Bag(X) = anUnfilteredBag(X)]

gets no diagnosis.

Equally a filtered Set is surely still a Set.
Comment 1 Laurent Goubet CLA 2010-07-27 09:37:14 EDT
Sorry, but I couldn't understand either the issue or the expected resolution ... Could you elaborate on what Acceleo gets wrong and what you expect it to do?
Comment 2 Ed Willink CLA 2010-07-27 11:55:42 EDT
I would expect

Collection(T)::filter(Classifier) : Collection(T)
Bag(T)::filter(Classifier) : Bag(T)
OrderedSet(T)::filter(Classifier) : OrderedSet(T)
Sequence(T)::filter(Classifier) : Sequence(T)
Set(T)::filter(Classifier) : Set(T)

(Classifier is what might replace OclType one day).
Comment 3 Laurent Goubet CLA 2010-07-28 03:24:07 EDT
This is already what Acceleo does, filter doesn't alter collection types. What you ask us to do is to add explicitely the Bag::filter() : Bag and all three others instead of only Collection::filter() : Collection?
Comment 4 Ed Willink CLA 2010-07-28 03:37:06 EDT
I did

[let aFilteredBag : Bag(X) = anUnfilteredBag(X)]

and aFiteredBag was empty.

I did

[let aFilteredBag : Sequence(X) = anUnfilteredBag(X)]

and aFiteredBag was not empty!

This suggests that the signature of filter is as documented

Collection::filter() : Sequence
Comment 5 Laurent Goubet CLA 2010-07-28 03:52:04 EDT
I can't figure out why you're talking about the "filter" operation with what you write as expressions. I could only figure the issue (well, more "deduce" as I am not sure this is your actual problem) with your last comment about a documentation issue on the filter operation.

There's indeed an implementation error on my side, I always return a Sequence from the filter operation... which provoked the documentation error as I am not the one who wrote it.
Comment 6 Laurent Goubet CLA 2010-07-30 09:36:02 EDT
filter should no longer implicitly cast everything to a Sequence. The fix has been committed on HEAD and will be available for the next build.
Comment 7 Laurent Goubet CLA 2011-08-18 04:22:20 EDT
Closing our "resolved" and "verified" bugs.