OCL Type Conformance Error [message #21250] |
Tue, 01 May 2007 16:03 |
Eclipse User |
|
|
|
Originally posted by: mike.aol.com
I don't understand how I can get a closure operation to create a result
with the type I want. Example:
let children : Set(TopologyObject) =
self->closure(tobj : TopologyObject | tobj.getChildren())
in
children
fails with "Init expression type does not conform to type of variable
(children)."
This variation:
let children : Set(OclAny) =
self->closure(tobj : TopologyObject | tobj.getChildren())
in
children
works. How can get a Set(TopologyObject) result? The
TopologyObject.getChildren() operation returns a list of TopologyObject.
Thanks,
Mike Gering
|
|
|
Re: OCL Type Conformance Error [message #21266 is a reply to message #21250] |
Tue, 01 May 2007 18:03 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Mike,
The fact that declaring children as type Set(OclAny) works suggests that
tobject.getChildren() doesn't actually return Set(TopologyObject) as far
ask OCL is concerned. Not only does Set(TopologyObject) conform to
Set(OclAny), but so does Set(EList).
:-)
I suspect that your operation is declared with the EEList data type, rather
than the TopologyObject type with multiplicity many. When you evaluate
this expression, what is the run-time type of the objects in the
Set(OclAny) variant?
Cheers,
Christian
Mike Gering wrote:
> I don't understand how I can get a closure operation to create a result
> with the type I want. Example:
>
> let children : Set(TopologyObject) =
> self->closure(tobj : TopologyObject | tobj.getChildren())
> in
> children
>
> fails with "Init expression type does not conform to type of variable
> (children)."
>
> This variation:
> let children : Set(OclAny) =
> self->closure(tobj : TopologyObject | tobj.getChildren())
> in
> children
>
> works. How can get a Set(TopologyObject) result? The
> TopologyObject.getChildren() operation returns a list of TopologyObject.
>
> Thanks,
> Mike Gering
|
|
|
Re: OCL Type Conformance Error [message #21295 is a reply to message #21266] |
Tue, 01 May 2007 18:23 |
Eclipse User |
|
|
|
Originally posted by: mike.aol.com
Christian,
You hit it exactly! I've been sloppy with my metamodel and it hasn't
mattered until now. I'll have to do some scrubbing now...
Thanks,
Mike
|
|
|
Powered by
FUDForum. Page generated in 0.02655 seconds