Similar to calls of generic methods, type inference must also be applied when a method group M containing a generic method is converted to a given delegate type D (§6.6). Given a method
Tr M1…Xn>(T1 x1 … Tm xm)
and the method group M being assigned to the delegate type D the task of type inference is to find type arguments S1…Sn so that the expression:
M1…Sn>
becomes compatible (§15.1) with D.
Unlike the type inference algorithm for generic method calls, in this case there are only argument types, no argument expressions. In particular, there are no anonymous functions and hence no need for multiple phases of inference.
Instead, all Xi are considered unfixed, and a lower-bound inference is made from each argument type Uj of D to the corresponding parameter type Tj of M. If for any of the Xi no bounds were found, type inference fails. Otherwise, all Xi are fixed to corresponding Si, which are the result of type inference.
Do'stlaringiz bilan baham: |