"Nicholls, Mark" <[EMAIL PROTECTED]> wrote: > [snip] Extension methods don't do inference that can't be done by normal method call inference either - the fact that the error occurs with extension methods is irrelevant. Calling an extension method M defined in class C using the extension syntax x.M() is equivalent to trying to call it as C.M(x), and the equivalent transformation in your problem case has the same failure.
The problem isn't so much the dependency in the generic constraints, but rather that the generic type arguments can't be inferred using the actual argument types. Your Extension.Test method is parameterized over two types, but only uses one of those types in the argument list, so the inference can't be completed - it's like having two variables but only one equation. The generic constraints aren't used in the inference process. I've rewritten your case to expose why it can't be solved in general, too; I also changed the definition of Test<,> to distinguish between B<> the generic type and B the type argument. Here's a different version which would have ambiguous resolutions if the generic constraints were actually used in the inference process: ---8<--- using System; static class Program { static void Main() { C t = new C(); t.Test(); // #1 t.Test<int,C>(); // #2 t.Test<string,C>(); // #3 } } public interface B<T> { } public class C : B<int>, B<string> { } public static class Extension { static public void Test<T,U>(this U self) where U : B<T> { } } --->8--- As you can see here, there are two possible inferences (in this case) for T, #2 and #3. -- Barry -- http://barrkel.blogspot.com/ =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com