Catcall Test Proposal

Revision as of 16:49, 5 November 2007 by Manus (Talk | contribs) (New conformance rules)

This article describe an implementation made by Eiffel Software in October 2007 for a solution of the CATCALL issue. It is merely a variation of already explored solution.

Syntax changes

A Type declaration can be preceded by the keyword frozen, that is to say:

a: frozen A

An actual generic parameter can be preceded by the keyword variant, that is to say:

a: LIST [variant A]

New conformance rules

When the actual generic parameters are preceded by variant then the existing conformance rules apply, otherwise it has to be the same type.

Information.png Note: This shows to be the most efficient way to validate existing code. For the Eiffel batch compiler, if the default was the existing rules, we would get about 40000 catcall violations. With the new default, we only get 2000 conformance errors.

New validity rules

  1. The target of a call involving a covariantly redefined routine should either be marked frozen or else the call has to be valid for all descendant types.
  2. If the formal arguments of a call involves a formal generic parameter, the corresponding actual should not be marked variant.

Implementation details

The tricky part in the above is the checks for the validity of a covariant call for all the descendant types of the target. The issue is when a descendant type is generic and the new formal generic parameter has not corresponding type in the ancestor. For example:

class A
	f (a: ANY) do end
class B [G]
	f (a: STRING) do end
class TEST
	make is
			a: A
			a.f ("My String")

In our case, we assume the descendant type to be instantiated with its constraint, in the above case B [ANY].