[Next] [Previous] [Up] [Top] [Contents] [Index]

4.3 Matching Against Type Patterns

4.3.5 Constraints on Supertype Graphs for Matching

The process for matching a dynamic type against a static type declaration containing implicit type parameter bindings depends on locating a single most-specific binding type. This may not always be possible without additional constraints. For example, in the following declaration:

concrete object strange isa collection[int], collection[string];
if the strange object is sent the do message, its type will be matched against the type pattern collection['T]. Both collection[int] and collection[string] will match, but the system needs to locate a single type to bind to the variable T. Binding T to int&string might seem reasonable, but then a type error will result, because strange is not a subtype of collection[int&string] (such a relationship would have to be explicitly declared). To avoid this sort of problem at method invocation time, objects like strange are disallowed.

For an object declaration to be legal, there must be at most one most-specific instantiation for any of its parameterized supertypes. This check is made when type-checking an object declaration or constructor expression.


The Cecil Language: Specification and Rationale, Version 2.1 - 25 MARCH 1997
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker