Skip to main content



      Home
Home » Modeling » OCL » OCL Type Conformance Error
OCL Type Conformance Error [message #21250] Tue, 01 May 2007 12:03 Go to next message
Eclipse UserFriend
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 14:03 Go to previous messageGo to next message
Eclipse UserFriend
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 14:23 Go to previous message
Eclipse UserFriend
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
Previous Topic:Variable definitions
Next Topic:String Literal Problem
Goto Forum:
  


Current Time: Tue Jul 22 16:05:34 EDT 2025

Powered by FUDForum. Page generated in 0.03792 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top