Reconsider behavior of parameter validation for inheritance hierarchies

Description

Let A extend B and A#foo() override B#foo(). When validating an invocation of A#foo() the current implementation will evaluate all parameter constraints defined at A#foo() and B#foo(). That way foo()'s preconditions defined in B are strengthened by A.

According to the "Programming by contract" article on WP this is not allowed, subtypes may only weaken preconditions defined by supertypes. The common implementation pattern for this is to combine the preconditions within a hierarchy by a logical OR, meaning the weakest precondition in the hierarchy applies.

Note that postconditions (return value constraints) may be strengthened (but not weakened) by subtypes. Therefore the current implementation (AND combination) should be correct here.

Environment

None

Status

Assignee

Unassigned

Reporter

Gunnar Morling

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Priority

Major
Configure