redefinition-direction-conformance

Available in: KerML, SysML

This checks that directed features are only redefined by features with compatible directions.

  • in by in

  • out by out

  • inout by any direction

Specification

If the redefined_feature of a Redefinition has a direction of in or out (relative to any featuring_type of the redefining_feature or the owning_type, if the redefining_feature has is_variable = true), then the redefining_feature must have the same direction. If the redefined_feature has a direction of inout, then the redefining_feature must have a non-null direction. (Note: the direction of the redefined_feature relative to a featuring_type of the redefining_feature is the direction it would have if it had been inherited and not redefined.)

Example

port def A {
    in attribute a;
}
port b : A {
    out attribute a :>> a; // error
}

Instead, use compatible directions:

port def A {
    in attribute a;
}
port b : A {
    in attribute a :>> a; // ok
}

Or use conjugated ports to reverse inherited directions:

port def A {
    in attribute a;
}
port b : ~A {
    out attribute a :>> a; // ok
}