OCL 2.0 Type Inference

Date view Thread view Subject view Author view Attachment view

Date: Mon 22 Dec 2003 - 05:52:54 GMT


I have some questions about type inference in OCL 2.0. If possible, please point
me to the relevent part of the specification (PTC/03-10-14 or a later version).

Consider these classes:

     Class A { a : Integer }
     Class B { b : Integer }
     Class C subclasses A, B
     Class D subclasses A, B {
         cd(c : C, d : D) : Sequence(Integer)

And this set of postconditions (please ignore the fact that they are
inconsistent with each other):

    context D::cd(c : C, d : D):
    post A: result = Sequence { c, d }.collect( v | v.b }
    post B: result = Sequence { c, d }.collect( v | v.a }
    post C: result = Sequence { c, d }.collect( v | v.a + v.b )

1. What is the type of the subexpression Sequence { c, d }? The most specific
common supertype of C and D is OclAny, so is it Sequence(OclAny)?
2. Are postconditions A and B well-typed and well-defined? If the answer to
question #1 is Sequence(OclAny) then the answer is "no" and "no," right?
3. Is postcondition C well-typed and well-defined? I am going to say "no" and
"no" because there seems to be no way to type the iteration variable.
4. I assume it is the case that expressions that are not well-typed are
undefined; i.e. an OCL expression evaluator is not required to accept any
expression that it cannot statically typecheck before attempting any evaluation.
Is that correct?

Thank you,

Date view Thread view Subject view Author view Attachment view