[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.modeling.mdt.uml2.ocl] Re: How to declare type of empty collection in OCL?
|
Hi, Tord,
The element type of a collection literal is inferred from its contents (as
the common supertype of its elements, which may be OclAny or
Collection(OclAny) in mixed cases). The inferred element type of an empty
collection literal is OclVoid, which conforms to all other types, so your
expression (I) should work.
This is a bug. Would you mind raising it? (on the MDT UML2 OCL component):
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MDT&version=1.0.1&component=UML2%20OCL&bug_severity=normal&form_name=enter_bug
Thanks,
Christian
Ed Merks wrote:
> Tord,
>
> I'll forward your question to the new OCL newsgroup.
>
>
> Tord Alenljung wrote:
>> How can I declare that for example a Set contains objects of some type
>> and then initialize it to be empty. Neither I or II below works, but
>> III does.
>>
>> (I) Not OK
>> let a:Set(Integer)=Set{} in a
>>
>> 'Init expression type does not conform to type of variable (a).'
>>
>> (II) Not OK
>> let a:Set(Integer)=Set(Integer){} in a
>>
>> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
>> "Set(Integer)"'
>>
>> (III) OK
>> let a:Set(Integer)=Set{1,3,2} in a
>>
>> 2
>> 1
>> 3
>>
>> Regards
>> Tord