Lower-bound inferences. A lower-bound inference from a type U for a type V is made as follows:
A lower-bound inference from a type U for a type V is made as follows: · If V is one of the unfixed Xi then U is added to the set of bounds for Xi. · Otherwise if U is an array type Ue[…] and V is either an array type Ve[…]of the same rank, or if U is a one-dimensional array type Ue[]and V is one of IEnumerable<Ve>, ICollection<Ve> or IList<Ve> then o If Ue is known to be a reference type then a lower-bound inference from Ue to Ve is made o Otherwise an exact inference from Ue to Ve is made · Otherwise if V is a constructed type C<V1…Vk> and there is a unique set of types U1…Uk such that a standard implicit conversion exists from U to C<U1…Uk> then an exact inference is made from each Ui for the corresponding Vi. · Otherwise, no inferences are made. Fixing An unfixed type variable Xi with a set of bounds is fixed as follows: · The set of candidate types Uj starts out as the set of all types in the set of bounds for Xi. · We then examine each bound for Xi in turn: For each bound U of Xi all types Uj to which there is not a standard implicit conversion from U are removed from the candidate set. · If among the remaining candidate types Uj there is a unique type V from which there is a standard implicit conversion to all the other candidate types, then Xi is fixed to V. · Otherwise, type inference fails.
|