Legacy Issue Number: 19405
Source: ADLINK Advanced Technology Office ( Angelo Corsaro)
The X-Types specification suffers a of inconsistency with respect to how it treats type widening for extensible and mutable types. Specifically widening is always supported for mutable types and never for extensible types.
That means that given two types X, and Y with Y <: X (read as Y subtype of X) then we have the following cases:
1. If X and Y are mutable and the TypeConsistencyEnforcementQosPolicy is set to ALLOW_TYPE_COERCION then:
i. a DR[X] will match a DW[Y] and in this case Y will be
projected on X.
ii. a DR[Y] will match a DR[X] and in this case X will be
widened to Y – by initializing missing attributes
with default constructors.
2. If X and Y are extensible and the TypeConsistencyEnforcementQosPolicy is set to ALLOW_TYPE_COERCION then the only possible case is for a DR[X] to match a DW[Y] through a projection of Y on X.
The inconsistency resulting from the non-uniform treatment of extensible types is not only unjustified but also creates practical issues.
The fixes that we propose to the specification are the following.
- Extend the the TypeConsistencyEnforcementQosPolicy to control both type widening as well as projection. Notice that although projection is safe (in most of the case) type widening may not be safe for some applications.
Thus the the TypeConsistencyEnforcementQosPolicy should be extended to provide the following options:
1. ALLOW_TYPE_PROJECTION to enable only type
projection regardless of wether a topic is mutable or
2. ALLOW_TYPE_WIDENING to enable only type widening
The conjunction of the previous options should allow for a type to support both projection as well as widening. Otherwise, but this option is less desirable, a third option named ALLOW_TYPE_PROJECTION_AND_WIDENING may be added.
3. Rename DISALLOW_TYPE_COERCION into
- Clarify the assignable-from to make it more explicit that type widening is also supported by extensible types.
Reported: DDS-XTypes 1.1 — Fri, 2 May 2014 04:00 GMT
Disposition: Duplicate or Merged — DDS-XTypes 1.2
Updated: Thu, 22 Jun 2017 16:42 GMT