The spec says:
Quote:
One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy. In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations) cannot mark the return value for cascaded validation if the return value has already been marked on the overridden method of the super type or interface.
My understanding of this requirement is that it is guaranteed this way that an overridden method in a subtype won't put a weaken set of constraints on the value returned from the method. The guarantee is reasonable though the way it is enforced is in my opinion too strict.
Consider the following example. An overridden method also marks the return value for cascaded validation and defines a strict superset of constraints defined on the supertype method. This way the requirement for not weakening the postconditions in a subtype still holds yet this example is explicitly prohibited by the current spec wording.
Instead of the current wording the spec should probably say that an overriden method in a subtype may mark the return value for cascaded validation if
- the return value has not already been marked on the overridden method of the super type or interface, or
- the return value has already been marked on the overridden method of the super type or interface and the set of constraints in the overriding method is not a strict subset of constraints defined by the superclass method.